diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index a08515c2568..96f109c555f 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -62,7 +62,7 @@ type stEnv struct { Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` WithdrawalsHash *libcommon.Hash `json:"withdrawalsRoot,omitempty"` Requests types.Requests `json:"requests,omitempty"` - RequestsRoot *libcommon.Hash `json:"requestsRoot,omitempty"` + RequestsHash *libcommon.Hash `json:"requestsHash,omitempty"` } type stEnvMarshaling struct { diff --git a/cmd/evm/internal/t8ntool/gen_stenv.go b/cmd/evm/internal/t8ntool/gen_stenv.go index 2b1bb7479e9..6be31364284 100644 --- a/cmd/evm/internal/t8ntool/gen_stenv.go +++ b/cmd/evm/internal/t8ntool/gen_stenv.go @@ -35,7 +35,7 @@ func (s stEnv) MarshalJSON() ([]byte, error) { Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot,omitempty"` Requests types.Requests `json:"requests,omitempty"` - RequestsRoot *common.Hash `json:"requestsRoot,omitempty"` + RequestsHash *common.Hash `json:"requestsHash,omitempty"` } var enc stEnv enc.Coinbase = common0.UnprefixedAddress(s.Coinbase) @@ -55,7 +55,7 @@ func (s stEnv) MarshalJSON() ([]byte, error) { enc.Withdrawals = s.Withdrawals enc.WithdrawalsHash = s.WithdrawalsHash enc.Requests = s.Requests - enc.RequestsRoot = s.RequestsRoot + enc.RequestsHash = s.RequestsHash return json.Marshal(&enc) } @@ -79,7 +79,7 @@ func (s *stEnv) UnmarshalJSON(input []byte) error { Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` WithdrawalsHash *common.Hash `json:"withdrawalsRoot,omitempty"` Requests *types.Requests `json:"requests,omitempty"` - RequestsRoot *common.Hash `json:"requestsRoot,omitempty"` + RequestsHash *common.Hash `json:"requestsHash,omitempty"` } var dec stEnv if err := json.Unmarshal(input, &dec); err != nil { @@ -140,8 +140,8 @@ func (s *stEnv) UnmarshalJSON(input []byte) error { if dec.Requests != nil { s.Requests = *dec.Requests } - if dec.RequestsRoot != nil { - s.RequestsRoot = dec.RequestsRoot + if dec.RequestsHash != nil { + s.RequestsHash = dec.RequestsHash } return nil } diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index a25e4cdf123..9ff2e2041c2 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -606,7 +606,7 @@ func NewHeader(env stEnv) *types.Header { header.UncleHash = env.UncleHash header.WithdrawalsHash = env.WithdrawalsHash - header.RequestsRoot = env.RequestsRoot + header.RequestsHash = env.RequestsHash return &header } diff --git a/consensus/clique/verifier.go b/consensus/clique/verifier.go index 8b9c22be82f..2c8686a70ce 100644 --- a/consensus/clique/verifier.go +++ b/consensus/clique/verifier.go @@ -81,7 +81,7 @@ func (c *Clique) verifyHeader(chain consensus.ChainHeaderReader, header *types.H return consensus.ErrUnexpectedWithdrawals } - if header.RequestsRoot != nil { + if header.RequestsHash != nil { return consensus.ErrUnexpectedRequests } diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index e83dca125e1..b3d3886b54d 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -249,7 +249,7 @@ func VerifyHeaderBasics(chain consensus.ChainHeaderReader, header, parent *types return consensus.ErrUnexpectedWithdrawals } - if header.RequestsRoot != nil { + if header.RequestsHash != nil { return consensus.ErrUnexpectedRequests } diff --git a/consensus/merge/merge.go b/consensus/merge/merge.go index 3a047d48c7e..97f1697c2cf 100644 --- a/consensus/merge/merge.go +++ b/consensus/merge/merge.go @@ -177,10 +177,10 @@ func (s *Merge) Finalize(config *chain.Config, header *types.Header, state *stat rs = append(rs, withdrawalReqs...) consolidations := misc.DequeueConsolidationRequests7251(syscall) rs = append(rs, consolidations...) - if requestsInBlock != nil || header.RequestsRoot != nil { + if requestsInBlock != nil || header.RequestsHash != nil { rh := types.DeriveSha(rs) - if *header.RequestsRoot != rh { - return nil, nil, nil, fmt.Errorf("error: invalid requests root hash in header, expected: %v, got :%v", header.RequestsRoot, rh) + if *header.RequestsHash != rh { + return nil, nil, nil, fmt.Errorf("error: invalid requests root hash in header, expected: %v, got :%v", header.RequestsHash, rh) } if !reflect.DeepEqual(requestsInBlock.Deposits(), depositReqs.Deposits()) { return nil, nil, nil, fmt.Errorf("error: invalid EIP-6110 Deposit Requests in block") @@ -204,7 +204,7 @@ func (s *Merge) FinalizeAndAssemble(config *chain.Config, header *types.Header, if !misc.IsPoSHeader(header) { return s.eth1Engine.FinalizeAndAssemble(config, header, state, txs, uncles, receipts, withdrawals, requests, chain, syscall, call, logger) } - header.RequestsRoot = nil + header.RequestsHash = nil outTxs, outReceipts, rs, err := s.Finalize(config, header, state, txs, uncles, receipts, withdrawals, requests, chain, syscall, logger) if err != nil { return nil, nil, nil, err @@ -294,12 +294,12 @@ func (s *Merge) verifyHeader(chain consensus.ChainHeaderReader, header, parent * return fmt.Errorf("invalid excessBlobGas: have %d, want %d", *header.ExcessBlobGas, expectedExcessBlobGas) } - // Verify existence / non-existence of requestsRoot + // Verify existence / non-existence of requestsHash prague := chain.Config().IsPrague(header.Time) - if prague && header.RequestsRoot == nil { - return fmt.Errorf("missing requestsRoot") + if prague && header.RequestsHash == nil { + return errors.New("missing requestsHash") } - if !prague && header.RequestsRoot != nil { + if !prague && header.RequestsHash != nil { return consensus.ErrUnexpectedRequests } diff --git a/core/genesis_write.go b/core/genesis_write.go index ec5ad7132f5..139f9cfc793 100644 --- a/core/genesis_write.go +++ b/core/genesis_write.go @@ -508,7 +508,7 @@ func GenesisToBlock(g *types.Genesis, tmpDir string, logger log.Logger) (*types. ExcessBlobGas: g.ExcessBlobGas, AuRaStep: g.AuRaStep, AuRaSeal: g.AuRaSeal, - RequestsRoot: g.RequestsRoot, + RequestsHash: g.RequestsHash, } if g.GasLimit == 0 { head.GasLimit = params.GenesisGasLimit @@ -552,10 +552,10 @@ func GenesisToBlock(g *types.Genesis, tmpDir string, logger log.Logger) (*types. requests = types.Requests{} // TODO @somnathb1 - if later iterations and/or tests don't need this from genesis.json, remove the following - if g.RequestsRoot != nil { - head.RequestsRoot = g.RequestsRoot + if g.RequestsHash != nil { + head.RequestsHash = g.RequestsHash } else { - head.RequestsRoot = &types.EmptyRootHash + head.RequestsHash = &types.EmptyRootHash } } diff --git a/core/types/block.go b/core/types/block.go index 47f773f66ab..a3aabf87c71 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -105,7 +105,7 @@ type Header struct { ParentBeaconBlockRoot *libcommon.Hash `json:"parentBeaconBlockRoot"` // EIP-4788 - RequestsRoot *libcommon.Hash `json:"requestsRoot"` // EIP-7685 + RequestsHash *libcommon.Hash `json:"requestsHash"` // EIP-7685 // The verkle proof is ignored in legacy headers Verkle bool @@ -163,7 +163,7 @@ func (h *Header) EncodingSize() int { encodingSize += 33 } - if h.RequestsRoot != nil { + if h.RequestsHash != nil { encodingSize += 33 } @@ -316,12 +316,12 @@ func (h *Header) EncodeRLP(w io.Writer) error { } } - if h.RequestsRoot != nil { + if h.RequestsHash != nil { b[0] = 128 + 32 if _, err := w.Write(b[:1]); err != nil { return err } - if _, err := w.Write(h.RequestsRoot.Bytes()); err != nil { + if _, err := w.Write(h.RequestsHash.Bytes()); err != nil { return err } } @@ -514,22 +514,22 @@ func (h *Header) DecodeRLP(s *rlp.Stream) error { h.ParentBeaconBlockRoot = new(libcommon.Hash) h.ParentBeaconBlockRoot.SetBytes(b) - // RequestsRoot + // RequestsHash if b, err = s.Bytes(); err != nil { if errors.Is(err, rlp.EOL) { - h.RequestsRoot = nil + h.RequestsHash = nil if err := s.ListEnd(); err != nil { - return fmt.Errorf("close header struct (no RequestsRoot): %w", err) + return fmt.Errorf("close header struct (no RequestsHash): %w", err) } return nil } - return fmt.Errorf("read RequestsRoot: %w", err) + return fmt.Errorf("read RequestsHash: %w", err) } if len(b) != 32 { - return fmt.Errorf("wrong size for RequestsRoot: %d", len(b)) + return fmt.Errorf("wrong size for RequestsHash: %d", len(b)) } - h.RequestsRoot = new(libcommon.Hash) - h.RequestsRoot.SetBytes(b) + h.RequestsHash = new(libcommon.Hash) + h.RequestsHash.SetBytes(b) if h.Verkle { if h.VerkleProof, err = s.Bytes(); err != nil { @@ -590,7 +590,7 @@ func (h *Header) Size() common.StorageSize { if h.ParentBeaconBlockRoot != nil { s += common.StorageSize(32) } - if h.RequestsRoot != nil { + if h.RequestsHash != nil { s += common.StorageSize(32) } return s @@ -1041,13 +1041,13 @@ func NewBlock(header *Header, txs []Transaction, uncles []*Header, receipts []*R b.header.ParentBeaconBlockRoot = header.ParentBeaconBlockRoot if requests == nil { - b.header.RequestsRoot = nil + b.header.RequestsHash = nil } else if len(requests) == 0 { - b.header.RequestsRoot = &EmptyRootHash + b.header.RequestsHash = &EmptyRootHash b.requests = make(Requests, len(requests)) } else { h := DeriveSha(requests) - b.header.RequestsRoot = &h + b.header.RequestsHash = &h b.requests = make(Requests, len(requests)) for i, r := range requests { rCopy := r.copy() @@ -1123,9 +1123,9 @@ func CopyHeader(h *Header) *Header { cpy.ParentBeaconBlockRoot = new(libcommon.Hash) cpy.ParentBeaconBlockRoot.SetBytes(h.ParentBeaconBlockRoot.Bytes()) } - if h.RequestsRoot != nil { - cpy.RequestsRoot = new(libcommon.Hash) - cpy.RequestsRoot.SetBytes(h.RequestsRoot.Bytes()) + if h.RequestsHash != nil { + cpy.RequestsHash = new(libcommon.Hash) + cpy.RequestsHash.SetBytes(h.RequestsHash.Bytes()) } return &cpy } @@ -1272,7 +1272,7 @@ func (b *Block) BaseFee() *big.Int { func (b *Block) WithdrawalsHash() *libcommon.Hash { return b.header.WithdrawalsHash } func (b *Block) Withdrawals() Withdrawals { return b.withdrawals } func (b *Block) ParentBeaconBlockRoot() *libcommon.Hash { return b.header.ParentBeaconBlockRoot } -func (b *Block) RequestsRoot() *libcommon.Hash { return b.header.RequestsRoot } +func (b *Block) RequestsHash() *libcommon.Hash { return b.header.RequestsHash } func (b *Block) Requests() Requests { return b.requests } // Header returns a deep-copy of the entire block header using CopyHeader() @@ -1371,15 +1371,15 @@ func (b *Block) HashCheck() error { return fmt.Errorf("block has invalid withdrawals hash: have %x, exp: %x", hash, b.WithdrawalsHash()) } - if b.RequestsRoot() == nil { + if b.RequestsHash() == nil { if b.Requests() != nil { - return errors.New("header missing RequestsRoot") + return errors.New("header missing RequestsHash") } return nil } - if hash := DeriveSha(b.Requests()); hash != *b.RequestsRoot() { - return fmt.Errorf("block has invalid requests root: have %x, exp: %x", hash, b.RequestsRoot()) + if hash := DeriveSha(b.Requests()); hash != *b.RequestsHash() { + return fmt.Errorf("block has invalid requests root: have %x, exp: %x", hash, b.RequestsHash()) } return nil diff --git a/core/types/gen_genesis.go b/core/types/gen_genesis.go index 75d8afa288d..c5f025f8776 100644 --- a/core/types/gen_genesis.go +++ b/core/types/gen_genesis.go @@ -37,7 +37,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) { BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot"` - RequestsRoot *common.Hash `json:"requestsRoot"` + RequestsHash *common.Hash `json:"requestsHash"` } var enc Genesis enc.Config = g.Config @@ -63,7 +63,7 @@ func (g Genesis) MarshalJSON() ([]byte, error) { enc.BlobGasUsed = (*math.HexOrDecimal64)(g.BlobGasUsed) enc.ExcessBlobGas = (*math.HexOrDecimal64)(g.ExcessBlobGas) enc.ParentBeaconBlockRoot = g.ParentBeaconBlockRoot - enc.RequestsRoot = g.RequestsRoot + enc.RequestsHash = g.RequestsHash return json.Marshal(&enc) } @@ -88,7 +88,7 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"` ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"` ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot"` - RequestsRoot *common.Hash `json:"requestsRoot"` + RequestsHash *common.Hash `json:"requestsHash"` } var dec Genesis if err := json.Unmarshal(input, &dec); err != nil { @@ -154,8 +154,8 @@ func (g *Genesis) UnmarshalJSON(input []byte) error { if dec.ParentBeaconBlockRoot != nil { g.ParentBeaconBlockRoot = dec.ParentBeaconBlockRoot } - if dec.RequestsRoot != nil { - g.RequestsRoot = dec.RequestsRoot + if dec.RequestsHash != nil { + g.RequestsHash = dec.RequestsHash } return nil } diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index 4b85e184c19..842a41e6be1 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -40,7 +40,7 @@ func (h Header) MarshalJSON() ([]byte, error) { BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"` ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"` ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot"` - RequestsRoot *common.Hash `json:"requestsRoot"` + RequestsHash *common.Hash `json:"requestsHash"` Verkle bool VerkleProof []byte VerkleKeyVals []verkle.KeyValuePair @@ -69,7 +69,7 @@ func (h Header) MarshalJSON() ([]byte, error) { enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed) enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas) enc.ParentBeaconBlockRoot = h.ParentBeaconBlockRoot - enc.RequestsRoot = h.RequestsRoot + enc.RequestsHash = h.RequestsHash enc.Verkle = h.Verkle enc.VerkleProof = h.VerkleProof enc.VerkleKeyVals = h.VerkleKeyVals @@ -102,7 +102,7 @@ func (h *Header) UnmarshalJSON(input []byte) error { BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"` ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"` ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot"` - RequestsRoot *common.Hash `json:"requestsRoot"` + RequestsHash *common.Hash `json:"requestsHash"` Verkle *bool VerkleProof []byte VerkleKeyVals []verkle.KeyValuePair @@ -189,8 +189,8 @@ func (h *Header) UnmarshalJSON(input []byte) error { if dec.ParentBeaconBlockRoot != nil { h.ParentBeaconBlockRoot = dec.ParentBeaconBlockRoot } - if dec.RequestsRoot != nil { - h.RequestsRoot = dec.RequestsRoot + if dec.RequestsHash != nil { + h.RequestsHash = dec.RequestsHash } if dec.Verkle != nil { h.Verkle = *dec.Verkle diff --git a/core/types/genesis.go b/core/types/genesis.go index 3f340cfff4f..b8763b8e4a5 100644 --- a/core/types/genesis.go +++ b/core/types/genesis.go @@ -65,7 +65,7 @@ type Genesis struct { BlobGasUsed *uint64 `json:"blobGasUsed"` // EIP-4844 ExcessBlobGas *uint64 `json:"excessBlobGas"` // EIP-4844 ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot"` // EIP-4788 - RequestsRoot *common.Hash `json:"requestsRoot"` // EIP-7685 + RequestsHash *common.Hash `json:"requestsHash"` // EIP-7685 } // GenesisAlloc specifies the initial state that is part of the genesis block. diff --git a/erigon-lib/go.mod b/erigon-lib/go.mod index 6b896ba19ba..bf5b81331de 100644 --- a/erigon-lib/go.mod +++ b/erigon-lib/go.mod @@ -5,7 +5,7 @@ go 1.22.0 require ( github.com/erigontech/mdbx-go v0.27.24 github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20240805114253-42da880260bb - github.com/ledgerwatch/interfaces v0.0.0-20241024121018-582714adcf8a + github.com/ledgerwatch/interfaces v0.0.0-20241024124715-46d0f9679d5f github.com/ledgerwatch/log/v3 v3.9.0 github.com/ledgerwatch/secp256k1 v1.0.0 github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417 diff --git a/erigon-lib/go.sum b/erigon-lib/go.sum index e902aa7d5fa..1d4842ba3ce 100644 --- a/erigon-lib/go.sum +++ b/erigon-lib/go.sum @@ -270,8 +270,8 @@ github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7 github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20240805114253-42da880260bb h1:bsoVxjnQGxhOODRmkdrbkRTB9+sIduguoNMSZPRRoTI= github.com/ledgerwatch/erigon-snapshot v1.3.1-0.20240805114253-42da880260bb/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo= -github.com/ledgerwatch/interfaces v0.0.0-20241024121018-582714adcf8a h1:2TsvVKrqykfCypZEqpG1ZphBu8wvmRgQsKGS+JQXhdg= -github.com/ledgerwatch/interfaces v0.0.0-20241024121018-582714adcf8a/go.mod h1:ugQv1QllJzBny3cKZKxUrSnykkjkBgm27eQM6dnGAcc= +github.com/ledgerwatch/interfaces v0.0.0-20241024124715-46d0f9679d5f h1:NCKhl9//nyPnWMDQySbusjctWyLjHj0WR+gtsEwcHgE= +github.com/ledgerwatch/interfaces v0.0.0-20241024124715-46d0f9679d5f/go.mod h1:ugQv1QllJzBny3cKZKxUrSnykkjkBgm27eQM6dnGAcc= github.com/ledgerwatch/log/v3 v3.9.0 h1:iDwrXe0PVwBC68Dd94YSsHbMgQ3ufsgjzXtFNFVZFRk= github.com/ledgerwatch/log/v3 v3.9.0/go.mod h1:EiAY6upmI/6LkNhOVxb4eVsmsP11HZCnZ3PlJMjYiqE= github.com/ledgerwatch/secp256k1 v1.0.0 h1:Usvz87YoTG0uePIV8woOof5cQnLXGYa162rFf3YnwaQ= diff --git a/erigon-lib/gointerfaces/execution/execution.pb.go b/erigon-lib/gointerfaces/execution/execution.pb.go index 0cba23efab0..19af7348d2f 100644 --- a/erigon-lib/gointerfaces/execution/execution.pb.go +++ b/erigon-lib/gointerfaces/execution/execution.pb.go @@ -281,7 +281,7 @@ type Header struct { BlobGasUsed *uint64 `protobuf:"varint,19,opt,name=blob_gas_used,json=blobGasUsed,proto3,oneof" json:"blob_gas_used,omitempty"` // added in Dencun (EIP-4844) ExcessBlobGas *uint64 `protobuf:"varint,20,opt,name=excess_blob_gas,json=excessBlobGas,proto3,oneof" json:"excess_blob_gas,omitempty"` // added in Dencun (EIP-4844) ParentBeaconBlockRoot *types.H256 `protobuf:"bytes,21,opt,name=parent_beacon_block_root,json=parentBeaconBlockRoot,proto3,oneof" json:"parent_beacon_block_root,omitempty"` // added in Dencun (EIP-4788) - RequestsRoot *types.H256 `protobuf:"bytes,22,opt,name=requests_root,json=requestsRoot,proto3,oneof" json:"requests_root,omitempty"` // added in Pectra (EIP-7685) + RequestsHash *types.H256 `protobuf:"bytes,22,opt,name=requests_hash,json=requestsHash,proto3,oneof" json:"requests_hash,omitempty"` // added in Pectra (EIP-7685) // AuRa AuraStep *uint64 `protobuf:"varint,23,opt,name=aura_step,json=auraStep,proto3,oneof" json:"aura_step,omitempty"` AuraSeal []byte `protobuf:"bytes,24,opt,name=aura_seal,json=auraSeal,proto3,oneof" json:"aura_seal,omitempty"` @@ -466,9 +466,9 @@ func (x *Header) GetParentBeaconBlockRoot() *types.H256 { return nil } -func (x *Header) GetRequestsRoot() *types.H256 { +func (x *Header) GetRequestsHash() *types.H256 { if x != nil { - return x.RequestsRoot + return x.RequestsHash } return nil } @@ -1785,9 +1785,9 @@ var file_execution_execution_proto_rawDesc = []byte{ 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x48, 0x32, 0x35, 0x36, 0x48, 0x04, 0x52, 0x15, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x6f, 0x6f, 0x74, 0x88, 0x01, 0x01, 0x12, 0x35, 0x0a, 0x0d, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, + 0x73, 0x74, 0x73, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x48, 0x32, 0x35, 0x36, 0x48, 0x05, 0x52, 0x0c, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x52, 0x6f, 0x6f, 0x74, 0x88, 0x01, 0x01, 0x12, 0x20, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x48, 0x61, 0x73, 0x68, 0x88, 0x01, 0x01, 0x12, 0x20, 0x0a, 0x09, 0x61, 0x75, 0x72, 0x61, 0x5f, 0x73, 0x74, 0x65, 0x70, 0x18, 0x17, 0x20, 0x01, 0x28, 0x04, 0x48, 0x06, 0x52, 0x08, 0x61, 0x75, 0x72, 0x61, 0x53, 0x74, 0x65, 0x70, 0x88, 0x01, 0x01, 0x12, 0x20, 0x0a, 0x09, 0x61, 0x75, 0x72, 0x61, 0x5f, 0x73, 0x65, 0x61, 0x6c, 0x18, 0x18, 0x20, @@ -1799,7 +1799,7 @@ var file_execution_execution_proto_rawDesc = []byte{ 0x10, 0x5f, 0x65, 0x78, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x67, 0x61, 0x73, 0x42, 0x1b, 0x0a, 0x19, 0x5f, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x62, 0x65, 0x61, 0x63, 0x6f, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x42, 0x10, - 0x0a, 0x0e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x72, 0x6f, 0x6f, 0x74, + 0x0a, 0x0e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x61, 0x75, 0x72, 0x61, 0x5f, 0x73, 0x74, 0x65, 0x70, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x61, 0x75, 0x72, 0x61, 0x5f, 0x73, 0x65, 0x61, 0x6c, 0x22, 0xfa, 0x01, 0x0a, 0x09, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x6f, 0x64, 0x79, 0x12, 0x2a, 0x0a, 0x0a, 0x62, 0x6c, @@ -2113,7 +2113,7 @@ var file_execution_execution_proto_depIdxs = []int32{ 27, // 14: execution.Header.base_fee_per_gas:type_name -> types.H256 27, // 15: execution.Header.withdrawal_hash:type_name -> types.H256 27, // 16: execution.Header.parent_beacon_block_root:type_name -> types.H256 - 27, // 17: execution.Header.requests_root:type_name -> types.H256 + 27, // 17: execution.Header.requests_hash:type_name -> types.H256 27, // 18: execution.BlockBody.block_hash:type_name -> types.H256 4, // 19: execution.BlockBody.uncles:type_name -> execution.Header 30, // 20: execution.BlockBody.withdrawals:type_name -> types.Withdrawal diff --git a/polygon/bor/bor.go b/polygon/bor/bor.go index 6235f2ca870..1423690eb4b 100644 --- a/polygon/bor/bor.go +++ b/polygon/bor/bor.go @@ -553,7 +553,7 @@ func ValidateHeaderUnusedFields(header *types.Header) error { return consensus.ErrUnexpectedWithdrawals } - if header.RequestsRoot != nil { + if header.RequestsHash != nil { return consensus.ErrUnexpectedRequests } @@ -990,7 +990,7 @@ func (c *Bor) Finalize(config *chain.Config, header *types.Header, state *state. return nil, nil, nil, consensus.ErrUnexpectedWithdrawals } - if requests != nil || header.RequestsRoot != nil { + if requests != nil || header.RequestsHash != nil { return nil, nil, nil, consensus.ErrUnexpectedRequests } @@ -1060,7 +1060,7 @@ func (c *Bor) FinalizeAndAssemble(chainConfig *chain.Config, header *types.Heade return nil, nil, nil, consensus.ErrUnexpectedWithdrawals } - if requests != nil || header.RequestsRoot != nil { + if requests != nil || header.RequestsHash != nil { return nil, nil, nil, consensus.ErrUnexpectedRequests } diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 17119dc6540..74886e520d7 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -23,21 +23,18 @@ import ( "encoding/hex" "encoding/json" "fmt" - "github.com/ledgerwatch/erigon-lib/common/hexutil" "math/big" "reflect" "testing" "github.com/holiman/uint256" + "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon-lib/chain" libcommon "github.com/ledgerwatch/erigon-lib/common" + "github.com/ledgerwatch/erigon-lib/common/hexutil" "github.com/ledgerwatch/erigon-lib/common/hexutility" "github.com/ledgerwatch/erigon-lib/kv" - "github.com/ledgerwatch/erigon/turbo/services" - "github.com/ledgerwatch/erigon/turbo/stages/mock" - - "github.com/ledgerwatch/log/v3" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/math" @@ -47,6 +44,8 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/eth/ethconsensusconfig" "github.com/ledgerwatch/erigon/rlp" + "github.com/ledgerwatch/erigon/turbo/services" + "github.com/ledgerwatch/erigon/turbo/stages/mock" ) // A BlockTest checks handling of entire blocks. @@ -101,7 +100,7 @@ type btHeader struct { BlobGasUsed *uint64 ExcessBlobGas *uint64 ParentBeaconBlockRoot *libcommon.Hash - RequestsRoot *libcommon.Hash + RequestsHash *libcommon.Hash } type btHeaderMarshaling struct { @@ -173,6 +172,7 @@ func (bt *BlockTest) genesis(config *chain.Config) *types.Genesis { BlobGasUsed: bt.json.Genesis.BlobGasUsed, ExcessBlobGas: bt.json.Genesis.ExcessBlobGas, ParentBeaconBlockRoot: bt.json.Genesis.ParentBeaconBlockRoot, + RequestsHash: bt.json.Genesis.RequestsHash, } } @@ -304,8 +304,8 @@ func validateHeader(h *btHeader, h2 *types.Header) error { if !reflect.DeepEqual(h.ParentBeaconBlockRoot, h2.ParentBeaconBlockRoot) { return fmt.Errorf("parentBeaconBlockRoot: want: %v have: %v", h.ParentBeaconBlockRoot, h2.ParentBeaconBlockRoot) } - if !reflect.DeepEqual(h.RequestsRoot, h2.RequestsRoot) { - return fmt.Errorf("requestsRoot: want: %v have: %v", h.RequestsRoot, h2.RequestsRoot) + if !reflect.DeepEqual(h.RequestsHash, h2.RequestsHash) { + return fmt.Errorf("requestsHash: want: %v have: %v", h.RequestsHash, h2.RequestsHash) } return nil } diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go index 7d0a802b22b..5f30c22bff1 100644 --- a/tests/gen_btheader.go +++ b/tests/gen_btheader.go @@ -38,7 +38,7 @@ func (b btHeader) MarshalJSON() ([]byte, error) { BlobGasUsed *math.HexOrDecimal64 ExcessBlobGas *math.HexOrDecimal64 ParentBeaconBlockRoot *common.Hash - RequestsRoot *common.Hash + RequestsHash *common.Hash } var enc btHeader enc.Bloom = b.Bloom @@ -62,7 +62,7 @@ func (b btHeader) MarshalJSON() ([]byte, error) { enc.BlobGasUsed = (*math.HexOrDecimal64)(b.BlobGasUsed) enc.ExcessBlobGas = (*math.HexOrDecimal64)(b.ExcessBlobGas) enc.ParentBeaconBlockRoot = b.ParentBeaconBlockRoot - enc.RequestsRoot = b.RequestsRoot + enc.RequestsHash = b.RequestsHash return json.Marshal(&enc) } @@ -90,7 +90,7 @@ func (b *btHeader) UnmarshalJSON(input []byte) error { BlobGasUsed *math.HexOrDecimal64 ExcessBlobGas *math.HexOrDecimal64 ParentBeaconBlockRoot *common.Hash - RequestsRoot *common.Hash + RequestsHash *common.Hash } var dec btHeader if err := json.Unmarshal(input, &dec); err != nil { @@ -159,8 +159,8 @@ func (b *btHeader) UnmarshalJSON(input []byte) error { if dec.ParentBeaconBlockRoot != nil { b.ParentBeaconBlockRoot = dec.ParentBeaconBlockRoot } - if dec.RequestsRoot != nil { - b.RequestsRoot = dec.RequestsRoot + if dec.RequestsHash != nil { + b.RequestsHash = dec.RequestsHash } return nil } diff --git a/turbo/adapter/ethapi/api.go b/turbo/adapter/ethapi/api.go index 70e31e82d86..2e2c65d7f9b 100644 --- a/turbo/adapter/ethapi/api.go +++ b/turbo/adapter/ethapi/api.go @@ -303,8 +303,8 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} { if head.ParentBeaconBlockRoot != nil { result["parentBeaconBlockRoot"] = head.ParentBeaconBlockRoot } - if head.RequestsRoot != nil { - result["requestsRoot"] = head.RequestsRoot + if head.RequestsHash != nil { + result["requestsHash"] = head.RequestsHash } return result diff --git a/turbo/engineapi/engine_server.go b/turbo/engineapi/engine_server.go index b2945f027cb..c26b51ca4ad 100644 --- a/turbo/engineapi/engine_server.go +++ b/turbo/engineapi/engine_server.go @@ -188,7 +188,7 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi requests = append(requests, req.WithdrawalRequests.Requests()...) requests = append(requests, req.ConsolidationRequests.Requests()...) rh := types.DeriveSha(requests) - header.RequestsRoot = &rh + header.RequestsHash = &rh } if version <= clparams.CapellaVersion { diff --git a/turbo/engineapi/engine_types/jsonrpc.go b/turbo/engineapi/engine_types/jsonrpc.go index dd46c8b172f..e98c9401ca7 100644 --- a/turbo/engineapi/engine_types/jsonrpc.go +++ b/turbo/engineapi/engine_types/jsonrpc.go @@ -155,7 +155,7 @@ func ConvertRpcBlockToExecutionPayload(payload *execution.Block) *ExecutionPaylo excessBlobGas := *header.ExcessBlobGas res.ExcessBlobGas = (*hexutil.Uint64)(&excessBlobGas) } - if header.RequestsRoot != nil { + if header.RequestsHash != nil { reqs, _ := types.UnmarshalRequestsFromBinary(body.Requests) res.DepositRequests = reqs.Deposits() res.WithdrawalRequests = reqs.Withdrawals() diff --git a/turbo/execution/eth1/eth1_utils/grpc.go b/turbo/execution/eth1/eth1_utils/grpc.go index 7d59c32b7d3..ea973037708 100644 --- a/turbo/execution/eth1/eth1_utils/grpc.go +++ b/turbo/execution/eth1/eth1_utils/grpc.go @@ -57,8 +57,8 @@ func HeaderToHeaderRPC(header *types.Header) *execution.Header { h.ParentBeaconBlockRoot = gointerfaces.ConvertHashToH256(*header.ParentBeaconBlockRoot) } - if header.RequestsRoot != nil { - h.RequestsRoot = gointerfaces.ConvertHashToH256(*header.RequestsRoot) + if header.RequestsHash != nil { + h.RequestsHash = gointerfaces.ConvertHashToH256(*header.RequestsHash) } if len(header.AuRaSeal) > 0 { @@ -135,9 +135,9 @@ func HeaderRpcToHeader(header *execution.Header) (*types.Header, error) { h.ParentBeaconBlockRoot = new(libcommon.Hash) *h.ParentBeaconBlockRoot = gointerfaces.ConvertH256ToHash(header.ParentBeaconBlockRoot) } - if header.RequestsRoot != nil { - h.RequestsRoot = new(libcommon.Hash) - *h.RequestsRoot = gointerfaces.ConvertH256ToHash(header.RequestsRoot) + if header.RequestsHash != nil { + h.RequestsHash = new(libcommon.Hash) + *h.RequestsHash = gointerfaces.ConvertH256ToHash(header.RequestsHash) } blockHash := gointerfaces.ConvertH256ToHash(header.BlockHash) if blockHash != h.Hash() { diff --git a/turbo/stages/bodydownload/body_algos.go b/turbo/stages/bodydownload/body_algos.go index 88ab74db3be..0e7b1b20a5b 100644 --- a/turbo/stages/bodydownload/body_algos.go +++ b/turbo/stages/bodydownload/body_algos.go @@ -143,15 +143,15 @@ func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullB if request { if header.UncleHash == types.EmptyUncleHash && header.TxHash == types.EmptyRootHash && (header.WithdrawalsHash == nil || *header.WithdrawalsHash == types.EmptyRootHash) && - (header.RequestsRoot == nil || *header.RequestsRoot == types.EmptyRootHash) { + (header.RequestsHash == nil || *header.RequestsHash == types.EmptyRootHash) { // Empty block body body := &types.RawBody{} if header.WithdrawalsHash != nil { // implies *header.WithdrawalsHash == types.EmptyRootHash body.Withdrawals = make([]*types.Withdrawal, 0) } - if header.RequestsRoot != nil { - // implies *header.RequestsRoot == types.EmptyRootHash + if header.RequestsHash != nil { + // implies *header.RequestsHash == types.EmptyRootHash body.Requests = make(types.Requests, 0) } bd.addBodyToCache(blockNum, body) @@ -174,14 +174,14 @@ func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullB if header.WithdrawalsHash != nil { copy(bodyHashes[2*length.Hash:], header.WithdrawalsHash.Bytes()) } - if header.RequestsRoot != nil { - copy(bodyHashes[3*length.Hash:], header.RequestsRoot.Bytes()) + if header.RequestsHash != nil { + copy(bodyHashes[3*length.Hash:], header.RequestsHash.Bytes()) } bd.requestedMap[bodyHashes] = blockNum blockNums = append(blockNums, blockNum) hashes = append(hashes, hash) } else { - // uncleHash, txHash, withdrawalsHash, and requestsRoot are all empty (or block is prefetched), no need to request + // uncleHash, txHash, withdrawalsHash, and requestsHash are all empty (or block is prefetched), no need to request bd.delivered.Add(blockNum) } } @@ -319,8 +319,8 @@ Loop: copy(bodyHashes[2*length.Hash:], withdrawalsHash.Bytes()) } if requests[i] != nil { - requestsRoot := types.DeriveSha(requests[i]) - copy(bodyHashes[3*length.Hash:], requestsRoot.Bytes()) + requestsHash := types.DeriveSha(requests[i]) + copy(bodyHashes[3*length.Hash:], requestsHash.Bytes()) } // Block numbers are added to the bd.delivered bitmap here, only for blocks for which the body has been received, and their double hashes are present in the bd.requestedMap