Skip to content

Commit

Permalink
bump go-eth2-client for devnet1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Jul 3, 2024
1 parent 80dc430 commit 334d212
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 106 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ require (
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/pk910/dynamic-ssz v0.0.3 // indirect
github.com/pk910/dynamic-ssz v0.0.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.51.1 // indirect
Expand All @@ -89,12 +89,12 @@ require (
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/tools v0.19.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand All @@ -104,4 +104,4 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/attestantio/go-eth2-client => github.com/attestantio/go-eth2-client v0.0.0-20240508205406-66fbb02e3c16
replace github.com/attestantio/go-eth2-client => github.com/attestantio/go-eth2-client v0.0.0-20240701211822-0a60485fce68
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
github.com/attestantio/go-eth2-client v0.0.0-20240508205406-66fbb02e3c16 h1:42mZV077pxU7zD/v5NSoA+L8qjetVsBcyYbYKDw4UpA=
github.com/attestantio/go-eth2-client v0.0.0-20240508205406-66fbb02e3c16/go.mod h1:Ht9tN0WlhpgIWWO7Hqfi3/nq2rUGQv/zCd/BMI93a84=
github.com/attestantio/go-eth2-client v0.0.0-20240701211822-0a60485fce68 h1:7WPMn57cFdqlpYRwbEmMdHFXdwu9GVethzEXheTcIpk=
github.com/attestantio/go-eth2-client v0.0.0-20240701211822-0a60485fce68/go.mod h1:vy5jU/uDZ2+RcVzq5BfnG+bQ3/6uu9DGwCrGsPtjJ1A=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
Expand Down Expand Up @@ -193,8 +193,8 @@ github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqky
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pk910/dynamic-ssz v0.0.3 h1:fCWzFowq9P6SYCc7NtJMkZcIHk+r5hSVD+32zVi6Aio=
github.com/pk910/dynamic-ssz v0.0.3/go.mod h1:b6CrLaB2X7pYA+OSEEbkgXDEcRnjLOZIxZTsMuO/Y9c=
github.com/pk910/dynamic-ssz v0.0.4 h1:DT29+1055tCEPCaR4V/ez+MOKW7BzBsmjyFvBRqx0ME=
github.com/pk910/dynamic-ssz v0.0.4/go.mod h1:b6CrLaB2X7pYA+OSEEbkgXDEcRnjLOZIxZTsMuO/Y9c=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down Expand Up @@ -291,8 +291,8 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand Down Expand Up @@ -324,17 +324,17 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
10 changes: 0 additions & 10 deletions pkg/coordinator/clients/consensus/rpc/beaconapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/attestantio/go-eth2-client/http"
"github.com/attestantio/go-eth2-client/spec"
"github.com/attestantio/go-eth2-client/spec/capella"
"github.com/attestantio/go-eth2-client/spec/electra"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/rs/zerolog"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -489,12 +488,3 @@ func (bc *BeaconClient) SubmitProposerSlashing(ctx context.Context, slashing *ph

return nil
}

func (bc *BeaconClient) SubmitConsolidation(ctx context.Context, consolidation *electra.SignedConsolidation) error {
err := bc.postJSON(ctx, fmt.Sprintf("%s/eth/v1/beacon/pool/consolidations", bc.endpoint), consolidation, nil)
if err != nil {
return err
}

return nil
}
83 changes: 1 addition & 82 deletions pkg/coordinator/tasks/generate_consolidations/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ import (
"time"

v1 "github.com/attestantio/go-eth2-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/electra"
"github.com/attestantio/go-eth2-client/spec/phase0"
"github.com/ethpandaops/assertoor/pkg/coordinator/clients/consensus"
"github.com/ethpandaops/assertoor/pkg/coordinator/types"
hbls "github.com/herumi/bls-eth-go-binary/bls"
"github.com/protolambda/zrnt/eth2/beacon/common"
"github.com/protolambda/ztyp/tree"
"github.com/sirupsen/logrus"
"github.com/tyler-smith/go-bip39"
e2types "github.com/wealdtech/go-eth2-types/v2"
Expand Down Expand Up @@ -177,7 +173,7 @@ func (t *Task) Execute(ctx context.Context) error {
return nil
}

func (t *Task) generateConsolidation(ctx context.Context, accountIdx uint64) error {
func (t *Task) generateConsolidation(_ context.Context, accountIdx uint64) error {
clientPool := t.ctx.Scheduler.GetServices().ClientPool()
validatorKeyPath := fmt.Sprintf("m/12381/3600/%d/0/0", accountIdx)

Expand All @@ -187,7 +183,6 @@ func (t *Task) generateConsolidation(ctx context.Context, accountIdx uint64) err
}

validatorSet := clientPool.GetConsensusPool().GetValidatorSet()
specs := clientPool.GetConsensusPool().GetBlockCache().GetSpecs()

var sourceValidator, targetValidator *v1.Validator

Expand Down Expand Up @@ -220,82 +215,6 @@ func (t *Task) generateConsolidation(ctx context.Context, accountIdx uint64) err
return fmt.Errorf("validator %v does not have 0x01 withdrawal creds", targetValidator.Index)
}

// select client
var client *consensus.Client

if t.config.ClientPattern == "" && t.config.ExcludeClientPattern == "" {
client = clientPool.GetConsensusPool().AwaitReadyEndpoint(ctx, consensus.AnyClient)
if client == nil {
return ctx.Err()
}
} else {
clients := clientPool.GetClientsByNamePatterns(t.config.ClientPattern, t.config.ExcludeClientPattern)
if len(clients) == 0 {
return fmt.Errorf("no client found with pattern %v", t.config.ClientPattern)
}

client = clients[0].ConsensusClient
}

// generate operation
operation := electra.Consolidation{
SourceIndex: sourceValidator.Index,
TargetIndex: targetValidator.Index,
}

if t.config.ConsolidationEpoch > 0 {
operation.Epoch = phase0.Epoch(t.config.ConsolidationEpoch)
} else {
currentSlot, _ := client.GetLastHead()
operation.Epoch = phase0.Epoch(currentSlot / phase0.Slot(specs.SlotsPerEpoch))
}

// sign operation
operationRoot, err := operation.HashTreeRoot()
if err != nil {
return fmt.Errorf("could not generate hash tree root for consolidation operation: %v", err)
}

genesis := clientPool.GetConsensusPool().GetBlockCache().GetGenesis()
dom := common.ComputeDomain(DomainConsolidation, common.Version(genesis.GenesisForkVersion), tree.Root(genesis.GenesisValidatorsRoot))
signingRoot := common.ComputeSigningRoot(operationRoot, dom)

// source signature
var sourceSecKey hbls.SecretKey

err = sourceSecKey.Deserialize(validatorPrivkey.Marshal())
if err != nil {
return fmt.Errorf("failed converting validator priv key: %w", err)
}

sig1 := sourceSecKey.SignHash(signingRoot[:])

// target signature
var targetSecKey hbls.SecretKey

err = targetSecKey.Deserialize(t.targetPrivKey.Marshal())
if err != nil {
return fmt.Errorf("failed converting validator priv key: %w", err)
}

sig2 := targetSecKey.SignHash(signingRoot[:])

// aggregate signature
sig1.Add(sig2)

// build signed operation
operationSigned := electra.SignedConsolidation{
Message: &operation,
Signature: phase0.BLSSignature(sig1.Serialize()),
}

t.logger.WithField("client", client.GetName()).Infof("sending consolidation for validator %v (consolidating to %v)", sourceValidator.Index, targetValidator.Index)

err = client.GetRPCClient().SubmitConsolidation(ctx, &operationSigned)
if err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 334d212

Please sign in to comment.