From ab932f5c8893de5d927400ad4bd8c64f0a9bd885 Mon Sep 17 00:00:00 2001 From: SiddyJ Date: Thu, 18 Jan 2024 16:32:39 -0800 Subject: [PATCH] init commit --- eigen_pod_proofs.go | 6 ++-- generate_validator_proof.go | 4 +-- go.mod | 15 +++++----- go.sum | 17 +++++++++++ merkle_util_test.go | 3 +- proof_utils.go | 59 +++++++++++++++++++------------------ proofs.go | 19 ++++++------ prove_validator.go | 5 ++-- 8 files changed, 75 insertions(+), 53 deletions(-) diff --git a/eigen_pod_proofs.go b/eigen_pod_proofs.go index 49eb2880..ffe6fa2f 100644 --- a/eigen_pod_proofs.go +++ b/eigen_pod_proofs.go @@ -7,7 +7,7 @@ import ( "strconv" "time" - "github.com/attestantio/go-eth2-client/spec/capella" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/hashicorp/golang-lru/v2/expirable" ) @@ -39,7 +39,7 @@ func NewEigenPodProofs(chainID uint64, oracleStateCacheExpirySeconds int) (*Eige }, nil } -func (epp *EigenPodProofs) ComputeBeaconStateRoot(beaconState *capella.BeaconState) (phase0.Root, error) { +func (epp *EigenPodProofs) ComputeBeaconStateRoot(beaconState *deneb.BeaconState) (phase0.Root, error) { // check if the beacon state root is cached beaconStateRootSlice, found := epp.oracleStateCache.Get(key(BEACON_STATE_ROOT_PREFIX, uint64(beaconState.Slot))) // if the beacon state root is cached, return it @@ -60,7 +60,7 @@ func (epp *EigenPodProofs) ComputeBeaconStateRoot(beaconState *capella.BeaconSta return beaconStateRoot, nil } -func (epp *EigenPodProofs) ComputeBeaconStateTopLevelRoots(beaconState *capella.BeaconState) (*BeaconStateTopLevelRoots, error) { +func (epp *EigenPodProofs) ComputeBeaconStateTopLevelRoots(beaconState *deneb.BeaconState) (*BeaconStateTopLevelRoots, error) { // check if the beacon state top level roots are cached beaconStateTopLevelRootsSlice, found := epp.oracleStateCache.Get(key(BEACON_STATE_TOP_LEVEL_ROOTS_PREFIX, uint64(beaconState.Slot))) // if the beacon state top level roots are cached, return them diff --git a/generate_validator_proof.go b/generate_validator_proof.go index 5885df5b..2a02fbd7 100644 --- a/generate_validator_proof.go +++ b/generate_validator_proof.go @@ -5,14 +5,14 @@ import ( "encoding/json" "os" - "github.com/attestantio/go-eth2-client/spec/capella" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/rs/zerolog/log" ) func GenerateValidatorFieldsProof(oracleBlockHeaderFile string, stateFile string, validatorIndex uint64, chainID uint64, output string) { - var state capella.BeaconState + var state deneb.BeaconState var oracleBeaconBlockHeader phase0.BeaconBlockHeader stateJSON, err := parseStateJSONFile(stateFile) if err != nil { diff --git a/go.mod b/go.mod index e61e5eef..10f77e19 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/Layr-Labs/eigenpod-proofs-generation go 1.20 require ( - github.com/attestantio/go-eth2-client v0.19.5 + github.com/attestantio/go-eth2-client v0.19.9 github.com/ethereum/go-ethereum v1.13.5 github.com/ferranbt/fastssz v0.1.3 github.com/hashicorp/golang-lru/v2 v2.0.7 @@ -15,17 +15,18 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.13.0 // indirect + github.com/fatih/color v1.16.0 // indirect github.com/goccy/go-yaml v1.9.2 // indirect - github.com/klauspost/cpuid/v2 v2.2.3 // indirect + github.com/holiman/uint256 v1.2.4 // indirect + github.com/klauspost/cpuid/v2 v2.2.6 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mitchellh/mapstructure v1.4.1 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prysmaticlabs/go-bitfield v0.0.0-20210809151128-385d8c5e3fb7 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/sys v0.16.0 // indirect + golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 993fcd64..2141312b 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/attestantio/go-eth2-client v0.19.5 h1:4V+vhXsCYji5jWrlONbr03GV7qoLRdzq96dLgXaqmek= github.com/attestantio/go-eth2-client v0.19.5/go.mod h1:mZve1kV9Ctj0I1HH9gdg+MnI8lZ+Cb2EktEtOYrBlsM= +github.com/attestantio/go-eth2-client v0.19.9 h1:g5LLX3X7cLC0KS0oai/MtxBOZz3U3QPIX5qryYMxgVE= +github.com/attestantio/go-eth2-client v0.19.9/go.mod h1:TTz7YF6w4z6ahvxKiHuGPn6DbQn7gH6HPuWm/DEQeGE= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -9,6 +11,8 @@ github.com/ethereum/go-ethereum v1.13.5/go.mod h1:yMTu38GSuyxaYzQMViqNmQ1s3cE84a github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/ferranbt/fastssz v0.1.3 h1:ZI+z3JH05h4kgmFXdHuR1aWYsgrg7o+Fw7/NCzM16Mo= github.com/ferranbt/fastssz v0.1.3/go.mod h1:0Y9TEd/9XuFlh7mskMPfXiI2Dkw4Ddg9EyXt1W7MRvE= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -24,10 +28,14 @@ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= +github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/huandu/go-clone v1.6.0 h1:HMo5uvg4wgfiy5FoGOqlFLQED/VGRm2D9Pi8g1FXPGc= github.com/huandu/go-clone/generic v1.6.0 h1:Wgmt/fUZ28r16F2Y3APotFD59sHk1p78K0XLdbUYN5U= github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y70BU= github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= +github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -44,6 +52,8 @@ github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dz github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= 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= @@ -62,6 +72,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -70,15 +82,20 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/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.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU= +golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/merkle_util_test.go b/merkle_util_test.go index 21f2569b..460f238e 100644 --- a/merkle_util_test.go +++ b/merkle_util_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/attestantio/go-eth2-client/spec/capella" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" ) @@ -22,7 +23,7 @@ var ( block capella.BeaconBlock validatorIndex phase0.ValidatorIndex beaconBlockHeaderToVerifyIndex uint64 - executionPayload capella.ExecutionPayload + executionPayload deneb.ExecutionPayload epp *EigenPodProofs ) diff --git a/proof_utils.go b/proof_utils.go index 2d3b363c..67664ef5 100644 --- a/proof_utils.go +++ b/proof_utils.go @@ -15,6 +15,7 @@ import ( "github.com/attestantio/go-eth2-client/spec/altair" "github.com/attestantio/go-eth2-client/spec/capella" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" ) @@ -57,34 +58,34 @@ type BalanceUpdateProofs struct { } type beaconStateJSON struct { - GenesisTime string `json:"genesis_time"` - GenesisValidatorsRoot string `json:"genesis_validators_root"` - Slot string `json:"slot"` - Fork *phase0.Fork `json:"fork"` - LatestBlockHeader *phase0.BeaconBlockHeader `json:"latest_block_header"` - BlockRoots []string `json:"block_roots"` - StateRoots []string `json:"state_roots"` - HistoricalRoots []string `json:"historical_roots"` - ETH1Data *phase0.ETH1Data `json:"eth1_data"` - ETH1DataVotes []*phase0.ETH1Data `json:"eth1_data_votes"` - ETH1DepositIndex string `json:"eth1_deposit_index"` - Validators []*phase0.Validator `json:"validators"` - Balances []string `json:"balances"` - RANDAOMixes []string `json:"randao_mixes"` - Slashings []string `json:"slashings"` - PreviousEpochParticipation []string `json:"previous_epoch_participation"` - CurrentEpochParticipation []string `json:"current_epoch_participation"` - JustificationBits string `json:"justification_bits"` - PreviousJustifiedCheckpoint *phase0.Checkpoint `json:"previous_justified_checkpoint"` - CurrentJustifiedCheckpoint *phase0.Checkpoint `json:"current_justified_checkpoint"` - FinalizedCheckpoint *phase0.Checkpoint `json:"finalized_checkpoint"` - InactivityScores []string `json:"inactivity_scores"` - CurrentSyncCommittee *altair.SyncCommittee `json:"current_sync_committee"` - NextSyncCommittee *altair.SyncCommittee `json:"next_sync_committee"` - LatestExecutionPayloadHeader *capella.ExecutionPayloadHeader `json:"latest_execution_payload_header"` - NextWithdrawalIndex string `json:"next_withdrawal_index"` - NextWithdrawalValidatorIndex string `json:"next_withdrawal_validator_index"` - HistoricalSummaries []*capella.HistoricalSummary `json:"historical_summaries"` + GenesisTime string `json:"genesis_time"` + GenesisValidatorsRoot string `json:"genesis_validators_root"` + Slot string `json:"slot"` + Fork *phase0.Fork `json:"fork"` + LatestBlockHeader *phase0.BeaconBlockHeader `json:"latest_block_header"` + BlockRoots []string `json:"block_roots"` + StateRoots []string `json:"state_roots"` + HistoricalRoots []string `json:"historical_roots"` + ETH1Data *phase0.ETH1Data `json:"eth1_data"` + ETH1DataVotes []*phase0.ETH1Data `json:"eth1_data_votes"` + ETH1DepositIndex string `json:"eth1_deposit_index"` + Validators []*phase0.Validator `json:"validators"` + Balances []string `json:"balances"` + RANDAOMixes []string `json:"randao_mixes"` + Slashings []string `json:"slashings"` + PreviousEpochParticipation []string `json:"previous_epoch_participation"` + CurrentEpochParticipation []string `json:"current_epoch_participation"` + JustificationBits string `json:"justification_bits"` + PreviousJustifiedCheckpoint *phase0.Checkpoint `json:"previous_justified_checkpoint"` + CurrentJustifiedCheckpoint *phase0.Checkpoint `json:"current_justified_checkpoint"` + FinalizedCheckpoint *phase0.Checkpoint `json:"finalized_checkpoint"` + InactivityScores []string `json:"inactivity_scores"` + CurrentSyncCommittee *altair.SyncCommittee `json:"current_sync_committee"` + NextSyncCommittee *altair.SyncCommittee `json:"next_sync_committee"` + LatestExecutionPayloadHeader *deneb.ExecutionPayloadHeader `json:"latest_execution_payload_header"` + NextWithdrawalIndex string `json:"next_withdrawal_index"` + NextWithdrawalValidatorIndex string `json:"next_withdrawal_validator_index"` + HistoricalSummaries []*capella.HistoricalSummary `json:"historical_summaries"` } type beaconStateVersion struct { @@ -232,7 +233,7 @@ func parseStateJSONFile(filePath string) (*beaconStateJSON, error) { } // nolint:gocyclo -func ParseCapellaBeaconStateFromJSON(data beaconStateJSON, s *capella.BeaconState) error { +func ParseCapellaBeaconStateFromJSON(data beaconStateJSON, s *deneb.BeaconState) error { var err error if data.GenesisTime == "" { diff --git a/proofs.go b/proofs.go index e0e7f494..60cfd406 100644 --- a/proofs.go +++ b/proofs.go @@ -7,6 +7,7 @@ import ( "github.com/attestantio/go-eth2-client/spec/altair" "github.com/attestantio/go-eth2-client/spec/capella" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" ssz "github.com/ferranbt/fastssz" "github.com/rs/zerolog/log" @@ -45,7 +46,7 @@ type BeaconStateTopLevelRoots struct { HistoricalSummariesRoot *phase0.Root } -func ProveBlockRootAgainstBeaconStateViaHistoricalSummaries(beaconStateTopLevelRoots *BeaconStateTopLevelRoots, historicalSummaries []*capella.HistoricalSummary, historicalBlockRoots []phase0.Root, historicalSummaryIndex uint64, blockRootIndex uint64) ([][32]byte, error) { +func ProveBlockRootAgainstBeaconStateViaHistoricalSummaries(beaconStateTopLevelRoots *BeaconStateTopLevelRoots, historicalSummaries []*deneb.HistoricalSummary, historicalBlockRoots []phase0.Root, historicalSummaryIndex uint64, blockRootIndex uint64) ([][32]byte, error) { // prove the historical summaries against the beacon state historicalSummariesListAgainstBeaconState, err := ProveBeaconTopLevelRootAgainstBeaconState(beaconStateTopLevelRoots, historicalSummaryListIndex) @@ -81,7 +82,7 @@ func ProveBlockRootAgainstBeaconStateViaHistoricalSummaries(beaconStateTopLevelR func ProveExecutionPayloadAgainstBlockHeader( blockHeader *phase0.BeaconBlockHeader, - withdrawalBeaconBlockBody *capella.BeaconBlockBody, + withdrawalBeaconBlockBody *deneb.BeaconBlockBody, ) ([][32]byte, [32]byte, error) { // prove block body root against block header beaconBlockBodyAgainstBeaconBlockHeaderProof, err := ProveBlockBodyAgainstBlockHeader(blockHeader) @@ -100,7 +101,7 @@ func ProveExecutionPayloadAgainstBlockHeader( } func ProveWithdrawalAgainstExecutionPayload( - executionPayload *capella.ExecutionPayload, + executionPayload *deneb.ExecutionPayload, withdrawalIndex uint8, ) ([][32]byte, error) { // prove withdrawal list against the execution payload @@ -286,7 +287,7 @@ func ProveBlockBodyAgainstBlockHeader(blockHeader *phase0.BeaconBlockHeader) (Pr return GetProof(blockHeaderContainerRoots, beaconBlockBodyRootIndex, blockHeaderMerkleSubtreeNumLayers) } -func ProveWithdrawalListAgainstExecutionPayload(executionPayloadFields *capella.ExecutionPayload) (Proof, error) { +func ProveWithdrawalListAgainstExecutionPayload(executionPayloadFields *deneb.ExecutionPayload) (Proof, error) { executionPayloadFieldRoots, err := GetExecutionPayloadFieldRoots(executionPayloadFields) if err != nil { @@ -296,7 +297,7 @@ func ProveWithdrawalListAgainstExecutionPayload(executionPayloadFields *capella. return GetProof(executionPayloadFieldRoots, withdrawalsIndex, executionPayloadMerkleSubtreeNumLayers) } -func ProveTimestampAgainstExecutionPayload(executionPayloadFields *capella.ExecutionPayload) (Proof, error) { +func ProveTimestampAgainstExecutionPayload(executionPayloadFields *deneb.ExecutionPayload) (Proof, error) { executionPayloadFieldRoots, err := GetExecutionPayloadFieldRoots(executionPayloadFields) if err != nil { return nil, err @@ -307,7 +308,7 @@ func ProveTimestampAgainstExecutionPayload(executionPayloadFields *capella.Execu // Refer to beaconblockbody.go in go-eth2-client // https://github.com/attestantio/go-eth2-client/blob/654ac05b4c534d96562329f988655e49e5743ff5/spec/bellatrix/beaconblockbody_encoding.go -func ProveExecutionPayloadAgainstBlockBody(beaconBlockBody *capella.BeaconBlockBody) (Proof, [32]byte, error) { +func ProveExecutionPayloadAgainstBlockBody(beaconBlockBody *deneb.BeaconBlockBody) (Proof, [32]byte, error) { beaconBlockBodyContainerRoots := make([]phase0.Root, 11) var err error @@ -470,8 +471,8 @@ func ProveStateRootAgainstBlockHeader(b *phase0.BeaconBlockHeader) (Proof, error return GetProof(beaconBlockHeaderContainerRoots, stateRootIndex, blockHeaderMerkleSubtreeNumLayers) } -// taken from https://github.com/attestantio/go-eth2-client/blob/654ac05b4c534d96562329f988655e49e5743ff5/spec/capella/beaconstate_ssz.go#L639 -func ComputeBeaconStateTopLevelRoots(b *capella.BeaconState) (*BeaconStateTopLevelRoots, error) { +// taken from https://github.com/attestantio/go-eth2-client/blob/21f7dd480fed933d8e0b1c88cee67da721c80eb2/spec/deneb/beaconstate_ssz.go#L640 +func ComputeBeaconStateTopLevelRoots(b *deneb.BeaconState) (*BeaconStateTopLevelRoots, error) { var err error beaconStateTopLevelRoots := &BeaconStateTopLevelRoots{} @@ -875,7 +876,7 @@ func ComputeBeaconStateTopLevelRoots(b *capella.BeaconState) (*BeaconStateTopLev return beaconStateTopLevelRoots, nil } -func GetExecutionPayloadFieldRoots(executionPayloadFields *capella.ExecutionPayload) ([]phase0.Root, error) { +func GetExecutionPayloadFieldRoots(executionPayloadFields *deneb.ExecutionPayload) ([]phase0.Root, error) { executionPayloadFieldRoots := make([]phase0.Root, 15) var err error diff --git a/prove_validator.go b/prove_validator.go index 9905a733..2153d307 100644 --- a/prove_validator.go +++ b/prove_validator.go @@ -4,6 +4,7 @@ import ( "math/big" "github.com/attestantio/go-eth2-client/spec/capella" + "github.com/attestantio/go-eth2-client/spec/deneb" "github.com/attestantio/go-eth2-client/spec/phase0" ) @@ -53,7 +54,7 @@ func (epp *EigenPodProofs) ProveValidatorWithdrawalCredentials(oracleBlockHeader return verifyWithdrawalCredentialsCallParams, nil } -func (epp *EigenPodProofs) ProveValidatorFields(oracleBlockHeader *phase0.BeaconBlockHeader, oracleBeaconState *capella.BeaconState, validatorIndex uint64) (*StateRootProof, Proof, error) { +func (epp *EigenPodProofs) ProveValidatorFields(oracleBlockHeader *phase0.BeaconBlockHeader, oracleBeaconState *deneb.BeaconState, validatorIndex uint64) (*StateRootProof, Proof, error) { stateRootProof := &StateRootProof{} // Get beacon state top level roots beaconStateTopLevelRoots, err := epp.ComputeBeaconStateTopLevelRoots(oracleBeaconState) @@ -82,7 +83,7 @@ func (epp *EigenPodProofs) ProveValidatorFields(oracleBlockHeader *phase0.Beacon return stateRootProof, validatorFieldsProof, nil } -func (epp *EigenPodProofs) ProveValidatorAgainstBeaconState(oracleBeaconState *capella.BeaconState, beaconStateTopLevelRoots *BeaconStateTopLevelRoots, validatorIndex uint64) (Proof, error) { +func (epp *EigenPodProofs) ProveValidatorAgainstBeaconState(oracleBeaconState *deneb.BeaconState, beaconStateTopLevelRoots *BeaconStateTopLevelRoots, validatorIndex uint64) (Proof, error) { // prove the validator list against the beacon state validatorListProof, err := ProveBeaconTopLevelRootAgainstBeaconState(beaconStateTopLevelRoots, validatorListIndex) if err != nil {