From a1e12b98edc436ddfe89ab0d0eb28a80b7b140a8 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 6 Sep 2024 16:00:15 +0200 Subject: [PATCH 01/13] electra upgrade --- web/packages/test/scripts/deploy-ethereum.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/web/packages/test/scripts/deploy-ethereum.sh b/web/packages/test/scripts/deploy-ethereum.sh index b96ad21213..8420bb2344 100755 --- a/web/packages/test/scripts/deploy-ethereum.sh +++ b/web/packages/test/scripts/deploy-ethereum.sh @@ -70,6 +70,7 @@ start_lodestar() { --params.BELLATRIX_FORK_EPOCH 0 \ --params.CAPELLA_FORK_EPOCH 0 \ --params.DENEB_FORK_EPOCH 0 \ + --params.ELECTRA_FORK_EPOCH 0 \ --eth1=true \ --rest.namespace="*" \ --jwt-secret $config_dir/jwtsecret \ From 934973eef8071046fcae20b57601741c33eec2f7 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Mon, 9 Sep 2024 11:58:06 +0200 Subject: [PATCH 02/13] relayer progress --- relayer/cmd/import_beacon_state.go | 2 +- relayer/magefile.go | 2 +- relayer/relays/beacon/config/config.go | 13 +- .../beacon/header/syncer/api/api_deneb.go | 48 ----- .../beacon/header/syncer/api/api_electra.go | 54 ++++++ .../beacon/header/syncer/api/api_response.go | 8 +- relayer/relays/beacon/header/syncer/syncer.go | 25 ++- relayer/relays/beacon/protocol/protocol.go | 24 ++- relayer/relays/beacon/state/beacon.go | 5 + relayer/relays/beacon/state/beacon_deneb.go | 14 +- .../beacon/state/beacon_deneb_encoding.go | 2 +- relayer/relays/beacon/state/beacon_electra.go | 172 ++++++++++++++++++ .../relays/beacon/state/beacon_encoding.go | 2 +- 13 files changed, 297 insertions(+), 74 deletions(-) create mode 100644 relayer/relays/beacon/header/syncer/api/api_electra.go create mode 100644 relayer/relays/beacon/state/beacon_electra.go diff --git a/relayer/cmd/import_beacon_state.go b/relayer/cmd/import_beacon_state.go index f683e48db0..854d916dcb 100644 --- a/relayer/cmd/import_beacon_state.go +++ b/relayer/cmd/import_beacon_state.go @@ -92,7 +92,7 @@ func importBeaconState(cmd *cobra.Command, _ []string) error { return fmt.Errorf("read finalized state data from file: %w", err) } - afterDenebFork := (conf.Source.Beacon.Spec.DenebForkEpoch + 1) * 32 + afterDenebFork := (conf.Source.Beacon.Spec.ForkVersions.Deneb + 1) * 32 attestedState, err := syncer.UnmarshalBeaconState(afterDenebFork, attestedData) if err != nil { diff --git a/relayer/magefile.go b/relayer/magefile.go index 859e614e06..c617a8a4da 100644 --- a/relayer/magefile.go +++ b/relayer/magefile.go @@ -13,7 +13,7 @@ func Build() { } func BuildMain() error { - err := sh.Run("sszgen", "--path", "relays/beacon/state", "--objs", "BeaconStateCapellaMainnet,BlockRootsContainerMainnet,TransactionsRootContainer,BeaconBlockCapellaMainnet,WithdrawalsRootContainerMainnet,BeaconStateDenebMainnet,BeaconBlockDenebMainnet") + err := sh.Run("sszgen", "--path", "relays/beacon/state", "--objs", "BeaconStateCapellaMainnet,BlockRootsContainerMainnet,TransactionsRootContainer,BeaconBlockCapellaMainnet,WithdrawalsRootContainerMainnet,BeaconStateDenebMainnet,BeaconBlockDenebMainnet,BeaconStateElectra,BeaconBlockElectra") if err != nil { return err } diff --git a/relayer/relays/beacon/config/config.go b/relayer/relays/beacon/config/config.go index 1e3b465597..09660e6985 100644 --- a/relayer/relays/beacon/config/config.go +++ b/relayer/relays/beacon/config/config.go @@ -12,10 +12,15 @@ type Config struct { } type SpecSettings struct { - SyncCommitteeSize uint64 `mapstructure:"syncCommitteeSize"` - SlotsInEpoch uint64 `mapstructure:"slotsInEpoch"` - EpochsPerSyncCommitteePeriod uint64 `mapstructure:"epochsPerSyncCommitteePeriod"` - DenebForkEpoch uint64 `mapstructure:"denebForkedEpoch"` + SyncCommitteeSize uint64 `mapstructure:"syncCommitteeSize"` + SlotsInEpoch uint64 `mapstructure:"slotsInEpoch"` + EpochsPerSyncCommitteePeriod uint64 `mapstructure:"epochsPerSyncCommitteePeriod"` + ForkVersions ForkVersions `mapstructure:"forkVersions"` +} + +type ForkVersions struct { + Deneb uint64 `mapstructure:"deneb"` + Electra uint64 `mapstructure:"electra"` } type SourceConfig struct { diff --git a/relayer/relays/beacon/header/syncer/api/api_deneb.go b/relayer/relays/beacon/header/syncer/api/api_deneb.go index 3ebe17f982..d57f1533b3 100644 --- a/relayer/relays/beacon/header/syncer/api/api_deneb.go +++ b/relayer/relays/beacon/header/syncer/api/api_deneb.go @@ -3,9 +3,7 @@ package api import ( "math/big" - "github.com/ethereum/go-ethereum/common" "github.com/snowfork/go-substrate-rpc-client/v4/types" - beaconjson "github.com/snowfork/snowbridge/relayer/relays/beacon/header/syncer/json" "github.com/snowfork/snowbridge/relayer/relays/beacon/header/syncer/scale" "github.com/snowfork/snowbridge/relayer/relays/beacon/state" "github.com/snowfork/snowbridge/relayer/relays/util" @@ -55,49 +53,3 @@ func DenebExecutionPayloadToScale(e *state.ExecutionPayloadDeneb) (scale.Executi }, nil } -func DenebJsonExecutionPayloadHeaderToScale(e *beaconjson.FullExecutionPayloadHeaderJson) (scale.ExecutionPayloadHeaderDeneb, error) { - var executionPayloadHeader scale.ExecutionPayloadHeaderDeneb - var baseFeePerGas big.Int - baseFeePerGasU64, err := util.ToUint64(e.BaseFeePerGas) - if err != nil { - return executionPayloadHeader, err - } - blockNumber, err := util.ToUint64(e.BlockNumber) - if err != nil { - return executionPayloadHeader, err - } - baseFeePerGas.SetUint64(baseFeePerGasU64) - gasLimit, err := util.ToUint64(e.GasLimit) - if err != nil { - return executionPayloadHeader, err - } - gasUsed, err := util.ToUint64(e.GasUsed) - if err != nil { - return executionPayloadHeader, err - } - timestamp, err := util.ToUint64(e.Timestamp) - if err != nil { - return executionPayloadHeader, err - } - blobGasUsed, _ := util.ToUint64(e.BlobGasUsed) - excessBlobGas, _ := util.ToUint64(e.ExcessBlobGas) - return scale.ExecutionPayloadHeaderDeneb{ - ParentHash: types.NewH256(common.HexToHash(e.ParentHash).Bytes()), - FeeRecipient: types.NewH160(common.HexToAddress(e.FeeRecipient).Bytes()), - StateRoot: types.NewH256(common.HexToHash(e.StateRoot).Bytes()), - ReceiptsRoot: types.NewH256(common.HexToHash(e.ReceiptsRoot).Bytes()), - LogsBloom: common.FromHex(e.LogsBloom), - PrevRandao: types.NewH256(common.HexToHash(e.PrevRandao).Bytes()), - BlockNumber: types.NewU64(blockNumber), - GasLimit: types.NewU64(gasLimit), - GasUsed: types.NewU64(gasUsed), - Timestamp: types.NewU64(timestamp), - ExtraData: common.FromHex(e.ExtraData), - BaseFeePerGas: types.NewU256(baseFeePerGas), - BlockHash: types.NewH256(common.HexToHash(e.BlockHash).Bytes()), - TransactionsRoot: types.NewH256(common.HexToHash(e.TransactionsRoot).Bytes()), - WithdrawalsRoot: types.NewH256(common.HexToHash(e.WithdrawalsRoot).Bytes()), - BlobGasUsed: types.NewU64(blobGasUsed), - ExcessBlobGas: types.NewU64(excessBlobGas), - }, nil -} diff --git a/relayer/relays/beacon/header/syncer/api/api_electra.go b/relayer/relays/beacon/header/syncer/api/api_electra.go new file mode 100644 index 0000000000..7a5bb43685 --- /dev/null +++ b/relayer/relays/beacon/header/syncer/api/api_electra.go @@ -0,0 +1,54 @@ +package api + +import ( + "math/big" + + "github.com/snowfork/go-substrate-rpc-client/v4/types" + "github.com/snowfork/snowbridge/relayer/relays/beacon/header/syncer/scale" + "github.com/snowfork/snowbridge/relayer/relays/beacon/state" + "github.com/snowfork/snowbridge/relayer/relays/util" +) + +func ElectraExecutionPayloadToScale(e *state.ExecutionPayloadElectra) (scale.ExecutionPayloadHeaderDeneb, error) { + var payloadHeader scale.ExecutionPayloadHeaderDeneb + transactionsContainer := state.TransactionsRootContainer{} + transactionsContainer.Transactions = e.Transactions + + transactionsRoot, err := transactionsContainer.HashTreeRoot() + if err != nil { + return payloadHeader, err + } + + var withdrawalRoot types.H256 + + withdrawalContainer := state.WithdrawalsRootContainerMainnet{} + withdrawalContainer.Withdrawals = e.Withdrawals + withdrawalRoot, err = withdrawalContainer.HashTreeRoot() + if err != nil { + return payloadHeader, err + } + + baseFeePerGas := big.Int{} + // Change BaseFeePerGas back from little-endian to big-endian + baseFeePerGas.SetBytes(util.ChangeByteOrder(e.BaseFeePerGas[:])) + + return scale.ExecutionPayloadHeaderDeneb{ + ParentHash: types.NewH256(e.ParentHash[:]), + FeeRecipient: e.FeeRecipient, + StateRoot: types.NewH256(e.StateRoot[:]), + ReceiptsRoot: types.NewH256(e.ReceiptsRoot[:]), + LogsBloom: e.LogsBloom[:], + PrevRandao: types.NewH256(e.PrevRandao[:]), + BlockNumber: types.NewU64(e.BlockNumber), + GasLimit: types.NewU64(e.GasLimit), + GasUsed: types.NewU64(e.GasUsed), + Timestamp: types.NewU64(e.Timestamp), + ExtraData: e.ExtraData, + BaseFeePerGas: types.NewU256(baseFeePerGas), + BlockHash: types.NewH256(e.BlockHash[:]), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalRoot, + BlobGasUsed: types.NewU64(e.BlobGasUsed), + ExcessBlobGas: types.NewU64(e.ExcessBlobGas), + }, nil +} diff --git a/relayer/relays/beacon/header/syncer/api/api_response.go b/relayer/relays/beacon/header/syncer/api/api_response.go index 1ba06034b7..c0084fd96c 100644 --- a/relayer/relays/beacon/header/syncer/api/api_response.go +++ b/relayer/relays/beacon/header/syncer/api/api_response.go @@ -2,6 +2,7 @@ package api import ( "fmt" + "github.com/snowfork/snowbridge/relayer/relays/beacon/protocol" "math/big" "strconv" @@ -461,7 +462,7 @@ func (s SyncAggregateResponse) ToScale() (scale.SyncAggregate, error) { // Because it only returns JSON, we need this interim step where we convert the block JSON to the data // types that the FastSSZ lib expects. When Lodestar supports SSZ block response, we can remove all these // and directly unmarshal SSZ bytes to state.BeaconBlock. -func (b BeaconBlockResponse) ToFastSSZ(isDeneb bool) (state.BeaconBlock, error) { +func (b BeaconBlockResponse) ToFastSSZ(forkVersion protocol.ForkVersion) (state.BeaconBlock, error) { data := b.Data.Message slot, err := util.ToUint64(data.Slot) @@ -691,7 +692,10 @@ func (b BeaconBlockResponse) ToFastSSZ(isDeneb bool) (state.BeaconBlock, error) kzgCommitments = append(kzgCommitments, kzgCommitmentSSZ) } - if isDeneb { + if forkVersion == protocol.Electra { + + } + if forkVersion == protocol.Deneb { return &state.BeaconBlockDenebMainnet{ Slot: slot, ProposerIndex: proposerIndex, diff --git a/relayer/relays/beacon/header/syncer/syncer.go b/relayer/relays/beacon/header/syncer/syncer.go index 7f23cb66e8..7d32b48d45 100644 --- a/relayer/relays/beacon/header/syncer/syncer.go +++ b/relayer/relays/beacon/header/syncer/syncer.go @@ -294,10 +294,13 @@ func (s *Syncer) GetBlockRoots(slot uint64) (scale.BlockRootProof, error) { if err != nil { return blockRootProof, fmt.Errorf("fetch beacon state: %w", err) } - isDeneb := s.protocol.DenebForked(slot) + + forkVersion := s.protocol.ForkVersion(slot) blockRootsContainer = &state.BlockRootsContainerMainnet{} - if isDeneb { + if forkVersion == protocol.Electra { + beaconState = &state.BeaconStateElectra{} + } else if forkVersion == protocol.Deneb { beaconState = &state.BeaconStateDenebMainnet{} } else { beaconState = &state.BeaconStateCapellaMainnet{} @@ -534,7 +537,7 @@ func (s *Syncer) GetHeaderUpdate(blockRoot common.Hash, checkpoint *cache.Proof) return update, err } - sszBlock, err := blockResponse.ToFastSSZ(s.protocol.DenebForked(slot)) + sszBlock, err := blockResponse.ToFastSSZ(s.protocol.ForkVersion(slot)) if err != nil { return update, err } @@ -555,7 +558,14 @@ func (s *Syncer) GetHeaderUpdate(blockRoot common.Hash, checkpoint *cache.Proof) } var versionedExecutionPayloadHeader scale.VersionedExecutionPayloadHeader - if s.protocol.DenebForked(slot) { + forkVersion := protocol.ForkVersion(slot) + if forkVersion == protocol.Electra { + executionPayloadScale, err := api.ElectraExecutionPayloadToScale(sszBlock.ExecutionPayloadElectra()) + if err != nil { + return scale.HeaderUpdatePayload{}, err + } + versionedExecutionPayloadHeader = scale.VersionedExecutionPayloadHeader{Deneb: &executionPayloadScale} + } else if forkVersion == protocol.Deneb { executionPayloadScale, err := api.DenebExecutionPayloadToScale(sszBlock.ExecutionPayloadDeneb()) if err != nil { return scale.HeaderUpdatePayload{}, err @@ -617,9 +627,10 @@ func (s *Syncer) getBeaconStateAtSlot(slot uint64) (state.BeaconState, error) { func (s *Syncer) UnmarshalBeaconState(slot uint64, data []byte) (state.BeaconState, error) { var beaconState state.BeaconState - isDeneb := s.protocol.DenebForked(slot) - - if isDeneb { + forkVersion := protocol.ForkVersion(slot) + if forkVersion == protocol.Electra { + beaconState = &state.BeaconStateElectra{} + } else if forkVersion == protocol.Deneb { beaconState = &state.BeaconStateDenebMainnet{} } else { beaconState = &state.BeaconStateCapellaMainnet{} diff --git a/relayer/relays/beacon/protocol/protocol.go b/relayer/relays/beacon/protocol/protocol.go index a0935730ab..facd3816b8 100644 --- a/relayer/relays/beacon/protocol/protocol.go +++ b/relayer/relays/beacon/protocol/protocol.go @@ -42,10 +42,6 @@ func (p *Protocol) CalculateNextCheckpointSlot(slot uint64) uint64 { return (syncPeriod + 1) * p.Settings.SlotsInEpoch * p.Settings.EpochsPerSyncCommitteePeriod } -func (p *Protocol) DenebForked(slot uint64) bool { - return p.ComputeEpochAtSlot(slot) >= p.Settings.DenebForkEpoch -} - func (p *Protocol) SyncPeriodLength() uint64 { return p.Settings.SlotsInEpoch * p.Settings.EpochsPerSyncCommitteePeriod } @@ -74,3 +70,23 @@ func (p *Protocol) SyncCommitteeSuperMajority(syncCommitteeHex string) (bool, er } return true, nil } + +// ForkVersion is a custom type for Ethereum fork versions. +type ForkVersion string + +const ( + Deneb ForkVersion = "Deneb" + Capella ForkVersion = "Capella" + Electra ForkVersion = "Electra" +) + +func (p *Protocol) ForkVersion(slot uint64) ForkVersion { + epoch := p.ComputeEpochAtSlot(slot) + if epoch >= p.Settings.ForkVersions.Electra { + return Electra + } + if epoch >= p.Settings.ForkVersions.Deneb { + return Deneb + } + return Capella +} diff --git a/relayer/relays/beacon/state/beacon.go b/relayer/relays/beacon/state/beacon.go index bd0f5e8907..62d0abfe54 100644 --- a/relayer/relays/beacon/state/beacon.go +++ b/relayer/relays/beacon/state/beacon.go @@ -187,6 +187,7 @@ type BeaconBlock interface { GetBeaconSlot() uint64 ExecutionPayloadCapella() *ExecutionPayloadCapella ExecutionPayloadDeneb() *ExecutionPayloadDeneb + ExecutionPayloadElectra() *ExecutionPayloadElectra GetTree() (*ssz.Node, error) GetBlockBodyTree() (*ssz.Node, error) } @@ -299,6 +300,10 @@ func (b *BeaconBlockCapellaMainnet) ExecutionPayloadDeneb() *ExecutionPayloadDen return nil } +func (b *BeaconBlockCapellaMainnet) ExecutionPayloadElectra() *ExecutionPayloadElectra { + return nil +} + func (b *BeaconStateCapellaMainnet) GetSlot() uint64 { return b.Slot } diff --git a/relayer/relays/beacon/state/beacon_deneb.go b/relayer/relays/beacon/state/beacon_deneb.go index f68f43ccfe..659ad13825 100644 --- a/relayer/relays/beacon/state/beacon_deneb.go +++ b/relayer/relays/beacon/state/beacon_deneb.go @@ -20,8 +20,8 @@ type ExecutionPayloadDeneb struct { BlockHash [32]byte `ssz-size:"32" json:"block_hash"` Transactions [][]byte `ssz-max:"1048576,1073741824" ssz-size:"?,?" json:"transactions"` Withdrawals []*Withdrawal `ssz-max:"16" json:"withdrawals"` - BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` - ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` + BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` // New in Deneb + ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` // New in Deneb } type ExecutionPayloadHeaderDeneb struct { @@ -40,8 +40,8 @@ type ExecutionPayloadHeaderDeneb struct { BlockHash []byte `json:"block_hash" ssz-size:"32"` TransactionsRoot []byte `json:"transactions_root" ssz-size:"32"` WithdrawalsRoot []byte `json:"withdrawals_root" ssz-size:"32"` - BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` - ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` + BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` // New in Deneb + ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` // New in Deneb } type BeaconBlockDenebMainnet struct { @@ -64,7 +64,7 @@ type BeaconBlockBodyDenebMainnet struct { SyncAggregate *SyncAggregateMainnet `json:"sync_aggregate"` ExecutionPayload *ExecutionPayloadDeneb `json:"execution_payload"` BlsToExecutionChanges []*SignedBLSToExecutionChange `json:"bls_to_execution_changes,omitempty" ssz-max:"16"` - BlobKzgCommitments [][48]byte `json:"blob_kzg_commitments,omitempty" ssz-max:"4096" ssz-size:"?,48"` + BlobKzgCommitments [][48]byte `json:"blob_kzg_commitments,omitempty" ssz-max:"4096" ssz-size:"?,48"` // New in Deneb } type BeaconStateDenebMainnet struct { @@ -114,6 +114,10 @@ func (b *BeaconBlockDenebMainnet) ExecutionPayloadDeneb() *ExecutionPayloadDeneb return b.Body.ExecutionPayload } +func (b *BeaconBlockDenebMainnet) ExecutionPayloadElectra() *ExecutionPayloadElectra { + return nil +} + func (b *BeaconStateDenebMainnet) GetSlot() uint64 { return b.Slot } diff --git a/relayer/relays/beacon/state/beacon_deneb_encoding.go b/relayer/relays/beacon/state/beacon_deneb_encoding.go index f041c55b0f..ec1be58299 100644 --- a/relayer/relays/beacon/state/beacon_deneb_encoding.go +++ b/relayer/relays/beacon/state/beacon_deneb_encoding.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 03b5096ab94e41e2c740924a4ae7ea8fdd515fe3dd4861032a569e28bcba8bb4 +// Hash: 3e0112db5bed3cd4f62a1a793a3a3ac15855471de0a75c0344de8218a658e89b // Version: 0.1.3 package state diff --git a/relayer/relays/beacon/state/beacon_electra.go b/relayer/relays/beacon/state/beacon_electra.go new file mode 100644 index 0000000000..2a266ded1e --- /dev/null +++ b/relayer/relays/beacon/state/beacon_electra.go @@ -0,0 +1,172 @@ +package state + +import ssz "github.com/ferranbt/fastssz" + +type ExecutionPayloadElectra struct { + ParentHash [32]byte `ssz-size:"32" json:"parent_hash"` + FeeRecipient [20]byte `ssz-size:"20" json:"fee_recipient"` + StateRoot [32]byte `ssz-size:"32" json:"state_root"` + ReceiptsRoot [32]byte `ssz-size:"32" json:"receipts_root"` + LogsBloom [256]byte `ssz-size:"256" json:"logs_bloom"` + PrevRandao [32]byte `ssz-size:"32" json:"prev_randao"` + BlockNumber uint64 `json:"block_number"` + GasLimit uint64 `json:"gas_limit"` + GasUsed uint64 `json:"gas_used"` + Timestamp uint64 `json:"timestamp"` + ExtraData []byte `ssz-max:"32" json:"extra_data"` + BaseFeePerGas [32]byte `ssz-size:"32" json:"base_fee_per_gas"` + BlockHash [32]byte `ssz-size:"32" json:"block_hash"` + Transactions [][]byte `ssz-max:"1048576,1073741824" ssz-size:"?,?" json:"transactions"` + Withdrawals []*Withdrawal `ssz-max:"16" json:"withdrawals"` + BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` + ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` +} + +type ExecutionPayloadHeaderElectra struct { + ParentHash []byte `json:"parent_hash" ssz-size:"32"` + FeeRecipient []byte `json:"fee_recipient" ssz-size:"20"` + StateRoot []byte `json:"state_root" ssz-size:"32"` + ReceiptsRoot []byte `json:"receipts_root" ssz-size:"32"` + LogsBloom []byte `json:"logs_bloom" ssz-size:"256"` + PrevRandao []byte `json:"prev_randao" ssz-size:"32"` + BlockNumber uint64 `json:"block_number"` + GasLimit uint64 `json:"gas_limit"` + GasUsed uint64 `json:"gas_used"` + Timestamp uint64 `json:"timestamp"` + ExtraData []byte `json:"extra_data" ssz-max:"32"` + BaseFeePerGas []byte `json:"base_fee_per_gas" ssz-size:"32"` + BlockHash []byte `json:"block_hash" ssz-size:"32"` + TransactionsRoot []byte `json:"transactions_root" ssz-size:"32"` + WithdrawalsRoot []byte `json:"withdrawals_root" ssz-size:"32"` + BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` + ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` + DepositRequestsRoot []byte `json:"deposit_requests_root" ssz-size:"32"` // New in Electra + WithdrawalRequestsRoot []byte `json:"withdrawal_requests_root" ssz-size:"32"` // New in Electra + ConsolidationRequestsRoot []byte `json:"consolidation_requests_root" ssz-size:"32"` // New in Electra +} + +type BeaconBlockElectra struct { + Slot uint64 `json:"slot"` + ProposerIndex uint64 `json:"proposer_index"` + ParentRoot []byte `json:"parent_root" ssz-size:"32"` + StateRoot []byte `json:"state_root" ssz-size:"32"` + Body *BeaconBlockBodyElectra `json:"body"` +} + +type BeaconBlockBodyElectra struct { + RandaoReveal []byte `json:"randao_reveal" ssz-size:"96"` + Eth1Data *Eth1Data `json:"eth1_data"` + Graffiti [32]byte `json:"graffiti" ssz-size:"32"` + ProposerSlashings []*ProposerSlashing `json:"proposer_slashings" ssz-max:"16"` + AttesterSlashings []*AttesterSlashing `json:"attester_slashings" ssz-max:"2"` + Attestations []*Attestation `json:"attestations" ssz-max:"128"` + Deposits []*Deposit `json:"deposits" ssz-max:"16"` + VoluntaryExits []*SignedVoluntaryExit `json:"voluntary_exits" ssz-max:"16"` + SyncAggregate *SyncAggregateMainnet `json:"sync_aggregate"` + ExecutionPayload *ExecutionPayloadElectra `json:"execution_payload"` // Modified in Electra + BlsToExecutionChanges []*SignedBLSToExecutionChange `json:"bls_to_execution_changes,omitempty" ssz-max:"16"` + BlobKzgCommitments [][48]byte `json:"blob_kzg_commitments,omitempty" ssz-max:"4096" ssz-size:"?,48"` +} + +type BeaconStateElectra struct { + GenesisTime uint64 `json:"genesis_time"` + GenesisValidatorsRoot []byte `json:"genesis_validators_root" ssz-size:"32"` + Slot uint64 `json:"slot"` + Fork *Fork `json:"fork"` + LatestBlockHeader *BeaconBlockHeader `json:"latest_block_header"` + BlockRoots [][]byte `json:"block_roots" ssz-size:"8192,32"` + StateRoots [][]byte `json:"state_roots" ssz-size:"8192,32"` + HistoricalRoots [][]byte `json:"historical_roots" ssz-max:"16777216" ssz-size:"?,32"` + Eth1Data *Eth1Data `json:"eth1_data"` + Eth1DataVotes []*Eth1Data `json:"eth1_data_votes" ssz-max:"2048"` + Eth1DepositIndex uint64 `json:"eth1_deposit_index"` + Validators []*Validator `json:"validators" ssz-max:"1099511627776"` + Balances []uint64 `json:"balances" ssz-max:"1099511627776"` + RandaoMixes [][]byte `json:"randao_mixes" ssz-size:"65536,32"` + Slashings []uint64 `json:"slashings" ssz-size:"8192"` + PreviousEpochParticipation []byte `json:"previous_epoch_participation" ssz-max:"1099511627776"` + CurrentEpochParticipation []byte `json:"current_epoch_participation" ssz-max:"1099511627776"` + JustificationBits []byte `json:"justification_bits" cast-type:"github.com/prysmaticlabs/go-bitfield.Bitvector4" ssz-size:"1"` + PreviousJustifiedCheckpoint *Checkpoint `json:"previous_justified_checkpoint"` + CurrentJustifiedCheckpoint *Checkpoint `json:"current_justified_checkpoint"` + FinalizedCheckpoint *Checkpoint `json:"finalized_checkpoint"` + InactivityScores []uint64 `json:"inactivity_scores" ssz-max:"1099511627776"` + CurrentSyncCommittee *SyncCommittee `json:"current_sync_committee"` + NextSyncCommittee *SyncCommittee `json:"next_sync_committee"` + LatestExecutionPayloadHeader *ExecutionPayloadHeaderElectra `json:"latest_execution_payload_header"` + NextWithdrawalIndex uint64 `json:"next_withdrawal_index,omitempty"` + NextWithdrawalValidatorIndex uint64 `json:"next_withdrawal_validator_index,omitempty"` + HistoricalSummaries []*HistoricalSummary `json:"historical_summaries,omitempty" ssz-max:"16777216"` + DepositRequestsStartIndex uint64 `json:"deposit_requests_start_index,omitempty"` // New in Electra + DepositBalanceToConsume uint64 `json:"deposit_balance_to_consume,omitempty"` // New in Electra + ExitBalanceToConsume uint64 `json:"exit_balance_to_consume,omitempty"` // New in Electra + EarliestExitEpoch uint64 `json:"earliest_exit_epoch,omitempty"` // New in Electra + ConsolidationBalanceToConsume uint64 `json:"consolidation_balance_to_consume,omitempty"` // New in Electra + EarliestConsolidationEpoch uint64 `json:"earliest_consolidation_epoch,omitempty"` // New in Electra + PendingBalanceDeposits []*PendingBalanceDeposit `json:"pending_balance_deposits,omitempty" ssz-max:"134217728"` // New in Electra + PendingPartialWithdrawals []*PendingPartialWithdrawal `json:"pending_partial_withdrawals,omitempty" ssz-max:"134217728"` // New in Electra + PendingConsolidations []*PendingConsolidation `json:"pending_consolidations,omitempty" ssz-max:"262144"` // New in Electra +} + +type PendingBalanceDeposit struct { + Index uint64 `json:"index"` + Amount uint64 `json:"amount"` +} + +type PendingPartialWithdrawal struct { + Index uint64 `json:"index"` + Amount uint64 `json:"amount"` + WithdrawableEpoch uint64 `json:"withdrawable_epoch"` +} + +type PendingConsolidation struct { + SourceIndex uint64 `json:"source_index"` + TargetIndex uint64 `json:"target_index"` +} + +func (b *BeaconBlockElectra) GetBeaconSlot() uint64 { + return b.Slot +} + +func (b *BeaconBlockElectra) GetBlockBodyTree() (*ssz.Node, error) { + return b.Body.GetTree() +} + +func (b *BeaconBlockElectra) ExecutionPayloadCapella() *ExecutionPayloadCapella { + return nil +} + +func (b *BeaconBlockElectra) ExecutionPayloadDeneb() *ExecutionPayloadDeneb { + return nil +} + +func (b *BeaconBlockElectra) ExecutionPayloadElectra() *ExecutionPayloadElectra { + return b.Body.ExecutionPayload +} + +func (b *BeaconStateElectra) GetSlot() uint64 { + return b.Slot +} + +func (b *BeaconStateElectra) GetLatestBlockHeader() *BeaconBlockHeader { + return b.LatestBlockHeader +} + +func (b *BeaconStateElectra) GetBlockRoots() [][]byte { + return b.BlockRoots +} + +func (b *BeaconStateElectra) SetBlockRoots(blockRoots [][]byte) { + b.BlockRoots = blockRoots +} + +func (b *BeaconStateElectra) GetFinalizedCheckpoint() *Checkpoint { + return b.FinalizedCheckpoint +} + +func (b *BeaconStateElectra) GetNextSyncCommittee() *SyncCommittee { + return b.NextSyncCommittee +} +func (b *BeaconStateElectra) GetCurrentSyncCommittee() *SyncCommittee { + return b.CurrentSyncCommittee +} diff --git a/relayer/relays/beacon/state/beacon_encoding.go b/relayer/relays/beacon/state/beacon_encoding.go index ea9e3b1fb0..53a3ab0fc6 100644 --- a/relayer/relays/beacon/state/beacon_encoding.go +++ b/relayer/relays/beacon/state/beacon_encoding.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 03b5096ab94e41e2c740924a4ae7ea8fdd515fe3dd4861032a569e28bcba8bb4 +// Hash: 3e0112db5bed3cd4f62a1a793a3a3ac15855471de0a75c0344de8218a658e89b // Version: 0.1.3 package state From d64e224ba3995ea8a81d4ad92b961c2f7ea1c46e Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Tue, 10 Sep 2024 11:51:29 +0200 Subject: [PATCH 03/13] more electra work --- relayer/contracts/gateway.go | 147 +- .../beacon/header/syncer/api/api_electra.go | 74 + .../beacon/header/syncer/api/api_response.go | 107 +- .../beacon/state/beacon_deneb_encoding.go | 2 +- relayer/relays/beacon/state/beacon_electra.go | 79 +- .../beacon/state/beacon_electra_encoding.go | 3740 +++++++++++++++++ 6 files changed, 3963 insertions(+), 186 deletions(-) create mode 100644 relayer/relays/beacon/state/beacon_electra_encoding.go diff --git a/relayer/contracts/gateway.go b/relayer/contracts/gateway.go index ff6723fc6c..aa7842c263 100644 --- a/relayer/contracts/gateway.go +++ b/relayer/contracts/gateway.go @@ -91,7 +91,7 @@ type VerificationProof struct { // GatewayMetaData contains all meta data concerning the Gateway contract. var GatewayMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"agentOf\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"channelNoncesOf\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"channelOperatingModeOf\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumOperatingMode\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"implementation\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isTokenRegistered\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"operatingMode\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumOperatingMode\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pricingParameters\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"UD60x18\"},{\"name\":\"\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"quoteRegisterTokenFee\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"quoteSendTokenFee\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"internalType\":\"ParaID\"},{\"name\":\"destinationFee\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"registerToken\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"sendToken\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"internalType\":\"ParaID\"},{\"name\":\"destinationAddress\",\"type\":\"tuple\",\"internalType\":\"structMultiAddress\",\"components\":[{\"name\":\"kind\",\"type\":\"uint8\",\"internalType\":\"enumKind\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"destinationFee\",\"type\":\"uint128\",\"internalType\":\"uint128\"},{\"name\":\"amount\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"submitV1\",\"inputs\":[{\"name\":\"message\",\"type\":\"tuple\",\"internalType\":\"structInboundMessage\",\"components\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"command\",\"type\":\"uint8\",\"internalType\":\"enumCommand\"},{\"name\":\"params\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"maxDispatchGas\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxFeePerGas\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"reward\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"id\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"leafProof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"},{\"name\":\"headerProof\",\"type\":\"tuple\",\"internalType\":\"structVerification.Proof\",\"components\":[{\"name\":\"header\",\"type\":\"tuple\",\"internalType\":\"structVerification.ParachainHeader\",\"components\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"number\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"extrinsicsRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"digestItems\",\"type\":\"tuple[]\",\"internalType\":\"structVerification.DigestItem[]\",\"components\":[{\"name\":\"kind\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"consensusEngineID\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"headProof\",\"type\":\"tuple\",\"internalType\":\"structVerification.HeadProof\",\"components\":[{\"name\":\"pos\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"width\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"proof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"}]},{\"name\":\"leafPartial\",\"type\":\"tuple\",\"internalType\":\"structVerification.MMRLeafPartial\",\"components\":[{\"name\":\"version\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"parentNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextAuthoritySetID\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"nextAuthoritySetLen\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"nextAuthoritySetRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"leafProof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"},{\"name\":\"leafProofOrder\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"AgentCreated\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"agent\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"AgentFundsWithdrawn\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"recipient\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ChannelCreated\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ChannelUpdated\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ForeignTokenRegistered\",\"inputs\":[{\"name\":\"tokenID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"token\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"InboundMessageDispatched\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"messageID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"success\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OperatingModeChanged\",\"inputs\":[{\"name\":\"mode\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"enumOperatingMode\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OutboundMessageAccepted\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"messageID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"payload\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"PricingParametersChanged\",\"inputs\":[],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenRegistrationSent\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenSent\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"sender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"indexed\":true,\"internalType\":\"ParaID\"},{\"name\":\"destinationAddress\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structMultiAddress\",\"components\":[{\"name\":\"kind\",\"type\":\"uint8\",\"internalType\":\"enumKind\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"amount\",\"type\":\"uint128\",\"indexed\":false,\"internalType\":\"uint128\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenTransferFeesChanged\",\"inputs\":[],\"anonymous\":false}]", + ABI: "[{\"type\":\"function\",\"name\":\"agentOf\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"channelNoncesOf\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"\",\"type\":\"uint64\",\"internalType\":\"uint64\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"channelOperatingModeOf\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumOperatingMode\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"implementation\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\",\"internalType\":\"address\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"isTokenRegistered\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\",\"internalType\":\"bool\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"operatingMode\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\",\"internalType\":\"enumOperatingMode\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"pricingParameters\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"UD60x18\"},{\"name\":\"\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"quoteRegisterTokenFee\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"quoteSendTokenFee\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"internalType\":\"ParaID\"},{\"name\":\"destinationFee\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"outputs\":[{\"name\":\"\",\"type\":\"uint256\",\"internalType\":\"uint256\"}],\"stateMutability\":\"view\"},{\"type\":\"function\",\"name\":\"registerToken\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"sendToken\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"internalType\":\"ParaID\"},{\"name\":\"destinationAddress\",\"type\":\"tuple\",\"internalType\":\"structMultiAddress\",\"components\":[{\"name\":\"kind\",\"type\":\"uint8\",\"internalType\":\"enumKind\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"destinationFee\",\"type\":\"uint128\",\"internalType\":\"uint128\"},{\"name\":\"amount\",\"type\":\"uint128\",\"internalType\":\"uint128\"}],\"outputs\":[],\"stateMutability\":\"payable\"},{\"type\":\"function\",\"name\":\"submitV1\",\"inputs\":[{\"name\":\"message\",\"type\":\"tuple\",\"internalType\":\"structInboundMessage\",\"components\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"command\",\"type\":\"uint8\",\"internalType\":\"enumCommand\"},{\"name\":\"params\",\"type\":\"bytes\",\"internalType\":\"bytes\"},{\"name\":\"maxDispatchGas\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"maxFeePerGas\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"reward\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"id\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"leafProof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"},{\"name\":\"headerProof\",\"type\":\"tuple\",\"internalType\":\"structVerification.Proof\",\"components\":[{\"name\":\"header\",\"type\":\"tuple\",\"internalType\":\"structVerification.ParachainHeader\",\"components\":[{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"number\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"stateRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"extrinsicsRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"digestItems\",\"type\":\"tuple[]\",\"internalType\":\"structVerification.DigestItem[]\",\"components\":[{\"name\":\"kind\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"consensusEngineID\",\"type\":\"bytes4\",\"internalType\":\"bytes4\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]}]},{\"name\":\"headProof\",\"type\":\"tuple\",\"internalType\":\"structVerification.HeadProof\",\"components\":[{\"name\":\"pos\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"width\",\"type\":\"uint256\",\"internalType\":\"uint256\"},{\"name\":\"proof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"}]},{\"name\":\"leafPartial\",\"type\":\"tuple\",\"internalType\":\"structVerification.MMRLeafPartial\",\"components\":[{\"name\":\"version\",\"type\":\"uint8\",\"internalType\":\"uint8\"},{\"name\":\"parentNumber\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"parentHash\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"},{\"name\":\"nextAuthoritySetID\",\"type\":\"uint64\",\"internalType\":\"uint64\"},{\"name\":\"nextAuthoritySetLen\",\"type\":\"uint32\",\"internalType\":\"uint32\"},{\"name\":\"nextAuthoritySetRoot\",\"type\":\"bytes32\",\"internalType\":\"bytes32\"}]},{\"name\":\"leafProof\",\"type\":\"bytes32[]\",\"internalType\":\"bytes32[]\"},{\"name\":\"leafProofOrder\",\"type\":\"uint256\",\"internalType\":\"uint256\"}]}],\"outputs\":[],\"stateMutability\":\"nonpayable\"},{\"type\":\"event\",\"name\":\"AgentCreated\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"indexed\":false,\"internalType\":\"bytes32\"},{\"name\":\"agent\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"AgentFundsWithdrawn\",\"inputs\":[{\"name\":\"agentID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"recipient\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\",\"indexed\":false,\"internalType\":\"uint256\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ChannelCreated\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"ChannelUpdated\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"InboundMessageDispatched\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"messageID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"success\",\"type\":\"bool\",\"indexed\":false,\"internalType\":\"bool\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OperatingModeChanged\",\"inputs\":[{\"name\":\"mode\",\"type\":\"uint8\",\"indexed\":false,\"internalType\":\"enumOperatingMode\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"OutboundMessageAccepted\",\"inputs\":[{\"name\":\"channelID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"ChannelID\"},{\"name\":\"nonce\",\"type\":\"uint64\",\"indexed\":false,\"internalType\":\"uint64\"},{\"name\":\"messageID\",\"type\":\"bytes32\",\"indexed\":true,\"internalType\":\"bytes32\"},{\"name\":\"payload\",\"type\":\"bytes\",\"indexed\":false,\"internalType\":\"bytes\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"PricingParametersChanged\",\"inputs\":[],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenRegistrationSent\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"indexed\":false,\"internalType\":\"address\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenSent\",\"inputs\":[{\"name\":\"token\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"sender\",\"type\":\"address\",\"indexed\":true,\"internalType\":\"address\"},{\"name\":\"destinationChain\",\"type\":\"uint32\",\"indexed\":true,\"internalType\":\"ParaID\"},{\"name\":\"destinationAddress\",\"type\":\"tuple\",\"indexed\":false,\"internalType\":\"structMultiAddress\",\"components\":[{\"name\":\"kind\",\"type\":\"uint8\",\"internalType\":\"enumKind\"},{\"name\":\"data\",\"type\":\"bytes\",\"internalType\":\"bytes\"}]},{\"name\":\"amount\",\"type\":\"uint128\",\"indexed\":false,\"internalType\":\"uint128\"}],\"anonymous\":false},{\"type\":\"event\",\"name\":\"TokenTransferFeesChanged\",\"inputs\":[],\"anonymous\":false}]", } // GatewayABI is the input ABI used to generate the binding from. @@ -1161,151 +1161,6 @@ func (_Gateway *GatewayFilterer) ParseChannelUpdated(log types.Log) (*GatewayCha return event, nil } -// GatewayForeignTokenRegisteredIterator is returned from FilterForeignTokenRegistered and is used to iterate over the raw logs and unpacked data for ForeignTokenRegistered events raised by the Gateway contract. -type GatewayForeignTokenRegisteredIterator struct { - Event *GatewayForeignTokenRegistered // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *GatewayForeignTokenRegisteredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(GatewayForeignTokenRegistered) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(GatewayForeignTokenRegistered) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *GatewayForeignTokenRegisteredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *GatewayForeignTokenRegisteredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// GatewayForeignTokenRegistered represents a ForeignTokenRegistered event raised by the Gateway contract. -type GatewayForeignTokenRegistered struct { - TokenID [32]byte - Token common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterForeignTokenRegistered is a free log retrieval operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. -// -// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) -func (_Gateway *GatewayFilterer) FilterForeignTokenRegistered(opts *bind.FilterOpts, tokenID [][32]byte) (*GatewayForeignTokenRegisteredIterator, error) { - - var tokenIDRule []interface{} - for _, tokenIDItem := range tokenID { - tokenIDRule = append(tokenIDRule, tokenIDItem) - } - - logs, sub, err := _Gateway.contract.FilterLogs(opts, "ForeignTokenRegistered", tokenIDRule) - if err != nil { - return nil, err - } - return &GatewayForeignTokenRegisteredIterator{contract: _Gateway.contract, event: "ForeignTokenRegistered", logs: logs, sub: sub}, nil -} - -// WatchForeignTokenRegistered is a free log subscription operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. -// -// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) -func (_Gateway *GatewayFilterer) WatchForeignTokenRegistered(opts *bind.WatchOpts, sink chan<- *GatewayForeignTokenRegistered, tokenID [][32]byte) (event.Subscription, error) { - - var tokenIDRule []interface{} - for _, tokenIDItem := range tokenID { - tokenIDRule = append(tokenIDRule, tokenIDItem) - } - - logs, sub, err := _Gateway.contract.WatchLogs(opts, "ForeignTokenRegistered", tokenIDRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(GatewayForeignTokenRegistered) - if err := _Gateway.contract.UnpackLog(event, "ForeignTokenRegistered", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseForeignTokenRegistered is a log parse operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. -// -// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) -func (_Gateway *GatewayFilterer) ParseForeignTokenRegistered(log types.Log) (*GatewayForeignTokenRegistered, error) { - event := new(GatewayForeignTokenRegistered) - if err := _Gateway.contract.UnpackLog(event, "ForeignTokenRegistered", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - // GatewayInboundMessageDispatchedIterator is returned from FilterInboundMessageDispatched and is used to iterate over the raw logs and unpacked data for InboundMessageDispatched events raised by the Gateway contract. type GatewayInboundMessageDispatchedIterator struct { Event *GatewayInboundMessageDispatched // Event containing the contract specifics and raw log diff --git a/relayer/relays/beacon/header/syncer/api/api_electra.go b/relayer/relays/beacon/header/syncer/api/api_electra.go index 7a5bb43685..10f942aa53 100644 --- a/relayer/relays/beacon/header/syncer/api/api_electra.go +++ b/relayer/relays/beacon/header/syncer/api/api_electra.go @@ -52,3 +52,77 @@ func ElectraExecutionPayloadToScale(e *state.ExecutionPayloadElectra) (scale.Exe ExcessBlobGas: types.NewU64(e.ExcessBlobGas), }, nil } + +func (a AttesterSlashingResponse) ToFastSSZElectra() (*state.AttesterSlashingElectra, error) { + attestation1, err := a.Attestation1.ToFastSSZElectra() + if err != nil { + return nil, err + } + + attestation2, err := a.Attestation2.ToFastSSZElectra() + if err != nil { + return nil, err + } + + return &state.AttesterSlashingElectra{ + Attestation1: attestation1, + Attestation2: attestation2, + }, nil +} + +func (i IndexedAttestationResponse) ToFastSSZElectra() (*state.IndexedAttestationElectra, error) { + data, err := i.Data.ToFastSSZ() + if err != nil { + return nil, err + } + + attestationIndexes := []uint64{} + for _, index := range i.AttestingIndices { + indexInt, err := util.ToUint64(index) + if err != nil { + return nil, err + } + + attestationIndexes = append(attestationIndexes, indexInt) + } + + signature, err := util.HexStringToByteArray(i.Signature) + if err != nil { + return nil, err + } + + return &state.IndexedAttestationElectra{ + AttestationIndices: attestationIndexes, + Data: data, + Signature: signature, + }, nil +} + +func (a AttestationResponse) ToFastSSZElectra() (*state.AttestationElectra, error) { + data, err := a.Data.ToFastSSZ() + if err != nil { + return nil, err + } + + aggregationBits, err := util.HexStringToByteArray(a.AggregationBits) + if err != nil { + return nil, err + } + + signature, err := util.HexStringTo96Bytes(a.Signature) + if err != nil { + return nil, err + } + + committeeBits, err := util.HexStringToByteArray(a.CommitteeBits) + if err != nil { + return nil, err + } + + return &state.AttestationElectra{ + AggregationBits: aggregationBits, + Data: data, + Signature: signature, + CommitteeBits: committeeBits, + }, nil +} diff --git a/relayer/relays/beacon/header/syncer/api/api_response.go b/relayer/relays/beacon/header/syncer/api/api_response.go index c0084fd96c..17a29b459f 100644 --- a/relayer/relays/beacon/header/syncer/api/api_response.go +++ b/relayer/relays/beacon/header/syncer/api/api_response.go @@ -151,6 +151,7 @@ type AttestationResponse struct { AggregationBits string `json:"aggregation_bits"` Data AttestationDataResponse `json:"data"` Signature string `json:"signature"` + CommitteeBits string `json:"committee_bits,omitempty"` } type SignedVoluntaryExitResponse struct { @@ -522,26 +523,6 @@ func (b BeaconBlockResponse) ToFastSSZ(forkVersion protocol.ForkVersion) (state. proposerSlashings = append(proposerSlashings, proposerSlashingSSZ) } - attesterSlashings := []*state.AttesterSlashing{} - for _, attesterSlashing := range body.AttesterSlashings { - attesterSlashingSSZ, err := attesterSlashing.ToFastSSZ() - if err != nil { - return nil, err - } - - attesterSlashings = append(attesterSlashings, attesterSlashingSSZ) - } - - attestations := []*state.Attestation{} - for _, attestation := range body.Attestations { - attestationSSZ, err := attestation.ToFastSSZ() - if err != nil { - return nil, err - } - - attestations = append(attestations, attestationSSZ) - } - deposits := []*state.Deposit{} for _, deposit := range body.Deposits { depositScale, err := deposit.ToFastSSZ() @@ -694,7 +675,93 @@ func (b BeaconBlockResponse) ToFastSSZ(forkVersion protocol.ForkVersion) (state. if forkVersion == protocol.Electra { + attesterSlashings := []*state.AttesterSlashingElectra{} + for _, attesterSlashing := range body.AttesterSlashings { + attesterSlashingSSZ, err := attesterSlashing.ToFastSSZElectra() + if err != nil { + return nil, err + } + + attesterSlashings = append(attesterSlashings, attesterSlashingSSZ) + } + + attestations := []*state.AttestationElectra{} + for _, attestation := range body.Attestations { + attestationSSZ, err := attestation.ToFastSSZElectra() + if err != nil { + return nil, err + } + + attestations = append(attestations, attestationSSZ) + } + + return &state.BeaconBlockElectra{ + Slot: slot, + ProposerIndex: proposerIndex, + ParentRoot: parentRoot, + StateRoot: stateRoot, + Body: &state.BeaconBlockBodyElectra{ + RandaoReveal: randaoReveal, + Eth1Data: &state.Eth1Data{ + DepositRoot: eth1DepositRoot, + DepositCount: eth1DepositCount, + BlockHash: eth1BlockHash, + }, + Graffiti: graffiti, + ProposerSlashings: proposerSlashings, + AttesterSlashings: attesterSlashings, + Attestations: attestations, + Deposits: deposits, + VoluntaryExits: voluntaryExits, + SyncAggregate: &state.SyncAggregateMainnet{ + SyncCommitteeBits: syncCommitteeBits, + SyncCommitteeSignature: syncCommitteeSignature, + }, + ExecutionPayload: &state.ExecutionPayloadElectra{ + ParentHash: parentHash, + FeeRecipient: feeRecipient, + StateRoot: executionStateRoot, + ReceiptsRoot: receiptsRoot, + LogsBloom: logsBloom, + PrevRandao: prevRando, + BlockNumber: blockNumber, + GasLimit: gasLimit, + GasUsed: gasUsed, + Timestamp: timestamp, + ExtraData: extraData, + BaseFeePerGas: baseFeePerGasBytes, + BlockHash: blockHash, + Transactions: transactions, + Withdrawals: withdrawals, + BlobGasUsed: blobGasUsed, + ExcessBlobGas: excessBlobGas, + }, + BlsToExecutionChanges: blsExecutionChanges, + BlobKzgCommitments: kzgCommitments, + }, + }, nil + } + + attesterSlashings := []*state.AttesterSlashing{} + for _, attesterSlashing := range body.AttesterSlashings { + attesterSlashingSSZ, err := attesterSlashing.ToFastSSZ() + if err != nil { + return nil, err + } + + attesterSlashings = append(attesterSlashings, attesterSlashingSSZ) } + + attestations := []*state.Attestation{} + for _, attestation := range body.Attestations { + attestationSSZ, err := attestation.ToFastSSZ() + if err != nil { + return nil, err + } + + attestations = append(attestations, attestationSSZ) + } + if forkVersion == protocol.Deneb { return &state.BeaconBlockDenebMainnet{ Slot: slot, diff --git a/relayer/relays/beacon/state/beacon_deneb_encoding.go b/relayer/relays/beacon/state/beacon_deneb_encoding.go index ec1be58299..9fa8996404 100644 --- a/relayer/relays/beacon/state/beacon_deneb_encoding.go +++ b/relayer/relays/beacon/state/beacon_deneb_encoding.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 3e0112db5bed3cd4f62a1a793a3a3ac15855471de0a75c0344de8218a658e89b +// Hash: 59f099d56dedd1f5875bcefc64e241f92e3ee92a89a3506957acdae15d8cf77e // Version: 0.1.3 package state diff --git a/relayer/relays/beacon/state/beacon_electra.go b/relayer/relays/beacon/state/beacon_electra.go index 2a266ded1e..2e5bafdb1f 100644 --- a/relayer/relays/beacon/state/beacon_electra.go +++ b/relayer/relays/beacon/state/beacon_electra.go @@ -3,23 +3,26 @@ package state import ssz "github.com/ferranbt/fastssz" type ExecutionPayloadElectra struct { - ParentHash [32]byte `ssz-size:"32" json:"parent_hash"` - FeeRecipient [20]byte `ssz-size:"20" json:"fee_recipient"` - StateRoot [32]byte `ssz-size:"32" json:"state_root"` - ReceiptsRoot [32]byte `ssz-size:"32" json:"receipts_root"` - LogsBloom [256]byte `ssz-size:"256" json:"logs_bloom"` - PrevRandao [32]byte `ssz-size:"32" json:"prev_randao"` - BlockNumber uint64 `json:"block_number"` - GasLimit uint64 `json:"gas_limit"` - GasUsed uint64 `json:"gas_used"` - Timestamp uint64 `json:"timestamp"` - ExtraData []byte `ssz-max:"32" json:"extra_data"` - BaseFeePerGas [32]byte `ssz-size:"32" json:"base_fee_per_gas"` - BlockHash [32]byte `ssz-size:"32" json:"block_hash"` - Transactions [][]byte `ssz-max:"1048576,1073741824" ssz-size:"?,?" json:"transactions"` - Withdrawals []*Withdrawal `ssz-max:"16" json:"withdrawals"` - BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` - ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` + ParentHash [32]byte `ssz-size:"32" json:"parent_hash"` + FeeRecipient [20]byte `ssz-size:"20" json:"fee_recipient"` + StateRoot [32]byte `ssz-size:"32" json:"state_root"` + ReceiptsRoot [32]byte `ssz-size:"32" json:"receipts_root"` + LogsBloom [256]byte `ssz-size:"256" json:"logs_bloom"` + PrevRandao [32]byte `ssz-size:"32" json:"prev_randao"` + BlockNumber uint64 `json:"block_number"` + GasLimit uint64 `json:"gas_limit"` + GasUsed uint64 `json:"gas_used"` + Timestamp uint64 `json:"timestamp"` + ExtraData []byte `ssz-max:"32" json:"extra_data"` + BaseFeePerGas [32]byte `ssz-size:"32" json:"base_fee_per_gas"` + BlockHash [32]byte `ssz-size:"32" json:"block_hash"` + Transactions [][]byte `ssz-max:"1048576,1073741824" ssz-size:"?,?" json:"transactions"` + Withdrawals []*Withdrawal `ssz-max:"16" json:"withdrawals"` + BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` + ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` + DepositRequests []*DepositRequest `ssz-max:"8192" json:"deposit_requests,omitempty"` // New in Electra + WithdrawalRequests []*WithdrawalRequest `ssz-max:"16" json:"withdrawal_requests,omitempty"` // New in Electra + ConsolidationRequests []*ConsolidationRequest `ssz-max:"1" json:"consolidation_requests,omitempty"` // New in Electra } type ExecutionPayloadHeaderElectra struct { @@ -45,6 +48,26 @@ type ExecutionPayloadHeaderElectra struct { ConsolidationRequestsRoot []byte `json:"consolidation_requests_root" ssz-size:"32"` // New in Electra } +type DepositRequest struct { + Pubkey [48]byte `json:"pubkey" ssz-size:"48"` + WithdrawalCredentials [32]byte `ssz-size:"32" json:"withdrawal_credentials"` + Amount uint64 `json:"amount"` + Signature []byte `json:"signature,omitempty" ssz-size:"96"` + Index uint64 `json:"index,omitempty"` +} + +type WithdrawalRequest struct { + SourceAddress [20]byte `ssz-size:"20" json:"source_address" ` + ValidatorPubkey [48]byte `ssz-size:"48" json:"validator_pubkey"` + Amount uint64 `json:"amount"` +} + +type ConsolidationRequest struct { + SourceAddress [20]byte `ssz-size:"20" json:"source_address" ` + SourcePubkey [48]byte `ssz-size:"48" json:"source_pubkey"` + TargetPubkey [48]byte `ssz-size:"48" json:"target_pubkey"` +} + type BeaconBlockElectra struct { Slot uint64 `json:"slot"` ProposerIndex uint64 `json:"proposer_index"` @@ -58,8 +81,8 @@ type BeaconBlockBodyElectra struct { Eth1Data *Eth1Data `json:"eth1_data"` Graffiti [32]byte `json:"graffiti" ssz-size:"32"` ProposerSlashings []*ProposerSlashing `json:"proposer_slashings" ssz-max:"16"` - AttesterSlashings []*AttesterSlashing `json:"attester_slashings" ssz-max:"2"` - Attestations []*Attestation `json:"attestations" ssz-max:"128"` + AttesterSlashings []*AttesterSlashingElectra `json:"attester_slashings" ssz-max:"1"` // Modified in Electra + Attestations []*AttestationElectra `json:"attestations" ssz-max:"8"` // Modified in Electra Deposits []*Deposit `json:"deposits" ssz-max:"16"` VoluntaryExits []*SignedVoluntaryExit `json:"voluntary_exits" ssz-max:"16"` SyncAggregate *SyncAggregateMainnet `json:"sync_aggregate"` @@ -108,6 +131,24 @@ type BeaconStateElectra struct { PendingConsolidations []*PendingConsolidation `json:"pending_consolidations,omitempty" ssz-max:"262144"` // New in Electra } +type AttestationElectra struct { + AggregationBits []byte `json:"aggregation_bits" ssz:"bitlist" ssz-max:"131072"` // Modified in Electra + Data *AttestationData `json:"data"` + Signature [96]byte `json:"signature" ssz-size:"96"` + CommitteeBits []byte `json:"committee_bits" ssz-size:"64"` // New in Electra +} + +type AttesterSlashingElectra struct { + Attestation1 *IndexedAttestationElectra `json:"attestation_1"` + Attestation2 *IndexedAttestationElectra `json:"attestation_2"` +} + +type IndexedAttestationElectra struct { + AttestationIndices []uint64 `json:"attesting_indices" ssz-max:"131072"` // Modified in Electra + Data *AttestationData `json:"data"` + Signature []byte `json:"signature" ssz-size:"96"` +} + type PendingBalanceDeposit struct { Index uint64 `json:"index"` Amount uint64 `json:"amount"` diff --git a/relayer/relays/beacon/state/beacon_electra_encoding.go b/relayer/relays/beacon/state/beacon_electra_encoding.go new file mode 100644 index 0000000000..455092dba8 --- /dev/null +++ b/relayer/relays/beacon/state/beacon_electra_encoding.go @@ -0,0 +1,3740 @@ +// Code generated by fastssz. DO NOT EDIT. +// Hash: 59f099d56dedd1f5875bcefc64e241f92e3ee92a89a3506957acdae15d8cf77e +// Version: 0.1.3 +package state + +import ( + ssz "github.com/ferranbt/fastssz" +) + +// MarshalSSZ ssz marshals the ExecutionPayloadElectra object +func (e *ExecutionPayloadElectra) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(e) +} + +// MarshalSSZTo ssz marshals the ExecutionPayloadElectra object to a target array +func (e *ExecutionPayloadElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(540) + + // Field (0) 'ParentHash' + dst = append(dst, e.ParentHash[:]...) + + // Field (1) 'FeeRecipient' + dst = append(dst, e.FeeRecipient[:]...) + + // Field (2) 'StateRoot' + dst = append(dst, e.StateRoot[:]...) + + // Field (3) 'ReceiptsRoot' + dst = append(dst, e.ReceiptsRoot[:]...) + + // Field (4) 'LogsBloom' + dst = append(dst, e.LogsBloom[:]...) + + // Field (5) 'PrevRandao' + dst = append(dst, e.PrevRandao[:]...) + + // Field (6) 'BlockNumber' + dst = ssz.MarshalUint64(dst, e.BlockNumber) + + // Field (7) 'GasLimit' + dst = ssz.MarshalUint64(dst, e.GasLimit) + + // Field (8) 'GasUsed' + dst = ssz.MarshalUint64(dst, e.GasUsed) + + // Field (9) 'Timestamp' + dst = ssz.MarshalUint64(dst, e.Timestamp) + + // Offset (10) 'ExtraData' + dst = ssz.WriteOffset(dst, offset) + offset += len(e.ExtraData) + + // Field (11) 'BaseFeePerGas' + dst = append(dst, e.BaseFeePerGas[:]...) + + // Field (12) 'BlockHash' + dst = append(dst, e.BlockHash[:]...) + + // Offset (13) 'Transactions' + dst = ssz.WriteOffset(dst, offset) + for ii := 0; ii < len(e.Transactions); ii++ { + offset += 4 + offset += len(e.Transactions[ii]) + } + + // Offset (14) 'Withdrawals' + dst = ssz.WriteOffset(dst, offset) + offset += len(e.Withdrawals) * 44 + + // Field (15) 'BlobGasUsed' + dst = ssz.MarshalUint64(dst, e.BlobGasUsed) + + // Field (16) 'ExcessBlobGas' + dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) + + // Offset (17) 'DepositRequests' + dst = ssz.WriteOffset(dst, offset) + offset += len(e.DepositRequests) * 192 + + // Offset (18) 'WithdrawalRequests' + dst = ssz.WriteOffset(dst, offset) + offset += len(e.WithdrawalRequests) * 76 + + // Offset (19) 'ConsolidationRequests' + dst = ssz.WriteOffset(dst, offset) + offset += len(e.ConsolidationRequests) * 116 + + // Field (10) 'ExtraData' + if size := len(e.ExtraData); size > 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadElectra.ExtraData", size, 32) + return + } + dst = append(dst, e.ExtraData...) + + // Field (13) 'Transactions' + if size := len(e.Transactions); size > 1048576 { + err = ssz.ErrListTooBigFn("ExecutionPayloadElectra.Transactions", size, 1048576) + return + } + { + offset = 4 * len(e.Transactions) + for ii := 0; ii < len(e.Transactions); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += len(e.Transactions[ii]) + } + } + for ii := 0; ii < len(e.Transactions); ii++ { + if size := len(e.Transactions[ii]); size > 1073741824 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadElectra.Transactions[ii]", size, 1073741824) + return + } + dst = append(dst, e.Transactions[ii]...) + } + + // Field (14) 'Withdrawals' + if size := len(e.Withdrawals); size > 16 { + err = ssz.ErrListTooBigFn("ExecutionPayloadElectra.Withdrawals", size, 16) + return + } + for ii := 0; ii < len(e.Withdrawals); ii++ { + if dst, err = e.Withdrawals[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (17) 'DepositRequests' + if size := len(e.DepositRequests); size > 8192 { + err = ssz.ErrListTooBigFn("ExecutionPayloadElectra.DepositRequests", size, 8192) + return + } + for ii := 0; ii < len(e.DepositRequests); ii++ { + if dst, err = e.DepositRequests[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (18) 'WithdrawalRequests' + if size := len(e.WithdrawalRequests); size > 16 { + err = ssz.ErrListTooBigFn("ExecutionPayloadElectra.WithdrawalRequests", size, 16) + return + } + for ii := 0; ii < len(e.WithdrawalRequests); ii++ { + if dst, err = e.WithdrawalRequests[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (19) 'ConsolidationRequests' + if size := len(e.ConsolidationRequests); size > 1 { + err = ssz.ErrListTooBigFn("ExecutionPayloadElectra.ConsolidationRequests", size, 1) + return + } + for ii := 0; ii < len(e.ConsolidationRequests); ii++ { + if dst, err = e.ConsolidationRequests[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + return +} + +// UnmarshalSSZ ssz unmarshals the ExecutionPayloadElectra object +func (e *ExecutionPayloadElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 540 { + return ssz.ErrSize + } + + tail := buf + var o10, o13, o14, o17, o18, o19 uint64 + + // Field (0) 'ParentHash' + copy(e.ParentHash[:], buf[0:32]) + + // Field (1) 'FeeRecipient' + copy(e.FeeRecipient[:], buf[32:52]) + + // Field (2) 'StateRoot' + copy(e.StateRoot[:], buf[52:84]) + + // Field (3) 'ReceiptsRoot' + copy(e.ReceiptsRoot[:], buf[84:116]) + + // Field (4) 'LogsBloom' + copy(e.LogsBloom[:], buf[116:372]) + + // Field (5) 'PrevRandao' + copy(e.PrevRandao[:], buf[372:404]) + + // Field (6) 'BlockNumber' + e.BlockNumber = ssz.UnmarshallUint64(buf[404:412]) + + // Field (7) 'GasLimit' + e.GasLimit = ssz.UnmarshallUint64(buf[412:420]) + + // Field (8) 'GasUsed' + e.GasUsed = ssz.UnmarshallUint64(buf[420:428]) + + // Field (9) 'Timestamp' + e.Timestamp = ssz.UnmarshallUint64(buf[428:436]) + + // Offset (10) 'ExtraData' + if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { + return ssz.ErrOffset + } + + if o10 < 540 { + return ssz.ErrInvalidVariableOffset + } + + // Field (11) 'BaseFeePerGas' + copy(e.BaseFeePerGas[:], buf[440:472]) + + // Field (12) 'BlockHash' + copy(e.BlockHash[:], buf[472:504]) + + // Offset (13) 'Transactions' + if o13 = ssz.ReadOffset(buf[504:508]); o13 > size || o10 > o13 { + return ssz.ErrOffset + } + + // Offset (14) 'Withdrawals' + if o14 = ssz.ReadOffset(buf[508:512]); o14 > size || o13 > o14 { + return ssz.ErrOffset + } + + // Field (15) 'BlobGasUsed' + e.BlobGasUsed = ssz.UnmarshallUint64(buf[512:520]) + + // Field (16) 'ExcessBlobGas' + e.ExcessBlobGas = ssz.UnmarshallUint64(buf[520:528]) + + // Offset (17) 'DepositRequests' + if o17 = ssz.ReadOffset(buf[528:532]); o17 > size || o14 > o17 { + return ssz.ErrOffset + } + + // Offset (18) 'WithdrawalRequests' + if o18 = ssz.ReadOffset(buf[532:536]); o18 > size || o17 > o18 { + return ssz.ErrOffset + } + + // Offset (19) 'ConsolidationRequests' + if o19 = ssz.ReadOffset(buf[536:540]); o19 > size || o18 > o19 { + return ssz.ErrOffset + } + + // Field (10) 'ExtraData' + { + buf = tail[o10:o13] + if len(buf) > 32 { + return ssz.ErrBytesLength + } + if cap(e.ExtraData) == 0 { + e.ExtraData = make([]byte, 0, len(buf)) + } + e.ExtraData = append(e.ExtraData, buf...) + } + + // Field (13) 'Transactions' + { + buf = tail[o13:o14] + num, err := ssz.DecodeDynamicLength(buf, 1048576) + if err != nil { + return err + } + e.Transactions = make([][]byte, num) + err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { + if len(buf) > 1073741824 { + return ssz.ErrBytesLength + } + if cap(e.Transactions[indx]) == 0 { + e.Transactions[indx] = make([]byte, 0, len(buf)) + } + e.Transactions[indx] = append(e.Transactions[indx], buf...) + return nil + }) + if err != nil { + return err + } + } + + // Field (14) 'Withdrawals' + { + buf = tail[o14:o17] + num, err := ssz.DivideInt2(len(buf), 44, 16) + if err != nil { + return err + } + e.Withdrawals = make([]*Withdrawal, num) + for ii := 0; ii < num; ii++ { + if e.Withdrawals[ii] == nil { + e.Withdrawals[ii] = new(Withdrawal) + } + if err = e.Withdrawals[ii].UnmarshalSSZ(buf[ii*44 : (ii+1)*44]); err != nil { + return err + } + } + } + + // Field (17) 'DepositRequests' + { + buf = tail[o17:o18] + num, err := ssz.DivideInt2(len(buf), 192, 8192) + if err != nil { + return err + } + e.DepositRequests = make([]*DepositRequest, num) + for ii := 0; ii < num; ii++ { + if e.DepositRequests[ii] == nil { + e.DepositRequests[ii] = new(DepositRequest) + } + if err = e.DepositRequests[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { + return err + } + } + } + + // Field (18) 'WithdrawalRequests' + { + buf = tail[o18:o19] + num, err := ssz.DivideInt2(len(buf), 76, 16) + if err != nil { + return err + } + e.WithdrawalRequests = make([]*WithdrawalRequest, num) + for ii := 0; ii < num; ii++ { + if e.WithdrawalRequests[ii] == nil { + e.WithdrawalRequests[ii] = new(WithdrawalRequest) + } + if err = e.WithdrawalRequests[ii].UnmarshalSSZ(buf[ii*76 : (ii+1)*76]); err != nil { + return err + } + } + } + + // Field (19) 'ConsolidationRequests' + { + buf = tail[o19:] + num, err := ssz.DivideInt2(len(buf), 116, 1) + if err != nil { + return err + } + e.ConsolidationRequests = make([]*ConsolidationRequest, num) + for ii := 0; ii < num; ii++ { + if e.ConsolidationRequests[ii] == nil { + e.ConsolidationRequests[ii] = new(ConsolidationRequest) + } + if err = e.ConsolidationRequests[ii].UnmarshalSSZ(buf[ii*116 : (ii+1)*116]); err != nil { + return err + } + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadElectra object +func (e *ExecutionPayloadElectra) SizeSSZ() (size int) { + size = 540 + + // Field (10) 'ExtraData' + size += len(e.ExtraData) + + // Field (13) 'Transactions' + for ii := 0; ii < len(e.Transactions); ii++ { + size += 4 + size += len(e.Transactions[ii]) + } + + // Field (14) 'Withdrawals' + size += len(e.Withdrawals) * 44 + + // Field (17) 'DepositRequests' + size += len(e.DepositRequests) * 192 + + // Field (18) 'WithdrawalRequests' + size += len(e.WithdrawalRequests) * 76 + + // Field (19) 'ConsolidationRequests' + size += len(e.ConsolidationRequests) * 116 + + return +} + +// HashTreeRoot ssz hashes the ExecutionPayloadElectra object +func (e *ExecutionPayloadElectra) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(e) +} + +// HashTreeRootWith ssz hashes the ExecutionPayloadElectra object with a hasher +func (e *ExecutionPayloadElectra) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'ParentHash' + hh.PutBytes(e.ParentHash[:]) + + // Field (1) 'FeeRecipient' + hh.PutBytes(e.FeeRecipient[:]) + + // Field (2) 'StateRoot' + hh.PutBytes(e.StateRoot[:]) + + // Field (3) 'ReceiptsRoot' + hh.PutBytes(e.ReceiptsRoot[:]) + + // Field (4) 'LogsBloom' + hh.PutBytes(e.LogsBloom[:]) + + // Field (5) 'PrevRandao' + hh.PutBytes(e.PrevRandao[:]) + + // Field (6) 'BlockNumber' + hh.PutUint64(e.BlockNumber) + + // Field (7) 'GasLimit' + hh.PutUint64(e.GasLimit) + + // Field (8) 'GasUsed' + hh.PutUint64(e.GasUsed) + + // Field (9) 'Timestamp' + hh.PutUint64(e.Timestamp) + + // Field (10) 'ExtraData' + { + elemIndx := hh.Index() + byteLen := uint64(len(e.ExtraData)) + if byteLen > 32 { + err = ssz.ErrIncorrectListSize + return + } + hh.Append(e.ExtraData) + hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + } + + // Field (11) 'BaseFeePerGas' + hh.PutBytes(e.BaseFeePerGas[:]) + + // Field (12) 'BlockHash' + hh.PutBytes(e.BlockHash[:]) + + // Field (13) 'Transactions' + { + subIndx := hh.Index() + num := uint64(len(e.Transactions)) + if num > 1048576 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range e.Transactions { + { + elemIndx := hh.Index() + byteLen := uint64(len(elem)) + if byteLen > 1073741824 { + err = ssz.ErrIncorrectListSize + return + } + hh.AppendBytes32(elem) + hh.MerkleizeWithMixin(elemIndx, byteLen, (1073741824+31)/32) + } + } + hh.MerkleizeWithMixin(subIndx, num, 1048576) + } + + // Field (14) 'Withdrawals' + { + subIndx := hh.Index() + num := uint64(len(e.Withdrawals)) + if num > 16 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range e.Withdrawals { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 16) + } + + // Field (15) 'BlobGasUsed' + hh.PutUint64(e.BlobGasUsed) + + // Field (16) 'ExcessBlobGas' + hh.PutUint64(e.ExcessBlobGas) + + // Field (17) 'DepositRequests' + { + subIndx := hh.Index() + num := uint64(len(e.DepositRequests)) + if num > 8192 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range e.DepositRequests { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 8192) + } + + // Field (18) 'WithdrawalRequests' + { + subIndx := hh.Index() + num := uint64(len(e.WithdrawalRequests)) + if num > 16 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range e.WithdrawalRequests { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 16) + } + + // Field (19) 'ConsolidationRequests' + { + subIndx := hh.Index() + num := uint64(len(e.ConsolidationRequests)) + if num > 1 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range e.ConsolidationRequests { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 1) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the ExecutionPayloadElectra object +func (e *ExecutionPayloadElectra) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(e) +} + +// MarshalSSZ ssz marshals the ExecutionPayloadHeaderElectra object +func (e *ExecutionPayloadHeaderElectra) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(e) +} + +// MarshalSSZTo ssz marshals the ExecutionPayloadHeaderElectra object to a target array +func (e *ExecutionPayloadHeaderElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(680) + + // Field (0) 'ParentHash' + if size := len(e.ParentHash); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ParentHash", size, 32) + return + } + dst = append(dst, e.ParentHash...) + + // Field (1) 'FeeRecipient' + if size := len(e.FeeRecipient); size != 20 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.FeeRecipient", size, 20) + return + } + dst = append(dst, e.FeeRecipient...) + + // Field (2) 'StateRoot' + if size := len(e.StateRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.StateRoot", size, 32) + return + } + dst = append(dst, e.StateRoot...) + + // Field (3) 'ReceiptsRoot' + if size := len(e.ReceiptsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ReceiptsRoot", size, 32) + return + } + dst = append(dst, e.ReceiptsRoot...) + + // Field (4) 'LogsBloom' + if size := len(e.LogsBloom); size != 256 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.LogsBloom", size, 256) + return + } + dst = append(dst, e.LogsBloom...) + + // Field (5) 'PrevRandao' + if size := len(e.PrevRandao); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.PrevRandao", size, 32) + return + } + dst = append(dst, e.PrevRandao...) + + // Field (6) 'BlockNumber' + dst = ssz.MarshalUint64(dst, e.BlockNumber) + + // Field (7) 'GasLimit' + dst = ssz.MarshalUint64(dst, e.GasLimit) + + // Field (8) 'GasUsed' + dst = ssz.MarshalUint64(dst, e.GasUsed) + + // Field (9) 'Timestamp' + dst = ssz.MarshalUint64(dst, e.Timestamp) + + // Offset (10) 'ExtraData' + dst = ssz.WriteOffset(dst, offset) + offset += len(e.ExtraData) + + // Field (11) 'BaseFeePerGas' + if size := len(e.BaseFeePerGas); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.BaseFeePerGas", size, 32) + return + } + dst = append(dst, e.BaseFeePerGas...) + + // Field (12) 'BlockHash' + if size := len(e.BlockHash); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.BlockHash", size, 32) + return + } + dst = append(dst, e.BlockHash...) + + // Field (13) 'TransactionsRoot' + if size := len(e.TransactionsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.TransactionsRoot", size, 32) + return + } + dst = append(dst, e.TransactionsRoot...) + + // Field (14) 'WithdrawalsRoot' + if size := len(e.WithdrawalsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.WithdrawalsRoot", size, 32) + return + } + dst = append(dst, e.WithdrawalsRoot...) + + // Field (15) 'BlobGasUsed' + dst = ssz.MarshalUint64(dst, e.BlobGasUsed) + + // Field (16) 'ExcessBlobGas' + dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) + + // Field (17) 'DepositRequestsRoot' + if size := len(e.DepositRequestsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.DepositRequestsRoot", size, 32) + return + } + dst = append(dst, e.DepositRequestsRoot...) + + // Field (18) 'WithdrawalRequestsRoot' + if size := len(e.WithdrawalRequestsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.WithdrawalRequestsRoot", size, 32) + return + } + dst = append(dst, e.WithdrawalRequestsRoot...) + + // Field (19) 'ConsolidationRequestsRoot' + if size := len(e.ConsolidationRequestsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ConsolidationRequestsRoot", size, 32) + return + } + dst = append(dst, e.ConsolidationRequestsRoot...) + + // Field (10) 'ExtraData' + if size := len(e.ExtraData); size > 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ExtraData", size, 32) + return + } + dst = append(dst, e.ExtraData...) + + return +} + +// UnmarshalSSZ ssz unmarshals the ExecutionPayloadHeaderElectra object +func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 680 { + return ssz.ErrSize + } + + tail := buf + var o10 uint64 + + // Field (0) 'ParentHash' + if cap(e.ParentHash) == 0 { + e.ParentHash = make([]byte, 0, len(buf[0:32])) + } + e.ParentHash = append(e.ParentHash, buf[0:32]...) + + // Field (1) 'FeeRecipient' + if cap(e.FeeRecipient) == 0 { + e.FeeRecipient = make([]byte, 0, len(buf[32:52])) + } + e.FeeRecipient = append(e.FeeRecipient, buf[32:52]...) + + // Field (2) 'StateRoot' + if cap(e.StateRoot) == 0 { + e.StateRoot = make([]byte, 0, len(buf[52:84])) + } + e.StateRoot = append(e.StateRoot, buf[52:84]...) + + // Field (3) 'ReceiptsRoot' + if cap(e.ReceiptsRoot) == 0 { + e.ReceiptsRoot = make([]byte, 0, len(buf[84:116])) + } + e.ReceiptsRoot = append(e.ReceiptsRoot, buf[84:116]...) + + // Field (4) 'LogsBloom' + if cap(e.LogsBloom) == 0 { + e.LogsBloom = make([]byte, 0, len(buf[116:372])) + } + e.LogsBloom = append(e.LogsBloom, buf[116:372]...) + + // Field (5) 'PrevRandao' + if cap(e.PrevRandao) == 0 { + e.PrevRandao = make([]byte, 0, len(buf[372:404])) + } + e.PrevRandao = append(e.PrevRandao, buf[372:404]...) + + // Field (6) 'BlockNumber' + e.BlockNumber = ssz.UnmarshallUint64(buf[404:412]) + + // Field (7) 'GasLimit' + e.GasLimit = ssz.UnmarshallUint64(buf[412:420]) + + // Field (8) 'GasUsed' + e.GasUsed = ssz.UnmarshallUint64(buf[420:428]) + + // Field (9) 'Timestamp' + e.Timestamp = ssz.UnmarshallUint64(buf[428:436]) + + // Offset (10) 'ExtraData' + if o10 = ssz.ReadOffset(buf[436:440]); o10 > size { + return ssz.ErrOffset + } + + if o10 < 680 { + return ssz.ErrInvalidVariableOffset + } + + // Field (11) 'BaseFeePerGas' + if cap(e.BaseFeePerGas) == 0 { + e.BaseFeePerGas = make([]byte, 0, len(buf[440:472])) + } + e.BaseFeePerGas = append(e.BaseFeePerGas, buf[440:472]...) + + // Field (12) 'BlockHash' + if cap(e.BlockHash) == 0 { + e.BlockHash = make([]byte, 0, len(buf[472:504])) + } + e.BlockHash = append(e.BlockHash, buf[472:504]...) + + // Field (13) 'TransactionsRoot' + if cap(e.TransactionsRoot) == 0 { + e.TransactionsRoot = make([]byte, 0, len(buf[504:536])) + } + e.TransactionsRoot = append(e.TransactionsRoot, buf[504:536]...) + + // Field (14) 'WithdrawalsRoot' + if cap(e.WithdrawalsRoot) == 0 { + e.WithdrawalsRoot = make([]byte, 0, len(buf[536:568])) + } + e.WithdrawalsRoot = append(e.WithdrawalsRoot, buf[536:568]...) + + // Field (15) 'BlobGasUsed' + e.BlobGasUsed = ssz.UnmarshallUint64(buf[568:576]) + + // Field (16) 'ExcessBlobGas' + e.ExcessBlobGas = ssz.UnmarshallUint64(buf[576:584]) + + // Field (17) 'DepositRequestsRoot' + if cap(e.DepositRequestsRoot) == 0 { + e.DepositRequestsRoot = make([]byte, 0, len(buf[584:616])) + } + e.DepositRequestsRoot = append(e.DepositRequestsRoot, buf[584:616]...) + + // Field (18) 'WithdrawalRequestsRoot' + if cap(e.WithdrawalRequestsRoot) == 0 { + e.WithdrawalRequestsRoot = make([]byte, 0, len(buf[616:648])) + } + e.WithdrawalRequestsRoot = append(e.WithdrawalRequestsRoot, buf[616:648]...) + + // Field (19) 'ConsolidationRequestsRoot' + if cap(e.ConsolidationRequestsRoot) == 0 { + e.ConsolidationRequestsRoot = make([]byte, 0, len(buf[648:680])) + } + e.ConsolidationRequestsRoot = append(e.ConsolidationRequestsRoot, buf[648:680]...) + + // Field (10) 'ExtraData' + { + buf = tail[o10:] + if len(buf) > 32 { + return ssz.ErrBytesLength + } + if cap(e.ExtraData) == 0 { + e.ExtraData = make([]byte, 0, len(buf)) + } + e.ExtraData = append(e.ExtraData, buf...) + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderElectra object +func (e *ExecutionPayloadHeaderElectra) SizeSSZ() (size int) { + size = 680 + + // Field (10) 'ExtraData' + size += len(e.ExtraData) + + return +} + +// HashTreeRoot ssz hashes the ExecutionPayloadHeaderElectra object +func (e *ExecutionPayloadHeaderElectra) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(e) +} + +// HashTreeRootWith ssz hashes the ExecutionPayloadHeaderElectra object with a hasher +func (e *ExecutionPayloadHeaderElectra) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'ParentHash' + if size := len(e.ParentHash); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ParentHash", size, 32) + return + } + hh.PutBytes(e.ParentHash) + + // Field (1) 'FeeRecipient' + if size := len(e.FeeRecipient); size != 20 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.FeeRecipient", size, 20) + return + } + hh.PutBytes(e.FeeRecipient) + + // Field (2) 'StateRoot' + if size := len(e.StateRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.StateRoot", size, 32) + return + } + hh.PutBytes(e.StateRoot) + + // Field (3) 'ReceiptsRoot' + if size := len(e.ReceiptsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ReceiptsRoot", size, 32) + return + } + hh.PutBytes(e.ReceiptsRoot) + + // Field (4) 'LogsBloom' + if size := len(e.LogsBloom); size != 256 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.LogsBloom", size, 256) + return + } + hh.PutBytes(e.LogsBloom) + + // Field (5) 'PrevRandao' + if size := len(e.PrevRandao); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.PrevRandao", size, 32) + return + } + hh.PutBytes(e.PrevRandao) + + // Field (6) 'BlockNumber' + hh.PutUint64(e.BlockNumber) + + // Field (7) 'GasLimit' + hh.PutUint64(e.GasLimit) + + // Field (8) 'GasUsed' + hh.PutUint64(e.GasUsed) + + // Field (9) 'Timestamp' + hh.PutUint64(e.Timestamp) + + // Field (10) 'ExtraData' + { + elemIndx := hh.Index() + byteLen := uint64(len(e.ExtraData)) + if byteLen > 32 { + err = ssz.ErrIncorrectListSize + return + } + hh.Append(e.ExtraData) + hh.MerkleizeWithMixin(elemIndx, byteLen, (32+31)/32) + } + + // Field (11) 'BaseFeePerGas' + if size := len(e.BaseFeePerGas); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.BaseFeePerGas", size, 32) + return + } + hh.PutBytes(e.BaseFeePerGas) + + // Field (12) 'BlockHash' + if size := len(e.BlockHash); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.BlockHash", size, 32) + return + } + hh.PutBytes(e.BlockHash) + + // Field (13) 'TransactionsRoot' + if size := len(e.TransactionsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.TransactionsRoot", size, 32) + return + } + hh.PutBytes(e.TransactionsRoot) + + // Field (14) 'WithdrawalsRoot' + if size := len(e.WithdrawalsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.WithdrawalsRoot", size, 32) + return + } + hh.PutBytes(e.WithdrawalsRoot) + + // Field (15) 'BlobGasUsed' + hh.PutUint64(e.BlobGasUsed) + + // Field (16) 'ExcessBlobGas' + hh.PutUint64(e.ExcessBlobGas) + + // Field (17) 'DepositRequestsRoot' + if size := len(e.DepositRequestsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.DepositRequestsRoot", size, 32) + return + } + hh.PutBytes(e.DepositRequestsRoot) + + // Field (18) 'WithdrawalRequestsRoot' + if size := len(e.WithdrawalRequestsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.WithdrawalRequestsRoot", size, 32) + return + } + hh.PutBytes(e.WithdrawalRequestsRoot) + + // Field (19) 'ConsolidationRequestsRoot' + if size := len(e.ConsolidationRequestsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ConsolidationRequestsRoot", size, 32) + return + } + hh.PutBytes(e.ConsolidationRequestsRoot) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the ExecutionPayloadHeaderElectra object +func (e *ExecutionPayloadHeaderElectra) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(e) +} + +// MarshalSSZ ssz marshals the DepositRequest object +func (d *DepositRequest) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(d) +} + +// MarshalSSZTo ssz marshals the DepositRequest object to a target array +func (d *DepositRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'Pubkey' + dst = append(dst, d.Pubkey[:]...) + + // Field (1) 'WithdrawalCredentials' + dst = append(dst, d.WithdrawalCredentials[:]...) + + // Field (2) 'Amount' + dst = ssz.MarshalUint64(dst, d.Amount) + + // Field (3) 'Signature' + if size := len(d.Signature); size != 96 { + err = ssz.ErrBytesLengthFn("DepositRequest.Signature", size, 96) + return + } + dst = append(dst, d.Signature...) + + // Field (4) 'Index' + dst = ssz.MarshalUint64(dst, d.Index) + + return +} + +// UnmarshalSSZ ssz unmarshals the DepositRequest object +func (d *DepositRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 192 { + return ssz.ErrSize + } + + // Field (0) 'Pubkey' + copy(d.Pubkey[:], buf[0:48]) + + // Field (1) 'WithdrawalCredentials' + copy(d.WithdrawalCredentials[:], buf[48:80]) + + // Field (2) 'Amount' + d.Amount = ssz.UnmarshallUint64(buf[80:88]) + + // Field (3) 'Signature' + if cap(d.Signature) == 0 { + d.Signature = make([]byte, 0, len(buf[88:184])) + } + d.Signature = append(d.Signature, buf[88:184]...) + + // Field (4) 'Index' + d.Index = ssz.UnmarshallUint64(buf[184:192]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the DepositRequest object +func (d *DepositRequest) SizeSSZ() (size int) { + size = 192 + return +} + +// HashTreeRoot ssz hashes the DepositRequest object +func (d *DepositRequest) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(d) +} + +// HashTreeRootWith ssz hashes the DepositRequest object with a hasher +func (d *DepositRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'Pubkey' + hh.PutBytes(d.Pubkey[:]) + + // Field (1) 'WithdrawalCredentials' + hh.PutBytes(d.WithdrawalCredentials[:]) + + // Field (2) 'Amount' + hh.PutUint64(d.Amount) + + // Field (3) 'Signature' + if size := len(d.Signature); size != 96 { + err = ssz.ErrBytesLengthFn("DepositRequest.Signature", size, 96) + return + } + hh.PutBytes(d.Signature) + + // Field (4) 'Index' + hh.PutUint64(d.Index) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the DepositRequest object +func (d *DepositRequest) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(d) +} + +// MarshalSSZ ssz marshals the WithdrawalRequest object +func (w *WithdrawalRequest) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(w) +} + +// MarshalSSZTo ssz marshals the WithdrawalRequest object to a target array +func (w *WithdrawalRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'SourceAddress' + dst = append(dst, w.SourceAddress[:]...) + + // Field (1) 'ValidatorPubkey' + dst = append(dst, w.ValidatorPubkey[:]...) + + // Field (2) 'Amount' + dst = ssz.MarshalUint64(dst, w.Amount) + + return +} + +// UnmarshalSSZ ssz unmarshals the WithdrawalRequest object +func (w *WithdrawalRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 76 { + return ssz.ErrSize + } + + // Field (0) 'SourceAddress' + copy(w.SourceAddress[:], buf[0:20]) + + // Field (1) 'ValidatorPubkey' + copy(w.ValidatorPubkey[:], buf[20:68]) + + // Field (2) 'Amount' + w.Amount = ssz.UnmarshallUint64(buf[68:76]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the WithdrawalRequest object +func (w *WithdrawalRequest) SizeSSZ() (size int) { + size = 76 + return +} + +// HashTreeRoot ssz hashes the WithdrawalRequest object +func (w *WithdrawalRequest) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(w) +} + +// HashTreeRootWith ssz hashes the WithdrawalRequest object with a hasher +func (w *WithdrawalRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'SourceAddress' + hh.PutBytes(w.SourceAddress[:]) + + // Field (1) 'ValidatorPubkey' + hh.PutBytes(w.ValidatorPubkey[:]) + + // Field (2) 'Amount' + hh.PutUint64(w.Amount) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the WithdrawalRequest object +func (w *WithdrawalRequest) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(w) +} + +// MarshalSSZ ssz marshals the ConsolidationRequest object +func (c *ConsolidationRequest) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(c) +} + +// MarshalSSZTo ssz marshals the ConsolidationRequest object to a target array +func (c *ConsolidationRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'SourceAddress' + dst = append(dst, c.SourceAddress[:]...) + + // Field (1) 'SourcePubkey' + dst = append(dst, c.SourcePubkey[:]...) + + // Field (2) 'TargetPubkey' + dst = append(dst, c.TargetPubkey[:]...) + + return +} + +// UnmarshalSSZ ssz unmarshals the ConsolidationRequest object +func (c *ConsolidationRequest) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 116 { + return ssz.ErrSize + } + + // Field (0) 'SourceAddress' + copy(c.SourceAddress[:], buf[0:20]) + + // Field (1) 'SourcePubkey' + copy(c.SourcePubkey[:], buf[20:68]) + + // Field (2) 'TargetPubkey' + copy(c.TargetPubkey[:], buf[68:116]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the ConsolidationRequest object +func (c *ConsolidationRequest) SizeSSZ() (size int) { + size = 116 + return +} + +// HashTreeRoot ssz hashes the ConsolidationRequest object +func (c *ConsolidationRequest) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(c) +} + +// HashTreeRootWith ssz hashes the ConsolidationRequest object with a hasher +func (c *ConsolidationRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'SourceAddress' + hh.PutBytes(c.SourceAddress[:]) + + // Field (1) 'SourcePubkey' + hh.PutBytes(c.SourcePubkey[:]) + + // Field (2) 'TargetPubkey' + hh.PutBytes(c.TargetPubkey[:]) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the ConsolidationRequest object +func (c *ConsolidationRequest) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(c) +} + +// MarshalSSZ ssz marshals the BeaconBlockElectra object +func (b *BeaconBlockElectra) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(b) +} + +// MarshalSSZTo ssz marshals the BeaconBlockElectra object to a target array +func (b *BeaconBlockElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(84) + + // Field (0) 'Slot' + dst = ssz.MarshalUint64(dst, b.Slot) + + // Field (1) 'ProposerIndex' + dst = ssz.MarshalUint64(dst, b.ProposerIndex) + + // Field (2) 'ParentRoot' + if size := len(b.ParentRoot); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconBlockElectra.ParentRoot", size, 32) + return + } + dst = append(dst, b.ParentRoot...) + + // Field (3) 'StateRoot' + if size := len(b.StateRoot); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconBlockElectra.StateRoot", size, 32) + return + } + dst = append(dst, b.StateRoot...) + + // Offset (4) 'Body' + dst = ssz.WriteOffset(dst, offset) + if b.Body == nil { + b.Body = new(BeaconBlockBodyElectra) + } + offset += b.Body.SizeSSZ() + + // Field (4) 'Body' + if dst, err = b.Body.MarshalSSZTo(dst); err != nil { + return + } + + return +} + +// UnmarshalSSZ ssz unmarshals the BeaconBlockElectra object +func (b *BeaconBlockElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 84 { + return ssz.ErrSize + } + + tail := buf + var o4 uint64 + + // Field (0) 'Slot' + b.Slot = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'ProposerIndex' + b.ProposerIndex = ssz.UnmarshallUint64(buf[8:16]) + + // Field (2) 'ParentRoot' + if cap(b.ParentRoot) == 0 { + b.ParentRoot = make([]byte, 0, len(buf[16:48])) + } + b.ParentRoot = append(b.ParentRoot, buf[16:48]...) + + // Field (3) 'StateRoot' + if cap(b.StateRoot) == 0 { + b.StateRoot = make([]byte, 0, len(buf[48:80])) + } + b.StateRoot = append(b.StateRoot, buf[48:80]...) + + // Offset (4) 'Body' + if o4 = ssz.ReadOffset(buf[80:84]); o4 > size { + return ssz.ErrOffset + } + + if o4 < 84 { + return ssz.ErrInvalidVariableOffset + } + + // Field (4) 'Body' + { + buf = tail[o4:] + if b.Body == nil { + b.Body = new(BeaconBlockBodyElectra) + } + if err = b.Body.UnmarshalSSZ(buf); err != nil { + return err + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockElectra object +func (b *BeaconBlockElectra) SizeSSZ() (size int) { + size = 84 + + // Field (4) 'Body' + if b.Body == nil { + b.Body = new(BeaconBlockBodyElectra) + } + size += b.Body.SizeSSZ() + + return +} + +// HashTreeRoot ssz hashes the BeaconBlockElectra object +func (b *BeaconBlockElectra) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(b) +} + +// HashTreeRootWith ssz hashes the BeaconBlockElectra object with a hasher +func (b *BeaconBlockElectra) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'Slot' + hh.PutUint64(b.Slot) + + // Field (1) 'ProposerIndex' + hh.PutUint64(b.ProposerIndex) + + // Field (2) 'ParentRoot' + if size := len(b.ParentRoot); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconBlockElectra.ParentRoot", size, 32) + return + } + hh.PutBytes(b.ParentRoot) + + // Field (3) 'StateRoot' + if size := len(b.StateRoot); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconBlockElectra.StateRoot", size, 32) + return + } + hh.PutBytes(b.StateRoot) + + // Field (4) 'Body' + if err = b.Body.HashTreeRootWith(hh); err != nil { + return + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the BeaconBlockElectra object +func (b *BeaconBlockElectra) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(b) +} + +// MarshalSSZ ssz marshals the BeaconBlockBodyElectra object +func (b *BeaconBlockBodyElectra) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(b) +} + +// MarshalSSZTo ssz marshals the BeaconBlockBodyElectra object to a target array +func (b *BeaconBlockBodyElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(392) + + // Field (0) 'RandaoReveal' + if size := len(b.RandaoReveal); size != 96 { + err = ssz.ErrBytesLengthFn("BeaconBlockBodyElectra.RandaoReveal", size, 96) + return + } + dst = append(dst, b.RandaoReveal...) + + // Field (1) 'Eth1Data' + if b.Eth1Data == nil { + b.Eth1Data = new(Eth1Data) + } + if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { + return + } + + // Field (2) 'Graffiti' + dst = append(dst, b.Graffiti[:]...) + + // Offset (3) 'ProposerSlashings' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.ProposerSlashings) * 416 + + // Offset (4) 'AttesterSlashings' + dst = ssz.WriteOffset(dst, offset) + for ii := 0; ii < len(b.AttesterSlashings); ii++ { + offset += 4 + offset += b.AttesterSlashings[ii].SizeSSZ() + } + + // Offset (5) 'Attestations' + dst = ssz.WriteOffset(dst, offset) + for ii := 0; ii < len(b.Attestations); ii++ { + offset += 4 + offset += b.Attestations[ii].SizeSSZ() + } + + // Offset (6) 'Deposits' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.Deposits) * 1240 + + // Offset (7) 'VoluntaryExits' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.VoluntaryExits) * 112 + + // Field (8) 'SyncAggregate' + if b.SyncAggregate == nil { + b.SyncAggregate = new(SyncAggregateMainnet) + } + if dst, err = b.SyncAggregate.MarshalSSZTo(dst); err != nil { + return + } + + // Offset (9) 'ExecutionPayload' + dst = ssz.WriteOffset(dst, offset) + if b.ExecutionPayload == nil { + b.ExecutionPayload = new(ExecutionPayloadElectra) + } + offset += b.ExecutionPayload.SizeSSZ() + + // Offset (10) 'BlsToExecutionChanges' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.BlsToExecutionChanges) * 172 + + // Offset (11) 'BlobKzgCommitments' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.BlobKzgCommitments) * 48 + + // Field (3) 'ProposerSlashings' + if size := len(b.ProposerSlashings); size > 16 { + err = ssz.ErrListTooBigFn("BeaconBlockBodyElectra.ProposerSlashings", size, 16) + return + } + for ii := 0; ii < len(b.ProposerSlashings); ii++ { + if dst, err = b.ProposerSlashings[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (4) 'AttesterSlashings' + if size := len(b.AttesterSlashings); size > 1 { + err = ssz.ErrListTooBigFn("BeaconBlockBodyElectra.AttesterSlashings", size, 1) + return + } + { + offset = 4 * len(b.AttesterSlashings) + for ii := 0; ii < len(b.AttesterSlashings); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += b.AttesterSlashings[ii].SizeSSZ() + } + } + for ii := 0; ii < len(b.AttesterSlashings); ii++ { + if dst, err = b.AttesterSlashings[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (5) 'Attestations' + if size := len(b.Attestations); size > 8 { + err = ssz.ErrListTooBigFn("BeaconBlockBodyElectra.Attestations", size, 8) + return + } + { + offset = 4 * len(b.Attestations) + for ii := 0; ii < len(b.Attestations); ii++ { + dst = ssz.WriteOffset(dst, offset) + offset += b.Attestations[ii].SizeSSZ() + } + } + for ii := 0; ii < len(b.Attestations); ii++ { + if dst, err = b.Attestations[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (6) 'Deposits' + if size := len(b.Deposits); size > 16 { + err = ssz.ErrListTooBigFn("BeaconBlockBodyElectra.Deposits", size, 16) + return + } + for ii := 0; ii < len(b.Deposits); ii++ { + if dst, err = b.Deposits[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (7) 'VoluntaryExits' + if size := len(b.VoluntaryExits); size > 16 { + err = ssz.ErrListTooBigFn("BeaconBlockBodyElectra.VoluntaryExits", size, 16) + return + } + for ii := 0; ii < len(b.VoluntaryExits); ii++ { + if dst, err = b.VoluntaryExits[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (9) 'ExecutionPayload' + if dst, err = b.ExecutionPayload.MarshalSSZTo(dst); err != nil { + return + } + + // Field (10) 'BlsToExecutionChanges' + if size := len(b.BlsToExecutionChanges); size > 16 { + err = ssz.ErrListTooBigFn("BeaconBlockBodyElectra.BlsToExecutionChanges", size, 16) + return + } + for ii := 0; ii < len(b.BlsToExecutionChanges); ii++ { + if dst, err = b.BlsToExecutionChanges[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (11) 'BlobKzgCommitments' + if size := len(b.BlobKzgCommitments); size > 4096 { + err = ssz.ErrListTooBigFn("BeaconBlockBodyElectra.BlobKzgCommitments", size, 4096) + return + } + for ii := 0; ii < len(b.BlobKzgCommitments); ii++ { + dst = append(dst, b.BlobKzgCommitments[ii][:]...) + } + + return +} + +// UnmarshalSSZ ssz unmarshals the BeaconBlockBodyElectra object +func (b *BeaconBlockBodyElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 392 { + return ssz.ErrSize + } + + tail := buf + var o3, o4, o5, o6, o7, o9, o10, o11 uint64 + + // Field (0) 'RandaoReveal' + if cap(b.RandaoReveal) == 0 { + b.RandaoReveal = make([]byte, 0, len(buf[0:96])) + } + b.RandaoReveal = append(b.RandaoReveal, buf[0:96]...) + + // Field (1) 'Eth1Data' + if b.Eth1Data == nil { + b.Eth1Data = new(Eth1Data) + } + if err = b.Eth1Data.UnmarshalSSZ(buf[96:168]); err != nil { + return err + } + + // Field (2) 'Graffiti' + copy(b.Graffiti[:], buf[168:200]) + + // Offset (3) 'ProposerSlashings' + if o3 = ssz.ReadOffset(buf[200:204]); o3 > size { + return ssz.ErrOffset + } + + if o3 < 392 { + return ssz.ErrInvalidVariableOffset + } + + // Offset (4) 'AttesterSlashings' + if o4 = ssz.ReadOffset(buf[204:208]); o4 > size || o3 > o4 { + return ssz.ErrOffset + } + + // Offset (5) 'Attestations' + if o5 = ssz.ReadOffset(buf[208:212]); o5 > size || o4 > o5 { + return ssz.ErrOffset + } + + // Offset (6) 'Deposits' + if o6 = ssz.ReadOffset(buf[212:216]); o6 > size || o5 > o6 { + return ssz.ErrOffset + } + + // Offset (7) 'VoluntaryExits' + if o7 = ssz.ReadOffset(buf[216:220]); o7 > size || o6 > o7 { + return ssz.ErrOffset + } + + // Field (8) 'SyncAggregate' + if b.SyncAggregate == nil { + b.SyncAggregate = new(SyncAggregateMainnet) + } + if err = b.SyncAggregate.UnmarshalSSZ(buf[220:380]); err != nil { + return err + } + + // Offset (9) 'ExecutionPayload' + if o9 = ssz.ReadOffset(buf[380:384]); o9 > size || o7 > o9 { + return ssz.ErrOffset + } + + // Offset (10) 'BlsToExecutionChanges' + if o10 = ssz.ReadOffset(buf[384:388]); o10 > size || o9 > o10 { + return ssz.ErrOffset + } + + // Offset (11) 'BlobKzgCommitments' + if o11 = ssz.ReadOffset(buf[388:392]); o11 > size || o10 > o11 { + return ssz.ErrOffset + } + + // Field (3) 'ProposerSlashings' + { + buf = tail[o3:o4] + num, err := ssz.DivideInt2(len(buf), 416, 16) + if err != nil { + return err + } + b.ProposerSlashings = make([]*ProposerSlashing, num) + for ii := 0; ii < num; ii++ { + if b.ProposerSlashings[ii] == nil { + b.ProposerSlashings[ii] = new(ProposerSlashing) + } + if err = b.ProposerSlashings[ii].UnmarshalSSZ(buf[ii*416 : (ii+1)*416]); err != nil { + return err + } + } + } + + // Field (4) 'AttesterSlashings' + { + buf = tail[o4:o5] + num, err := ssz.DecodeDynamicLength(buf, 1) + if err != nil { + return err + } + b.AttesterSlashings = make([]*AttesterSlashingElectra, num) + err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { + if b.AttesterSlashings[indx] == nil { + b.AttesterSlashings[indx] = new(AttesterSlashingElectra) + } + if err = b.AttesterSlashings[indx].UnmarshalSSZ(buf); err != nil { + return err + } + return nil + }) + if err != nil { + return err + } + } + + // Field (5) 'Attestations' + { + buf = tail[o5:o6] + num, err := ssz.DecodeDynamicLength(buf, 8) + if err != nil { + return err + } + b.Attestations = make([]*AttestationElectra, num) + err = ssz.UnmarshalDynamic(buf, num, func(indx int, buf []byte) (err error) { + if b.Attestations[indx] == nil { + b.Attestations[indx] = new(AttestationElectra) + } + if err = b.Attestations[indx].UnmarshalSSZ(buf); err != nil { + return err + } + return nil + }) + if err != nil { + return err + } + } + + // Field (6) 'Deposits' + { + buf = tail[o6:o7] + num, err := ssz.DivideInt2(len(buf), 1240, 16) + if err != nil { + return err + } + b.Deposits = make([]*Deposit, num) + for ii := 0; ii < num; ii++ { + if b.Deposits[ii] == nil { + b.Deposits[ii] = new(Deposit) + } + if err = b.Deposits[ii].UnmarshalSSZ(buf[ii*1240 : (ii+1)*1240]); err != nil { + return err + } + } + } + + // Field (7) 'VoluntaryExits' + { + buf = tail[o7:o9] + num, err := ssz.DivideInt2(len(buf), 112, 16) + if err != nil { + return err + } + b.VoluntaryExits = make([]*SignedVoluntaryExit, num) + for ii := 0; ii < num; ii++ { + if b.VoluntaryExits[ii] == nil { + b.VoluntaryExits[ii] = new(SignedVoluntaryExit) + } + if err = b.VoluntaryExits[ii].UnmarshalSSZ(buf[ii*112 : (ii+1)*112]); err != nil { + return err + } + } + } + + // Field (9) 'ExecutionPayload' + { + buf = tail[o9:o10] + if b.ExecutionPayload == nil { + b.ExecutionPayload = new(ExecutionPayloadElectra) + } + if err = b.ExecutionPayload.UnmarshalSSZ(buf); err != nil { + return err + } + } + + // Field (10) 'BlsToExecutionChanges' + { + buf = tail[o10:o11] + num, err := ssz.DivideInt2(len(buf), 172, 16) + if err != nil { + return err + } + b.BlsToExecutionChanges = make([]*SignedBLSToExecutionChange, num) + for ii := 0; ii < num; ii++ { + if b.BlsToExecutionChanges[ii] == nil { + b.BlsToExecutionChanges[ii] = new(SignedBLSToExecutionChange) + } + if err = b.BlsToExecutionChanges[ii].UnmarshalSSZ(buf[ii*172 : (ii+1)*172]); err != nil { + return err + } + } + } + + // Field (11) 'BlobKzgCommitments' + { + buf = tail[o11:] + num, err := ssz.DivideInt2(len(buf), 48, 4096) + if err != nil { + return err + } + b.BlobKzgCommitments = make([][48]byte, num) + for ii := 0; ii < num; ii++ { + copy(b.BlobKzgCommitments[ii][:], buf[ii*48:(ii+1)*48]) + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the BeaconBlockBodyElectra object +func (b *BeaconBlockBodyElectra) SizeSSZ() (size int) { + size = 392 + + // Field (3) 'ProposerSlashings' + size += len(b.ProposerSlashings) * 416 + + // Field (4) 'AttesterSlashings' + for ii := 0; ii < len(b.AttesterSlashings); ii++ { + size += 4 + size += b.AttesterSlashings[ii].SizeSSZ() + } + + // Field (5) 'Attestations' + for ii := 0; ii < len(b.Attestations); ii++ { + size += 4 + size += b.Attestations[ii].SizeSSZ() + } + + // Field (6) 'Deposits' + size += len(b.Deposits) * 1240 + + // Field (7) 'VoluntaryExits' + size += len(b.VoluntaryExits) * 112 + + // Field (9) 'ExecutionPayload' + if b.ExecutionPayload == nil { + b.ExecutionPayload = new(ExecutionPayloadElectra) + } + size += b.ExecutionPayload.SizeSSZ() + + // Field (10) 'BlsToExecutionChanges' + size += len(b.BlsToExecutionChanges) * 172 + + // Field (11) 'BlobKzgCommitments' + size += len(b.BlobKzgCommitments) * 48 + + return +} + +// HashTreeRoot ssz hashes the BeaconBlockBodyElectra object +func (b *BeaconBlockBodyElectra) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(b) +} + +// HashTreeRootWith ssz hashes the BeaconBlockBodyElectra object with a hasher +func (b *BeaconBlockBodyElectra) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'RandaoReveal' + if size := len(b.RandaoReveal); size != 96 { + err = ssz.ErrBytesLengthFn("BeaconBlockBodyElectra.RandaoReveal", size, 96) + return + } + hh.PutBytes(b.RandaoReveal) + + // Field (1) 'Eth1Data' + if b.Eth1Data == nil { + b.Eth1Data = new(Eth1Data) + } + if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { + return + } + + // Field (2) 'Graffiti' + hh.PutBytes(b.Graffiti[:]) + + // Field (3) 'ProposerSlashings' + { + subIndx := hh.Index() + num := uint64(len(b.ProposerSlashings)) + if num > 16 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.ProposerSlashings { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 16) + } + + // Field (4) 'AttesterSlashings' + { + subIndx := hh.Index() + num := uint64(len(b.AttesterSlashings)) + if num > 1 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.AttesterSlashings { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 1) + } + + // Field (5) 'Attestations' + { + subIndx := hh.Index() + num := uint64(len(b.Attestations)) + if num > 8 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.Attestations { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 8) + } + + // Field (6) 'Deposits' + { + subIndx := hh.Index() + num := uint64(len(b.Deposits)) + if num > 16 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.Deposits { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 16) + } + + // Field (7) 'VoluntaryExits' + { + subIndx := hh.Index() + num := uint64(len(b.VoluntaryExits)) + if num > 16 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.VoluntaryExits { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 16) + } + + // Field (8) 'SyncAggregate' + if b.SyncAggregate == nil { + b.SyncAggregate = new(SyncAggregateMainnet) + } + if err = b.SyncAggregate.HashTreeRootWith(hh); err != nil { + return + } + + // Field (9) 'ExecutionPayload' + if err = b.ExecutionPayload.HashTreeRootWith(hh); err != nil { + return + } + + // Field (10) 'BlsToExecutionChanges' + { + subIndx := hh.Index() + num := uint64(len(b.BlsToExecutionChanges)) + if num > 16 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.BlsToExecutionChanges { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 16) + } + + // Field (11) 'BlobKzgCommitments' + { + if size := len(b.BlobKzgCommitments); size > 4096 { + err = ssz.ErrListTooBigFn("BeaconBlockBodyElectra.BlobKzgCommitments", size, 4096) + return + } + subIndx := hh.Index() + for _, i := range b.BlobKzgCommitments { + hh.PutBytes(i[:]) + } + numItems := uint64(len(b.BlobKzgCommitments)) + hh.MerkleizeWithMixin(subIndx, numItems, 4096) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the BeaconBlockBodyElectra object +func (b *BeaconBlockBodyElectra) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(b) +} + +// MarshalSSZ ssz marshals the BeaconStateElectra object +func (b *BeaconStateElectra) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(b) +} + +// MarshalSSZTo ssz marshals the BeaconStateElectra object to a target array +func (b *BeaconStateElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(2736713) + + // Field (0) 'GenesisTime' + dst = ssz.MarshalUint64(dst, b.GenesisTime) + + // Field (1) 'GenesisValidatorsRoot' + if size := len(b.GenesisValidatorsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.GenesisValidatorsRoot", size, 32) + return + } + dst = append(dst, b.GenesisValidatorsRoot...) + + // Field (2) 'Slot' + dst = ssz.MarshalUint64(dst, b.Slot) + + // Field (3) 'Fork' + if b.Fork == nil { + b.Fork = new(Fork) + } + if dst, err = b.Fork.MarshalSSZTo(dst); err != nil { + return + } + + // Field (4) 'LatestBlockHeader' + if b.LatestBlockHeader == nil { + b.LatestBlockHeader = new(BeaconBlockHeader) + } + if dst, err = b.LatestBlockHeader.MarshalSSZTo(dst); err != nil { + return + } + + // Field (5) 'BlockRoots' + if size := len(b.BlockRoots); size != 8192 { + err = ssz.ErrVectorLengthFn("BeaconStateElectra.BlockRoots", size, 8192) + return + } + for ii := 0; ii < 8192; ii++ { + if size := len(b.BlockRoots[ii]); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.BlockRoots[ii]", size, 32) + return + } + dst = append(dst, b.BlockRoots[ii]...) + } + + // Field (6) 'StateRoots' + if size := len(b.StateRoots); size != 8192 { + err = ssz.ErrVectorLengthFn("BeaconStateElectra.StateRoots", size, 8192) + return + } + for ii := 0; ii < 8192; ii++ { + if size := len(b.StateRoots[ii]); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.StateRoots[ii]", size, 32) + return + } + dst = append(dst, b.StateRoots[ii]...) + } + + // Offset (7) 'HistoricalRoots' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.HistoricalRoots) * 32 + + // Field (8) 'Eth1Data' + if b.Eth1Data == nil { + b.Eth1Data = new(Eth1Data) + } + if dst, err = b.Eth1Data.MarshalSSZTo(dst); err != nil { + return + } + + // Offset (9) 'Eth1DataVotes' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.Eth1DataVotes) * 72 + + // Field (10) 'Eth1DepositIndex' + dst = ssz.MarshalUint64(dst, b.Eth1DepositIndex) + + // Offset (11) 'Validators' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.Validators) * 121 + + // Offset (12) 'Balances' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.Balances) * 8 + + // Field (13) 'RandaoMixes' + if size := len(b.RandaoMixes); size != 65536 { + err = ssz.ErrVectorLengthFn("BeaconStateElectra.RandaoMixes", size, 65536) + return + } + for ii := 0; ii < 65536; ii++ { + if size := len(b.RandaoMixes[ii]); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.RandaoMixes[ii]", size, 32) + return + } + dst = append(dst, b.RandaoMixes[ii]...) + } + + // Field (14) 'Slashings' + if size := len(b.Slashings); size != 8192 { + err = ssz.ErrVectorLengthFn("BeaconStateElectra.Slashings", size, 8192) + return + } + for ii := 0; ii < 8192; ii++ { + dst = ssz.MarshalUint64(dst, b.Slashings[ii]) + } + + // Offset (15) 'PreviousEpochParticipation' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.PreviousEpochParticipation) + + // Offset (16) 'CurrentEpochParticipation' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.CurrentEpochParticipation) + + // Field (17) 'JustificationBits' + if size := len(b.JustificationBits); size != 1 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.JustificationBits", size, 1) + return + } + dst = append(dst, b.JustificationBits...) + + // Field (18) 'PreviousJustifiedCheckpoint' + if b.PreviousJustifiedCheckpoint == nil { + b.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = b.PreviousJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return + } + + // Field (19) 'CurrentJustifiedCheckpoint' + if b.CurrentJustifiedCheckpoint == nil { + b.CurrentJustifiedCheckpoint = new(Checkpoint) + } + if dst, err = b.CurrentJustifiedCheckpoint.MarshalSSZTo(dst); err != nil { + return + } + + // Field (20) 'FinalizedCheckpoint' + if b.FinalizedCheckpoint == nil { + b.FinalizedCheckpoint = new(Checkpoint) + } + if dst, err = b.FinalizedCheckpoint.MarshalSSZTo(dst); err != nil { + return + } + + // Offset (21) 'InactivityScores' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.InactivityScores) * 8 + + // Field (22) 'CurrentSyncCommittee' + if b.CurrentSyncCommittee == nil { + b.CurrentSyncCommittee = new(SyncCommittee) + } + if dst, err = b.CurrentSyncCommittee.MarshalSSZTo(dst); err != nil { + return + } + + // Field (23) 'NextSyncCommittee' + if b.NextSyncCommittee == nil { + b.NextSyncCommittee = new(SyncCommittee) + } + if dst, err = b.NextSyncCommittee.MarshalSSZTo(dst); err != nil { + return + } + + // Offset (24) 'LatestExecutionPayloadHeader' + dst = ssz.WriteOffset(dst, offset) + if b.LatestExecutionPayloadHeader == nil { + b.LatestExecutionPayloadHeader = new(ExecutionPayloadHeaderElectra) + } + offset += b.LatestExecutionPayloadHeader.SizeSSZ() + + // Field (25) 'NextWithdrawalIndex' + dst = ssz.MarshalUint64(dst, b.NextWithdrawalIndex) + + // Field (26) 'NextWithdrawalValidatorIndex' + dst = ssz.MarshalUint64(dst, b.NextWithdrawalValidatorIndex) + + // Offset (27) 'HistoricalSummaries' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.HistoricalSummaries) * 64 + + // Field (28) 'DepositRequestsStartIndex' + dst = ssz.MarshalUint64(dst, b.DepositRequestsStartIndex) + + // Field (29) 'DepositBalanceToConsume' + dst = ssz.MarshalUint64(dst, b.DepositBalanceToConsume) + + // Field (30) 'ExitBalanceToConsume' + dst = ssz.MarshalUint64(dst, b.ExitBalanceToConsume) + + // Field (31) 'EarliestExitEpoch' + dst = ssz.MarshalUint64(dst, b.EarliestExitEpoch) + + // Field (32) 'ConsolidationBalanceToConsume' + dst = ssz.MarshalUint64(dst, b.ConsolidationBalanceToConsume) + + // Field (33) 'EarliestConsolidationEpoch' + dst = ssz.MarshalUint64(dst, b.EarliestConsolidationEpoch) + + // Offset (34) 'PendingBalanceDeposits' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.PendingBalanceDeposits) * 16 + + // Offset (35) 'PendingPartialWithdrawals' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.PendingPartialWithdrawals) * 24 + + // Offset (36) 'PendingConsolidations' + dst = ssz.WriteOffset(dst, offset) + offset += len(b.PendingConsolidations) * 16 + + // Field (7) 'HistoricalRoots' + if size := len(b.HistoricalRoots); size > 16777216 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.HistoricalRoots", size, 16777216) + return + } + for ii := 0; ii < len(b.HistoricalRoots); ii++ { + if size := len(b.HistoricalRoots[ii]); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.HistoricalRoots[ii]", size, 32) + return + } + dst = append(dst, b.HistoricalRoots[ii]...) + } + + // Field (9) 'Eth1DataVotes' + if size := len(b.Eth1DataVotes); size > 2048 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.Eth1DataVotes", size, 2048) + return + } + for ii := 0; ii < len(b.Eth1DataVotes); ii++ { + if dst, err = b.Eth1DataVotes[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (11) 'Validators' + if size := len(b.Validators); size > 1099511627776 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.Validators", size, 1099511627776) + return + } + for ii := 0; ii < len(b.Validators); ii++ { + if dst, err = b.Validators[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (12) 'Balances' + if size := len(b.Balances); size > 1099511627776 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.Balances", size, 1099511627776) + return + } + for ii := 0; ii < len(b.Balances); ii++ { + dst = ssz.MarshalUint64(dst, b.Balances[ii]) + } + + // Field (15) 'PreviousEpochParticipation' + if size := len(b.PreviousEpochParticipation); size > 1099511627776 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.PreviousEpochParticipation", size, 1099511627776) + return + } + dst = append(dst, b.PreviousEpochParticipation...) + + // Field (16) 'CurrentEpochParticipation' + if size := len(b.CurrentEpochParticipation); size > 1099511627776 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.CurrentEpochParticipation", size, 1099511627776) + return + } + dst = append(dst, b.CurrentEpochParticipation...) + + // Field (21) 'InactivityScores' + if size := len(b.InactivityScores); size > 1099511627776 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.InactivityScores", size, 1099511627776) + return + } + for ii := 0; ii < len(b.InactivityScores); ii++ { + dst = ssz.MarshalUint64(dst, b.InactivityScores[ii]) + } + + // Field (24) 'LatestExecutionPayloadHeader' + if dst, err = b.LatestExecutionPayloadHeader.MarshalSSZTo(dst); err != nil { + return + } + + // Field (27) 'HistoricalSummaries' + if size := len(b.HistoricalSummaries); size > 16777216 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.HistoricalSummaries", size, 16777216) + return + } + for ii := 0; ii < len(b.HistoricalSummaries); ii++ { + if dst, err = b.HistoricalSummaries[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (34) 'PendingBalanceDeposits' + if size := len(b.PendingBalanceDeposits); size > 134217728 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.PendingBalanceDeposits", size, 134217728) + return + } + for ii := 0; ii < len(b.PendingBalanceDeposits); ii++ { + if dst, err = b.PendingBalanceDeposits[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (35) 'PendingPartialWithdrawals' + if size := len(b.PendingPartialWithdrawals); size > 134217728 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.PendingPartialWithdrawals", size, 134217728) + return + } + for ii := 0; ii < len(b.PendingPartialWithdrawals); ii++ { + if dst, err = b.PendingPartialWithdrawals[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + // Field (36) 'PendingConsolidations' + if size := len(b.PendingConsolidations); size > 262144 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.PendingConsolidations", size, 262144) + return + } + for ii := 0; ii < len(b.PendingConsolidations); ii++ { + if dst, err = b.PendingConsolidations[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + return +} + +// UnmarshalSSZ ssz unmarshals the BeaconStateElectra object +func (b *BeaconStateElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 2736713 { + return ssz.ErrSize + } + + tail := buf + var o7, o9, o11, o12, o15, o16, o21, o24, o27, o34, o35, o36 uint64 + + // Field (0) 'GenesisTime' + b.GenesisTime = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'GenesisValidatorsRoot' + if cap(b.GenesisValidatorsRoot) == 0 { + b.GenesisValidatorsRoot = make([]byte, 0, len(buf[8:40])) + } + b.GenesisValidatorsRoot = append(b.GenesisValidatorsRoot, buf[8:40]...) + + // Field (2) 'Slot' + b.Slot = ssz.UnmarshallUint64(buf[40:48]) + + // Field (3) 'Fork' + if b.Fork == nil { + b.Fork = new(Fork) + } + if err = b.Fork.UnmarshalSSZ(buf[48:64]); err != nil { + return err + } + + // Field (4) 'LatestBlockHeader' + if b.LatestBlockHeader == nil { + b.LatestBlockHeader = new(BeaconBlockHeader) + } + if err = b.LatestBlockHeader.UnmarshalSSZ(buf[64:176]); err != nil { + return err + } + + // Field (5) 'BlockRoots' + b.BlockRoots = make([][]byte, 8192) + for ii := 0; ii < 8192; ii++ { + if cap(b.BlockRoots[ii]) == 0 { + b.BlockRoots[ii] = make([]byte, 0, len(buf[176:262320][ii*32:(ii+1)*32])) + } + b.BlockRoots[ii] = append(b.BlockRoots[ii], buf[176:262320][ii*32:(ii+1)*32]...) + } + + // Field (6) 'StateRoots' + b.StateRoots = make([][]byte, 8192) + for ii := 0; ii < 8192; ii++ { + if cap(b.StateRoots[ii]) == 0 { + b.StateRoots[ii] = make([]byte, 0, len(buf[262320:524464][ii*32:(ii+1)*32])) + } + b.StateRoots[ii] = append(b.StateRoots[ii], buf[262320:524464][ii*32:(ii+1)*32]...) + } + + // Offset (7) 'HistoricalRoots' + if o7 = ssz.ReadOffset(buf[524464:524468]); o7 > size { + return ssz.ErrOffset + } + + if o7 < 2736713 { + return ssz.ErrInvalidVariableOffset + } + + // Field (8) 'Eth1Data' + if b.Eth1Data == nil { + b.Eth1Data = new(Eth1Data) + } + if err = b.Eth1Data.UnmarshalSSZ(buf[524468:524540]); err != nil { + return err + } + + // Offset (9) 'Eth1DataVotes' + if o9 = ssz.ReadOffset(buf[524540:524544]); o9 > size || o7 > o9 { + return ssz.ErrOffset + } + + // Field (10) 'Eth1DepositIndex' + b.Eth1DepositIndex = ssz.UnmarshallUint64(buf[524544:524552]) + + // Offset (11) 'Validators' + if o11 = ssz.ReadOffset(buf[524552:524556]); o11 > size || o9 > o11 { + return ssz.ErrOffset + } + + // Offset (12) 'Balances' + if o12 = ssz.ReadOffset(buf[524556:524560]); o12 > size || o11 > o12 { + return ssz.ErrOffset + } + + // Field (13) 'RandaoMixes' + b.RandaoMixes = make([][]byte, 65536) + for ii := 0; ii < 65536; ii++ { + if cap(b.RandaoMixes[ii]) == 0 { + b.RandaoMixes[ii] = make([]byte, 0, len(buf[524560:2621712][ii*32:(ii+1)*32])) + } + b.RandaoMixes[ii] = append(b.RandaoMixes[ii], buf[524560:2621712][ii*32:(ii+1)*32]...) + } + + // Field (14) 'Slashings' + b.Slashings = ssz.ExtendUint64(b.Slashings, 8192) + for ii := 0; ii < 8192; ii++ { + b.Slashings[ii] = ssz.UnmarshallUint64(buf[2621712:2687248][ii*8 : (ii+1)*8]) + } + + // Offset (15) 'PreviousEpochParticipation' + if o15 = ssz.ReadOffset(buf[2687248:2687252]); o15 > size || o12 > o15 { + return ssz.ErrOffset + } + + // Offset (16) 'CurrentEpochParticipation' + if o16 = ssz.ReadOffset(buf[2687252:2687256]); o16 > size || o15 > o16 { + return ssz.ErrOffset + } + + // Field (17) 'JustificationBits' + if cap(b.JustificationBits) == 0 { + b.JustificationBits = make([]byte, 0, len(buf[2687256:2687257])) + } + b.JustificationBits = append(b.JustificationBits, buf[2687256:2687257]...) + + // Field (18) 'PreviousJustifiedCheckpoint' + if b.PreviousJustifiedCheckpoint == nil { + b.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if err = b.PreviousJustifiedCheckpoint.UnmarshalSSZ(buf[2687257:2687297]); err != nil { + return err + } + + // Field (19) 'CurrentJustifiedCheckpoint' + if b.CurrentJustifiedCheckpoint == nil { + b.CurrentJustifiedCheckpoint = new(Checkpoint) + } + if err = b.CurrentJustifiedCheckpoint.UnmarshalSSZ(buf[2687297:2687337]); err != nil { + return err + } + + // Field (20) 'FinalizedCheckpoint' + if b.FinalizedCheckpoint == nil { + b.FinalizedCheckpoint = new(Checkpoint) + } + if err = b.FinalizedCheckpoint.UnmarshalSSZ(buf[2687337:2687377]); err != nil { + return err + } + + // Offset (21) 'InactivityScores' + if o21 = ssz.ReadOffset(buf[2687377:2687381]); o21 > size || o16 > o21 { + return ssz.ErrOffset + } + + // Field (22) 'CurrentSyncCommittee' + if b.CurrentSyncCommittee == nil { + b.CurrentSyncCommittee = new(SyncCommittee) + } + if err = b.CurrentSyncCommittee.UnmarshalSSZ(buf[2687381:2712005]); err != nil { + return err + } + + // Field (23) 'NextSyncCommittee' + if b.NextSyncCommittee == nil { + b.NextSyncCommittee = new(SyncCommittee) + } + if err = b.NextSyncCommittee.UnmarshalSSZ(buf[2712005:2736629]); err != nil { + return err + } + + // Offset (24) 'LatestExecutionPayloadHeader' + if o24 = ssz.ReadOffset(buf[2736629:2736633]); o24 > size || o21 > o24 { + return ssz.ErrOffset + } + + // Field (25) 'NextWithdrawalIndex' + b.NextWithdrawalIndex = ssz.UnmarshallUint64(buf[2736633:2736641]) + + // Field (26) 'NextWithdrawalValidatorIndex' + b.NextWithdrawalValidatorIndex = ssz.UnmarshallUint64(buf[2736641:2736649]) + + // Offset (27) 'HistoricalSummaries' + if o27 = ssz.ReadOffset(buf[2736649:2736653]); o27 > size || o24 > o27 { + return ssz.ErrOffset + } + + // Field (28) 'DepositRequestsStartIndex' + b.DepositRequestsStartIndex = ssz.UnmarshallUint64(buf[2736653:2736661]) + + // Field (29) 'DepositBalanceToConsume' + b.DepositBalanceToConsume = ssz.UnmarshallUint64(buf[2736661:2736669]) + + // Field (30) 'ExitBalanceToConsume' + b.ExitBalanceToConsume = ssz.UnmarshallUint64(buf[2736669:2736677]) + + // Field (31) 'EarliestExitEpoch' + b.EarliestExitEpoch = ssz.UnmarshallUint64(buf[2736677:2736685]) + + // Field (32) 'ConsolidationBalanceToConsume' + b.ConsolidationBalanceToConsume = ssz.UnmarshallUint64(buf[2736685:2736693]) + + // Field (33) 'EarliestConsolidationEpoch' + b.EarliestConsolidationEpoch = ssz.UnmarshallUint64(buf[2736693:2736701]) + + // Offset (34) 'PendingBalanceDeposits' + if o34 = ssz.ReadOffset(buf[2736701:2736705]); o34 > size || o27 > o34 { + return ssz.ErrOffset + } + + // Offset (35) 'PendingPartialWithdrawals' + if o35 = ssz.ReadOffset(buf[2736705:2736709]); o35 > size || o34 > o35 { + return ssz.ErrOffset + } + + // Offset (36) 'PendingConsolidations' + if o36 = ssz.ReadOffset(buf[2736709:2736713]); o36 > size || o35 > o36 { + return ssz.ErrOffset + } + + // Field (7) 'HistoricalRoots' + { + buf = tail[o7:o9] + num, err := ssz.DivideInt2(len(buf), 32, 16777216) + if err != nil { + return err + } + b.HistoricalRoots = make([][]byte, num) + for ii := 0; ii < num; ii++ { + if cap(b.HistoricalRoots[ii]) == 0 { + b.HistoricalRoots[ii] = make([]byte, 0, len(buf[ii*32:(ii+1)*32])) + } + b.HistoricalRoots[ii] = append(b.HistoricalRoots[ii], buf[ii*32:(ii+1)*32]...) + } + } + + // Field (9) 'Eth1DataVotes' + { + buf = tail[o9:o11] + num, err := ssz.DivideInt2(len(buf), 72, 2048) + if err != nil { + return err + } + b.Eth1DataVotes = make([]*Eth1Data, num) + for ii := 0; ii < num; ii++ { + if b.Eth1DataVotes[ii] == nil { + b.Eth1DataVotes[ii] = new(Eth1Data) + } + if err = b.Eth1DataVotes[ii].UnmarshalSSZ(buf[ii*72 : (ii+1)*72]); err != nil { + return err + } + } + } + + // Field (11) 'Validators' + { + buf = tail[o11:o12] + num, err := ssz.DivideInt2(len(buf), 121, 1099511627776) + if err != nil { + return err + } + b.Validators = make([]*Validator, num) + for ii := 0; ii < num; ii++ { + if b.Validators[ii] == nil { + b.Validators[ii] = new(Validator) + } + if err = b.Validators[ii].UnmarshalSSZ(buf[ii*121 : (ii+1)*121]); err != nil { + return err + } + } + } + + // Field (12) 'Balances' + { + buf = tail[o12:o15] + num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) + if err != nil { + return err + } + b.Balances = ssz.ExtendUint64(b.Balances, num) + for ii := 0; ii < num; ii++ { + b.Balances[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) + } + } + + // Field (15) 'PreviousEpochParticipation' + { + buf = tail[o15:o16] + if len(buf) > 1099511627776 { + return ssz.ErrBytesLength + } + if cap(b.PreviousEpochParticipation) == 0 { + b.PreviousEpochParticipation = make([]byte, 0, len(buf)) + } + b.PreviousEpochParticipation = append(b.PreviousEpochParticipation, buf...) + } + + // Field (16) 'CurrentEpochParticipation' + { + buf = tail[o16:o21] + if len(buf) > 1099511627776 { + return ssz.ErrBytesLength + } + if cap(b.CurrentEpochParticipation) == 0 { + b.CurrentEpochParticipation = make([]byte, 0, len(buf)) + } + b.CurrentEpochParticipation = append(b.CurrentEpochParticipation, buf...) + } + + // Field (21) 'InactivityScores' + { + buf = tail[o21:o24] + num, err := ssz.DivideInt2(len(buf), 8, 1099511627776) + if err != nil { + return err + } + b.InactivityScores = ssz.ExtendUint64(b.InactivityScores, num) + for ii := 0; ii < num; ii++ { + b.InactivityScores[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) + } + } + + // Field (24) 'LatestExecutionPayloadHeader' + { + buf = tail[o24:o27] + if b.LatestExecutionPayloadHeader == nil { + b.LatestExecutionPayloadHeader = new(ExecutionPayloadHeaderElectra) + } + if err = b.LatestExecutionPayloadHeader.UnmarshalSSZ(buf); err != nil { + return err + } + } + + // Field (27) 'HistoricalSummaries' + { + buf = tail[o27:o34] + num, err := ssz.DivideInt2(len(buf), 64, 16777216) + if err != nil { + return err + } + b.HistoricalSummaries = make([]*HistoricalSummary, num) + for ii := 0; ii < num; ii++ { + if b.HistoricalSummaries[ii] == nil { + b.HistoricalSummaries[ii] = new(HistoricalSummary) + } + if err = b.HistoricalSummaries[ii].UnmarshalSSZ(buf[ii*64 : (ii+1)*64]); err != nil { + return err + } + } + } + + // Field (34) 'PendingBalanceDeposits' + { + buf = tail[o34:o35] + num, err := ssz.DivideInt2(len(buf), 16, 134217728) + if err != nil { + return err + } + b.PendingBalanceDeposits = make([]*PendingBalanceDeposit, num) + for ii := 0; ii < num; ii++ { + if b.PendingBalanceDeposits[ii] == nil { + b.PendingBalanceDeposits[ii] = new(PendingBalanceDeposit) + } + if err = b.PendingBalanceDeposits[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { + return err + } + } + } + + // Field (35) 'PendingPartialWithdrawals' + { + buf = tail[o35:o36] + num, err := ssz.DivideInt2(len(buf), 24, 134217728) + if err != nil { + return err + } + b.PendingPartialWithdrawals = make([]*PendingPartialWithdrawal, num) + for ii := 0; ii < num; ii++ { + if b.PendingPartialWithdrawals[ii] == nil { + b.PendingPartialWithdrawals[ii] = new(PendingPartialWithdrawal) + } + if err = b.PendingPartialWithdrawals[ii].UnmarshalSSZ(buf[ii*24 : (ii+1)*24]); err != nil { + return err + } + } + } + + // Field (36) 'PendingConsolidations' + { + buf = tail[o36:] + num, err := ssz.DivideInt2(len(buf), 16, 262144) + if err != nil { + return err + } + b.PendingConsolidations = make([]*PendingConsolidation, num) + for ii := 0; ii < num; ii++ { + if b.PendingConsolidations[ii] == nil { + b.PendingConsolidations[ii] = new(PendingConsolidation) + } + if err = b.PendingConsolidations[ii].UnmarshalSSZ(buf[ii*16 : (ii+1)*16]); err != nil { + return err + } + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the BeaconStateElectra object +func (b *BeaconStateElectra) SizeSSZ() (size int) { + size = 2736713 + + // Field (7) 'HistoricalRoots' + size += len(b.HistoricalRoots) * 32 + + // Field (9) 'Eth1DataVotes' + size += len(b.Eth1DataVotes) * 72 + + // Field (11) 'Validators' + size += len(b.Validators) * 121 + + // Field (12) 'Balances' + size += len(b.Balances) * 8 + + // Field (15) 'PreviousEpochParticipation' + size += len(b.PreviousEpochParticipation) + + // Field (16) 'CurrentEpochParticipation' + size += len(b.CurrentEpochParticipation) + + // Field (21) 'InactivityScores' + size += len(b.InactivityScores) * 8 + + // Field (24) 'LatestExecutionPayloadHeader' + if b.LatestExecutionPayloadHeader == nil { + b.LatestExecutionPayloadHeader = new(ExecutionPayloadHeaderElectra) + } + size += b.LatestExecutionPayloadHeader.SizeSSZ() + + // Field (27) 'HistoricalSummaries' + size += len(b.HistoricalSummaries) * 64 + + // Field (34) 'PendingBalanceDeposits' + size += len(b.PendingBalanceDeposits) * 16 + + // Field (35) 'PendingPartialWithdrawals' + size += len(b.PendingPartialWithdrawals) * 24 + + // Field (36) 'PendingConsolidations' + size += len(b.PendingConsolidations) * 16 + + return +} + +// HashTreeRoot ssz hashes the BeaconStateElectra object +func (b *BeaconStateElectra) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(b) +} + +// HashTreeRootWith ssz hashes the BeaconStateElectra object with a hasher +func (b *BeaconStateElectra) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'GenesisTime' + hh.PutUint64(b.GenesisTime) + + // Field (1) 'GenesisValidatorsRoot' + if size := len(b.GenesisValidatorsRoot); size != 32 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.GenesisValidatorsRoot", size, 32) + return + } + hh.PutBytes(b.GenesisValidatorsRoot) + + // Field (2) 'Slot' + hh.PutUint64(b.Slot) + + // Field (3) 'Fork' + if b.Fork == nil { + b.Fork = new(Fork) + } + if err = b.Fork.HashTreeRootWith(hh); err != nil { + return + } + + // Field (4) 'LatestBlockHeader' + if b.LatestBlockHeader == nil { + b.LatestBlockHeader = new(BeaconBlockHeader) + } + if err = b.LatestBlockHeader.HashTreeRootWith(hh); err != nil { + return + } + + // Field (5) 'BlockRoots' + { + if size := len(b.BlockRoots); size != 8192 { + err = ssz.ErrVectorLengthFn("BeaconStateElectra.BlockRoots", size, 8192) + return + } + subIndx := hh.Index() + for _, i := range b.BlockRoots { + if len(i) != 32 { + err = ssz.ErrBytesLength + return + } + hh.Append(i) + } + hh.Merkleize(subIndx) + } + + // Field (6) 'StateRoots' + { + if size := len(b.StateRoots); size != 8192 { + err = ssz.ErrVectorLengthFn("BeaconStateElectra.StateRoots", size, 8192) + return + } + subIndx := hh.Index() + for _, i := range b.StateRoots { + if len(i) != 32 { + err = ssz.ErrBytesLength + return + } + hh.Append(i) + } + hh.Merkleize(subIndx) + } + + // Field (7) 'HistoricalRoots' + { + if size := len(b.HistoricalRoots); size > 16777216 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.HistoricalRoots", size, 16777216) + return + } + subIndx := hh.Index() + for _, i := range b.HistoricalRoots { + if len(i) != 32 { + err = ssz.ErrBytesLength + return + } + hh.Append(i) + } + numItems := uint64(len(b.HistoricalRoots)) + hh.MerkleizeWithMixin(subIndx, numItems, 16777216) + } + + // Field (8) 'Eth1Data' + if b.Eth1Data == nil { + b.Eth1Data = new(Eth1Data) + } + if err = b.Eth1Data.HashTreeRootWith(hh); err != nil { + return + } + + // Field (9) 'Eth1DataVotes' + { + subIndx := hh.Index() + num := uint64(len(b.Eth1DataVotes)) + if num > 2048 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.Eth1DataVotes { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 2048) + } + + // Field (10) 'Eth1DepositIndex' + hh.PutUint64(b.Eth1DepositIndex) + + // Field (11) 'Validators' + { + subIndx := hh.Index() + num := uint64(len(b.Validators)) + if num > 1099511627776 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.Validators { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 1099511627776) + } + + // Field (12) 'Balances' + { + if size := len(b.Balances); size > 1099511627776 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.Balances", size, 1099511627776) + return + } + subIndx := hh.Index() + for _, i := range b.Balances { + hh.AppendUint64(i) + } + hh.FillUpTo32() + numItems := uint64(len(b.Balances)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + } + + // Field (13) 'RandaoMixes' + { + if size := len(b.RandaoMixes); size != 65536 { + err = ssz.ErrVectorLengthFn("BeaconStateElectra.RandaoMixes", size, 65536) + return + } + subIndx := hh.Index() + for _, i := range b.RandaoMixes { + if len(i) != 32 { + err = ssz.ErrBytesLength + return + } + hh.Append(i) + } + hh.Merkleize(subIndx) + } + + // Field (14) 'Slashings' + { + if size := len(b.Slashings); size != 8192 { + err = ssz.ErrVectorLengthFn("BeaconStateElectra.Slashings", size, 8192) + return + } + subIndx := hh.Index() + for _, i := range b.Slashings { + hh.AppendUint64(i) + } + hh.Merkleize(subIndx) + } + + // Field (15) 'PreviousEpochParticipation' + { + elemIndx := hh.Index() + byteLen := uint64(len(b.PreviousEpochParticipation)) + if byteLen > 1099511627776 { + err = ssz.ErrIncorrectListSize + return + } + hh.Append(b.PreviousEpochParticipation) + hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + } + + // Field (16) 'CurrentEpochParticipation' + { + elemIndx := hh.Index() + byteLen := uint64(len(b.CurrentEpochParticipation)) + if byteLen > 1099511627776 { + err = ssz.ErrIncorrectListSize + return + } + hh.Append(b.CurrentEpochParticipation) + hh.MerkleizeWithMixin(elemIndx, byteLen, (1099511627776+31)/32) + } + + // Field (17) 'JustificationBits' + if size := len(b.JustificationBits); size != 1 { + err = ssz.ErrBytesLengthFn("BeaconStateElectra.JustificationBits", size, 1) + return + } + hh.PutBytes(b.JustificationBits) + + // Field (18) 'PreviousJustifiedCheckpoint' + if b.PreviousJustifiedCheckpoint == nil { + b.PreviousJustifiedCheckpoint = new(Checkpoint) + } + if err = b.PreviousJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return + } + + // Field (19) 'CurrentJustifiedCheckpoint' + if b.CurrentJustifiedCheckpoint == nil { + b.CurrentJustifiedCheckpoint = new(Checkpoint) + } + if err = b.CurrentJustifiedCheckpoint.HashTreeRootWith(hh); err != nil { + return + } + + // Field (20) 'FinalizedCheckpoint' + if b.FinalizedCheckpoint == nil { + b.FinalizedCheckpoint = new(Checkpoint) + } + if err = b.FinalizedCheckpoint.HashTreeRootWith(hh); err != nil { + return + } + + // Field (21) 'InactivityScores' + { + if size := len(b.InactivityScores); size > 1099511627776 { + err = ssz.ErrListTooBigFn("BeaconStateElectra.InactivityScores", size, 1099511627776) + return + } + subIndx := hh.Index() + for _, i := range b.InactivityScores { + hh.AppendUint64(i) + } + hh.FillUpTo32() + numItems := uint64(len(b.InactivityScores)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(1099511627776, numItems, 8)) + } + + // Field (22) 'CurrentSyncCommittee' + if b.CurrentSyncCommittee == nil { + b.CurrentSyncCommittee = new(SyncCommittee) + } + if err = b.CurrentSyncCommittee.HashTreeRootWith(hh); err != nil { + return + } + + // Field (23) 'NextSyncCommittee' + if b.NextSyncCommittee == nil { + b.NextSyncCommittee = new(SyncCommittee) + } + if err = b.NextSyncCommittee.HashTreeRootWith(hh); err != nil { + return + } + + // Field (24) 'LatestExecutionPayloadHeader' + if err = b.LatestExecutionPayloadHeader.HashTreeRootWith(hh); err != nil { + return + } + + // Field (25) 'NextWithdrawalIndex' + hh.PutUint64(b.NextWithdrawalIndex) + + // Field (26) 'NextWithdrawalValidatorIndex' + hh.PutUint64(b.NextWithdrawalValidatorIndex) + + // Field (27) 'HistoricalSummaries' + { + subIndx := hh.Index() + num := uint64(len(b.HistoricalSummaries)) + if num > 16777216 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.HistoricalSummaries { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 16777216) + } + + // Field (28) 'DepositRequestsStartIndex' + hh.PutUint64(b.DepositRequestsStartIndex) + + // Field (29) 'DepositBalanceToConsume' + hh.PutUint64(b.DepositBalanceToConsume) + + // Field (30) 'ExitBalanceToConsume' + hh.PutUint64(b.ExitBalanceToConsume) + + // Field (31) 'EarliestExitEpoch' + hh.PutUint64(b.EarliestExitEpoch) + + // Field (32) 'ConsolidationBalanceToConsume' + hh.PutUint64(b.ConsolidationBalanceToConsume) + + // Field (33) 'EarliestConsolidationEpoch' + hh.PutUint64(b.EarliestConsolidationEpoch) + + // Field (34) 'PendingBalanceDeposits' + { + subIndx := hh.Index() + num := uint64(len(b.PendingBalanceDeposits)) + if num > 134217728 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.PendingBalanceDeposits { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 134217728) + } + + // Field (35) 'PendingPartialWithdrawals' + { + subIndx := hh.Index() + num := uint64(len(b.PendingPartialWithdrawals)) + if num > 134217728 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.PendingPartialWithdrawals { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 134217728) + } + + // Field (36) 'PendingConsolidations' + { + subIndx := hh.Index() + num := uint64(len(b.PendingConsolidations)) + if num > 262144 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range b.PendingConsolidations { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 262144) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the BeaconStateElectra object +func (b *BeaconStateElectra) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(b) +} + +// MarshalSSZ ssz marshals the AttestationElectra object +func (a *AttestationElectra) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(a) +} + +// MarshalSSZTo ssz marshals the AttestationElectra object to a target array +func (a *AttestationElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(292) + + // Offset (0) 'AggregationBits' + dst = ssz.WriteOffset(dst, offset) + offset += len(a.AggregationBits) + + // Field (1) 'Data' + if a.Data == nil { + a.Data = new(AttestationData) + } + if dst, err = a.Data.MarshalSSZTo(dst); err != nil { + return + } + + // Field (2) 'Signature' + dst = append(dst, a.Signature[:]...) + + // Field (3) 'CommitteeBits' + if size := len(a.CommitteeBits); size != 64 { + err = ssz.ErrBytesLengthFn("AttestationElectra.CommitteeBits", size, 64) + return + } + dst = append(dst, a.CommitteeBits...) + + // Field (0) 'AggregationBits' + if size := len(a.AggregationBits); size > 131072 { + err = ssz.ErrBytesLengthFn("AttestationElectra.AggregationBits", size, 131072) + return + } + dst = append(dst, a.AggregationBits...) + + return +} + +// UnmarshalSSZ ssz unmarshals the AttestationElectra object +func (a *AttestationElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 292 { + return ssz.ErrSize + } + + tail := buf + var o0 uint64 + + // Offset (0) 'AggregationBits' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 < 292 { + return ssz.ErrInvalidVariableOffset + } + + // Field (1) 'Data' + if a.Data == nil { + a.Data = new(AttestationData) + } + if err = a.Data.UnmarshalSSZ(buf[4:132]); err != nil { + return err + } + + // Field (2) 'Signature' + copy(a.Signature[:], buf[132:228]) + + // Field (3) 'CommitteeBits' + if cap(a.CommitteeBits) == 0 { + a.CommitteeBits = make([]byte, 0, len(buf[228:292])) + } + a.CommitteeBits = append(a.CommitteeBits, buf[228:292]...) + + // Field (0) 'AggregationBits' + { + buf = tail[o0:] + if err = ssz.ValidateBitlist(buf, 131072); err != nil { + return err + } + if cap(a.AggregationBits) == 0 { + a.AggregationBits = make([]byte, 0, len(buf)) + } + a.AggregationBits = append(a.AggregationBits, buf...) + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the AttestationElectra object +func (a *AttestationElectra) SizeSSZ() (size int) { + size = 292 + + // Field (0) 'AggregationBits' + size += len(a.AggregationBits) + + return +} + +// HashTreeRoot ssz hashes the AttestationElectra object +func (a *AttestationElectra) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(a) +} + +// HashTreeRootWith ssz hashes the AttestationElectra object with a hasher +func (a *AttestationElectra) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'AggregationBits' + if len(a.AggregationBits) == 0 { + err = ssz.ErrEmptyBitlist + return + } + hh.PutBitlist(a.AggregationBits, 131072) + + // Field (1) 'Data' + if a.Data == nil { + a.Data = new(AttestationData) + } + if err = a.Data.HashTreeRootWith(hh); err != nil { + return + } + + // Field (2) 'Signature' + hh.PutBytes(a.Signature[:]) + + // Field (3) 'CommitteeBits' + if size := len(a.CommitteeBits); size != 64 { + err = ssz.ErrBytesLengthFn("AttestationElectra.CommitteeBits", size, 64) + return + } + hh.PutBytes(a.CommitteeBits) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the AttestationElectra object +func (a *AttestationElectra) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(a) +} + +// MarshalSSZ ssz marshals the AttesterSlashingElectra object +func (a *AttesterSlashingElectra) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(a) +} + +// MarshalSSZTo ssz marshals the AttesterSlashingElectra object to a target array +func (a *AttesterSlashingElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(8) + + // Offset (0) 'Attestation1' + dst = ssz.WriteOffset(dst, offset) + if a.Attestation1 == nil { + a.Attestation1 = new(IndexedAttestationElectra) + } + offset += a.Attestation1.SizeSSZ() + + // Offset (1) 'Attestation2' + dst = ssz.WriteOffset(dst, offset) + if a.Attestation2 == nil { + a.Attestation2 = new(IndexedAttestationElectra) + } + offset += a.Attestation2.SizeSSZ() + + // Field (0) 'Attestation1' + if dst, err = a.Attestation1.MarshalSSZTo(dst); err != nil { + return + } + + // Field (1) 'Attestation2' + if dst, err = a.Attestation2.MarshalSSZTo(dst); err != nil { + return + } + + return +} + +// UnmarshalSSZ ssz unmarshals the AttesterSlashingElectra object +func (a *AttesterSlashingElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 8 { + return ssz.ErrSize + } + + tail := buf + var o0, o1 uint64 + + // Offset (0) 'Attestation1' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 < 8 { + return ssz.ErrInvalidVariableOffset + } + + // Offset (1) 'Attestation2' + if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 { + return ssz.ErrOffset + } + + // Field (0) 'Attestation1' + { + buf = tail[o0:o1] + if a.Attestation1 == nil { + a.Attestation1 = new(IndexedAttestationElectra) + } + if err = a.Attestation1.UnmarshalSSZ(buf); err != nil { + return err + } + } + + // Field (1) 'Attestation2' + { + buf = tail[o1:] + if a.Attestation2 == nil { + a.Attestation2 = new(IndexedAttestationElectra) + } + if err = a.Attestation2.UnmarshalSSZ(buf); err != nil { + return err + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashingElectra object +func (a *AttesterSlashingElectra) SizeSSZ() (size int) { + size = 8 + + // Field (0) 'Attestation1' + if a.Attestation1 == nil { + a.Attestation1 = new(IndexedAttestationElectra) + } + size += a.Attestation1.SizeSSZ() + + // Field (1) 'Attestation2' + if a.Attestation2 == nil { + a.Attestation2 = new(IndexedAttestationElectra) + } + size += a.Attestation2.SizeSSZ() + + return +} + +// HashTreeRoot ssz hashes the AttesterSlashingElectra object +func (a *AttesterSlashingElectra) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(a) +} + +// HashTreeRootWith ssz hashes the AttesterSlashingElectra object with a hasher +func (a *AttesterSlashingElectra) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'Attestation1' + if err = a.Attestation1.HashTreeRootWith(hh); err != nil { + return + } + + // Field (1) 'Attestation2' + if err = a.Attestation2.HashTreeRootWith(hh); err != nil { + return + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the AttesterSlashingElectra object +func (a *AttesterSlashingElectra) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(a) +} + +// MarshalSSZ ssz marshals the IndexedAttestationElectra object +func (i *IndexedAttestationElectra) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(i) +} + +// MarshalSSZTo ssz marshals the IndexedAttestationElectra object to a target array +func (i *IndexedAttestationElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(228) + + // Offset (0) 'AttestationIndices' + dst = ssz.WriteOffset(dst, offset) + offset += len(i.AttestationIndices) * 8 + + // Field (1) 'Data' + if i.Data == nil { + i.Data = new(AttestationData) + } + if dst, err = i.Data.MarshalSSZTo(dst); err != nil { + return + } + + // Field (2) 'Signature' + if size := len(i.Signature); size != 96 { + err = ssz.ErrBytesLengthFn("IndexedAttestationElectra.Signature", size, 96) + return + } + dst = append(dst, i.Signature...) + + // Field (0) 'AttestationIndices' + if size := len(i.AttestationIndices); size > 131072 { + err = ssz.ErrListTooBigFn("IndexedAttestationElectra.AttestationIndices", size, 131072) + return + } + for ii := 0; ii < len(i.AttestationIndices); ii++ { + dst = ssz.MarshalUint64(dst, i.AttestationIndices[ii]) + } + + return +} + +// UnmarshalSSZ ssz unmarshals the IndexedAttestationElectra object +func (i *IndexedAttestationElectra) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 228 { + return ssz.ErrSize + } + + tail := buf + var o0 uint64 + + // Offset (0) 'AttestationIndices' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 < 228 { + return ssz.ErrInvalidVariableOffset + } + + // Field (1) 'Data' + if i.Data == nil { + i.Data = new(AttestationData) + } + if err = i.Data.UnmarshalSSZ(buf[4:132]); err != nil { + return err + } + + // Field (2) 'Signature' + if cap(i.Signature) == 0 { + i.Signature = make([]byte, 0, len(buf[132:228])) + } + i.Signature = append(i.Signature, buf[132:228]...) + + // Field (0) 'AttestationIndices' + { + buf = tail[o0:] + num, err := ssz.DivideInt2(len(buf), 8, 131072) + if err != nil { + return err + } + i.AttestationIndices = ssz.ExtendUint64(i.AttestationIndices, num) + for ii := 0; ii < num; ii++ { + i.AttestationIndices[ii] = ssz.UnmarshallUint64(buf[ii*8 : (ii+1)*8]) + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the IndexedAttestationElectra object +func (i *IndexedAttestationElectra) SizeSSZ() (size int) { + size = 228 + + // Field (0) 'AttestationIndices' + size += len(i.AttestationIndices) * 8 + + return +} + +// HashTreeRoot ssz hashes the IndexedAttestationElectra object +func (i *IndexedAttestationElectra) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(i) +} + +// HashTreeRootWith ssz hashes the IndexedAttestationElectra object with a hasher +func (i *IndexedAttestationElectra) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'AttestationIndices' + { + if size := len(i.AttestationIndices); size > 131072 { + err = ssz.ErrListTooBigFn("IndexedAttestationElectra.AttestationIndices", size, 131072) + return + } + subIndx := hh.Index() + for _, i := range i.AttestationIndices { + hh.AppendUint64(i) + } + hh.FillUpTo32() + numItems := uint64(len(i.AttestationIndices)) + hh.MerkleizeWithMixin(subIndx, numItems, ssz.CalculateLimit(131072, numItems, 8)) + } + + // Field (1) 'Data' + if i.Data == nil { + i.Data = new(AttestationData) + } + if err = i.Data.HashTreeRootWith(hh); err != nil { + return + } + + // Field (2) 'Signature' + if size := len(i.Signature); size != 96 { + err = ssz.ErrBytesLengthFn("IndexedAttestationElectra.Signature", size, 96) + return + } + hh.PutBytes(i.Signature) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the IndexedAttestationElectra object +func (i *IndexedAttestationElectra) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(i) +} + +// MarshalSSZ ssz marshals the PendingBalanceDeposit object +func (p *PendingBalanceDeposit) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(p) +} + +// MarshalSSZTo ssz marshals the PendingBalanceDeposit object to a target array +func (p *PendingBalanceDeposit) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'Index' + dst = ssz.MarshalUint64(dst, p.Index) + + // Field (1) 'Amount' + dst = ssz.MarshalUint64(dst, p.Amount) + + return +} + +// UnmarshalSSZ ssz unmarshals the PendingBalanceDeposit object +func (p *PendingBalanceDeposit) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } + + // Field (0) 'Index' + p.Index = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'Amount' + p.Amount = ssz.UnmarshallUint64(buf[8:16]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the PendingBalanceDeposit object +func (p *PendingBalanceDeposit) SizeSSZ() (size int) { + size = 16 + return +} + +// HashTreeRoot ssz hashes the PendingBalanceDeposit object +func (p *PendingBalanceDeposit) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(p) +} + +// HashTreeRootWith ssz hashes the PendingBalanceDeposit object with a hasher +func (p *PendingBalanceDeposit) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'Index' + hh.PutUint64(p.Index) + + // Field (1) 'Amount' + hh.PutUint64(p.Amount) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the PendingBalanceDeposit object +func (p *PendingBalanceDeposit) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(p) +} + +// MarshalSSZ ssz marshals the PendingPartialWithdrawal object +func (p *PendingPartialWithdrawal) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(p) +} + +// MarshalSSZTo ssz marshals the PendingPartialWithdrawal object to a target array +func (p *PendingPartialWithdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'Index' + dst = ssz.MarshalUint64(dst, p.Index) + + // Field (1) 'Amount' + dst = ssz.MarshalUint64(dst, p.Amount) + + // Field (2) 'WithdrawableEpoch' + dst = ssz.MarshalUint64(dst, p.WithdrawableEpoch) + + return +} + +// UnmarshalSSZ ssz unmarshals the PendingPartialWithdrawal object +func (p *PendingPartialWithdrawal) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 24 { + return ssz.ErrSize + } + + // Field (0) 'Index' + p.Index = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'Amount' + p.Amount = ssz.UnmarshallUint64(buf[8:16]) + + // Field (2) 'WithdrawableEpoch' + p.WithdrawableEpoch = ssz.UnmarshallUint64(buf[16:24]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the PendingPartialWithdrawal object +func (p *PendingPartialWithdrawal) SizeSSZ() (size int) { + size = 24 + return +} + +// HashTreeRoot ssz hashes the PendingPartialWithdrawal object +func (p *PendingPartialWithdrawal) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(p) +} + +// HashTreeRootWith ssz hashes the PendingPartialWithdrawal object with a hasher +func (p *PendingPartialWithdrawal) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'Index' + hh.PutUint64(p.Index) + + // Field (1) 'Amount' + hh.PutUint64(p.Amount) + + // Field (2) 'WithdrawableEpoch' + hh.PutUint64(p.WithdrawableEpoch) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the PendingPartialWithdrawal object +func (p *PendingPartialWithdrawal) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(p) +} + +// MarshalSSZ ssz marshals the PendingConsolidation object +func (p *PendingConsolidation) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(p) +} + +// MarshalSSZTo ssz marshals the PendingConsolidation object to a target array +func (p *PendingConsolidation) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + + // Field (0) 'SourceIndex' + dst = ssz.MarshalUint64(dst, p.SourceIndex) + + // Field (1) 'TargetIndex' + dst = ssz.MarshalUint64(dst, p.TargetIndex) + + return +} + +// UnmarshalSSZ ssz unmarshals the PendingConsolidation object +func (p *PendingConsolidation) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size != 16 { + return ssz.ErrSize + } + + // Field (0) 'SourceIndex' + p.SourceIndex = ssz.UnmarshallUint64(buf[0:8]) + + // Field (1) 'TargetIndex' + p.TargetIndex = ssz.UnmarshallUint64(buf[8:16]) + + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the PendingConsolidation object +func (p *PendingConsolidation) SizeSSZ() (size int) { + size = 16 + return +} + +// HashTreeRoot ssz hashes the PendingConsolidation object +func (p *PendingConsolidation) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(p) +} + +// HashTreeRootWith ssz hashes the PendingConsolidation object with a hasher +func (p *PendingConsolidation) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'SourceIndex' + hh.PutUint64(p.SourceIndex) + + // Field (1) 'TargetIndex' + hh.PutUint64(p.TargetIndex) + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the PendingConsolidation object +func (p *PendingConsolidation) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(p) +} From aaf566bc794fef66ab486b65d39d041fa953d651 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Tue, 10 Sep 2024 11:54:15 +0200 Subject: [PATCH 04/13] fix config --- web/packages/test/config/beacon-relay.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/packages/test/config/beacon-relay.json b/web/packages/test/config/beacon-relay.json index b7ac5fc9d6..26ff1626c6 100644 --- a/web/packages/test/config/beacon-relay.json +++ b/web/packages/test/config/beacon-relay.json @@ -7,7 +7,10 @@ "syncCommitteeSize": 512, "slotsInEpoch": 32, "epochsPerSyncCommitteePeriod": 256, - "denebForkedEpoch": 0 + "forkVersions": { + "deneb": 0, + "electra": 0 + } }, "datastore": { "location": "/tmp/snowbridge/beaconstore", From 7cfd41226b050df87d7e271ddfb0790e7d35d7a2 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Tue, 10 Sep 2024 13:22:00 +0200 Subject: [PATCH 05/13] fixes --- relayer/magefile.go | 2 +- .../beacon/header/syncer/api/api_electra.go | 68 ++++++++++----- .../beacon/header/syncer/json/beacon_json.go | 3 + .../header/syncer/json/beacon_json_deneb.go | 20 ----- .../header/syncer/json/beacon_json_electra.go | 83 +++++++++++++++++++ .../header/syncer/scale/beacon_electra.go | 75 +++++++++++++++++ .../header/syncer/scale/beacon_scale.go | 1 + .../header/syncer/scale/json_conversion.go | 5 +- relayer/relays/beacon/header/syncer/syncer.go | 2 +- relayer/relays/beacon/state/beacon_electra.go | 12 +++ 10 files changed, 225 insertions(+), 46 deletions(-) create mode 100644 relayer/relays/beacon/header/syncer/json/beacon_json_electra.go create mode 100644 relayer/relays/beacon/header/syncer/scale/beacon_electra.go diff --git a/relayer/magefile.go b/relayer/magefile.go index c617a8a4da..56aabb4f5f 100644 --- a/relayer/magefile.go +++ b/relayer/magefile.go @@ -13,7 +13,7 @@ func Build() { } func BuildMain() error { - err := sh.Run("sszgen", "--path", "relays/beacon/state", "--objs", "BeaconStateCapellaMainnet,BlockRootsContainerMainnet,TransactionsRootContainer,BeaconBlockCapellaMainnet,WithdrawalsRootContainerMainnet,BeaconStateDenebMainnet,BeaconBlockDenebMainnet,BeaconStateElectra,BeaconBlockElectra") + err := sh.Run("sszgen", "--path", "relays/beacon/state", "--objs", "BeaconStateCapellaMainnet,BlockRootsContainerMainnet,TransactionsRootContainer,BeaconBlockCapellaMainnet,WithdrawalsRootContainerMainnet,BeaconStateDenebMainnet,BeaconBlockDenebMainnet,BeaconStateElectra,BeaconBlockElectra,DepositRequestsContainer,WithdrawalRequestsContainer,ConsolidationRequestsContainer") if err != nil { return err } diff --git a/relayer/relays/beacon/header/syncer/api/api_electra.go b/relayer/relays/beacon/header/syncer/api/api_electra.go index 10f942aa53..3415edeaa4 100644 --- a/relayer/relays/beacon/header/syncer/api/api_electra.go +++ b/relayer/relays/beacon/header/syncer/api/api_electra.go @@ -9,8 +9,8 @@ import ( "github.com/snowfork/snowbridge/relayer/relays/util" ) -func ElectraExecutionPayloadToScale(e *state.ExecutionPayloadElectra) (scale.ExecutionPayloadHeaderDeneb, error) { - var payloadHeader scale.ExecutionPayloadHeaderDeneb +func ElectraExecutionPayloadToScale(e *state.ExecutionPayloadElectra) (scale.ExecutionPayloadHeaderElectra, error) { + var payloadHeader scale.ExecutionPayloadHeaderElectra transactionsContainer := state.TransactionsRootContainer{} transactionsContainer.Transactions = e.Transactions @@ -19,11 +19,30 @@ func ElectraExecutionPayloadToScale(e *state.ExecutionPayloadElectra) (scale.Exe return payloadHeader, err } - var withdrawalRoot types.H256 - withdrawalContainer := state.WithdrawalsRootContainerMainnet{} withdrawalContainer.Withdrawals = e.Withdrawals - withdrawalRoot, err = withdrawalContainer.HashTreeRoot() + withdrawalRoot, err := withdrawalContainer.HashTreeRoot() + if err != nil { + return payloadHeader, err + } + + depositRequestsContainer := state.DepositRequestsContainer{} + depositRequestsContainer.DepositRequests = e.DepositRequests + depositRequestsRoot, err := depositRequestsContainer.HashTreeRoot() + if err != nil { + return payloadHeader, err + } + + withdrawalRequestsContainer := state.WithdrawalRequestsContainer{} + withdrawalRequestsContainer.WithdrawalRequests = e.WithdrawalRequests + withdrawalRequestsRoot, err := withdrawalRequestsContainer.HashTreeRoot() + if err != nil { + return payloadHeader, err + } + + consolidationRequestsContainer := state.ConsolidationRequestsContainer{} + consolidationRequestsContainer.ConsolidationRequests = e.ConsolidationRequests + consolidationRequestsRoot, err := consolidationRequestsContainer.HashTreeRoot() if err != nil { return payloadHeader, err } @@ -32,24 +51,27 @@ func ElectraExecutionPayloadToScale(e *state.ExecutionPayloadElectra) (scale.Exe // Change BaseFeePerGas back from little-endian to big-endian baseFeePerGas.SetBytes(util.ChangeByteOrder(e.BaseFeePerGas[:])) - return scale.ExecutionPayloadHeaderDeneb{ - ParentHash: types.NewH256(e.ParentHash[:]), - FeeRecipient: e.FeeRecipient, - StateRoot: types.NewH256(e.StateRoot[:]), - ReceiptsRoot: types.NewH256(e.ReceiptsRoot[:]), - LogsBloom: e.LogsBloom[:], - PrevRandao: types.NewH256(e.PrevRandao[:]), - BlockNumber: types.NewU64(e.BlockNumber), - GasLimit: types.NewU64(e.GasLimit), - GasUsed: types.NewU64(e.GasUsed), - Timestamp: types.NewU64(e.Timestamp), - ExtraData: e.ExtraData, - BaseFeePerGas: types.NewU256(baseFeePerGas), - BlockHash: types.NewH256(e.BlockHash[:]), - TransactionsRoot: transactionsRoot, - WithdrawalsRoot: withdrawalRoot, - BlobGasUsed: types.NewU64(e.BlobGasUsed), - ExcessBlobGas: types.NewU64(e.ExcessBlobGas), + return scale.ExecutionPayloadHeaderElectra{ + ParentHash: types.NewH256(e.ParentHash[:]), + FeeRecipient: e.FeeRecipient, + StateRoot: types.NewH256(e.StateRoot[:]), + ReceiptsRoot: types.NewH256(e.ReceiptsRoot[:]), + LogsBloom: e.LogsBloom[:], + PrevRandao: types.NewH256(e.PrevRandao[:]), + BlockNumber: types.NewU64(e.BlockNumber), + GasLimit: types.NewU64(e.GasLimit), + GasUsed: types.NewU64(e.GasUsed), + Timestamp: types.NewU64(e.Timestamp), + ExtraData: e.ExtraData, + BaseFeePerGas: types.NewU256(baseFeePerGas), + BlockHash: types.NewH256(e.BlockHash[:]), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalRoot, + BlobGasUsed: types.NewU64(e.BlobGasUsed), + ExcessBlobGas: types.NewU64(e.ExcessBlobGas), + DepositRequestsRoot: depositRequestsRoot, + WithdrawalRequestsRoot: withdrawalRequestsRoot, + ConsolidationRequestsRoot: consolidationRequestsRoot, }, nil } diff --git a/relayer/relays/beacon/header/syncer/json/beacon_json.go b/relayer/relays/beacon/header/syncer/json/beacon_json.go index cda9afae1a..8ce3b986e4 100644 --- a/relayer/relays/beacon/header/syncer/json/beacon_json.go +++ b/relayer/relays/beacon/header/syncer/json/beacon_json.go @@ -295,6 +295,7 @@ func removeLeadingZeroHash(s string) string { type VersionedExecutionPayloadHeader struct { Capella *ExecutionPayloadHeaderCapella `json:"Capella,omitempty"` Deneb *ExecutionPayloadHeaderDeneb `json:"Deneb,omitempty"` + Electra *ExecutionPayloadHeaderElectra `json:"Electra,omitempty"` } func (v *VersionedExecutionPayloadHeader) RemoveLeadingZeroHashes() { @@ -302,5 +303,7 @@ func (v *VersionedExecutionPayloadHeader) RemoveLeadingZeroHashes() { v.Capella.RemoveLeadingZeroHashes() } else if v.Deneb != nil { v.Deneb.RemoveLeadingZeroHashes() + } else if v.Electra != nil { + v.Electra.RemoveLeadingZeroHashes() } } diff --git a/relayer/relays/beacon/header/syncer/json/beacon_json_deneb.go b/relayer/relays/beacon/header/syncer/json/beacon_json_deneb.go index 1c05aed0eb..c5d924da58 100644 --- a/relayer/relays/beacon/header/syncer/json/beacon_json_deneb.go +++ b/relayer/relays/beacon/header/syncer/json/beacon_json_deneb.go @@ -20,26 +20,6 @@ type ExecutionPayloadHeaderDeneb struct { ExcessBlobGas uint64 `json:"excess_blob_gas"` } -type FullExecutionPayloadHeaderJson struct { - ParentHash string `json:"parent_hash"` - FeeRecipient string `json:"fee_recipient"` - StateRoot string `json:"state_root"` - ReceiptsRoot string `json:"receipts_root"` - LogsBloom string `json:"logs_bloom"` - PrevRandao string `json:"prev_randao"` - BlockNumber string `json:"block_number"` - GasLimit string `json:"gas_limit"` - GasUsed string `json:"gas_used"` - Timestamp string `json:"timestamp"` - ExtraData string `json:"extra_data"` - BaseFeePerGas string `json:"base_fee_per_gas"` - BlockHash string `json:"block_hash"` - TransactionsRoot string `json:"transactions_root"` - WithdrawalsRoot string `json:"withdrawals_root"` - BlobGasUsed string `json:"blob_gas_used,omitempty"` - ExcessBlobGas string `json:"excess_blob_gas,omitempty"` -} - func (e *ExecutionPayloadHeaderDeneb) RemoveLeadingZeroHashes() { e.ParentHash = removeLeadingZeroHash(e.ParentHash) e.FeeRecipient = removeLeadingZeroHash(e.FeeRecipient) diff --git a/relayer/relays/beacon/header/syncer/json/beacon_json_electra.go b/relayer/relays/beacon/header/syncer/json/beacon_json_electra.go new file mode 100644 index 0000000000..43c23978b8 --- /dev/null +++ b/relayer/relays/beacon/header/syncer/json/beacon_json_electra.go @@ -0,0 +1,83 @@ +package json + +type ExecutionPayloadHeaderElectra struct { + ParentHash string `json:"parent_hash"` + FeeRecipient string `json:"fee_recipient"` + StateRoot string `json:"state_root"` + ReceiptsRoot string `json:"receipts_root"` + LogsBloom string `json:"logs_bloom"` + PrevRandao string `json:"prev_randao"` + BlockNumber uint64 `json:"block_number"` + GasLimit uint64 `json:"gas_limit"` + GasUsed uint64 `json:"gas_used"` + Timestamp uint64 `json:"timestamp"` + ExtraData string `json:"extra_data"` + BaseFeePerGas uint64 `json:"base_fee_per_gas"` + BlockHash string `json:"block_hash"` + TransactionsRoot string `json:"transactions_root"` + WithdrawalsRoot string `json:"withdrawals_root"` + BlobGasUsed uint64 `json:"blob_gas_used"` + ExcessBlobGas uint64 `json:"excess_blob_gas"` + DepositRequestsRoot string `json:"deposit_requests"` + WithdrawalRequestsRoot string `json:"withdrawal_requests"` + ConsolidationRequestsRoot string `json:"consolidation_requests"` +} + +type FullExecutionPayloadHeaderJson struct { + ParentHash string `json:"parent_hash"` + FeeRecipient string `json:"fee_recipient"` + StateRoot string `json:"state_root"` + ReceiptsRoot string `json:"receipts_root"` + LogsBloom string `json:"logs_bloom"` + PrevRandao string `json:"prev_randao"` + BlockNumber string `json:"block_number"` + GasLimit string `json:"gas_limit"` + GasUsed string `json:"gas_used"` + Timestamp string `json:"timestamp"` + ExtraData string `json:"extra_data"` + BaseFeePerGas string `json:"base_fee_per_gas"` + BlockHash string `json:"block_hash"` + TransactionsRoot string `json:"transactions_root"` + WithdrawalsRoot string `json:"withdrawals_root"` + BlobGasUsed string `json:"blob_gas_used,omitempty"` + ExcessBlobGas string `json:"excess_blob_gas,omitempty"` + DepositRequestsRoot string `json:"deposit_requests,omitempty"` + WithdrawalRequestsRoot string `json:"withdrawal_requests,omitempty"` + ConsolidationRequestsRoot string `json:"consolidation_requests,omitempty"` +} + +type DepositRequestJson struct { + Pubkey string `json:"pubkey"` + WithdrawalCredentials string `json:"withdrawal_credentials"` + Amount string `json:"amount"` + Signature string `json:"signature"` + Index string `json:"index"` +} + +type WithdrawalRequestJson struct { + SourceAddress string `json:"source_address" ` + ValidatorPubkey string `json:"validator_pubkey"` + Amount string `json:"amount"` +} + +type ConsolidationRequestJson struct { + SourceAddress string `json:"source_address" ` + SourcePubkey string `json:"source_pubkey"` + TargetPubkey string `json:"target_pubkey"` +} + +func (e *ExecutionPayloadHeaderElectra) RemoveLeadingZeroHashes() { + e.ParentHash = removeLeadingZeroHash(e.ParentHash) + e.FeeRecipient = removeLeadingZeroHash(e.FeeRecipient) + e.StateRoot = removeLeadingZeroHash(e.StateRoot) + e.ReceiptsRoot = removeLeadingZeroHash(e.ReceiptsRoot) + e.LogsBloom = removeLeadingZeroHash(e.LogsBloom) + e.PrevRandao = removeLeadingZeroHash(e.PrevRandao) + e.ExtraData = removeLeadingZeroHash(e.ExtraData) + e.BlockHash = removeLeadingZeroHash(e.BlockHash) + e.TransactionsRoot = removeLeadingZeroHash(e.TransactionsRoot) + e.WithdrawalsRoot = removeLeadingZeroHash(e.WithdrawalsRoot) + e.WithdrawalRequestsRoot = removeLeadingZeroHash(e.WithdrawalRequestsRoot) + e.DepositRequestsRoot = removeLeadingZeroHash(e.DepositRequestsRoot) + e.ConsolidationRequestsRoot = removeLeadingZeroHash(e.ConsolidationRequestsRoot) +} diff --git a/relayer/relays/beacon/header/syncer/scale/beacon_electra.go b/relayer/relays/beacon/header/syncer/scale/beacon_electra.go new file mode 100644 index 0000000000..85a65379e5 --- /dev/null +++ b/relayer/relays/beacon/header/syncer/scale/beacon_electra.go @@ -0,0 +1,75 @@ +package scale + +import ( + "github.com/snowfork/go-substrate-rpc-client/v4/types" + "github.com/snowfork/snowbridge/relayer/relays/beacon/header/syncer/json" + "github.com/snowfork/snowbridge/relayer/relays/util" +) + +type ExecutionPayloadHeaderElectra struct { + ParentHash types.H256 + FeeRecipient types.H160 + StateRoot types.H256 + ReceiptsRoot types.H256 + LogsBloom []byte + PrevRandao types.H256 + BlockNumber types.U64 + GasLimit types.U64 + GasUsed types.U64 + Timestamp types.U64 + ExtraData []byte + BaseFeePerGas types.U256 + BlockHash types.H256 + TransactionsRoot types.H256 + WithdrawalsRoot types.H256 + BlobGasUsed types.U64 + ExcessBlobGas types.U64 + DepositRequestsRoot types.H256 + WithdrawalRequestsRoot types.H256 + ConsolidationRequestsRoot types.H256 +} + +type DepositRequest struct { + Pubkey []byte + WithdrawalCredentials []byte + Amount types.U64 + Signature []byte + Index types.U64 +} + +type WithdrawalRequest struct { + SourceAddress []byte + ValidatorPubkey []byte + Amount types.U64 +} + +type ConsolidationRequest struct { + SourceAddress []byte + SourcePubkey []byte + TargetPubkey []byte +} + +func (e *ExecutionPayloadHeaderElectra) ToJSON() json.ExecutionPayloadHeaderElectra { + return json.ExecutionPayloadHeaderElectra{ + ParentHash: e.ParentHash.Hex(), + FeeRecipient: util.BytesToHexString(e.FeeRecipient[:]), + StateRoot: e.StateRoot.Hex(), + ReceiptsRoot: e.ReceiptsRoot.Hex(), + LogsBloom: util.BytesToHexString(e.LogsBloom), + PrevRandao: e.PrevRandao.Hex(), + BlockNumber: uint64(e.BlockNumber), + GasLimit: uint64(e.GasLimit), + GasUsed: uint64(e.GasUsed), + Timestamp: uint64(e.Timestamp), + ExtraData: util.BytesToHexString(e.ExtraData), + BaseFeePerGas: e.BaseFeePerGas.Uint64(), + BlockHash: e.BlockHash.Hex(), + TransactionsRoot: e.TransactionsRoot.Hex(), + WithdrawalsRoot: e.WithdrawalsRoot.Hex(), + BlobGasUsed: uint64(e.BlobGasUsed), + ExcessBlobGas: uint64(e.ExcessBlobGas), + DepositRequestsRoot: e.DepositRequestsRoot.Hex(), + WithdrawalRequestsRoot: e.WithdrawalRequestsRoot.Hex(), + ConsolidationRequestsRoot: e.ConsolidationRequestsRoot.Hex(), + } +} diff --git a/relayer/relays/beacon/header/syncer/scale/beacon_scale.go b/relayer/relays/beacon/header/syncer/scale/beacon_scale.go index 18cd8f2585..62f6b6dfce 100644 --- a/relayer/relays/beacon/header/syncer/scale/beacon_scale.go +++ b/relayer/relays/beacon/header/syncer/scale/beacon_scale.go @@ -303,6 +303,7 @@ type BeaconState struct { type VersionedExecutionPayloadHeader struct { Capella *ExecutionPayloadHeaderCapella Deneb *ExecutionPayloadHeaderDeneb + Electra *ExecutionPayloadHeaderElectra } var ( diff --git a/relayer/relays/beacon/header/syncer/scale/json_conversion.go b/relayer/relays/beacon/header/syncer/scale/json_conversion.go index 69b0baa4a1..780d993239 100644 --- a/relayer/relays/beacon/header/syncer/scale/json_conversion.go +++ b/relayer/relays/beacon/header/syncer/scale/json_conversion.go @@ -103,7 +103,10 @@ func (s *SyncAggregate) ToJSON() json.SyncAggregate { } func (v *VersionedExecutionPayloadHeader) ToJSON() json.VersionedExecutionPayloadHeader { - if v.Deneb != nil { + if v.Electra != nil { + data := v.Electra.ToJSON() + return json.VersionedExecutionPayloadHeader{Electra: &data} + } else if v.Deneb != nil { data := v.Deneb.ToJSON() return json.VersionedExecutionPayloadHeader{Deneb: &data} } else { diff --git a/relayer/relays/beacon/header/syncer/syncer.go b/relayer/relays/beacon/header/syncer/syncer.go index 7d32b48d45..65cbecf974 100644 --- a/relayer/relays/beacon/header/syncer/syncer.go +++ b/relayer/relays/beacon/header/syncer/syncer.go @@ -564,7 +564,7 @@ func (s *Syncer) GetHeaderUpdate(blockRoot common.Hash, checkpoint *cache.Proof) if err != nil { return scale.HeaderUpdatePayload{}, err } - versionedExecutionPayloadHeader = scale.VersionedExecutionPayloadHeader{Deneb: &executionPayloadScale} + versionedExecutionPayloadHeader = scale.VersionedExecutionPayloadHeader{Electra: &executionPayloadScale} } else if forkVersion == protocol.Deneb { executionPayloadScale, err := api.DenebExecutionPayloadToScale(sszBlock.ExecutionPayloadDeneb()) if err != nil { diff --git a/relayer/relays/beacon/state/beacon_electra.go b/relayer/relays/beacon/state/beacon_electra.go index 2e5bafdb1f..17d3292d83 100644 --- a/relayer/relays/beacon/state/beacon_electra.go +++ b/relayer/relays/beacon/state/beacon_electra.go @@ -48,6 +48,18 @@ type ExecutionPayloadHeaderElectra struct { ConsolidationRequestsRoot []byte `json:"consolidation_requests_root" ssz-size:"32"` // New in Electra } +type DepositRequestsContainer struct { + DepositRequests []*DepositRequest `ssz-max:"8192" json:"deposit_requests"` +} + +type WithdrawalRequestsContainer struct { + WithdrawalRequests []*WithdrawalRequest `ssz-max:"16" json:"withdrawal_requests"` +} + +type ConsolidationRequestsContainer struct { + ConsolidationRequests []*ConsolidationRequest `ssz-max:"1" json:"consolidation_requests"` +} + type DepositRequest struct { Pubkey [48]byte `json:"pubkey" ssz-size:"48"` WithdrawalCredentials [32]byte `ssz-size:"32" json:"withdrawal_credentials"` From 5d345b7b4dbf0976ce175aaf185b4bb8e19619cc Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Tue, 10 Sep 2024 13:58:27 +0200 Subject: [PATCH 06/13] fix tests --- relayer/relays/beacon/header/header_test.go | 19 ++++++++++++++----- relayer/relays/beacon/header/syncer/syncer.go | 4 ++-- .../beacon/header/syncer/syncer_test.go | 6 ------ relayer/relays/beacon/store/datastore_test.go | 15 ++++++++++++--- 4 files changed, 28 insertions(+), 16 deletions(-) diff --git a/relayer/relays/beacon/header/header_test.go b/relayer/relays/beacon/header/header_test.go index 5ff7cee5ef..b8ecde2317 100644 --- a/relayer/relays/beacon/header/header_test.go +++ b/relayer/relays/beacon/header/header_test.go @@ -20,7 +20,10 @@ func TestSyncInterimFinalizedUpdate_WithDataFromAPI(t *testing.T) { settings := config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, + ForkVersions: config.ForkVersions{ + Deneb: 0, + Electra: 800000, + }, } p := protocol.New(settings) client := mock.API{} @@ -78,7 +81,10 @@ func TestSyncInterimFinalizedUpdate_WithDataFromStore(t *testing.T) { settings := config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, + ForkVersions: config.ForkVersions{ + Deneb: 0, + Electra: 800000, + }, } p := protocol.New(settings) client := mock.API{} @@ -144,7 +150,10 @@ func TestSyncInterimFinalizedUpdate_WithDataFromStoreWithDifferentBlocks(t *test settings := config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, + ForkVersions: config.ForkVersions{ + Deneb: 0, + Electra: 800000, + }, } p := protocol.New(settings) client := mock.API{} @@ -210,7 +219,7 @@ func TestSyncInterimFinalizedUpdate_BeaconStateNotAvailableInAPIAndStore(t *test settings := config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, + //DenebForkEpoch: 0, } p := protocol.New(settings) client := mock.API{} @@ -254,7 +263,7 @@ func TestSyncInterimFinalizedUpdate_NoValidBlocksFound(t *testing.T) { settings := config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, + //DenebForkEpoch: 0, } p := protocol.New(settings) client := mock.API{} diff --git a/relayer/relays/beacon/header/syncer/syncer.go b/relayer/relays/beacon/header/syncer/syncer.go index 65cbecf974..cf75bbd8d5 100644 --- a/relayer/relays/beacon/header/syncer/syncer.go +++ b/relayer/relays/beacon/header/syncer/syncer.go @@ -558,7 +558,7 @@ func (s *Syncer) GetHeaderUpdate(blockRoot common.Hash, checkpoint *cache.Proof) } var versionedExecutionPayloadHeader scale.VersionedExecutionPayloadHeader - forkVersion := protocol.ForkVersion(slot) + forkVersion := s.protocol.ForkVersion(slot) if forkVersion == protocol.Electra { executionPayloadScale, err := api.ElectraExecutionPayloadToScale(sszBlock.ExecutionPayloadElectra()) if err != nil { @@ -627,7 +627,7 @@ func (s *Syncer) getBeaconStateAtSlot(slot uint64) (state.BeaconState, error) { func (s *Syncer) UnmarshalBeaconState(slot uint64, data []byte) (state.BeaconState, error) { var beaconState state.BeaconState - forkVersion := protocol.ForkVersion(slot) + forkVersion := s.protocol.ForkVersion(slot) if forkVersion == protocol.Electra { beaconState = &state.BeaconStateElectra{} } else if forkVersion == protocol.Deneb { diff --git a/relayer/relays/beacon/header/syncer/syncer_test.go b/relayer/relays/beacon/header/syncer/syncer_test.go index 3e94469058..04f3d9a008 100644 --- a/relayer/relays/beacon/header/syncer/syncer_test.go +++ b/relayer/relays/beacon/header/syncer/syncer_test.go @@ -24,7 +24,6 @@ func newTestRunner() *Syncer { return New(api.NewBeaconClient(TestUrl, TestUrl), &mock.Store{}, protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, })) } @@ -109,7 +108,6 @@ func TestGetFinalizedUpdateWithSyncCommitteeUpdateAtSlot(t *testing.T) { }, protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, })) // Manually construct a finalized update @@ -164,7 +162,6 @@ func TestFindAttestedAndFinalizedHeadersAtBoundary(t *testing.T) { syncer := New(&mockAPI, &mock.Store{}, protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, })) attested, err := syncer.FindValidAttestedHeader(8000, 8160) @@ -194,7 +191,6 @@ func TestFindAttestedAndFinalizedHeadersAtBoundary(t *testing.T) { syncer = New(&mockAPI, &mock.Store{}, protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, })) attested, err = syncer.FindValidAttestedHeader(32576, 32704) @@ -224,7 +220,6 @@ func TestFindAttestedAndFinalizedHeadersAtBoundary(t *testing.T) { syncer = New(&mockAPI, &mock.Store{}, protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, })) attested, err = syncer.FindValidAttestedHeader(25076, 32736) @@ -248,7 +243,6 @@ func TestFindAttestedAndFinalizedHeadersAtBoundary(t *testing.T) { syncer = New(&mockAPI, &mock.Store{}, protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, })) attested, err = syncer.FindValidAttestedHeader(32540, 32768) diff --git a/relayer/relays/beacon/store/datastore_test.go b/relayer/relays/beacon/store/datastore_test.go index efb10f75d7..f261fb6f9d 100644 --- a/relayer/relays/beacon/store/datastore_test.go +++ b/relayer/relays/beacon/store/datastore_test.go @@ -21,7 +21,10 @@ func TestGetBeaconState(t *testing.T) { store := New(TestDataStoreFile, 100, *protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, + ForkVersions: config.ForkVersions{ + Deneb: 0, + Electra: 800000, + }, })) err := store.Connect() require.NoError(t, err) @@ -65,7 +68,10 @@ func TestPruneOldStates(t *testing.T) { store := New(TestDataStoreFile, 2, *protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, + ForkVersions: config.ForkVersions{ + Deneb: 0, + Electra: 800000, + }, })) err := store.Connect() require.NoError(t, err) @@ -136,7 +142,10 @@ func TestFindBeaconStateWithinRange(t *testing.T) { p := protocol.New(config.SpecSettings{ SlotsInEpoch: 32, EpochsPerSyncCommitteePeriod: 256, - DenebForkEpoch: 0, + ForkVersions: config.ForkVersions{ + Deneb: 0, + Electra: 800000, + }, }) store := New(TestDataStoreFile, 2, *p) err := store.Connect() From 51aa8dec3b0b499e1119cee2335bb66d0db6ff6f Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Tue, 10 Sep 2024 14:03:46 +0200 Subject: [PATCH 07/13] update go version --- .github/workflows/relayer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/relayer.yml b/.github/workflows/relayer.yml index 4a67172004..f932b8340d 100644 --- a/.github/workflows/relayer.yml +++ b/.github/workflows/relayer.yml @@ -22,7 +22,7 @@ jobs: - name: setup go uses: actions/checkout@v4 with: - go-version: '^1.20.1' + go-version: '^1.22.5' - name: check go version run: go version From 3a25d81f54358332d9acd86ff16225da3a493015 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Tue, 10 Sep 2024 14:07:09 +0200 Subject: [PATCH 08/13] containers --- .../beacon/state/beacon_electra_encoding.go | 338 +++++++++++++++++- 1 file changed, 337 insertions(+), 1 deletion(-) diff --git a/relayer/relays/beacon/state/beacon_electra_encoding.go b/relayer/relays/beacon/state/beacon_electra_encoding.go index 455092dba8..3ab2cb42af 100644 --- a/relayer/relays/beacon/state/beacon_electra_encoding.go +++ b/relayer/relays/beacon/state/beacon_electra_encoding.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 59f099d56dedd1f5875bcefc64e241f92e3ee92a89a3506957acdae15d8cf77e +// Hash: 26de6be168c07374a8bcc6262d218dfae18c063a7af308fbab963179eda0441b // Version: 0.1.3 package state @@ -955,6 +955,342 @@ func (e *ExecutionPayloadHeaderElectra) GetTree() (*ssz.Node, error) { return ssz.ProofTree(e) } +// MarshalSSZ ssz marshals the DepositRequestsContainer object +func (d *DepositRequestsContainer) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(d) +} + +// MarshalSSZTo ssz marshals the DepositRequestsContainer object to a target array +func (d *DepositRequestsContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(4) + + // Offset (0) 'DepositRequests' + dst = ssz.WriteOffset(dst, offset) + offset += len(d.DepositRequests) * 192 + + // Field (0) 'DepositRequests' + if size := len(d.DepositRequests); size > 8192 { + err = ssz.ErrListTooBigFn("DepositRequestsContainer.DepositRequests", size, 8192) + return + } + for ii := 0; ii < len(d.DepositRequests); ii++ { + if dst, err = d.DepositRequests[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + return +} + +// UnmarshalSSZ ssz unmarshals the DepositRequestsContainer object +func (d *DepositRequestsContainer) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 4 { + return ssz.ErrSize + } + + tail := buf + var o0 uint64 + + // Offset (0) 'DepositRequests' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 < 4 { + return ssz.ErrInvalidVariableOffset + } + + // Field (0) 'DepositRequests' + { + buf = tail[o0:] + num, err := ssz.DivideInt2(len(buf), 192, 8192) + if err != nil { + return err + } + d.DepositRequests = make([]*DepositRequest, num) + for ii := 0; ii < num; ii++ { + if d.DepositRequests[ii] == nil { + d.DepositRequests[ii] = new(DepositRequest) + } + if err = d.DepositRequests[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { + return err + } + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the DepositRequestsContainer object +func (d *DepositRequestsContainer) SizeSSZ() (size int) { + size = 4 + + // Field (0) 'DepositRequests' + size += len(d.DepositRequests) * 192 + + return +} + +// HashTreeRoot ssz hashes the DepositRequestsContainer object +func (d *DepositRequestsContainer) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(d) +} + +// HashTreeRootWith ssz hashes the DepositRequestsContainer object with a hasher +func (d *DepositRequestsContainer) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'DepositRequests' + { + subIndx := hh.Index() + num := uint64(len(d.DepositRequests)) + if num > 8192 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range d.DepositRequests { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 8192) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the DepositRequestsContainer object +func (d *DepositRequestsContainer) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(d) +} + +// MarshalSSZ ssz marshals the WithdrawalRequestsContainer object +func (w *WithdrawalRequestsContainer) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(w) +} + +// MarshalSSZTo ssz marshals the WithdrawalRequestsContainer object to a target array +func (w *WithdrawalRequestsContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(4) + + // Offset (0) 'WithdrawalRequests' + dst = ssz.WriteOffset(dst, offset) + offset += len(w.WithdrawalRequests) * 76 + + // Field (0) 'WithdrawalRequests' + if size := len(w.WithdrawalRequests); size > 16 { + err = ssz.ErrListTooBigFn("WithdrawalRequestsContainer.WithdrawalRequests", size, 16) + return + } + for ii := 0; ii < len(w.WithdrawalRequests); ii++ { + if dst, err = w.WithdrawalRequests[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + return +} + +// UnmarshalSSZ ssz unmarshals the WithdrawalRequestsContainer object +func (w *WithdrawalRequestsContainer) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 4 { + return ssz.ErrSize + } + + tail := buf + var o0 uint64 + + // Offset (0) 'WithdrawalRequests' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 < 4 { + return ssz.ErrInvalidVariableOffset + } + + // Field (0) 'WithdrawalRequests' + { + buf = tail[o0:] + num, err := ssz.DivideInt2(len(buf), 76, 16) + if err != nil { + return err + } + w.WithdrawalRequests = make([]*WithdrawalRequest, num) + for ii := 0; ii < num; ii++ { + if w.WithdrawalRequests[ii] == nil { + w.WithdrawalRequests[ii] = new(WithdrawalRequest) + } + if err = w.WithdrawalRequests[ii].UnmarshalSSZ(buf[ii*76 : (ii+1)*76]); err != nil { + return err + } + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the WithdrawalRequestsContainer object +func (w *WithdrawalRequestsContainer) SizeSSZ() (size int) { + size = 4 + + // Field (0) 'WithdrawalRequests' + size += len(w.WithdrawalRequests) * 76 + + return +} + +// HashTreeRoot ssz hashes the WithdrawalRequestsContainer object +func (w *WithdrawalRequestsContainer) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(w) +} + +// HashTreeRootWith ssz hashes the WithdrawalRequestsContainer object with a hasher +func (w *WithdrawalRequestsContainer) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'WithdrawalRequests' + { + subIndx := hh.Index() + num := uint64(len(w.WithdrawalRequests)) + if num > 16 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range w.WithdrawalRequests { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 16) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the WithdrawalRequestsContainer object +func (w *WithdrawalRequestsContainer) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(w) +} + +// MarshalSSZ ssz marshals the ConsolidationRequestsContainer object +func (c *ConsolidationRequestsContainer) MarshalSSZ() ([]byte, error) { + return ssz.MarshalSSZ(c) +} + +// MarshalSSZTo ssz marshals the ConsolidationRequestsContainer object to a target array +func (c *ConsolidationRequestsContainer) MarshalSSZTo(buf []byte) (dst []byte, err error) { + dst = buf + offset := int(4) + + // Offset (0) 'ConsolidationRequests' + dst = ssz.WriteOffset(dst, offset) + offset += len(c.ConsolidationRequests) * 116 + + // Field (0) 'ConsolidationRequests' + if size := len(c.ConsolidationRequests); size > 1 { + err = ssz.ErrListTooBigFn("ConsolidationRequestsContainer.ConsolidationRequests", size, 1) + return + } + for ii := 0; ii < len(c.ConsolidationRequests); ii++ { + if dst, err = c.ConsolidationRequests[ii].MarshalSSZTo(dst); err != nil { + return + } + } + + return +} + +// UnmarshalSSZ ssz unmarshals the ConsolidationRequestsContainer object +func (c *ConsolidationRequestsContainer) UnmarshalSSZ(buf []byte) error { + var err error + size := uint64(len(buf)) + if size < 4 { + return ssz.ErrSize + } + + tail := buf + var o0 uint64 + + // Offset (0) 'ConsolidationRequests' + if o0 = ssz.ReadOffset(buf[0:4]); o0 > size { + return ssz.ErrOffset + } + + if o0 < 4 { + return ssz.ErrInvalidVariableOffset + } + + // Field (0) 'ConsolidationRequests' + { + buf = tail[o0:] + num, err := ssz.DivideInt2(len(buf), 116, 1) + if err != nil { + return err + } + c.ConsolidationRequests = make([]*ConsolidationRequest, num) + for ii := 0; ii < num; ii++ { + if c.ConsolidationRequests[ii] == nil { + c.ConsolidationRequests[ii] = new(ConsolidationRequest) + } + if err = c.ConsolidationRequests[ii].UnmarshalSSZ(buf[ii*116 : (ii+1)*116]); err != nil { + return err + } + } + } + return err +} + +// SizeSSZ returns the ssz encoded size in bytes for the ConsolidationRequestsContainer object +func (c *ConsolidationRequestsContainer) SizeSSZ() (size int) { + size = 4 + + // Field (0) 'ConsolidationRequests' + size += len(c.ConsolidationRequests) * 116 + + return +} + +// HashTreeRoot ssz hashes the ConsolidationRequestsContainer object +func (c *ConsolidationRequestsContainer) HashTreeRoot() ([32]byte, error) { + return ssz.HashWithDefaultHasher(c) +} + +// HashTreeRootWith ssz hashes the ConsolidationRequestsContainer object with a hasher +func (c *ConsolidationRequestsContainer) HashTreeRootWith(hh ssz.HashWalker) (err error) { + indx := hh.Index() + + // Field (0) 'ConsolidationRequests' + { + subIndx := hh.Index() + num := uint64(len(c.ConsolidationRequests)) + if num > 1 { + err = ssz.ErrIncorrectListSize + return + } + for _, elem := range c.ConsolidationRequests { + if err = elem.HashTreeRootWith(hh); err != nil { + return + } + } + hh.MerkleizeWithMixin(subIndx, num, 1) + } + + hh.Merkleize(indx) + return +} + +// GetTree ssz hashes the ConsolidationRequestsContainer object +func (c *ConsolidationRequestsContainer) GetTree() (*ssz.Node, error) { + return ssz.ProofTree(c) +} + // MarshalSSZ ssz marshals the DepositRequest object func (d *DepositRequest) MarshalSSZ() ([]byte, error) { return ssz.MarshalSSZ(d) From b2379ac738fa61933a50094b4ac88d111de4b8b6 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Thu, 19 Sep 2024 15:53:50 +0200 Subject: [PATCH 09/13] electra changes --- flake.lock | 18 +++++++++--------- flake.nix | 2 +- web/packages/test/config/genesis.json | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 44f9fcfd63..47a2130673 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", "type": "github" }, "original": { @@ -39,11 +39,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1722676286, - "narHash": "sha256-wEDJdvwRZF2ErQ33nQ0Lqn/48XrPbaadv56/bM2MSZU=", + "lastModified": 1725354688, + "narHash": "sha256-KHHFemVt6C/hbGoMzIq7cpxmjdp+KZVZaqbvx02aliY=", "owner": "shazow", "repo": "foundry.nix", - "rev": "d84c83b1c1722c8742b3d2d84c9386814d75384e", + "rev": "671672bd60a0d2e5f6757638fdf27e806df755a4", "type": "github" }, "original": { @@ -69,11 +69,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1723991338, - "narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=", + "lastModified": 1726463316, + "narHash": "sha256-gI9kkaH0ZjakJOKrdjaI/VbaMEo9qBbSUl93DnU7f4c=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8a3354191c0d7144db9756a74755672387b702ba", + "rev": "99dc8785f6a0adac95f5e2ab05cc2e1bf666d172", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index aedccae990..ae16db40c4 100644 --- a/flake.nix +++ b/flake.nix @@ -44,7 +44,7 @@ # ethereum foundry-bin - go-ethereum + #go-ethereum Geth 1.14.9 is not in nix flakes yet # gnupg for forge install gnupg diff --git a/web/packages/test/config/genesis.json b/web/packages/test/config/genesis.json index e90d106d2a..61d729d8d4 100644 --- a/web/packages/test/config/genesis.json +++ b/web/packages/test/config/genesis.json @@ -16,6 +16,7 @@ "terminalTotalDifficulty": 0, "ShanghaiTime": 0, "CancunTime": null, + "PragueTime": null, "terminalTotalDifficultyPassed": true }, "difficulty": "0x9FFE0", From c1b3e9ca19071e3bab999b54b5b1bb2e3cfe1fa0 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 20 Sep 2024 11:58:11 +0200 Subject: [PATCH 10/13] try testing lodestar + electra --- web/packages/test/config/genesis.json | 4 +- web/packages/test/scripts/deploy-ethereum.sh | 80 +++++++++++++------- 2 files changed, 53 insertions(+), 31 deletions(-) diff --git a/web/packages/test/config/genesis.json b/web/packages/test/config/genesis.json index 61d729d8d4..a0fdd654b6 100644 --- a/web/packages/test/config/genesis.json +++ b/web/packages/test/config/genesis.json @@ -15,8 +15,8 @@ "ethash": {}, "terminalTotalDifficulty": 0, "ShanghaiTime": 0, - "CancunTime": null, - "PragueTime": null, + "CancunTime": 0, + "PragueTime": 0, "terminalTotalDifficultyPassed": true }, "difficulty": "0x9FFE0", diff --git a/web/packages/test/scripts/deploy-ethereum.sh b/web/packages/test/scripts/deploy-ethereum.sh index 8420bb2344..ca6395b66e 100755 --- a/web/packages/test/scripts/deploy-ethereum.sh +++ b/web/packages/test/scripts/deploy-ethereum.sh @@ -1,37 +1,55 @@ #!/usr/bin/env bash -set -eu +set -eux source scripts/set-env.sh +HOST=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1') start_geth() { + mkdir -p snowbridge + mkdir -p snowbridge/ethereum + cp config/genesis.json snowbridge + cp config/jwtsecret snowbridge + if [ "$eth_network" == "localhost" ]; then echo "Starting geth local node" - local timestamp="0" #start Cancun from genesis - jq \ - --argjson timestamp "$timestamp" \ - ' - .config.CancunTime = $timestamp - ' \ - config/genesis.json >$output_dir/genesis.json - geth init --datadir "$ethereum_data_dir" --state.scheme=hash "$output_dir/genesis.json" - geth --vmdebug --datadir "$ethereum_data_dir" --networkid 11155111 \ - --http --http.api debug,personal,eth,net,web3,txpool,engine,miner --ws --ws.api debug,eth,net,web3 \ - --rpc.allow-unprotected-txs --mine \ - --miner.etherbase=0xBe68fC2d8249eb60bfCf0e71D5A0d2F2e292c4eD \ - --authrpc.addr="127.0.0.1" \ - --http.addr="0.0.0.0" \ - --ws.addr="0.0.0.0" \ + docker run -it --rm \ + -v "$(pwd)/snowbridge:/mnt" \ + docker.io/ethpandaops/geth:prague-devnet-3-effcd38 \ + init --datadir /mnt/ethereum --state.scheme=hash /mnt/genesis.json + docker run --rm -m=12g --memory-reservation=8g --cpus 2 \ + -v snowbridge:/mnt \ + -p 8551:8551 \ + -p 8545:8545 \ + -p 8546:8546 \ + --env 'NODE_OPTIONS=--max-old-space-size=8192' \ + docker.io/ethpandaops/geth:prague-devnet-3-effcd38 \ + --vmdebug \ + --datadir /mnt/ethereum \ + --networkid 11155111 \ + --http \ + --http.api debug,personal,eth,net,web3,txpool,engine \ + --ws --ws.api debug,eth,net,web3 \ + --rpc.allow-unprotected-txs \ + --authrpc.addr 0.0.0.0 \ + --authrpc.vhosts "*" \ + --http \ + --http.api "debug,personal,eth,net,web3,txpool,engine,miner" \ + --http.addr 0.0.0.0 \ + --http.vhosts "*" \ --http.corsdomain '*' \ + --ws \ + --ws.api "debug,eth,net,web3" \ + --ws.addr 0.0.0.0 \ + --ws.origins "*" \ --allow-insecure-unlock \ - --authrpc.jwtsecret config/jwtsecret \ + --authrpc.jwtsecret mnt/jwtsecret \ --password /dev/null \ --rpc.gascap 0 \ --ws.origins "*" \ - --trace "$ethereum_data_dir/trace" \ --gcmode archive \ --syncmode=full \ --state.scheme=hash \ - >"$output_dir/geth.log" 2>&1 & + > ./snowbridge/geth.log 2>&1 & fi } @@ -53,16 +71,20 @@ start_lodestar() { export LODESTAR_PRESET="mainnet" - pushd $root_dir/lodestar - ./lodestar dev \ + #pushd $root_dir/lodestar + docker run --rm -m=12g --memory-reservation=8g --cpus 2 \ + -v snowbridge:/mnt \ + -p 9596:9596 \ + --env 'NODE_OPTIONS=--max-old-space-size=8192' \ + docker.io/ethpandaops/lodestar:unstable-295690b \ + dev \ --genesisValidators 8 \ --genesisTime $timestamp \ --startValidators "0..7" \ --enr.ip6 "127.0.0.1" \ - --rest.address "0.0.0.0" \ - --eth1.providerUrls "http://127.0.0.1:8545" \ - --execution.urls "http://127.0.0.1:8551" \ - --dataDir "$ethereum_data_dir" \ + --eth1.providerUrls "http://$HOST:8545" \ + --execution.urls "http://$HOST:8551" \ + --dataDir "/mnt/lodestar" \ --reset \ --terminal-total-difficulty-override 0 \ --genesisEth1Hash $genesisHash \ @@ -73,10 +95,10 @@ start_lodestar() { --params.ELECTRA_FORK_EPOCH 0 \ --eth1=true \ --rest.namespace="*" \ - --jwt-secret $config_dir/jwtsecret \ + --jwt-secret /mnt/jwtsecret \ --chain.archiveStateEpochFrequency 1 \ - >"$output_dir/lodestar.log" 2>&1 & - popd + > ./snowbridge/lodestar.log 2>&1 & + # popd fi } @@ -86,7 +108,7 @@ deploy_local() { start_geth echo "Waiting for geth API to be ready" - sleep 3 + sleep 10 # 2. deploy consensus client echo "Starting beacon node" From b940cc204c5cf60f0d8445f4fc3fcff4a9f15bb0 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Thu, 19 Dec 2024 10:26:12 +0200 Subject: [PATCH 11/13] revert local script --- web/packages/test/scripts/deploy-ethereum.sh | 77 +++++++------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/web/packages/test/scripts/deploy-ethereum.sh b/web/packages/test/scripts/deploy-ethereum.sh index ca6395b66e..b3ba1e793f 100755 --- a/web/packages/test/scripts/deploy-ethereum.sh +++ b/web/packages/test/scripts/deploy-ethereum.sh @@ -2,54 +2,36 @@ set -eux source scripts/set-env.sh -HOST=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1') start_geth() { - mkdir -p snowbridge - mkdir -p snowbridge/ethereum - cp config/genesis.json snowbridge - cp config/jwtsecret snowbridge - if [ "$eth_network" == "localhost" ]; then echo "Starting geth local node" - docker run -it --rm \ - -v "$(pwd)/snowbridge:/mnt" \ - docker.io/ethpandaops/geth:prague-devnet-3-effcd38 \ - init --datadir /mnt/ethereum --state.scheme=hash /mnt/genesis.json - docker run --rm -m=12g --memory-reservation=8g --cpus 2 \ - -v snowbridge:/mnt \ - -p 8551:8551 \ - -p 8545:8545 \ - -p 8546:8546 \ - --env 'NODE_OPTIONS=--max-old-space-size=8192' \ - docker.io/ethpandaops/geth:prague-devnet-3-effcd38 \ - --vmdebug \ - --datadir /mnt/ethereum \ - --networkid 11155111 \ - --http \ - --http.api debug,personal,eth,net,web3,txpool,engine \ - --ws --ws.api debug,eth,net,web3 \ - --rpc.allow-unprotected-txs \ - --authrpc.addr 0.0.0.0 \ - --authrpc.vhosts "*" \ - --http \ - --http.api "debug,personal,eth,net,web3,txpool,engine,miner" \ - --http.addr 0.0.0.0 \ - --http.vhosts "*" \ + local timestamp="0" #start Cancun from genesis + jq \ + --argjson timestamp "$timestamp" \ + ' + .config.CancunTime = $timestamp + ' \ + config/genesis.json >$output_dir/genesis.json + geth init --datadir "$ethereum_data_dir" --state.scheme=hash "$output_dir/genesis.json" + geth --vmdebug --datadir "$ethereum_data_dir" --networkid 11155111 \ + --http --http.api debug,personal,eth,net,web3,txpool,engine,miner --ws --ws.api debug,eth,net,web3 \ + --rpc.allow-unprotected-txs --mine \ + --miner.etherbase=0xBe68fC2d8249eb60bfCf0e71D5A0d2F2e292c4eD \ + --authrpc.addr="127.0.0.1" \ + --http.addr="0.0.0.0" \ + --ws.addr="0.0.0.0" \ --http.corsdomain '*' \ - --ws \ - --ws.api "debug,eth,net,web3" \ - --ws.addr 0.0.0.0 \ - --ws.origins "*" \ --allow-insecure-unlock \ - --authrpc.jwtsecret mnt/jwtsecret \ + --authrpc.jwtsecret config/jwtsecret \ --password /dev/null \ --rpc.gascap 0 \ --ws.origins "*" \ + --trace "$ethereum_data_dir/trace" \ --gcmode archive \ --syncmode=full \ --state.scheme=hash \ - > ./snowbridge/geth.log 2>&1 & + >"$output_dir/geth.log" 2>&1 & fi } @@ -71,20 +53,16 @@ start_lodestar() { export LODESTAR_PRESET="mainnet" - #pushd $root_dir/lodestar - docker run --rm -m=12g --memory-reservation=8g --cpus 2 \ - -v snowbridge:/mnt \ - -p 9596:9596 \ - --env 'NODE_OPTIONS=--max-old-space-size=8192' \ - docker.io/ethpandaops/lodestar:unstable-295690b \ - dev \ + pushd $root_dir/lodestar + ./lodestar dev \ --genesisValidators 8 \ --genesisTime $timestamp \ --startValidators "0..7" \ --enr.ip6 "127.0.0.1" \ - --eth1.providerUrls "http://$HOST:8545" \ - --execution.urls "http://$HOST:8551" \ - --dataDir "/mnt/lodestar" \ + --rest.address "0.0.0.0" \ + --eth1.providerUrls "http://127.0.0.1:8545" \ + --execution.urls "http://127.0.0.1:8551" \ + --dataDir "$ethereum_data_dir" \ --reset \ --terminal-total-difficulty-override 0 \ --genesisEth1Hash $genesisHash \ @@ -92,13 +70,12 @@ start_lodestar() { --params.BELLATRIX_FORK_EPOCH 0 \ --params.CAPELLA_FORK_EPOCH 0 \ --params.DENEB_FORK_EPOCH 0 \ - --params.ELECTRA_FORK_EPOCH 0 \ --eth1=true \ --rest.namespace="*" \ - --jwt-secret /mnt/jwtsecret \ + --jwt-secret $config_dir/jwtsecret \ --chain.archiveStateEpochFrequency 1 \ - > ./snowbridge/lodestar.log 2>&1 & - # popd + >"$output_dir/lodestar.log" 2>&1 & + popd fi } From 29e83b53c575815a5e1f96653905efbaeb793498 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 20 Dec 2024 09:49:14 +0200 Subject: [PATCH 12/13] mekong network setup --- scripts/init-geth.sh | 9 + scripts/init.sh | 6 + web/packages/test/config/config.yaml | 153 +++ web/packages/test/config/genesis-mekong.json | 927 ++++++++++++++++++ .../test/scripts/deploy-ethereum-mekong.sh | 110 +++ .../test/scripts/start-relayer-electra.sh | 54 + .../test/scripts/start-services-electra.sh | 59 ++ 7 files changed, 1318 insertions(+) create mode 100755 scripts/init-geth.sh create mode 100644 web/packages/test/config/config.yaml create mode 100644 web/packages/test/config/genesis-mekong.json create mode 100755 web/packages/test/scripts/deploy-ethereum-mekong.sh create mode 100755 web/packages/test/scripts/start-relayer-electra.sh create mode 100755 web/packages/test/scripts/start-services-electra.sh diff --git a/scripts/init-geth.sh b/scripts/init-geth.sh new file mode 100755 index 0000000000..b5a04be758 --- /dev/null +++ b/scripts/init-geth.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -eux +echo "Download geth for Mekong fork to replace the nix version" +git clone https://github.com/lightclient/go-ethereum.git +cd go-ethereum +make geth +mkdir -p $GOPATH/bin +cp geth $GOPATH/bin diff --git a/scripts/init.sh b/scripts/init.sh index 5ca0a9ce88..918befdd76 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -50,3 +50,9 @@ cargo install cargo-fuzz echo "Installing web packages" (cd web && pnpm install) +echo "Download geth for Mekong fork to replace the nix version" +git clone https://github.com/lightclient/go-ethereum.git +cd go-ethereum +make geth +mkdir -p $GOPATH/bin +cp geth $GOPATH/bin diff --git a/web/packages/test/config/config.yaml b/web/packages/test/config/config.yaml new file mode 100644 index 0000000000..eed63477c0 --- /dev/null +++ b/web/packages/test/config/config.yaml @@ -0,0 +1,153 @@ +# Extends the mainnet preset +PRESET_BASE: mainnet +CONFIG_NAME: mekong # needs to exist because of Prysm. Otherwise it conflicts with mainnet genesis + +# Genesis +# --------------------------------------------------------------- +# `2**14` (= 16,384) +MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 100000 +# 2024-Nov-05 03:59:00 PM UTC +MIN_GENESIS_TIME: 1730822340 +GENESIS_FORK_VERSION: 0x10637624 +GENESIS_DELAY: 60 + + +# Forking +# --------------------------------------------------------------- +# Some forks are disabled for now: +# - These may be re-assigned to another fork-version later +# - Temporarily set to max uint64 value: 2**64 - 1 + +# Altair +ALTAIR_FORK_VERSION: 0x20637624 +ALTAIR_FORK_EPOCH: 0 +# Merge +BELLATRIX_FORK_VERSION: 0x30637624 +BELLATRIX_FORK_EPOCH: 0 +TERMINAL_TOTAL_DIFFICULTY: 0 +TERMINAL_BLOCK_HASH: 0x0000000000000000000000000000000000000000000000000000000000000000 +TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: 18446744073709551615 + +# Capella +CAPELLA_FORK_VERSION: 0x40637624 +CAPELLA_FORK_EPOCH: 0 + +# DENEB +DENEB_FORK_VERSION: 0x50637624 +DENEB_FORK_EPOCH: 0 + +# Electra +ELECTRA_FORK_VERSION: 0x60637624 +ELECTRA_FORK_EPOCH: 256 + +# Fulu +FULU_FORK_VERSION: 0x70000000 +FULU_FORK_EPOCH: 99999 + +# EIP7594 - Peerdas +EIP7594_FORK_VERSION: 0x70000000 +EIP7594_FORK_EPOCH: 99999 + +# Time parameters +# --------------------------------------------------------------- +# 12 seconds +SECONDS_PER_SLOT: 12 +# 14 (estimate from Eth1 mainnet) +SECONDS_PER_ETH1_BLOCK: 12 +# 2**8 (= 256) epochs ~27 hours +MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 2 +# 2**8 (= 256) epochs ~27 hours +SHARD_COMMITTEE_PERIOD: 256 +# 2**11 (= 2,048) Eth1 blocks ~8 hours +ETH1_FOLLOW_DISTANCE: 2048 + +# Validator cycle +# --------------------------------------------------------------- +# 2**2 (= 4) +INACTIVITY_SCORE_BIAS: 4 +# 2**4 (= 16) +INACTIVITY_SCORE_RECOVERY_RATE: 16 +# 2**4 * 10**9 (= 16,000,000,000) Gwei +EJECTION_BALANCE: 30000000000 +# 2**2 (= 4) +MIN_PER_EPOCH_CHURN_LIMIT: 4 +# 2**16 (= 65,536) +CHURN_LIMIT_QUOTIENT: 128 +# [New in Deneb:EIP7514] 2**3 (= 8) +MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8 + +# Fork choice +# --------------------------------------------------------------- +# 40% +PROPOSER_SCORE_BOOST: 40 +# 20% +REORG_HEAD_WEIGHT_THRESHOLD: 20 +# 160% +REORG_PARENT_WEIGHT_THRESHOLD: 160 +# `2` epochs +REORG_MAX_EPOCHS_SINCE_FINALIZATION: 2 + +# Deposit contract +# --------------------------------------------------------------- +DEPOSIT_CHAIN_ID: 7078815900 +DEPOSIT_NETWORK_ID: 7078815900 +DEPOSIT_CONTRACT_ADDRESS: 0x4242424242424242424242424242424242424242 + +# Networking +# --------------------------------------------------------------- +# `10 * 2**20` (= 10485760, 10 MiB) +GOSSIP_MAX_SIZE: 10485760 +# `2**10` (= 1024) +MAX_REQUEST_BLOCKS: 1024 +# `2**8` (= 256) +EPOCHS_PER_SUBNET_SUBSCRIPTION: 256 +# `MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT // 2` (= 33024, ~5 months) +MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024 +# `10 * 2**20` (=10485760, 10 MiB) +MAX_CHUNK_SIZE: 10485760 +# 5s +TTFB_TIMEOUT: 5 +# 10s +RESP_TIMEOUT: 10 +ATTESTATION_PROPAGATION_SLOT_RANGE: 32 +# 500ms +MAXIMUM_GOSSIP_CLOCK_DISPARITY: 500 +MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000 +MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000 +# 2 subnets per node +SUBNETS_PER_NODE: 2 +# 2**8 (= 64) +ATTESTATION_SUBNET_COUNT: 64 +ATTESTATION_SUBNET_EXTRA_BITS: 0 +# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS +ATTESTATION_SUBNET_PREFIX_BITS: 6 + +# Deneb +# `2**7` (=128) +MAX_REQUEST_BLOCKS_DENEB: 128 +# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK +MAX_REQUEST_BLOB_SIDECARS: 768 +# `2**12` (= 4096 epochs, ~18 days) +MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096 +# `6` +BLOB_SIDECAR_SUBNET_COUNT: 6 +## `uint64(6)` +MAX_BLOBS_PER_BLOCK: 6 + +# Whisk +# `Epoch(2**8)` +WHISK_EPOCHS_PER_SHUFFLING_PHASE: 256 +# `Epoch(2)` +WHISK_PROPOSER_SELECTION_GAP: 2 + +# EIP7594 +NUMBER_OF_COLUMNS: 128 +MAX_CELLS_IN_EXTENDED_MATRIX: 768 +DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128 +MAX_REQUEST_DATA_COLUMN_SIDECARS: 16384 +SAMPLES_PER_SLOT: 8 +CUSTODY_REQUIREMENT: 4 + +# [New in Electra:EIP7251] +MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000 # 2**7 * 10**9 (= 128,000,000,000) +MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 256000000000 # 2**8 * 10**9 (= 256,000,000,000) \ No newline at end of file diff --git a/web/packages/test/config/genesis-mekong.json b/web/packages/test/config/genesis-mekong.json new file mode 100644 index 0000000000..b6730173d3 --- /dev/null +++ b/web/packages/test/config/genesis-mekong.json @@ -0,0 +1,927 @@ +{ + "config": { + "chainId": 7078815900, + "homesteadBlock": 0, + "eip150Block": 0, + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "berlinBlock": 0, + "londonBlock": 0, + "mergeNetsplitBlock": 0, + "terminalTotalDifficulty": 0, + "terminalTotalDifficultyPassed": true, + "shanghaiTime": 0, + "cancunTime": 0, + "depositContractAddress": "0x4242424242424242424242424242424242424242", + "pragueTime": 1730920704, + "osakaTime": 1769222016 + }, + "alloc": { + "0x0000000000000000000000000000000000000000": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000001": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000002": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000003": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000004": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000005": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000006": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000007": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000008": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000009": { + "balance": "1" + }, + "0x000000000000000000000000000000000000000a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000000b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000000c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000000d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000000e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000000f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000010": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000011": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000012": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000013": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000014": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000015": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000016": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000017": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000018": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000019": { + "balance": "1" + }, + "0x000000000000000000000000000000000000001a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000001b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000001c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000001d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000001e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000001f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000020": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000021": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000022": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000023": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000024": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000025": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000026": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000027": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000028": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000029": { + "balance": "1" + }, + "0x000000000000000000000000000000000000002a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000002b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000002c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000002d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000002e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000002f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000030": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000031": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000032": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000033": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000034": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000035": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000036": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000037": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000038": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000039": { + "balance": "1" + }, + "0x000000000000000000000000000000000000003a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000003b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000003c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000003d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000003e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000003f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000040": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000041": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000042": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000043": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000044": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000045": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000046": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000047": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000048": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000049": { + "balance": "1" + }, + "0x000000000000000000000000000000000000004a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000004b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000004c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000004d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000004e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000004f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000050": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000051": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000052": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000053": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000054": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000055": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000056": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000057": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000058": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000059": { + "balance": "1" + }, + "0x000000000000000000000000000000000000005a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000005b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000005c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000005d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000005e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000005f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000060": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000061": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000062": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000063": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000064": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000065": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000066": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000067": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000068": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000069": { + "balance": "1" + }, + "0x000000000000000000000000000000000000006a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000006b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000006c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000006d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000006e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000006f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000070": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000071": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000072": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000073": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000074": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000075": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000076": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000077": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000078": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000079": { + "balance": "1" + }, + "0x000000000000000000000000000000000000007a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000007b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000007c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000007d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000007e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000007f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000080": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000081": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000082": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000083": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000084": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000085": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000086": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000087": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000088": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000089": { + "balance": "1" + }, + "0x000000000000000000000000000000000000008a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000008b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000008c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000008d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000008e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000008f": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000090": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000091": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000092": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000093": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000094": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000095": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000096": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000097": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000098": { + "balance": "1" + }, + "0x0000000000000000000000000000000000000099": { + "balance": "1" + }, + "0x000000000000000000000000000000000000009a": { + "balance": "1" + }, + "0x000000000000000000000000000000000000009b": { + "balance": "1" + }, + "0x000000000000000000000000000000000000009c": { + "balance": "1" + }, + "0x000000000000000000000000000000000000009d": { + "balance": "1" + }, + "0x000000000000000000000000000000000000009e": { + "balance": "1" + }, + "0x000000000000000000000000000000000000009f": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a0": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a1": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a2": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a3": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a4": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a5": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a6": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a7": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a8": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000a9": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000aa": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ab": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ac": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ad": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ae": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000af": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b0": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b1": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b2": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b3": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b4": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b5": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b6": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b7": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b8": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000b9": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ba": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000bb": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000bc": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000bd": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000be": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000bf": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c0": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c1": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c2": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c3": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c4": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c5": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c6": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c7": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c8": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000c9": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ca": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000cb": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000cc": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000cd": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ce": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000cf": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d0": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d1": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d2": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d3": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d4": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d5": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d6": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d7": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d8": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000d9": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000da": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000db": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000dc": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000dd": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000de": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000df": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e0": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e1": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e2": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e3": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e4": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e5": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e6": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e7": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e8": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000e9": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ea": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000eb": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ec": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ed": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ee": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ef": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f0": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f1": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f2": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f3": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f4": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f5": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f6": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f7": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f8": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000f9": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000fa": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000fb": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000fc": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000fd": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000fe": { + "balance": "1" + }, + "0x00000000000000000000000000000000000000ff": { + "balance": "1" + }, + "0x4242424242424242424242424242424242424242": { + "balance": "0", + "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a2646970667358221220dceca8706b29e917dacf25fceef95acac8d90d765ac926663ce4096195952b6164736f6c634300060b0033", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", + "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", + "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", + "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", + "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30", + "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", + "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", + "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", + "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1", + "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", + "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", + "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", + "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e", + "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", + "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb", + "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", + "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", + "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", + "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", + "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", + "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", + "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167", + "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", + "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", + "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", + "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", + "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", + "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1", + "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", + "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", + "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" + } + }, + "0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02": { + "balance": "0", + "nonce": "1", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500" + }, + "0x0aae40965e6800cd9b1f4b05ff21581047e3f91e": { + "balance": "0", + "nonce": "1", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460575767ffffffffffffffff5f3511605357600143035f3511604b575f35612000014311604b57611fff5f3516545f5260205ff35b5f5f5260205ff35b5f5ffd5b5f35611fff60014303165500" + }, + "0x09Fc772D0857550724b07B850a4323f39112aAaA": { + "balance": "0", + "nonce": "1", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460c7573615156028575f545f5260205ff35b36603814156101f05760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff146101f057600182026001905f5b5f821115608057810190830284830290049160010191906065565b9093900434106101f057600154600101600155600354806003026004013381556001015f35815560010160203590553360601b5f5260385f601437604c5fa0600101600355005b6003546002548082038060101160db575060105b5f5b81811461017f5780604c02838201600302600401805490600101805490600101549160601b83528260140152807fffffffffffffffffffffffffffffffff0000000000000000000000000000000016826034015260401c906044018160381c81600701538160301c81600601538160281c81600501538160201c81600401538160181c81600301538160101c81600201538160081c81600101535360010160dd565b9101809214610191579060025561019c565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14156101c957505f5b6001546002828201116101de5750505f6101e4565b01600290035b5f555f600155604c025ff35b5f5ffd", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + } + }, + "0x01aBEa29659e5e97C95107F20bb753cD3e09bBBb": { + "balance": "0", + "nonce": "1", + "code": "0x3373fffffffffffffffffffffffffffffffffffffffe1460cf573615156028575f545f5260205ff35b366060141561019a5760115f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1461019a57600182026001905f5b5f821115608057810190830284830290049160010191906065565b90939004341061019a57600154600101600155600354806004026004013381556001015f358155600101602035815560010160403590553360601b5f5260605f60143760745fa0600101600355005b6003546002548082038060011160e3575060015b5f5b8181146101295780607402838201600402600401805490600101805490600101805490600101549260601b84529083601401528260340152906054015260010160e5565b910180921461013b5790600255610146565b90505f6002555f6003555b5f54807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff141561017357505f5b6001546001828201116101885750505f61018e565b01600190035b5f555f6001556074025ff35b5f5ffd", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000000": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + } + }, + "0x454b0EA7d8aD3C56D0CF2e44Ed97b2Feab4D7AF2": { + "balance": "1000000000000000000000000000" + }, + "0xd3248BA3E5492D767F8e427Cb9C7B9D5C3972D7B": { + "balance": "1000000000000000000000000000" + }, + "0xAD01b55d7c3448B8899862eb335FBb17075d8DE2": { + "balance": "1000000000000000000000000000" + }, + "0x7e454a14B8e7528465eeF86f0DC1da4f235d9D79": { + "balance": "1000000000000000000000000000" + }, + "0x7a40026A3b9A41754a95EeC8c92C6B99886f440C": { + "balance": "1000000000000000000000000000" + }, + "0x8c4D8CDD1f474510Dd70D66F2785a3a38a29AC1A": { + "balance": "1000000000000000000000000000" + }, + "0xfC7360b3b28cf4204268A8354dbEc60720d155D2": { + "balance": "1000000000000000000000000000" + }, + "0x2F7626bBDb8c0f9071bC98046Ef6fDed2167F97F": { + "balance": "1000000000000000000000000000" + }, + "0x752CE31Dec0dde7D1563CdF6438d892De2D4FBee": { + "balance": "1000000000000000000000000000" + }, + "0x455f42d91096c4Aa708D7Cbcb2DC499dE89C402c": { + "balance": "1000000000000000000000000000" + }, + "0x85154341488732D57a97F54AB9706Bc4B71B8636": { + "balance": "1000000000000000000000000000" + }, + "0x6a9CcA73d4Ff3a249fa778C7651f4Df8B9fFa0Df": { + "balance": "1000000000000000000000000000" + }, + "0xee2d0567AAe8080CA269b7908F4aF8BBb59A6804": { + "balance": "1000000000000000000000000000" + }, + "0xDd8D4027078a471816e4Ef7F69aFc0A5d2947dDc": { + "balance": "1000000000000000000000000000" + }, + "0x20466E9A67f299F6056bE52A50ea324FA6Bd05D5": { + "balance": "1000000000000000000000000000" + }, + "0x03F24BB0C9cfb30217Ff992A36ae9230F2A1697f": { + "balance": "1000000000000000000000000000" + }, + "0x032d8372C519c3927b87BDe4479E846a81EF2d10": { + "balance": "1000000000000000000000000000" + }, + "0xF863DF14954df73804b3150F3754a8F98CBB1D0d": { + "balance": "1000000000000000000000000000" + }, + "0xbe918A6aef1920F3706E23d153146aA6C5982620": { + "balance": "1000000000000000000000000000" + }, + "0xA0c7edA3CE474BC670A11EA9537cBEfd36331123": { + "balance": "1000000000000000000000000000" + }, + "0xF03b43BeB861044492Eb43E247bEE2AC6C80c651": { + "balance": "1000000000000000000000000000" + } + }, + "coinbase": "0x0000000000000000000000000000000000000000", + "difficulty": "0x01", + "extraData": "", + "gasLimit": "0x17d7840", + "nonce": "0x1234", + "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "timestamp": "1730822340" +} diff --git a/web/packages/test/scripts/deploy-ethereum-mekong.sh b/web/packages/test/scripts/deploy-ethereum-mekong.sh new file mode 100755 index 0000000000..8ce5e4a6a3 --- /dev/null +++ b/web/packages/test/scripts/deploy-ethereum-mekong.sh @@ -0,0 +1,110 @@ +#!/usr/bin/env bash +set -eux + +source scripts/set-env.sh +HOST=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1') +export output_electra_dir="$output_dir/electra" + +start_geth() { + mkdir -p $output_electra_dir + mkdir -p $output_electra_dir/ethereum + cp config/genesis-mekong.json $output_electra_dir + cp config/jwtsecret $output_electra_dir + cp config/config.yaml $output_electra_dir + cp config/genesis.ssz $output_electra_dir + + echo "Test dir: $output_electra_dir" + + echo "Starting geth local node" + docker run --rm \ + -v "${output_electra_dir}:/mnt" \ + docker.io/ethpandaops/geth:master \ + --datadir /mnt/ethereum \ + --state.scheme=hash \ + init /mnt/genesis-mekong.json + echo "**********************************" + docker run --rm -m=12g --memory-reservation=8g --cpus 2 \ + -v "${output_electra_dir}:/mnt" \ + -p 8551:8551 \ + -p 8545:8545 \ + -p 8546:8546 \ + --env 'NODE_OPTIONS=--max-old-space-size=8192' \ + docker.io/ethpandaops/geth:master \ + --networkid 7078815900 \ + --vmdebug \ + --datadir /mnt/ethereum \ + --http \ + --http.api debug,personal,eth,net,web3,txpool,engine \ + --ws --ws.api debug,eth,net,web3 \ + --rpc.allow-unprotected-txs \ + --authrpc.addr 0.0.0.0 \ + --authrpc.vhosts "*" \ + --http \ + --http.api "debug,personal,eth,net,web3,txpool,engine,miner" \ + --http.addr 0.0.0.0 \ + --http.vhosts "*" \ + --http.corsdomain '*' \ + --ws \ + --ws.api "debug,eth,net,web3" \ + --ws.addr 0.0.0.0 \ + --ws.origins "*" \ + --allow-insecure-unlock \ + --authrpc.jwtsecret mnt/jwtsecret \ + --password /dev/null \ + --rpc.gascap 0 \ + --ws.origins "*" \ + --gcmode archive \ + --syncmode=full \ + --bootnodes "enode://125d2dddd0dc0d34b526910d49592545a1e4fe25139be9d9e0eed396211dbd37aa0c0a7fa0444c315803d814e743f890529b58b9261289d5303e16477c216b39@157.230.225.158:30303?discport=30303,enode://508bff69cbb852337cfbf3db9e58fe66ec3254e6a3960c0ef266a2ab1ea78e12f101bba51e3d2e066947a0b9b315e5b26009af81584510394c1b87a5908dca7b@137.184.72.127:30303?discport=30303,enode://b273c662dd15148162c23a5c8407d3d5dbb35fb331ae0c1c3a80c6bfa2bbe077683b28c0cd59f7a482efc00a64a09273eb4767a173441a79b833fdf705d331ae@152.42.247.97:30303?discport=30303" \ + --state.scheme=hash \ + > "$output_dir/geth.log" 2>&1 & +} + +start_lodestar() { + echo "Starting lodestar local node" + + docker run --rm -m=12g --memory-reservation=8g --cpus 2 \ + -v "${output_electra_dir}:/mnt" \ + -p 9596:9596 \ + --env 'NODE_OPTIONS=--max-old-space-size=8192' \ + docker.io/chainsafe/lodestar:v1.23.1 \ + beacon \ + --eth1.depositContractDeployBlock=0 \ + --rest.address "0.0.0.0" \ + --bootnodes="enr:-Iq4QB2ny1q6gkBjqNRU_e-GTbpcJQcI4i3cIZDea0mnAzGgbUTKH8j81g9PRl_-m40F1V4GFBlqZElrcbGnUj9AjGeGAZL8bgmtgmlkgnY0gmlwhJ3m4Z6Jc2VjcDI1NmsxoQJJ3h8aUO3GJHv-bdvHtsQZ2OEisutelYfGjXO4lSg8BYN1ZHCCIzI,enr:-LK4QF2XD_Fe5H9QMVVwBoDs6P_37eURcFvNTcLzOc60p_XlDKIBleMgudA7nltZ7TyAiOuY0BSQzHsdv5iUs7sFyWQEh2F0dG5ldHOIAwAAAAAAAACEZXRoMpDY3UMGYGN2JAABAAAAAAAAgmlkgnY0gmlwhJ3m4Z6Jc2VjcDI1NmsxoQJJ7y6LF_to7NYQd3BVRW1840gm5r1Lm3lfAfC9Wqmw8YN0Y3CCIyiDdWRwgiMo,enr:-Mm4QPtT8J4rpYkixx-COebnEPreuWv9OpgOGOvM01hqZ19eeySxCxOEEVHl2r2c0BYwBuct_yZhvkLqUQatRORlIP4Bh2F0dG5ldHOIAAAAAAAAAACDY3NjBIRldGgykNjdQwZgY3YkAAEAAAAAAACCaWSCdjSCaXCEibhIf4RxdWljgiMpiXNlY3AyNTZrMaEDjight_62uShKNt4IorH13hfqm7kZzVyFxXKI_qDlsTGIc3luY25ldHMAg3RjcIIjKIN1ZHCCIyg,enr:-Mm4QBL6auezk-Zi385j0PyjkzGwQJW7TdOFZKGZMKTGRkI4fxTSTiHLe7kTvdjhBq4kgjPXvUnFiXR6AisA8a0w2lQBh2F0dG5ldHOIAAAAAAAAAACDY3NjBIRldGgykNjdQwZgY3YkAAEAAAAAAACCaWSCdjSCaXCEmCr3YYRxdWljgiMpiXNlY3AyNTZrMaEDJ4xl2Our0Y7OKsSDX9f908HznXm3PKzmC9zD8OB2d0mIc3luY25ldHMAg3RjcIIjKIN1ZHCCIyg" \ + --eth1.providerUrls "http://$HOST:8545" \ + --execution.urls "http://$HOST:8551" \ + --dataDir "/mnt/lodestar" \ + --paramsFile="/mnt/config.yaml" \ + --genesisStateFile="/mnt/genesis.ssz" \ + --rest.namespace="*" \ + --jwt-secret /mnt/jwtsecret \ + --checkpointSyncUrl https://checkpoint-sync.mekong.ethpandaops.io \ + --chain.archiveStateEpochFrequency 1 \ + > "$output_dir/lodestar.log" 2>&1 & +} + +deploy_local() { + # 1. deploy execution client + echo "Starting execution node" + start_geth + + echo "Waiting for geth API to be ready" + sleep 10 + + # 2. deploy consensus client + echo "Starting beacon node" + start_lodestar +} + +deploy_ethereum() { + check_tool && rm -rf "$ethereum_data_dir" && deploy_local +} + +if [ -z "${from_start_services:-}" ]; then + echo "start ethereum only!" + trap kill_all SIGINT SIGTERM EXIT + deploy_ethereum + echo "ethereum local nodes started!" + wait +fi diff --git a/web/packages/test/scripts/start-relayer-electra.sh b/web/packages/test/scripts/start-relayer-electra.sh new file mode 100755 index 0000000000..49c5f5c744 --- /dev/null +++ b/web/packages/test/scripts/start-relayer-electra.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +set -eu + +source scripts/set-env.sh + +config_relayer() { + # Configure beacon relay + local deneb_forked_epoch=0 + local electra_forked_epoch=256 + if [ "$eth_fast_mode" == "true" ]; then + deneb_forked_epoch=0 + fi + jq \ + --arg beacon_endpoint_http $beacon_endpoint_http \ + --argjson deneb_forked_epoch $deneb_forked_epoch \ + ' + .source.beacon.endpoint = $beacon_endpoint_http + | .source.beacon.spec.forkVersions.deneb = $deneb_forked_epoch + | .source.beacon.spec.forkVersions.electra = $electra_forked_epoch + ' \ + config/beacon-relay.json >$output_dir/beacon-relay.json +} + +start_relayer() { + # Launch beacon relay + ( + : >"$output_dir"/beacon-relay.log + while :; do + echo "Starting beacon relay at $(date)" + "${relay_bin}" run beacon \ + --config $output_dir/beacon-relay.json \ + --substrate.private-key "//BeaconRelay" \ + >>"$output_dir"/beacon-relay.log 2>&1 || true + sleep 20 + done + ) & +} + +build_relayer() { + echo "Building relayer" + mage -d "$relay_dir" build + cp $relay_bin "$output_bin_dir" +} + +deploy_relayer() { + check_tool && build_relayer && config_relayer && start_relayer +} + +if [ -z "${from_start_services:-}" ]; then + echo "start relayers only!" + trap kill_all SIGINT SIGTERM EXIT + deploy_relayer + wait +fi diff --git a/web/packages/test/scripts/start-services-electra.sh b/web/packages/test/scripts/start-services-electra.sh new file mode 100755 index 0000000000..4b23dbb916 --- /dev/null +++ b/web/packages/test/scripts/start-services-electra.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +set -eu + +start=$(date +%s) + +from_start_services=true + +source scripts/set-env.sh +source scripts/build-binary.sh + +trap kill_all SIGINT SIGTERM EXIT +cleanup + +# 0. check required tools +echo "Check building tools" +check_tool + +# 1. install binary if required +echo "Installing binaries if required" +install_binary + +# 2. start ethereum +echo "Starting ethereum nodes" +if [ "$eth_network" == "localhost" ]; then + source scripts/deploy-ethereum.sh + deploy_ethereum +fi + +# 3. start polkadot +echo "Starting polkadot nodes" +source scripts/deploy-polkadot.sh +deploy_polkadot + +# 4. generate beefy checkpoint +echo "Generate beefy checkpoint" +source scripts/generate-beefy-checkpoint.sh +generate_beefy_checkpoint + +# 6. config substrate +echo "Config Substrate" +source scripts/configure-substrate.sh +configure_substrate + +if [ "$skip_relayer" == "false" ]; then + # 7. start relayer + echo "Starting relayers" + source scripts/start-relayer.sh + deploy_relayer +fi + +echo "Testnet has been initialized" + +end=$(date +%s) +runtime=$((end - start)) +minutes=$(((runtime % 3600) / 60)) +seconds=$(((runtime % 3600) % 60)) +echo "Took $minutes minutes $seconds seconds" + +wait From fb78a95d8e87e07a5779a097ee4002fecd4bcc17 Mon Sep 17 00:00:00 2001 From: claravanstaden Date: Fri, 20 Dec 2024 13:35:29 +0200 Subject: [PATCH 13/13] electra updates --- relayer/contracts/gateway.go | 145 ++++++++++ .../beacon/header/syncer/api/api_electra.go | 58 ++-- relayer/relays/beacon/header/syncer/syncer.go | 5 + .../beacon/state/beacon_deneb_encoding.go | 2 +- relayer/relays/beacon/state/beacon_electra.go | 74 +++-- .../beacon/state/beacon_electra_encoding.go | 253 +----------------- .../relays/beacon/state/beacon_encoding.go | 2 +- .../test/scripts/configure-substrate.sh | 20 ++ .../test/scripts/deploy-ethereum-mekong.sh | 10 +- .../test/scripts/start-relayer-electra.sh | 20 +- .../test/scripts/start-services-electra.sh | 9 +- 11 files changed, 241 insertions(+), 357 deletions(-) diff --git a/relayer/contracts/gateway.go b/relayer/contracts/gateway.go index 047c0ff17b..1a4eba075a 100644 --- a/relayer/contracts/gateway.go +++ b/relayer/contracts/gateway.go @@ -1192,6 +1192,151 @@ func (_Gateway *GatewayFilterer) ParseChannelUpdated(log types.Log) (*GatewayCha return event, nil } +// GatewayForeignTokenRegisteredIterator is returned from FilterForeignTokenRegistered and is used to iterate over the raw logs and unpacked data for ForeignTokenRegistered events raised by the Gateway contract. +type GatewayForeignTokenRegisteredIterator struct { + Event *GatewayForeignTokenRegistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *GatewayForeignTokenRegisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(GatewayForeignTokenRegistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(GatewayForeignTokenRegistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *GatewayForeignTokenRegisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *GatewayForeignTokenRegisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// GatewayForeignTokenRegistered represents a ForeignTokenRegistered event raised by the Gateway contract. +type GatewayForeignTokenRegistered struct { + TokenID [32]byte + Token common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterForeignTokenRegistered is a free log retrieval operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. +// +// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) +func (_Gateway *GatewayFilterer) FilterForeignTokenRegistered(opts *bind.FilterOpts, tokenID [][32]byte) (*GatewayForeignTokenRegisteredIterator, error) { + + var tokenIDRule []interface{} + for _, tokenIDItem := range tokenID { + tokenIDRule = append(tokenIDRule, tokenIDItem) + } + + logs, sub, err := _Gateway.contract.FilterLogs(opts, "ForeignTokenRegistered", tokenIDRule) + if err != nil { + return nil, err + } + return &GatewayForeignTokenRegisteredIterator{contract: _Gateway.contract, event: "ForeignTokenRegistered", logs: logs, sub: sub}, nil +} + +// WatchForeignTokenRegistered is a free log subscription operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. +// +// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) +func (_Gateway *GatewayFilterer) WatchForeignTokenRegistered(opts *bind.WatchOpts, sink chan<- *GatewayForeignTokenRegistered, tokenID [][32]byte) (event.Subscription, error) { + + var tokenIDRule []interface{} + for _, tokenIDItem := range tokenID { + tokenIDRule = append(tokenIDRule, tokenIDItem) + } + + logs, sub, err := _Gateway.contract.WatchLogs(opts, "ForeignTokenRegistered", tokenIDRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(GatewayForeignTokenRegistered) + if err := _Gateway.contract.UnpackLog(event, "ForeignTokenRegistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseForeignTokenRegistered is a log parse operation binding the contract event 0x57f58171b8777633d03aff1e7408b96a3d910c93a7ce433a8cb7fb837dc306a6. +// +// Solidity: event ForeignTokenRegistered(bytes32 indexed tokenID, address token) +func (_Gateway *GatewayFilterer) ParseForeignTokenRegistered(log types.Log) (*GatewayForeignTokenRegistered, error) { + event := new(GatewayForeignTokenRegistered) + if err := _Gateway.contract.UnpackLog(event, "ForeignTokenRegistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // GatewayInboundMessageDispatchedIterator is returned from FilterInboundMessageDispatched and is used to iterate over the raw logs and unpacked data for InboundMessageDispatched events raised by the Gateway contract. type GatewayInboundMessageDispatchedIterator struct { Event *GatewayInboundMessageDispatched // Event containing the contract specifics and raw log diff --git a/relayer/relays/beacon/header/syncer/api/api_electra.go b/relayer/relays/beacon/header/syncer/api/api_electra.go index 3415edeaa4..b2ba37b58e 100644 --- a/relayer/relays/beacon/header/syncer/api/api_electra.go +++ b/relayer/relays/beacon/header/syncer/api/api_electra.go @@ -26,52 +26,28 @@ func ElectraExecutionPayloadToScale(e *state.ExecutionPayloadElectra) (scale.Exe return payloadHeader, err } - depositRequestsContainer := state.DepositRequestsContainer{} - depositRequestsContainer.DepositRequests = e.DepositRequests - depositRequestsRoot, err := depositRequestsContainer.HashTreeRoot() - if err != nil { - return payloadHeader, err - } - - withdrawalRequestsContainer := state.WithdrawalRequestsContainer{} - withdrawalRequestsContainer.WithdrawalRequests = e.WithdrawalRequests - withdrawalRequestsRoot, err := withdrawalRequestsContainer.HashTreeRoot() - if err != nil { - return payloadHeader, err - } - - consolidationRequestsContainer := state.ConsolidationRequestsContainer{} - consolidationRequestsContainer.ConsolidationRequests = e.ConsolidationRequests - consolidationRequestsRoot, err := consolidationRequestsContainer.HashTreeRoot() - if err != nil { - return payloadHeader, err - } - baseFeePerGas := big.Int{} // Change BaseFeePerGas back from little-endian to big-endian baseFeePerGas.SetBytes(util.ChangeByteOrder(e.BaseFeePerGas[:])) return scale.ExecutionPayloadHeaderElectra{ - ParentHash: types.NewH256(e.ParentHash[:]), - FeeRecipient: e.FeeRecipient, - StateRoot: types.NewH256(e.StateRoot[:]), - ReceiptsRoot: types.NewH256(e.ReceiptsRoot[:]), - LogsBloom: e.LogsBloom[:], - PrevRandao: types.NewH256(e.PrevRandao[:]), - BlockNumber: types.NewU64(e.BlockNumber), - GasLimit: types.NewU64(e.GasLimit), - GasUsed: types.NewU64(e.GasUsed), - Timestamp: types.NewU64(e.Timestamp), - ExtraData: e.ExtraData, - BaseFeePerGas: types.NewU256(baseFeePerGas), - BlockHash: types.NewH256(e.BlockHash[:]), - TransactionsRoot: transactionsRoot, - WithdrawalsRoot: withdrawalRoot, - BlobGasUsed: types.NewU64(e.BlobGasUsed), - ExcessBlobGas: types.NewU64(e.ExcessBlobGas), - DepositRequestsRoot: depositRequestsRoot, - WithdrawalRequestsRoot: withdrawalRequestsRoot, - ConsolidationRequestsRoot: consolidationRequestsRoot, + ParentHash: types.NewH256(e.ParentHash[:]), + FeeRecipient: e.FeeRecipient, + StateRoot: types.NewH256(e.StateRoot[:]), + ReceiptsRoot: types.NewH256(e.ReceiptsRoot[:]), + LogsBloom: e.LogsBloom[:], + PrevRandao: types.NewH256(e.PrevRandao[:]), + BlockNumber: types.NewU64(e.BlockNumber), + GasLimit: types.NewU64(e.GasLimit), + GasUsed: types.NewU64(e.GasUsed), + Timestamp: types.NewU64(e.Timestamp), + ExtraData: e.ExtraData, + BaseFeePerGas: types.NewU256(baseFeePerGas), + BlockHash: types.NewH256(e.BlockHash[:]), + TransactionsRoot: transactionsRoot, + WithdrawalsRoot: withdrawalRoot, + BlobGasUsed: types.NewU64(e.BlobGasUsed), + ExcessBlobGas: types.NewU64(e.ExcessBlobGas), }, nil } diff --git a/relayer/relays/beacon/header/syncer/syncer.go b/relayer/relays/beacon/header/syncer/syncer.go index a6f354834b..cb6afb01e6 100644 --- a/relayer/relays/beacon/header/syncer/syncer.go +++ b/relayer/relays/beacon/header/syncer/syncer.go @@ -64,11 +64,13 @@ func (s *Syncer) GetCheckpoint() (scale.BeaconCheckpoint, error) { return scale.BeaconCheckpoint{}, fmt.Errorf("get finalized checkpoint: %w", err) } + log.WithField("root", checkpoint.FinalizedBlockRoot).Info("found block root") bootstrap, err := s.Client.GetBootstrap(checkpoint.FinalizedBlockRoot) if err != nil { return scale.BeaconCheckpoint{}, fmt.Errorf("get bootstrap: %w", err) } + log.WithField("slot", bootstrap.Data.Header.Beacon.Slot).Info("found block root") genesis, err := s.Client.GetGenesis() if err != nil { return scale.BeaconCheckpoint{}, fmt.Errorf("get genesis: %w", err) @@ -300,10 +302,13 @@ func (s *Syncer) GetBlockRoots(slot uint64) (scale.BlockRootProof, error) { blockRootsContainer = &state.BlockRootsContainerMainnet{} if forkVersion == protocol.Electra { + log.Info("found Electra fork") beaconState = &state.BeaconStateElectra{} } else if forkVersion == protocol.Deneb { + log.Info("found Deneb fork") beaconState = &state.BeaconStateDenebMainnet{} } else { + log.Info("found Capella fork") beaconState = &state.BeaconStateCapellaMainnet{} } diff --git a/relayer/relays/beacon/state/beacon_deneb_encoding.go b/relayer/relays/beacon/state/beacon_deneb_encoding.go index 9fa8996404..c5df7456e3 100644 --- a/relayer/relays/beacon/state/beacon_deneb_encoding.go +++ b/relayer/relays/beacon/state/beacon_deneb_encoding.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 59f099d56dedd1f5875bcefc64e241f92e3ee92a89a3506957acdae15d8cf77e +// Hash: 102b99e06f43fa22848c793cecd95d88dce7318ab706d62adaf73f11cab9ce82 // Version: 0.1.3 package state diff --git a/relayer/relays/beacon/state/beacon_electra.go b/relayer/relays/beacon/state/beacon_electra.go index 17d3292d83..173ac5a3b0 100644 --- a/relayer/relays/beacon/state/beacon_electra.go +++ b/relayer/relays/beacon/state/beacon_electra.go @@ -3,49 +3,43 @@ package state import ssz "github.com/ferranbt/fastssz" type ExecutionPayloadElectra struct { - ParentHash [32]byte `ssz-size:"32" json:"parent_hash"` - FeeRecipient [20]byte `ssz-size:"20" json:"fee_recipient"` - StateRoot [32]byte `ssz-size:"32" json:"state_root"` - ReceiptsRoot [32]byte `ssz-size:"32" json:"receipts_root"` - LogsBloom [256]byte `ssz-size:"256" json:"logs_bloom"` - PrevRandao [32]byte `ssz-size:"32" json:"prev_randao"` - BlockNumber uint64 `json:"block_number"` - GasLimit uint64 `json:"gas_limit"` - GasUsed uint64 `json:"gas_used"` - Timestamp uint64 `json:"timestamp"` - ExtraData []byte `ssz-max:"32" json:"extra_data"` - BaseFeePerGas [32]byte `ssz-size:"32" json:"base_fee_per_gas"` - BlockHash [32]byte `ssz-size:"32" json:"block_hash"` - Transactions [][]byte `ssz-max:"1048576,1073741824" ssz-size:"?,?" json:"transactions"` - Withdrawals []*Withdrawal `ssz-max:"16" json:"withdrawals"` - BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` - ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` - DepositRequests []*DepositRequest `ssz-max:"8192" json:"deposit_requests,omitempty"` // New in Electra - WithdrawalRequests []*WithdrawalRequest `ssz-max:"16" json:"withdrawal_requests,omitempty"` // New in Electra - ConsolidationRequests []*ConsolidationRequest `ssz-max:"1" json:"consolidation_requests,omitempty"` // New in Electra + ParentHash [32]byte `ssz-size:"32" json:"parent_hash"` + FeeRecipient [20]byte `ssz-size:"20" json:"fee_recipient"` + StateRoot [32]byte `ssz-size:"32" json:"state_root"` + ReceiptsRoot [32]byte `ssz-size:"32" json:"receipts_root"` + LogsBloom [256]byte `ssz-size:"256" json:"logs_bloom"` + PrevRandao [32]byte `ssz-size:"32" json:"prev_randao"` + BlockNumber uint64 `json:"block_number"` + GasLimit uint64 `json:"gas_limit"` + GasUsed uint64 `json:"gas_used"` + Timestamp uint64 `json:"timestamp"` + ExtraData []byte `ssz-max:"32" json:"extra_data"` + BaseFeePerGas [32]byte `ssz-size:"32" json:"base_fee_per_gas"` + BlockHash [32]byte `ssz-size:"32" json:"block_hash"` + Transactions [][]byte `ssz-max:"1048576,1073741824" ssz-size:"?,?" json:"transactions"` + Withdrawals []*Withdrawal `ssz-max:"16" json:"withdrawals"` + BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` + ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` } type ExecutionPayloadHeaderElectra struct { - ParentHash []byte `json:"parent_hash" ssz-size:"32"` - FeeRecipient []byte `json:"fee_recipient" ssz-size:"20"` - StateRoot []byte `json:"state_root" ssz-size:"32"` - ReceiptsRoot []byte `json:"receipts_root" ssz-size:"32"` - LogsBloom []byte `json:"logs_bloom" ssz-size:"256"` - PrevRandao []byte `json:"prev_randao" ssz-size:"32"` - BlockNumber uint64 `json:"block_number"` - GasLimit uint64 `json:"gas_limit"` - GasUsed uint64 `json:"gas_used"` - Timestamp uint64 `json:"timestamp"` - ExtraData []byte `json:"extra_data" ssz-max:"32"` - BaseFeePerGas []byte `json:"base_fee_per_gas" ssz-size:"32"` - BlockHash []byte `json:"block_hash" ssz-size:"32"` - TransactionsRoot []byte `json:"transactions_root" ssz-size:"32"` - WithdrawalsRoot []byte `json:"withdrawals_root" ssz-size:"32"` - BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` - ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` - DepositRequestsRoot []byte `json:"deposit_requests_root" ssz-size:"32"` // New in Electra - WithdrawalRequestsRoot []byte `json:"withdrawal_requests_root" ssz-size:"32"` // New in Electra - ConsolidationRequestsRoot []byte `json:"consolidation_requests_root" ssz-size:"32"` // New in Electra + ParentHash []byte `json:"parent_hash" ssz-size:"32"` + FeeRecipient []byte `json:"fee_recipient" ssz-size:"20"` + StateRoot []byte `json:"state_root" ssz-size:"32"` + ReceiptsRoot []byte `json:"receipts_root" ssz-size:"32"` + LogsBloom []byte `json:"logs_bloom" ssz-size:"256"` + PrevRandao []byte `json:"prev_randao" ssz-size:"32"` + BlockNumber uint64 `json:"block_number"` + GasLimit uint64 `json:"gas_limit"` + GasUsed uint64 `json:"gas_used"` + Timestamp uint64 `json:"timestamp"` + ExtraData []byte `json:"extra_data" ssz-max:"32"` + BaseFeePerGas []byte `json:"base_fee_per_gas" ssz-size:"32"` + BlockHash []byte `json:"block_hash" ssz-size:"32"` + TransactionsRoot []byte `json:"transactions_root" ssz-size:"32"` + WithdrawalsRoot []byte `json:"withdrawals_root" ssz-size:"32"` + BlobGasUsed uint64 `json:"blob_gas_used,omitempty"` + ExcessBlobGas uint64 `json:"excess_blob_gas,omitempty"` } type DepositRequestsContainer struct { diff --git a/relayer/relays/beacon/state/beacon_electra_encoding.go b/relayer/relays/beacon/state/beacon_electra_encoding.go index 3ab2cb42af..80245e5a40 100644 --- a/relayer/relays/beacon/state/beacon_electra_encoding.go +++ b/relayer/relays/beacon/state/beacon_electra_encoding.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 26de6be168c07374a8bcc6262d218dfae18c063a7af308fbab963179eda0441b +// Hash: 102b99e06f43fa22848c793cecd95d88dce7318ab706d62adaf73f11cab9ce82 // Version: 0.1.3 package state @@ -15,7 +15,7 @@ func (e *ExecutionPayloadElectra) MarshalSSZ() ([]byte, error) { // MarshalSSZTo ssz marshals the ExecutionPayloadElectra object to a target array func (e *ExecutionPayloadElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(540) + offset := int(528) // Field (0) 'ParentHash' dst = append(dst, e.ParentHash[:]...) @@ -74,18 +74,6 @@ func (e *ExecutionPayloadElectra) MarshalSSZTo(buf []byte) (dst []byte, err erro // Field (16) 'ExcessBlobGas' dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) - // Offset (17) 'DepositRequests' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.DepositRequests) * 192 - - // Offset (18) 'WithdrawalRequests' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.WithdrawalRequests) * 76 - - // Offset (19) 'ConsolidationRequests' - dst = ssz.WriteOffset(dst, offset) - offset += len(e.ConsolidationRequests) * 116 - // Field (10) 'ExtraData' if size := len(e.ExtraData); size > 32 { err = ssz.ErrBytesLengthFn("ExecutionPayloadElectra.ExtraData", size, 32) @@ -124,39 +112,6 @@ func (e *ExecutionPayloadElectra) MarshalSSZTo(buf []byte) (dst []byte, err erro } } - // Field (17) 'DepositRequests' - if size := len(e.DepositRequests); size > 8192 { - err = ssz.ErrListTooBigFn("ExecutionPayloadElectra.DepositRequests", size, 8192) - return - } - for ii := 0; ii < len(e.DepositRequests); ii++ { - if dst, err = e.DepositRequests[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (18) 'WithdrawalRequests' - if size := len(e.WithdrawalRequests); size > 16 { - err = ssz.ErrListTooBigFn("ExecutionPayloadElectra.WithdrawalRequests", size, 16) - return - } - for ii := 0; ii < len(e.WithdrawalRequests); ii++ { - if dst, err = e.WithdrawalRequests[ii].MarshalSSZTo(dst); err != nil { - return - } - } - - // Field (19) 'ConsolidationRequests' - if size := len(e.ConsolidationRequests); size > 1 { - err = ssz.ErrListTooBigFn("ExecutionPayloadElectra.ConsolidationRequests", size, 1) - return - } - for ii := 0; ii < len(e.ConsolidationRequests); ii++ { - if dst, err = e.ConsolidationRequests[ii].MarshalSSZTo(dst); err != nil { - return - } - } - return } @@ -164,12 +119,12 @@ func (e *ExecutionPayloadElectra) MarshalSSZTo(buf []byte) (dst []byte, err erro func (e *ExecutionPayloadElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 540 { + if size < 528 { return ssz.ErrSize } tail := buf - var o10, o13, o14, o17, o18, o19 uint64 + var o10, o13, o14 uint64 // Field (0) 'ParentHash' copy(e.ParentHash[:], buf[0:32]) @@ -206,7 +161,7 @@ func (e *ExecutionPayloadElectra) UnmarshalSSZ(buf []byte) error { return ssz.ErrOffset } - if o10 < 540 { + if o10 < 528 { return ssz.ErrInvalidVariableOffset } @@ -232,21 +187,6 @@ func (e *ExecutionPayloadElectra) UnmarshalSSZ(buf []byte) error { // Field (16) 'ExcessBlobGas' e.ExcessBlobGas = ssz.UnmarshallUint64(buf[520:528]) - // Offset (17) 'DepositRequests' - if o17 = ssz.ReadOffset(buf[528:532]); o17 > size || o14 > o17 { - return ssz.ErrOffset - } - - // Offset (18) 'WithdrawalRequests' - if o18 = ssz.ReadOffset(buf[532:536]); o18 > size || o17 > o18 { - return ssz.ErrOffset - } - - // Offset (19) 'ConsolidationRequests' - if o19 = ssz.ReadOffset(buf[536:540]); o19 > size || o18 > o19 { - return ssz.ErrOffset - } - // Field (10) 'ExtraData' { buf = tail[o10:o13] @@ -284,7 +224,7 @@ func (e *ExecutionPayloadElectra) UnmarshalSSZ(buf []byte) error { // Field (14) 'Withdrawals' { - buf = tail[o14:o17] + buf = tail[o14:] num, err := ssz.DivideInt2(len(buf), 44, 16) if err != nil { return err @@ -299,66 +239,12 @@ func (e *ExecutionPayloadElectra) UnmarshalSSZ(buf []byte) error { } } } - - // Field (17) 'DepositRequests' - { - buf = tail[o17:o18] - num, err := ssz.DivideInt2(len(buf), 192, 8192) - if err != nil { - return err - } - e.DepositRequests = make([]*DepositRequest, num) - for ii := 0; ii < num; ii++ { - if e.DepositRequests[ii] == nil { - e.DepositRequests[ii] = new(DepositRequest) - } - if err = e.DepositRequests[ii].UnmarshalSSZ(buf[ii*192 : (ii+1)*192]); err != nil { - return err - } - } - } - - // Field (18) 'WithdrawalRequests' - { - buf = tail[o18:o19] - num, err := ssz.DivideInt2(len(buf), 76, 16) - if err != nil { - return err - } - e.WithdrawalRequests = make([]*WithdrawalRequest, num) - for ii := 0; ii < num; ii++ { - if e.WithdrawalRequests[ii] == nil { - e.WithdrawalRequests[ii] = new(WithdrawalRequest) - } - if err = e.WithdrawalRequests[ii].UnmarshalSSZ(buf[ii*76 : (ii+1)*76]); err != nil { - return err - } - } - } - - // Field (19) 'ConsolidationRequests' - { - buf = tail[o19:] - num, err := ssz.DivideInt2(len(buf), 116, 1) - if err != nil { - return err - } - e.ConsolidationRequests = make([]*ConsolidationRequest, num) - for ii := 0; ii < num; ii++ { - if e.ConsolidationRequests[ii] == nil { - e.ConsolidationRequests[ii] = new(ConsolidationRequest) - } - if err = e.ConsolidationRequests[ii].UnmarshalSSZ(buf[ii*116 : (ii+1)*116]); err != nil { - return err - } - } - } return err } // SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadElectra object func (e *ExecutionPayloadElectra) SizeSSZ() (size int) { - size = 540 + size = 528 // Field (10) 'ExtraData' size += len(e.ExtraData) @@ -372,15 +258,6 @@ func (e *ExecutionPayloadElectra) SizeSSZ() (size int) { // Field (14) 'Withdrawals' size += len(e.Withdrawals) * 44 - // Field (17) 'DepositRequests' - size += len(e.DepositRequests) * 192 - - // Field (18) 'WithdrawalRequests' - size += len(e.WithdrawalRequests) * 76 - - // Field (19) 'ConsolidationRequests' - size += len(e.ConsolidationRequests) * 116 - return } @@ -486,54 +363,6 @@ func (e *ExecutionPayloadElectra) HashTreeRootWith(hh ssz.HashWalker) (err error // Field (16) 'ExcessBlobGas' hh.PutUint64(e.ExcessBlobGas) - // Field (17) 'DepositRequests' - { - subIndx := hh.Index() - num := uint64(len(e.DepositRequests)) - if num > 8192 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.DepositRequests { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 8192) - } - - // Field (18) 'WithdrawalRequests' - { - subIndx := hh.Index() - num := uint64(len(e.WithdrawalRequests)) - if num > 16 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.WithdrawalRequests { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 16) - } - - // Field (19) 'ConsolidationRequests' - { - subIndx := hh.Index() - num := uint64(len(e.ConsolidationRequests)) - if num > 1 { - err = ssz.ErrIncorrectListSize - return - } - for _, elem := range e.ConsolidationRequests { - if err = elem.HashTreeRootWith(hh); err != nil { - return - } - } - hh.MerkleizeWithMixin(subIndx, num, 1) - } - hh.Merkleize(indx) return } @@ -551,7 +380,7 @@ func (e *ExecutionPayloadHeaderElectra) MarshalSSZ() ([]byte, error) { // MarshalSSZTo ssz marshals the ExecutionPayloadHeaderElectra object to a target array func (e *ExecutionPayloadHeaderElectra) MarshalSSZTo(buf []byte) (dst []byte, err error) { dst = buf - offset := int(680) + offset := int(584) // Field (0) 'ParentHash' if size := len(e.ParentHash); size != 32 { @@ -645,27 +474,6 @@ func (e *ExecutionPayloadHeaderElectra) MarshalSSZTo(buf []byte) (dst []byte, er // Field (16) 'ExcessBlobGas' dst = ssz.MarshalUint64(dst, e.ExcessBlobGas) - // Field (17) 'DepositRequestsRoot' - if size := len(e.DepositRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.DepositRequestsRoot", size, 32) - return - } - dst = append(dst, e.DepositRequestsRoot...) - - // Field (18) 'WithdrawalRequestsRoot' - if size := len(e.WithdrawalRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.WithdrawalRequestsRoot", size, 32) - return - } - dst = append(dst, e.WithdrawalRequestsRoot...) - - // Field (19) 'ConsolidationRequestsRoot' - if size := len(e.ConsolidationRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ConsolidationRequestsRoot", size, 32) - return - } - dst = append(dst, e.ConsolidationRequestsRoot...) - // Field (10) 'ExtraData' if size := len(e.ExtraData); size > 32 { err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ExtraData", size, 32) @@ -680,7 +488,7 @@ func (e *ExecutionPayloadHeaderElectra) MarshalSSZTo(buf []byte) (dst []byte, er func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { var err error size := uint64(len(buf)) - if size < 680 { + if size < 584 { return ssz.ErrSize } @@ -740,7 +548,7 @@ func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { return ssz.ErrOffset } - if o10 < 680 { + if o10 < 584 { return ssz.ErrInvalidVariableOffset } @@ -774,24 +582,6 @@ func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { // Field (16) 'ExcessBlobGas' e.ExcessBlobGas = ssz.UnmarshallUint64(buf[576:584]) - // Field (17) 'DepositRequestsRoot' - if cap(e.DepositRequestsRoot) == 0 { - e.DepositRequestsRoot = make([]byte, 0, len(buf[584:616])) - } - e.DepositRequestsRoot = append(e.DepositRequestsRoot, buf[584:616]...) - - // Field (18) 'WithdrawalRequestsRoot' - if cap(e.WithdrawalRequestsRoot) == 0 { - e.WithdrawalRequestsRoot = make([]byte, 0, len(buf[616:648])) - } - e.WithdrawalRequestsRoot = append(e.WithdrawalRequestsRoot, buf[616:648]...) - - // Field (19) 'ConsolidationRequestsRoot' - if cap(e.ConsolidationRequestsRoot) == 0 { - e.ConsolidationRequestsRoot = make([]byte, 0, len(buf[648:680])) - } - e.ConsolidationRequestsRoot = append(e.ConsolidationRequestsRoot, buf[648:680]...) - // Field (10) 'ExtraData' { buf = tail[o10:] @@ -808,7 +598,7 @@ func (e *ExecutionPayloadHeaderElectra) UnmarshalSSZ(buf []byte) error { // SizeSSZ returns the ssz encoded size in bytes for the ExecutionPayloadHeaderElectra object func (e *ExecutionPayloadHeaderElectra) SizeSSZ() (size int) { - size = 680 + size = 584 // Field (10) 'ExtraData' size += len(e.ExtraData) @@ -925,27 +715,6 @@ func (e *ExecutionPayloadHeaderElectra) HashTreeRootWith(hh ssz.HashWalker) (err // Field (16) 'ExcessBlobGas' hh.PutUint64(e.ExcessBlobGas) - // Field (17) 'DepositRequestsRoot' - if size := len(e.DepositRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.DepositRequestsRoot", size, 32) - return - } - hh.PutBytes(e.DepositRequestsRoot) - - // Field (18) 'WithdrawalRequestsRoot' - if size := len(e.WithdrawalRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.WithdrawalRequestsRoot", size, 32) - return - } - hh.PutBytes(e.WithdrawalRequestsRoot) - - // Field (19) 'ConsolidationRequestsRoot' - if size := len(e.ConsolidationRequestsRoot); size != 32 { - err = ssz.ErrBytesLengthFn("ExecutionPayloadHeaderElectra.ConsolidationRequestsRoot", size, 32) - return - } - hh.PutBytes(e.ConsolidationRequestsRoot) - hh.Merkleize(indx) return } diff --git a/relayer/relays/beacon/state/beacon_encoding.go b/relayer/relays/beacon/state/beacon_encoding.go index 53a3ab0fc6..f21d9a09e5 100644 --- a/relayer/relays/beacon/state/beacon_encoding.go +++ b/relayer/relays/beacon/state/beacon_encoding.go @@ -1,5 +1,5 @@ // Code generated by fastssz. DO NOT EDIT. -// Hash: 3e0112db5bed3cd4f62a1a793a3a3ac15855471de0a75c0344de8218a658e89b +// Hash: 102b99e06f43fa22848c793cecd95d88dce7318ab706d62adaf73f11cab9ce82 // Version: 0.1.3 package state diff --git a/web/packages/test/scripts/configure-substrate.sh b/web/packages/test/scripts/configure-substrate.sh index 582006fe8d..3d385ef2a4 100755 --- a/web/packages/test/scripts/configure-substrate.sh +++ b/web/packages/test/scripts/configure-substrate.sh @@ -4,6 +4,25 @@ set -eu source scripts/set-env.sh source scripts/xcm-helper.sh +config_relayer() { + # Configure beacon relay + local deneb_forked_epoch=0 + local electra_forked_epoch=256 + if [ "$eth_fast_mode" == "true" ]; then + deneb_forked_epoch=0 + fi + jq \ + --arg beacon_endpoint_http $beacon_endpoint_http \ + --argjson deneb_forked_epoch $deneb_forked_epoch \ + --argjson electra_forked_epoch $electra_forked_epoch \ + ' + .source.beacon.endpoint = $beacon_endpoint_http + | .source.beacon.spec.forkVersions.deneb = $deneb_forked_epoch + | .source.beacon.spec.forkVersions.electra = $electra_forked_epoch + ' \ + config/beacon-relay.json >$output_dir/beacon-relay.json +} + config_beacon_checkpoint() { pushd $root_dir local check_point_hex=$($relay_bin generate-beacon-checkpoint --config $config_dir/beacon-relay.json) @@ -89,6 +108,7 @@ configure_substrate() { open_hrmp_channels config_xcm_version wait_beacon_chain_ready + config_relayer config_beacon_checkpoint } diff --git a/web/packages/test/scripts/deploy-ethereum-mekong.sh b/web/packages/test/scripts/deploy-ethereum-mekong.sh index 8ce5e4a6a3..7ddd3fe71a 100755 --- a/web/packages/test/scripts/deploy-ethereum-mekong.sh +++ b/web/packages/test/scripts/deploy-ethereum-mekong.sh @@ -3,7 +3,7 @@ set -eux source scripts/set-env.sh HOST=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1') -export output_electra_dir="$output_dir/electra" +export output_electra_dir="/tmp/electra" start_geth() { mkdir -p $output_electra_dir @@ -18,7 +18,7 @@ start_geth() { echo "Starting geth local node" docker run --rm \ -v "${output_electra_dir}:/mnt" \ - docker.io/ethpandaops/geth:master \ + docker.io/ethpandaops/geth:lightclient-prague-devnet-4 \ --datadir /mnt/ethereum \ --state.scheme=hash \ init /mnt/genesis-mekong.json @@ -29,7 +29,7 @@ start_geth() { -p 8545:8545 \ -p 8546:8546 \ --env 'NODE_OPTIONS=--max-old-space-size=8192' \ - docker.io/ethpandaops/geth:master \ + docker.io/ethpandaops/geth:lightclient-prague-devnet-4 \ --networkid 7078815900 \ --vmdebug \ --datadir /mnt/ethereum \ @@ -57,7 +57,7 @@ start_geth() { --syncmode=full \ --bootnodes "enode://125d2dddd0dc0d34b526910d49592545a1e4fe25139be9d9e0eed396211dbd37aa0c0a7fa0444c315803d814e743f890529b58b9261289d5303e16477c216b39@157.230.225.158:30303?discport=30303,enode://508bff69cbb852337cfbf3db9e58fe66ec3254e6a3960c0ef266a2ab1ea78e12f101bba51e3d2e066947a0b9b315e5b26009af81584510394c1b87a5908dca7b@137.184.72.127:30303?discport=30303,enode://b273c662dd15148162c23a5c8407d3d5dbb35fb331ae0c1c3a80c6bfa2bbe077683b28c0cd59f7a482efc00a64a09273eb4767a173441a79b833fdf705d331ae@152.42.247.97:30303?discport=30303" \ --state.scheme=hash \ - > "$output_dir/geth.log" 2>&1 & + > "$output_electra_dir/geth.log" 2>&1 & } start_lodestar() { @@ -81,7 +81,7 @@ start_lodestar() { --jwt-secret /mnt/jwtsecret \ --checkpointSyncUrl https://checkpoint-sync.mekong.ethpandaops.io \ --chain.archiveStateEpochFrequency 1 \ - > "$output_dir/lodestar.log" 2>&1 & + > "$output_electra_dir/lodestar.log" 2>&1 & } deploy_local() { diff --git a/web/packages/test/scripts/start-relayer-electra.sh b/web/packages/test/scripts/start-relayer-electra.sh index 49c5f5c744..d7cac2a6f3 100755 --- a/web/packages/test/scripts/start-relayer-electra.sh +++ b/web/packages/test/scripts/start-relayer-electra.sh @@ -3,24 +3,6 @@ set -eu source scripts/set-env.sh -config_relayer() { - # Configure beacon relay - local deneb_forked_epoch=0 - local electra_forked_epoch=256 - if [ "$eth_fast_mode" == "true" ]; then - deneb_forked_epoch=0 - fi - jq \ - --arg beacon_endpoint_http $beacon_endpoint_http \ - --argjson deneb_forked_epoch $deneb_forked_epoch \ - ' - .source.beacon.endpoint = $beacon_endpoint_http - | .source.beacon.spec.forkVersions.deneb = $deneb_forked_epoch - | .source.beacon.spec.forkVersions.electra = $electra_forked_epoch - ' \ - config/beacon-relay.json >$output_dir/beacon-relay.json -} - start_relayer() { # Launch beacon relay ( @@ -43,7 +25,7 @@ build_relayer() { } deploy_relayer() { - check_tool && build_relayer && config_relayer && start_relayer + check_tool && build_relayer && start_relayer } if [ -z "${from_start_services:-}" ]; then diff --git a/web/packages/test/scripts/start-services-electra.sh b/web/packages/test/scripts/start-services-electra.sh index 4b23dbb916..865698df9d 100755 --- a/web/packages/test/scripts/start-services-electra.sh +++ b/web/packages/test/scripts/start-services-electra.sh @@ -19,13 +19,6 @@ check_tool echo "Installing binaries if required" install_binary -# 2. start ethereum -echo "Starting ethereum nodes" -if [ "$eth_network" == "localhost" ]; then - source scripts/deploy-ethereum.sh - deploy_ethereum -fi - # 3. start polkadot echo "Starting polkadot nodes" source scripts/deploy-polkadot.sh @@ -44,7 +37,7 @@ configure_substrate if [ "$skip_relayer" == "false" ]; then # 7. start relayer echo "Starting relayers" - source scripts/start-relayer.sh + source scripts/start-relayer-electra.sh deploy_relayer fi