@ -30,6 +30,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-verkle"
)
// A BlockNonce is a 64-bit hash which proves (combined with the
@ -59,6 +60,13 @@ func (n *BlockNonce) UnmarshalText(input []byte) error {
return hexutil . UnmarshalFixedText ( "BlockNonce" , input , n [ : ] )
}
// ExecutionWitness represents the witness + proof used in a verkle context,
// to provide the ability to execute a block statelessly.
type ExecutionWitness struct {
StateDiff verkle . StateDiff ` json:"stateDiff" `
VerkleProof * verkle . VerkleProof ` json:"verkleProof" `
}
//go:generate go run github.com/fjl/gencodec -type Header -field-override headerMarshaling -out gen_header_json.go
//go:generate go run ../../rlp/rlpgen -type Header -out gen_header_rlp.go
@ -197,6 +205,11 @@ type Block struct {
transactions Transactions
withdrawals Withdrawals
// witness is not an encoded part of the block body.
// It is held in Block in order for easy relaying to the places
// that process it.
witness * ExecutionWitness
// caches
hash atomic . Pointer [ common . Hash ]
size atomic . Uint64
@ -401,6 +414,9 @@ func (b *Block) BlobGasUsed() *uint64 {
return blobGasUsed
}
// ExecutionWitness returns the verkle execution witneess + proof for a block
func ( b * Block ) ExecutionWitness ( ) * ExecutionWitness { return b . witness }
// Size returns the true RLP encoded storage size of the block, either by encoding
// and returning it, or returning a previously cached value.
func ( b * Block ) Size ( ) uint64 {
@ -448,6 +464,7 @@ func (b *Block) WithSeal(header *Header) *Block {
transactions : b . transactions ,
uncles : b . uncles ,
withdrawals : b . withdrawals ,
witness : b . witness ,
}
}
@ -459,6 +476,7 @@ func (b *Block) WithBody(body Body) *Block {
transactions : slices . Clone ( body . Transactions ) ,
uncles : make ( [ ] * Header , len ( body . Uncles ) ) ,
withdrawals : slices . Clone ( body . Withdrawals ) ,
witness : b . witness ,
}
for i := range body . Uncles {
block . uncles [ i ] = CopyHeader ( body . Uncles [ i ] )
@ -466,6 +484,16 @@ func (b *Block) WithBody(body Body) *Block {
return block
}
func ( b * Block ) WithWitness ( witness * ExecutionWitness ) * Block {
return & Block {
header : b . header ,
transactions : b . transactions ,
uncles : b . uncles ,
withdrawals : b . withdrawals ,
witness : witness ,
}
}
// Hash returns the keccak256 hash of b's header.
// The hash is computed on the first call and cached thereafter.
func ( b * Block ) Hash ( ) common . Hash {