Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fca0876
beacon/goclient: get beacon config from beacon node
nkryuchkov Apr 16, 2025
5253cca
Merge branch 'networkconfig-extract-beacon-params' into networkconfig…
nkryuchkov Apr 16, 2025
c3f3527
use beacon config obtained from beacon node
nkryuchkov Apr 16, 2025
e57ef03
log config as JSON
nkryuchkov Apr 17, 2025
65acd9b
delete a comment
nkryuchkov Apr 17, 2025
7dd8ea4
Merge branch 'networkconfig-extract-beacon-params' into networkconfig…
nkryuchkov Apr 17, 2025
d5dea5a
use Stringer to log node
nkryuchkov Apr 17, 2025
4fc30f2
guard beacon config reads with mutex
nkryuchkov Apr 17, 2025
c04d2b9
add a timeout log
nkryuchkov Apr 17, 2025
c2e2f8f
delete hardcoded beacon configs
nkryuchkov Apr 19, 2025
be8fbb7
Revert "delete hardcoded beacon configs"
nkryuchkov Apr 19, 2025
b1d22f0
Merge branch 'networkconfig-extract-beacon-params' into networkconfig…
nkryuchkov Apr 24, 2025
e8d1fa2
fix issues after merging
nkryuchkov Apr 24, 2025
301fe46
code review comments
nkryuchkov Apr 24, 2025
a22b256
unexport supportedSSVConfigs
nkryuchkov Apr 24, 2025
f8af8b0
Merge branch 'networkconfig-extract-beacon-params' into networkconfig…
nkryuchkov Apr 28, 2025
a04d173
Merge branch 'networkconfig-extract-beacon-params' into networkconfig…
nkryuchkov May 12, 2025
a91171b
Merge branch 'networkconfig-extract-beacon-params' into networkconfig…
nkryuchkov May 21, 2025
3ec364e
fix a context bug
nkryuchkov May 22, 2025
f790d99
pass network config name
nkryuchkov May 26, 2025
ae9dde4
Merge branch 'networkconfig-extract-beacon-params' into networkconfig…
nkryuchkov May 26, 2025
f601c0f
feat(networkconfig): CLI for custom SSV config generation (#2156)
nkryuchkov May 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions beacon/goclient/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if err != nil {
return nil, DataVersionNil, fmt.Errorf("failed to get attestation data: %w", err)
}
if gc.DataVersion(gc.beaconConfig.EstimatedEpochAtSlot(attData.Slot)) < spec.DataVersionElectra {
if gc.DataVersion(gc.getBeaconConfig().EstimatedEpochAtSlot(attData.Slot)) < spec.DataVersionElectra {

Check warning on line 42 in beacon/goclient/aggregator.go

View check run for this annotation

Codecov / codecov/patch

beacon/goclient/aggregator.go#L42

Added line #L42 was not covered by tests
attData.Index = committeeIndex
}

Expand Down Expand Up @@ -201,9 +201,9 @@

// waitToSlotTwoThirds waits until two-third of the slot has transpired (SECONDS_PER_SLOT * 2 / 3 seconds after slot start time)
func (gc *GoClient) waitToSlotTwoThirds(slot phase0.Slot) {
oneThird := gc.beaconConfig.SlotDuration / 3 /* one third of slot duration */

finalTime := gc.beaconConfig.GetSlotStartTime(slot).Add(2 * oneThird)
config := gc.getBeaconConfig()
oneThird := config.SlotDuration / 3 /* one third of slot duration */
finalTime := config.GetSlotStartTime(slot).Add(2 * oneThird)

Check warning on line 206 in beacon/goclient/aggregator.go

View check run for this annotation

Codecov / codecov/patch

beacon/goclient/aggregator.go#L204-L206

Added lines #L204 - L206 were not covered by tests
wait := time.Until(finalTime)
if wait <= 0 {
return
Expand Down
16 changes: 0 additions & 16 deletions beacon/goclient/attest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/zap"

"github.com/ssvlabs/ssv/networkconfig"
"github.com/ssvlabs/ssv/operator/slotticker"
"github.com/ssvlabs/ssv/utils/hashmap"
)

Expand Down Expand Up @@ -204,17 +202,10 @@ func TestGoClient_GetAttestationData_Simple(t *testing.T) {
t.Context(),
zap.NewNop(),
Options{
BeaconConfig: networkconfig.Mainnet.BeaconConfig,
BeaconNodeAddr: server.URL,
CommonTimeout: 1 * time.Second,
LongTimeout: 1 * time.Second,
},
func() slotticker.SlotTicker {
return slotticker.New(zap.NewNop(), slotticker.Config{
SlotDuration: 12 * time.Second,
GenesisTime: time.Now(),
})
},
)
require.NoError(t, err)

Expand Down Expand Up @@ -500,18 +491,11 @@ func createClient(
ctx,
zap.NewNop(),
Options{
BeaconConfig: networkconfig.Mainnet.BeaconConfig,
BeaconNodeAddr: beaconServerURL,
CommonTimeout: defaultHardTimeout,
LongTimeout: time.Second,
WithWeightedAttestationData: withWeightedAttestationData,
},
func() slotticker.SlotTicker {
return slotticker.New(zap.NewNop(), slotticker.Config{
SlotDuration: 12 * time.Second,
GenesisTime: time.Now(),
})
},
)
return client, err
}
Expand Down
3 changes: 0 additions & 3 deletions beacon/goclient/current_fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func TestCurrentFork(t *testing.T) {
CommonTimeout: 100 * time.Millisecond,
LongTimeout: 500 * time.Millisecond,
},
tests.MockSlotTickerProvider,
)
require.NoError(t, err)

Expand Down Expand Up @@ -86,7 +85,6 @@ func TestCurrentFork(t *testing.T) {
CommonTimeout: 100 * time.Millisecond,
LongTimeout: 500 * time.Millisecond,
},
tests.MockSlotTickerProvider,
)
require.NoError(t, err)

