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 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/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/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/magefile.go b/relayer/magefile.go index 859e614e06..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") + 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/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/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/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..3415edeaa4 --- /dev/null +++ b/relayer/relays/beacon/header/syncer/api/api_electra.go @@ -0,0 +1,150 @@ +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.ExecutionPayloadHeaderElectra, error) { + var payloadHeader scale.ExecutionPayloadHeaderElectra + transactionsContainer := state.TransactionsRootContainer{} + transactionsContainer.Transactions = e.Transactions + + transactionsRoot, err := transactionsContainer.HashTreeRoot() + if err != nil { + return payloadHeader, err + } + + withdrawalContainer := state.WithdrawalsRootContainerMainnet{} + withdrawalContainer.Withdrawals = e.Withdrawals + 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 + } + + 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, + }, 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 1ba06034b7..17a29b459f 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" @@ -150,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 { @@ -461,7 +463,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) @@ -521,26 +523,6 @@ func (b BeaconBlockResponse) ToFastSSZ(isDeneb bool) (state.BeaconBlock, error) 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() @@ -691,7 +673,96 @@ func (b BeaconBlockResponse) ToFastSSZ(isDeneb bool) (state.BeaconBlock, error) kzgCommitments = append(kzgCommitments, kzgCommitmentSSZ) } - if isDeneb { + 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, ProposerIndex: proposerIndex, 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 7f23cb66e8..cf75bbd8d5 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 := s.protocol.ForkVersion(slot) + if forkVersion == protocol.Electra { + executionPayloadScale, err := api.ElectraExecutionPayloadToScale(sszBlock.ExecutionPayloadElectra()) + if err != nil { + return scale.HeaderUpdatePayload{}, err + } + versionedExecutionPayloadHeader = scale.VersionedExecutionPayloadHeader{Electra: &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 := s.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/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/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..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: 03b5096ab94e41e2c740924a4ae7ea8fdd515fe3dd4861032a569e28bcba8bb4 +// 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 new file mode 100644 index 0000000000..17d3292d83 --- /dev/null +++ b/relayer/relays/beacon/state/beacon_electra.go @@ -0,0 +1,225 @@ +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 +} + +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 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"` + 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"` + 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 []*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"` + 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 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"` +} + +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_electra_encoding.go b/relayer/relays/beacon/state/beacon_electra_encoding.go new file mode 100644 index 0000000000..3ab2cb42af --- /dev/null +++ b/relayer/relays/beacon/state/beacon_electra_encoding.go @@ -0,0 +1,4076 @@ +// Code generated by fastssz. DO NOT EDIT. +// Hash: 26de6be168c07374a8bcc6262d218dfae18c063a7af308fbab963179eda0441b +// 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 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) +} + +// 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) +} 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 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() 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", diff --git a/web/packages/test/config/genesis.json b/web/packages/test/config/genesis.json index e90d106d2a..a0fdd654b6 100644 --- a/web/packages/test/config/genesis.json +++ b/web/packages/test/config/genesis.json @@ -15,7 +15,8 @@ "ethash": {}, "terminalTotalDifficulty": 0, "ShanghaiTime": 0, - "CancunTime": 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 b96ad21213..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 \ @@ -70,12 +92,13 @@ 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 \ + --jwt-secret /mnt/jwtsecret \ --chain.archiveStateEpochFrequency 1 \ - >"$output_dir/lodestar.log" 2>&1 & - popd + > ./snowbridge/lodestar.log 2>&1 & + # popd fi } @@ -85,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"