Skip to content

Commit

Permalink
*: release v1.1.1 (#3287)
Browse files Browse the repository at this point in the history
For release v1.1.1 cherry picked:

* [core/validatorapi: workaround for Gnosis proposals](#3238)
* [*: enable gnosis hotfix automatically](#3257)
*: [fix flaky testpeers test #3267](#3267)
* [cmd: increase testpeers tests timeouts #3268](#3268)
* [cmd: fix test peers out of range #3280](#3280)
* [testutil: update docker-compose command to docker compose](#3249)

category: misc
ticket: none
  • Loading branch information
pinebit authored Sep 17, 2024
1 parent a193f84 commit dc848df
Show file tree
Hide file tree
Showing 32 changed files with 297 additions and 56 deletions.
8 changes: 8 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ func Run(ctx context.Context, conf Config) (err error) {
network = "unknown"
}

// For Gnosis/Chiado we automatically enable GnosisBlockHotfix feature.
if network == eth2util.Chiado.Name || network == eth2util.Gnosis.Name {
// Even though we alter the feature flag post Init() call,
// this shall be safe for the GnosisBlockHotfix feature flag.
// We don't expect any serialization to happen in between.
featureset.EnableGnosisBlockHotfixIfNotDisabled(ctx, conf.Feature)
}

p2pKey := conf.TestConfig.P2PKey
if p2pKey == nil {
var err error
Expand Down
23 changes: 23 additions & 0 deletions app/featureset/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,29 @@ func Init(ctx context.Context, config Config) error {
return nil
}

// EnableGnosisBlockHotfixIfNotDisabled enables GnosisBlockHotfix if it was not disabled by the user.
// This is still a temporary workaround for the gnosis chain.
// When go-eth2-client is fully supporting custom specs, this function has to be removed with GnosisBlockHotfix feature.
func EnableGnosisBlockHotfixIfNotDisabled(ctx context.Context, config Config) {
initMu.Lock()
defer initMu.Unlock()

disabled := false

for _, f := range config.Disabled {
if strings.EqualFold(string(GnosisBlockHotfix), f) {
disabled = true
break
}
}

if disabled {
log.Warn(ctx, "Feature gnosis_block_hotfix is required by gnosis/chiado, but explicitly disabled", nil)
} else {
state[GnosisBlockHotfix] = enable
}
}

// EnableForT enables a feature for testing.
func EnableForT(t *testing.T, feature Feature) {
t.Helper()
Expand Down
23 changes: 23 additions & 0 deletions app/featureset/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,26 @@ func TestEnableForT(t *testing.T) {
featureset.DisableForT(t, testFeature)
require.False(t, featureset.Enabled(testFeature))
}

func TestEnableGnosisBlockHotfixIfNotDisabled(t *testing.T) {
ctx := context.Background()
config := featureset.DefaultConfig()

t.Run("not disabled explicitly", func(t *testing.T) {
err := featureset.Init(ctx, config)
require.NoError(t, err)

featureset.EnableGnosisBlockHotfixIfNotDisabled(ctx, config)
require.True(t, featureset.Enabled(featureset.GnosisBlockHotfix))
})

t.Run("disabled explicitly", func(t *testing.T) {
config.Disabled = append(config.Disabled, string(featureset.GnosisBlockHotfix))

err := featureset.Init(ctx, config)
require.NoError(t, err)

featureset.EnableGnosisBlockHotfixIfNotDisabled(ctx, config)
require.False(t, featureset.Enabled(featureset.GnosisBlockHotfix))
})
}
6 changes: 6 additions & 0 deletions app/featureset/featureset.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const (

// JSONRequests enables JSON requests for eth2 client.
JSONRequests Feature = "json_requests"

// GnosisBlockHotfix enables Gnosis/Chiado SSZ fix.
// The feature gets automatically enabled when the current network is gnosis|chiado,
// unless the user disabled this feature explicitly.
GnosisBlockHotfix Feature = "gnosis_block_hotfix"
)

var (
Expand All @@ -50,6 +55,7 @@ var (
MockAlpha: statusAlpha,
AggSigDBV2: statusAlpha,
JSONRequests: statusAlpha,
GnosisBlockHotfix: statusAlpha,
// Add all features and there status here.
}

Expand Down
1 change: 1 addition & 0 deletions app/featureset/featureset_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestAllFeatureStatus(t *testing.T) {
EagerDoubleLinear,
ConsensusParticipate,
JSONRequests,
GnosisBlockHotfix,
}

for _, feature := range features {
Expand Down
2 changes: 1 addition & 1 deletion cmd/createcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func bindClusterFlags(flags *pflag.FlagSet, config *clusterConfig) {
flags.IntVar(&config.Threshold, "threshold", 0, "Optional override of threshold required for signature reconstruction. Defaults to ceil(n*2/3) if zero. Warning, non-default values decrease security.")
flags.StringSliceVar(&config.FeeRecipientAddrs, "fee-recipient-addresses", nil, "Comma separated list of Ethereum addresses of the fee recipient for each validator. Either provide a single fee recipient address or fee recipient addresses for each validator.")
flags.StringSliceVar(&config.WithdrawalAddrs, "withdrawal-addresses", nil, "Comma separated list of Ethereum addresses to receive the returned stake and accrued rewards for each validator. Either provide a single withdrawal address or withdrawal addresses for each validator.")
flags.StringVar(&config.Network, "network", "", "Ethereum network to create validators for. Options: mainnet, goerli, gnosis, sepolia, holesky.")
flags.StringVar(&config.Network, "network", "", "Ethereum network to create validators for. Options: mainnet, goerli, sepolia, holesky, gnosis, chiado.")
flags.IntVar(&config.NumDVs, "num-validators", 0, "The number of distributed validators needed in the cluster.")
flags.BoolVar(&config.SplitKeys, "split-existing-keys", false, "Split an existing validator's private key into a set of distributed validator private key shares. Does not re-create deposit data for this key.")
flags.StringVar(&config.SplitKeysDir, "split-keys-dir", "", "Directory containing keys to split. Expects keys in keystore-*.json and passwords in keystore-*.txt. Requires --split-existing-keys.")
Expand Down
2 changes: 1 addition & 1 deletion cmd/createdkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func bindCreateDKGFlags(cmd *cobra.Command, config *createDKGConfig) {
cmd.Flags().IntVarP(&config.Threshold, "threshold", "t", 0, "Optional override of threshold required for signature reconstruction. Defaults to ceil(n*2/3) if zero. Warning, non-default values decrease security.")
cmd.Flags().StringSliceVar(&config.FeeRecipientAddrs, "fee-recipient-addresses", nil, "Comma separated list of Ethereum addresses of the fee recipient for each validator. Either provide a single fee recipient address or fee recipient addresses for each validator.")
cmd.Flags().StringSliceVar(&config.WithdrawalAddrs, "withdrawal-addresses", nil, "Comma separated list of Ethereum addresses to receive the returned stake and accrued rewards for each validator. Either provide a single withdrawal address or withdrawal addresses for each validator.")
cmd.Flags().StringVar(&config.Network, "network", defaultNetwork, "Ethereum network to create validators for. Options: mainnet, goerli, gnosis, sepolia, holesky.")
cmd.Flags().StringVar(&config.Network, "network", defaultNetwork, "Ethereum network to create validators for. Options: mainnet, goerli, sepolia, holesky, gnosis, chiado.")
cmd.Flags().StringVar(&config.DKGAlgo, "dkg-algorithm", "default", "DKG algorithm to use; default, frost")
cmd.Flags().IntSliceVar(&config.DepositAmounts, "deposit-amounts", nil, "List of partial deposit amounts (integers) in ETH. Values must sum up to exactly 32ETH.")
cmd.Flags().StringSliceVar(&config.OperatorENRs, operatorENRs, nil, "[REQUIRED] Comma-separated list of each operator's Charon ENR address.")
Expand Down
4 changes: 2 additions & 2 deletions cmd/testbeacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func testAllBeacons(ctx context.Context, queuedTestCases []testCaseName, allTest

doneReading := make(chan bool)
go func() {
for singlePeerRes := range singleBeaconResCh {
maps.Copy(allBeaconsRes, singlePeerRes)
for singleBeaconRes := range singleBeaconResCh {
maps.Copy(allBeaconsRes, singleBeaconRes)
}
doneReading <- true
}()
Expand Down
4 changes: 2 additions & 2 deletions cmd/testmev.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func testAllMEVs(ctx context.Context, queuedTestCases []testCaseName, allTestCas

doneReading := make(chan bool)
go func() {
for singlePeerRes := range singleMEVResCh {
maps.Copy(allMEVsRes, singlePeerRes)
for singleMEVRes := range singleMEVResCh {
maps.Copy(allMEVsRes, singleMEVRes)
}
doneReading <- true
}()
Expand Down
7 changes: 5 additions & 2 deletions cmd/testpeers.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,10 @@ func testSinglePeer(ctx context.Context, queuedTestCases []testCaseName, allTest
var testName string
select {
case <-ctx.Done():
testName = queuedTestCases[testCounter].name
allTestRes = append(allTestRes, testResult{Name: testName, Verdict: testVerdictFail, Error: errTimeoutInterrupted})
if testCounter < len(queuedTestCases) {
testName = queuedTestCases[testCounter].name
allTestRes = append(allTestRes, testResult{Name: testName, Verdict: testVerdictFail, Error: errTimeoutInterrupted})
}
finished = true
case result, ok := <-singleTestResCh:
if !ok {
Expand All @@ -499,6 +501,7 @@ func runPeerTest(ctx context.Context, queuedTestCases []testCaseName, allTestCas
for _, t := range queuedTestCases {
select {
case <-ctx.Done():
testResCh <- failedTestResult(testResult{Name: t.name}, errTimeoutInterrupted)
return
default:
testResCh <- allTestCases[t](ctx, &conf, tcpNode, target)
Expand Down
11 changes: 6 additions & 5 deletions cmd/testpeers_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestPeersTest(t *testing.T) {
OutputToml: "",
Quiet: true,
TestCases: nil,
Timeout: time.Second,
Timeout: 3 * time.Second,
},
ENRs: []string{
"enr:-HW4QBHlcyD3fYWUMADiOv4OxODaL5wJG0a7P7d_ltu4VZe1MibZ1N-twFaoaq0BoCtXcY71etxLJGeEZT5p3XCO6GOAgmlkgnY0iXNlY3AyNTZrMaEDI2HRUlVBag__njkOWEEQRLlC9ylIVCrIXOuNBSlrx6o",
Expand Down Expand Up @@ -188,7 +188,7 @@ func TestPeersTest(t *testing.T) {
OutputToml: "",
Quiet: false,
TestCases: []string{"ping"},
Timeout: time.Second,
Timeout: 200 * time.Millisecond,
},
ENRs: []string{
"enr:-HW4QBHlcyD3fYWUMADiOv4OxODaL5wJG0a7P7d_ltu4VZe1MibZ1N-twFaoaq0BoCtXcY71etxLJGeEZT5p3XCO6GOAgmlkgnY0iXNlY3AyNTZrMaEDI2HRUlVBag__njkOWEEQRLlC9ylIVCrIXOuNBSlrx6o",
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestPeersTest(t *testing.T) {
testConfig: testConfig{
OutputToml: "./write-to-file-test.toml.tmp",
Quiet: false,
Timeout: 100 * time.Millisecond,
Timeout: 3 * time.Second,
},
ENRs: []string{
"enr:-HW4QBHlcyD3fYWUMADiOv4OxODaL5wJG0a7P7d_ltu4VZe1MibZ1N-twFaoaq0BoCtXcY71etxLJGeEZT5p3XCO6GOAgmlkgnY0iXNlY3AyNTZrMaEDI2HRUlVBag__njkOWEEQRLlC9ylIVCrIXOuNBSlrx6o",
Expand All @@ -241,10 +241,11 @@ func TestPeersTest(t *testing.T) {
CategoryName: peersTestCategory,
Targets: map[string][]testResult{
"self": {
{Name: "libp2pTCPPortOpenTest", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: errTimeoutInterrupted},
{Name: "libp2pTCPPortOpenTest", Verdict: testVerdictOk, Measurement: "", Suggestion: "", Error: testResultError{}},
},
fmt.Sprintf("relay %v", relayAddr): {
{Name: "pingRelay", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: errTimeoutInterrupted},
{Name: "pingRelay", Verdict: testVerdictOk, Measurement: "", Suggestion: "", Error: testResultError{}},
{Name: "pingMeasureRelay", Verdict: testVerdictGood, Measurement: "", Suggestion: "", Error: testResultError{}},
},
"peer inexpensive-farm enr:-HW4QBHlcyD3fYWUMADiOv4OxODaL5wJG0a7P7d_ltu4VZe1MibZ1N-twFaoaq0BoCtXcY71etxLJGeEZT5p3XCO6GOAgmlkgnY0iXNlY3AyNTZrMaEDI2HRUlVBag__njkOWEEQRLlC9ylIVCrIXOuNBSlrx6o": {
{Name: "ping", Verdict: testVerdictFail, Measurement: "", Suggestion: "", Error: errTimeoutInterrupted},
Expand Down
8 changes: 8 additions & 0 deletions core/signeddata.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import (
"github.com/attestantio/go-eth2-client/spec/altair"
"github.com/attestantio/go-eth2-client/spec/bellatrix"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/deneb"
eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"

"github.com/obolnetwork/charon/app/errors"
"github.com/obolnetwork/charon/app/eth2wrap"
"github.com/obolnetwork/charon/app/featureset"
"github.com/obolnetwork/charon/eth2util"
"github.com/obolnetwork/charon/eth2util/eth2exp"
"github.com/obolnetwork/charon/eth2util/signing"
Expand Down Expand Up @@ -320,6 +322,12 @@ func (p VersionedSignedProposal) MessageRoot() ([32]byte, error) {
return p.DenebBlinded.Message.HashTreeRoot()
}

if featureset.Enabled(featureset.GnosisBlockHotfix) {
// translate p.Deneb.SignedBlock to its Gnosis associate and return its hash tree root
sbGnosis := deneb.BeaconBlockToGnosis(*p.Deneb.SignedBlock.Message)
return sbGnosis.HashTreeRoot()
}

return p.Deneb.SignedBlock.Message.HashTreeRoot()
default:
panic("unknown version") // Note this is avoided by using `NewVersionedSignedProposal`.
Expand Down
Loading

0 comments on commit dc848df

Please sign in to comment.