Expand Down Expand Up @@ -126,7 +124,6 @@ func TestCurrentFork(t *testing.T) {
CommonTimeout: 100 * time.Millisecond,
LongTimeout: 500 * time.Millisecond,
},
tests.MockSlotTickerProvider,
)
require.NoError(t, err)

Expand Down
5 changes: 1 addition & 4 deletions beacon/goclient/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"go.uber.org/zap"

"github.com/ssvlabs/ssv/beacon/goclient/tests"
"github.com/ssvlabs/ssv/networkconfig"
)

func TestSubscribeToHeadEvents(t *testing.T) {
Expand Down Expand Up @@ -84,9 +83,7 @@ func eventsTestClient(t *testing.T, serverURL string) *GoClient {
zap.NewNop(),
Options{
BeaconNodeAddr: serverURL,
BeaconConfig: networkconfig.Mainnet.BeaconConfig,
},
tests.MockSlotTickerProvider)
})

require.NoError(t, err)
return server
Expand Down
43 changes: 31 additions & 12 deletions beacon/goclient/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import (
"github.com/ssvlabs/ssv/networkconfig"
)

const genesisPath = "/eth/v1/beacon/genesis"
const (
genesisPath = "/eth/v1/beacon/genesis"
specPath = "/eth/v1/config/spec"
)

func TestGenesis(t *testing.T) {
ctx := context.Background()
Expand All @@ -30,6 +33,29 @@ func TestGenesis(t *testing.T) {
}
}`), nil
}
if r.URL.Path == specPath {
return json.RawMessage(`{
"data": {
"CONFIG_NAME": "holesky",
"GENESIS_FORK_VERSION": "0x00000000",
"CAPELLA_FORK_VERSION": "0x04017000",
"MIN_GENESIS_TIME": "1695902100",
"SECONDS_PER_SLOT": "12",
"SLOTS_PER_EPOCH": "32",
"EPOCHS_PER_SYNC_COMMITTEE_PERIOD": "256",
"SYNC_COMMITTEE_SIZE": "512",
"SYNC_COMMITTEE_SUBNET_COUNT": "4",
"TARGET_AGGREGATORS_PER_COMMITTEE": "16",
"TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE": "16",
"INTERVALS_PER_SLOT": "3",
"ALTAIR_FORK_EPOCH": "74240",
"BELLATRIX_FORK_EPOCH": "144896",
"CAPELLA_FORK_EPOCH": "194048",
"DENEB_FORK_EPOCH": "269568",
"ELECTRA_FORK_EPOCH": "18446744073709551615"
}
}`), nil
}
return resp, nil
})
defer mockServer.Close()
Expand All @@ -43,7 +69,6 @@ func TestGenesis(t *testing.T) {
CommonTimeout: 100 * time.Millisecond,
LongTimeout: 500 * time.Millisecond,
},
tests.MockSlotTickerProvider,
)
require.NoError(t, err)

Expand Down Expand Up @@ -73,13 +98,10 @@ func TestGenesis(t *testing.T) {
CommonTimeout: 100 * time.Millisecond,
LongTimeout: 500 * time.Millisecond,
},
tests.MockSlotTickerProvider,
)
require.NoError(t, err)

_, err = client.Genesis(ctx)
require.Error(t, err)
require.Contains(t, err.Error(), "genesis response data is nil")
require.Contains(t, err.Error(), "timed out awaiting config initialization") // node cannot initialize if it cannot get genesis
require.Nil(t, client)
})

t.Run("error", func(t *testing.T) {
Expand All @@ -100,12 +122,9 @@ func TestGenesis(t *testing.T) {
CommonTimeout: 100 * time.Millisecond,
LongTimeout: 500 * time.Millisecond,
},
tests.MockSlotTickerProvider,
)
require.NoError(t, err)

_, err = client.Genesis(ctx)
require.Error(t, err)
require.Contains(t, err.Error(), "failed to request genesis")
require.Contains(t, err.Error(), "timed out awaiting config initialization") // node cannot initialize if it cannot get genesis
require.Nil(t, client)
})
}
Loading