all: rename dataGas to blobGas (#27789)
This commit is contained in:
parent
0f4b21feac
commit
57268f7e6c
@ -32,8 +32,8 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
|
|||||||
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
|
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
|
||||||
Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"`
|
Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"`
|
||||||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||||
DataGasUsed *hexutil.Uint64 `json:"dataGasUsed"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||||
ExcessDataGas *hexutil.Uint64 `json:"excessDataGas"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||||
}
|
}
|
||||||
var enc ExecutableData
|
var enc ExecutableData
|
||||||
enc.ParentHash = e.ParentHash
|
enc.ParentHash = e.ParentHash
|
||||||
@ -56,8 +56,8 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
enc.Withdrawals = e.Withdrawals
|
enc.Withdrawals = e.Withdrawals
|
||||||
enc.DataGasUsed = (*hexutil.Uint64)(e.DataGasUsed)
|
enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed)
|
||||||
enc.ExcessDataGas = (*hexutil.Uint64)(e.ExcessDataGas)
|
enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas)
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +79,8 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
|
|||||||
BlockHash *common.Hash `json:"blockHash" gencodec:"required"`
|
BlockHash *common.Hash `json:"blockHash" gencodec:"required"`
|
||||||
Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"`
|
Transactions []hexutil.Bytes `json:"transactions" gencodec:"required"`
|
||||||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||||
DataGasUsed *hexutil.Uint64 `json:"dataGasUsed"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||||
ExcessDataGas *hexutil.Uint64 `json:"excessDataGas"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||||
}
|
}
|
||||||
var dec ExecutableData
|
var dec ExecutableData
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
@ -148,11 +148,11 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
|
|||||||
if dec.Withdrawals != nil {
|
if dec.Withdrawals != nil {
|
||||||
e.Withdrawals = dec.Withdrawals
|
e.Withdrawals = dec.Withdrawals
|
||||||
}
|
}
|
||||||
if dec.DataGasUsed != nil {
|
if dec.BlobGasUsed != nil {
|
||||||
e.DataGasUsed = (*uint64)(dec.DataGasUsed)
|
e.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
|
||||||
}
|
}
|
||||||
if dec.ExcessDataGas != nil {
|
if dec.ExcessBlobGas != nil {
|
||||||
e.ExcessDataGas = (*uint64)(dec.ExcessDataGas)
|
e.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,8 @@ type ExecutableData struct {
|
|||||||
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
|
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
|
||||||
Transactions [][]byte `json:"transactions" gencodec:"required"`
|
Transactions [][]byte `json:"transactions" gencodec:"required"`
|
||||||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||||
DataGasUsed *uint64 `json:"dataGasUsed"`
|
BlobGasUsed *uint64 `json:"blobGasUsed"`
|
||||||
ExcessDataGas *uint64 `json:"excessDataGas"`
|
ExcessBlobGas *uint64 `json:"excessBlobGas"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON type overrides for executableData.
|
// JSON type overrides for executableData.
|
||||||
@ -76,8 +76,8 @@ type executableDataMarshaling struct {
|
|||||||
ExtraData hexutil.Bytes
|
ExtraData hexutil.Bytes
|
||||||
LogsBloom hexutil.Bytes
|
LogsBloom hexutil.Bytes
|
||||||
Transactions []hexutil.Bytes
|
Transactions []hexutil.Bytes
|
||||||
DataGasUsed *hexutil.Uint64
|
BlobGasUsed *hexutil.Uint64
|
||||||
ExcessDataGas *hexutil.Uint64
|
ExcessBlobGas *hexutil.Uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go
|
//go:generate go run github.com/fjl/gencodec -type ExecutionPayloadEnvelope -field-override executionPayloadEnvelopeMarshaling -out gen_epe.go
|
||||||
@ -224,8 +224,8 @@ func ExecutableDataToBlock(params ExecutableData, versionedHashes []common.Hash)
|
|||||||
Extra: params.ExtraData,
|
Extra: params.ExtraData,
|
||||||
MixDigest: params.Random,
|
MixDigest: params.Random,
|
||||||
WithdrawalsHash: withdrawalsRoot,
|
WithdrawalsHash: withdrawalsRoot,
|
||||||
ExcessDataGas: params.ExcessDataGas,
|
ExcessBlobGas: params.ExcessBlobGas,
|
||||||
DataGasUsed: params.DataGasUsed,
|
BlobGasUsed: params.BlobGasUsed,
|
||||||
}
|
}
|
||||||
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */).WithWithdrawals(params.Withdrawals)
|
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */).WithWithdrawals(params.Withdrawals)
|
||||||
if block.Hash() != params.BlockHash {
|
if block.Hash() != params.BlockHash {
|
||||||
@ -253,8 +253,8 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, blobs []kzg4844.Bl
|
|||||||
Random: block.MixDigest(),
|
Random: block.MixDigest(),
|
||||||
ExtraData: block.Extra(),
|
ExtraData: block.Extra(),
|
||||||
Withdrawals: block.Withdrawals(),
|
Withdrawals: block.Withdrawals(),
|
||||||
DataGasUsed: block.DataGasUsed(),
|
BlobGasUsed: block.BlobGasUsed(),
|
||||||
ExcessDataGas: block.ExcessDataGas(),
|
ExcessBlobGas: block.ExcessBlobGas(),
|
||||||
}
|
}
|
||||||
blobsBundle := BlobsBundleV1{
|
blobsBundle := BlobsBundleV1{
|
||||||
Commitments: make([]hexutil.Bytes, 0),
|
Commitments: make([]hexutil.Bytes, 0),
|
||||||
|
@ -269,13 +269,13 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
|
|||||||
if !shanghai && header.WithdrawalsHash != nil {
|
if !shanghai && header.WithdrawalsHash != nil {
|
||||||
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
|
return fmt.Errorf("invalid withdrawalsHash: have %x, expected nil", header.WithdrawalsHash)
|
||||||
}
|
}
|
||||||
// Verify the existence / non-existence of excessDataGas
|
// Verify the existence / non-existence of excessBlobGas
|
||||||
cancun := chain.Config().IsCancun(header.Number, header.Time)
|
cancun := chain.Config().IsCancun(header.Number, header.Time)
|
||||||
if !cancun && header.ExcessDataGas != nil {
|
if !cancun && header.ExcessBlobGas != nil {
|
||||||
return fmt.Errorf("invalid excessDataGas: have %d, expected nil", header.ExcessDataGas)
|
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
|
||||||
}
|
}
|
||||||
if !cancun && header.DataGasUsed != nil {
|
if !cancun && header.BlobGasUsed != nil {
|
||||||
return fmt.Errorf("invalid dataGasUsed: have %d, expected nil", header.DataGasUsed)
|
return fmt.Errorf("invalid blobGasUsed: have %d, expected nil", header.BlobGasUsed)
|
||||||
}
|
}
|
||||||
if cancun {
|
if cancun {
|
||||||
if err := eip4844.VerifyEIP4844Header(parent, header); err != nil {
|
if err := eip4844.VerifyEIP4844Header(parent, header); err != nil {
|
||||||
|
@ -26,58 +26,58 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
minDataGasPrice = big.NewInt(params.BlobTxMinDataGasprice)
|
minBlobGasPrice = big.NewInt(params.BlobTxMinBlobGasprice)
|
||||||
dataGaspriceUpdateFraction = big.NewInt(params.BlobTxDataGaspriceUpdateFraction)
|
blobGaspriceUpdateFraction = big.NewInt(params.BlobTxBlobGaspriceUpdateFraction)
|
||||||
)
|
)
|
||||||
|
|
||||||
// VerifyEIP4844Header verifies the presence of the excessDataGas field and that
|
// VerifyEIP4844Header verifies the presence of the excessBlobGas field and that
|
||||||
// if the current block contains no transactions, the excessDataGas is updated
|
// if the current block contains no transactions, the excessBlobGas is updated
|
||||||
// accordingly.
|
// accordingly.
|
||||||
func VerifyEIP4844Header(parent, header *types.Header) error {
|
func VerifyEIP4844Header(parent, header *types.Header) error {
|
||||||
// Verify the header is not malformed
|
// Verify the header is not malformed
|
||||||
if header.ExcessDataGas == nil {
|
if header.ExcessBlobGas == nil {
|
||||||
return errors.New("header is missing excessDataGas")
|
return errors.New("header is missing excessBlobGas")
|
||||||
}
|
}
|
||||||
if header.DataGasUsed == nil {
|
if header.BlobGasUsed == nil {
|
||||||
return errors.New("header is missing dataGasUsed")
|
return errors.New("header is missing blobGasUsed")
|
||||||
}
|
}
|
||||||
// Verify that the data gas used remains within reasonable limits.
|
// Verify that the data gas used remains within reasonable limits.
|
||||||
if *header.DataGasUsed > params.BlobTxMaxDataGasPerBlock {
|
if *header.BlobGasUsed > params.BlobTxMaxBlobGasPerBlock {
|
||||||
return fmt.Errorf("data gas used %d exceeds maximum allowance %d", *header.DataGasUsed, params.BlobTxMaxDataGasPerBlock)
|
return fmt.Errorf("data gas used %d exceeds maximum allowance %d", *header.BlobGasUsed, params.BlobTxMaxBlobGasPerBlock)
|
||||||
}
|
}
|
||||||
if *header.DataGasUsed%params.BlobTxDataGasPerBlob != 0 {
|
if *header.BlobGasUsed%params.BlobTxBlobGasPerBlob != 0 {
|
||||||
return fmt.Errorf("data gas used %d not a multiple of data gas per blob %d", header.DataGasUsed, params.BlobTxDataGasPerBlob)
|
return fmt.Errorf("data gas used %d not a multiple of data gas per blob %d", header.BlobGasUsed, params.BlobTxBlobGasPerBlob)
|
||||||
}
|
}
|
||||||
// Verify the excessDataGas is correct based on the parent header
|
// Verify the excessBlobGas is correct based on the parent header
|
||||||
var (
|
var (
|
||||||
parentExcessDataGas uint64
|
parentExcessBlobGas uint64
|
||||||
parentDataGasUsed uint64
|
parentBlobGasUsed uint64
|
||||||
)
|
)
|
||||||
if parent.ExcessDataGas != nil {
|
if parent.ExcessBlobGas != nil {
|
||||||
parentExcessDataGas = *parent.ExcessDataGas
|
parentExcessBlobGas = *parent.ExcessBlobGas
|
||||||
parentDataGasUsed = *parent.DataGasUsed
|
parentBlobGasUsed = *parent.BlobGasUsed
|
||||||
}
|
}
|
||||||
expectedExcessDataGas := CalcExcessDataGas(parentExcessDataGas, parentDataGasUsed)
|
expectedExcessBlobGas := CalcExcessBlobGas(parentExcessBlobGas, parentBlobGasUsed)
|
||||||
if *header.ExcessDataGas != expectedExcessDataGas {
|
if *header.ExcessBlobGas != expectedExcessBlobGas {
|
||||||
return fmt.Errorf("invalid excessDataGas: have %d, want %d, parent excessDataGas %d, parent blobDataUsed %d",
|
return fmt.Errorf("invalid excessBlobGas: have %d, want %d, parent excessBlobGas %d, parent blobDataUsed %d",
|
||||||
*header.ExcessDataGas, expectedExcessDataGas, parentExcessDataGas, parentDataGasUsed)
|
*header.ExcessBlobGas, expectedExcessBlobGas, parentExcessBlobGas, parentBlobGasUsed)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalcExcessDataGas calculates the excess data gas after applying the set of
|
// CalcExcessBlobGas calculates the excess data gas after applying the set of
|
||||||
// blobs on top of the excess data gas.
|
// blobs on top of the excess data gas.
|
||||||
func CalcExcessDataGas(parentExcessDataGas uint64, parentDataGasUsed uint64) uint64 {
|
func CalcExcessBlobGas(parentExcessBlobGas uint64, parentBlobGasUsed uint64) uint64 {
|
||||||
excessDataGas := parentExcessDataGas + parentDataGasUsed
|
excessBlobGas := parentExcessBlobGas + parentBlobGasUsed
|
||||||
if excessDataGas < params.BlobTxTargetDataGasPerBlock {
|
if excessBlobGas < params.BlobTxTargetBlobGasPerBlock {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return excessDataGas - params.BlobTxTargetDataGasPerBlock
|
return excessBlobGas - params.BlobTxTargetBlobGasPerBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
// CalcBlobFee calculates the blobfee from the header's excess data gas field.
|
// CalcBlobFee calculates the blobfee from the header's excess data gas field.
|
||||||
func CalcBlobFee(excessDataGas uint64) *big.Int {
|
func CalcBlobFee(excessBlobGas uint64) *big.Int {
|
||||||
return fakeExponential(minDataGasPrice, new(big.Int).SetUint64(excessDataGas), dataGaspriceUpdateFraction)
|
return fakeExponential(minBlobGasPrice, new(big.Int).SetUint64(excessBlobGas), blobGaspriceUpdateFraction)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fakeExponential approximates factor * e ** (numerator / denominator) using
|
// fakeExponential approximates factor * e ** (numerator / denominator) using
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCalcExcessDataGas(t *testing.T) {
|
func TestCalcExcessBlobGas(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
excess uint64
|
excess uint64
|
||||||
blobs uint64
|
blobs uint64
|
||||||
@ -34,23 +34,23 @@ func TestCalcExcessDataGas(t *testing.T) {
|
|||||||
// slots are below - or equal - to the target.
|
// slots are below - or equal - to the target.
|
||||||
{0, 0, 0},
|
{0, 0, 0},
|
||||||
{0, 1, 0},
|
{0, 1, 0},
|
||||||
{0, params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob, 0},
|
{0, params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob, 0},
|
||||||
|
|
||||||
// If the target data gas is exceeded, the excessDataGas should increase
|
// If the target data gas is exceeded, the excessBlobGas should increase
|
||||||
// by however much it was overshot
|
// by however much it was overshot
|
||||||
{0, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 1, params.BlobTxDataGasPerBlob},
|
{0, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 1, params.BlobTxBlobGasPerBlob},
|
||||||
{1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 1, params.BlobTxDataGasPerBlob + 1},
|
{1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 1, params.BlobTxBlobGasPerBlob + 1},
|
||||||
{1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) + 2, 2*params.BlobTxDataGasPerBlob + 1},
|
{1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) + 2, 2*params.BlobTxBlobGasPerBlob + 1},
|
||||||
|
|
||||||
// The excess data gas should decrease by however much the target was
|
// The excess data gas should decrease by however much the target was
|
||||||
// under-shot, capped at zero.
|
// under-shot, capped at zero.
|
||||||
{params.BlobTxTargetDataGasPerBlock, params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob, params.BlobTxTargetDataGasPerBlock},
|
{params.BlobTxTargetBlobGasPerBlock, params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob, params.BlobTxTargetBlobGasPerBlock},
|
||||||
{params.BlobTxTargetDataGasPerBlock, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 1, params.BlobTxDataGasPerBlob},
|
{params.BlobTxTargetBlobGasPerBlock, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 1, params.BlobTxBlobGasPerBlob},
|
||||||
{params.BlobTxTargetDataGasPerBlock, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 2, 0},
|
{params.BlobTxTargetBlobGasPerBlock, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 2, 0},
|
||||||
{params.BlobTxDataGasPerBlob - 1, (params.BlobTxTargetDataGasPerBlock / params.BlobTxDataGasPerBlob) - 1, 0},
|
{params.BlobTxBlobGasPerBlob - 1, (params.BlobTxTargetBlobGasPerBlock / params.BlobTxBlobGasPerBlob) - 1, 0},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
result := CalcExcessDataGas(tt.excess, tt.blobs*params.BlobTxDataGasPerBlob)
|
result := CalcExcessBlobGas(tt.excess, tt.blobs*params.BlobTxBlobGasPerBlob)
|
||||||
if result != tt.want {
|
if result != tt.want {
|
||||||
t.Errorf("excess data gas mismatch: have %v, want %v", result, tt.want)
|
t.Errorf("excess data gas mismatch: have %v, want %v", result, tt.want)
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ func TestCalcExcessDataGas(t *testing.T) {
|
|||||||
|
|
||||||
func TestCalcBlobFee(t *testing.T) {
|
func TestCalcBlobFee(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
excessDataGas uint64
|
excessBlobGas uint64
|
||||||
blobfee int64
|
blobfee int64
|
||||||
}{
|
}{
|
||||||
{0, 1},
|
{0, 1},
|
||||||
@ -68,7 +68,7 @@ func TestCalcBlobFee(t *testing.T) {
|
|||||||
{10 * 1024 * 1024, 111},
|
{10 * 1024 * 1024, 111},
|
||||||
}
|
}
|
||||||
for i, tt := range tests {
|
for i, tt := range tests {
|
||||||
have := CalcBlobFee(tt.excessDataGas)
|
have := CalcBlobFee(tt.excessBlobGas)
|
||||||
if have.Int64() != tt.blobfee {
|
if have.Int64() != tt.blobfee {
|
||||||
t.Errorf("test %d: blobfee mismatch: have %v want %v", i, have, tt.blobfee)
|
t.Errorf("test %d: blobfee mismatch: have %v want %v", i, have, tt.blobfee)
|
||||||
}
|
}
|
||||||
|
@ -84,14 +84,14 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
|||||||
// Blob transactions may be present after the Cancun fork.
|
// Blob transactions may be present after the Cancun fork.
|
||||||
var blobs int
|
var blobs int
|
||||||
for _, tx := range block.Transactions() {
|
for _, tx := range block.Transactions() {
|
||||||
// Count the number of blobs to validate against the header's dataGasUsed
|
// Count the number of blobs to validate against the header's blobGasUsed
|
||||||
blobs += len(tx.BlobHashes())
|
blobs += len(tx.BlobHashes())
|
||||||
// The individual checks for blob validity (version-check + not empty)
|
// The individual checks for blob validity (version-check + not empty)
|
||||||
// happens in the state_transition check.
|
// happens in the state_transition check.
|
||||||
}
|
}
|
||||||
if header.DataGasUsed != nil {
|
if header.BlobGasUsed != nil {
|
||||||
if want := *header.DataGasUsed / params.BlobTxDataGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated
|
if want := *header.BlobGasUsed / params.BlobTxBlobGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated
|
||||||
return fmt.Errorf("data gas used mismatch (header %v, calculated %v)", *header.DataGasUsed, blobs*params.BlobTxDataGasPerBlob)
|
return fmt.Errorf("data gas used mismatch (header %v, calculated %v)", *header.BlobGasUsed, blobs*params.BlobTxBlobGasPerBlob)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if blobs > 0 {
|
if blobs > 0 {
|
||||||
|
@ -2028,17 +2028,15 @@ func (bc *BlockChain) recoverAncestors(block *types.Block) (common.Hash, error)
|
|||||||
// collectLogs collects the logs that were generated or removed during
|
// collectLogs collects the logs that were generated or removed during
|
||||||
// the processing of a block. These logs are later announced as deleted or reborn.
|
// the processing of a block. These logs are later announced as deleted or reborn.
|
||||||
func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log {
|
func (bc *BlockChain) collectLogs(b *types.Block, removed bool) []*types.Log {
|
||||||
var dataGasPrice *big.Int
|
var blobGasPrice *big.Int
|
||||||
excessDataGas := b.ExcessDataGas()
|
excessBlobGas := b.ExcessBlobGas()
|
||||||
if excessDataGas != nil {
|
if excessBlobGas != nil {
|
||||||
dataGasPrice = eip4844.CalcBlobFee(*excessDataGas)
|
blobGasPrice = eip4844.CalcBlobFee(*excessBlobGas)
|
||||||
}
|
}
|
||||||
|
|
||||||
receipts := rawdb.ReadRawReceipts(bc.db, b.Hash(), b.NumberU64())
|
receipts := rawdb.ReadRawReceipts(bc.db, b.Hash(), b.NumberU64())
|
||||||
if err := receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Time(), b.BaseFee(), dataGasPrice, b.Transactions()); err != nil {
|
if err := receipts.DeriveFields(bc.chainConfig, b.Hash(), b.NumberU64(), b.Time(), b.BaseFee(), blobGasPrice, b.Transactions()); err != nil {
|
||||||
log.Error("Failed to derive block receipts fields", "hash", b.Hash(), "number", b.NumberU64(), "err", err)
|
log.Error("Failed to derive block receipts fields", "hash", b.Hash(), "number", b.NumberU64(), "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var logs []*types.Log
|
var logs []*types.Log
|
||||||
for _, receipt := range receipts {
|
for _, receipt := range receipts {
|
||||||
for _, log := range receipt.Logs {
|
for _, log := range receipt.Logs {
|
||||||
|
@ -66,7 +66,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
|
|||||||
BaseFee: baseFee,
|
BaseFee: baseFee,
|
||||||
GasLimit: header.GasLimit,
|
GasLimit: header.GasLimit,
|
||||||
Random: random,
|
Random: random,
|
||||||
ExcessDataGas: header.ExcessDataGas,
|
ExcessBlobGas: header.ExcessBlobGas,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
|
|||||||
GasUsed math.HexOrDecimal64 `json:"gasUsed"`
|
GasUsed math.HexOrDecimal64 `json:"gasUsed"`
|
||||||
ParentHash common.Hash `json:"parentHash"`
|
ParentHash common.Hash `json:"parentHash"`
|
||||||
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
||||||
ExcessDataGas *math.HexOrDecimal64 `json:"excessDataGas"`
|
ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"`
|
||||||
DataGasUsed *math.HexOrDecimal64 `json:"dataGasUsed"`
|
BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"`
|
||||||
}
|
}
|
||||||
var enc Genesis
|
var enc Genesis
|
||||||
enc.Config = g.Config
|
enc.Config = g.Config
|
||||||
@ -53,8 +53,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
|
|||||||
enc.GasUsed = math.HexOrDecimal64(g.GasUsed)
|
enc.GasUsed = math.HexOrDecimal64(g.GasUsed)
|
||||||
enc.ParentHash = g.ParentHash
|
enc.ParentHash = g.ParentHash
|
||||||
enc.BaseFee = (*math.HexOrDecimal256)(g.BaseFee)
|
enc.BaseFee = (*math.HexOrDecimal256)(g.BaseFee)
|
||||||
enc.ExcessDataGas = (*math.HexOrDecimal64)(g.ExcessDataGas)
|
enc.ExcessBlobGas = (*math.HexOrDecimal64)(g.ExcessBlobGas)
|
||||||
enc.DataGasUsed = (*math.HexOrDecimal64)(g.DataGasUsed)
|
enc.BlobGasUsed = (*math.HexOrDecimal64)(g.BlobGasUsed)
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +74,8 @@ func (g *Genesis) UnmarshalJSON(input []byte) error {
|
|||||||
GasUsed *math.HexOrDecimal64 `json:"gasUsed"`
|
GasUsed *math.HexOrDecimal64 `json:"gasUsed"`
|
||||||
ParentHash *common.Hash `json:"parentHash"`
|
ParentHash *common.Hash `json:"parentHash"`
|
||||||
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
||||||
ExcessDataGas *math.HexOrDecimal64 `json:"excessDataGas"`
|
ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"`
|
||||||
DataGasUsed *math.HexOrDecimal64 `json:"dataGasUsed"`
|
BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"`
|
||||||
}
|
}
|
||||||
var dec Genesis
|
var dec Genesis
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
@ -126,11 +126,11 @@ func (g *Genesis) UnmarshalJSON(input []byte) error {
|
|||||||
if dec.BaseFee != nil {
|
if dec.BaseFee != nil {
|
||||||
g.BaseFee = (*big.Int)(dec.BaseFee)
|
g.BaseFee = (*big.Int)(dec.BaseFee)
|
||||||
}
|
}
|
||||||
if dec.ExcessDataGas != nil {
|
if dec.ExcessBlobGas != nil {
|
||||||
g.ExcessDataGas = (*uint64)(dec.ExcessDataGas)
|
g.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
||||||
}
|
}
|
||||||
if dec.DataGasUsed != nil {
|
if dec.BlobGasUsed != nil {
|
||||||
g.DataGasUsed = (*uint64)(dec.DataGasUsed)
|
g.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -63,8 +63,8 @@ type Genesis struct {
|
|||||||
GasUsed uint64 `json:"gasUsed"`
|
GasUsed uint64 `json:"gasUsed"`
|
||||||
ParentHash common.Hash `json:"parentHash"`
|
ParentHash common.Hash `json:"parentHash"`
|
||||||
BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559
|
BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559
|
||||||
ExcessDataGas *uint64 `json:"excessDataGas"` // EIP-4844
|
ExcessBlobGas *uint64 `json:"excessBlobGas"` // EIP-4844
|
||||||
DataGasUsed *uint64 `json:"dataGasUsed"` // EIP-4844
|
BlobGasUsed *uint64 `json:"blobGasUsed"` // EIP-4844
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadGenesis(db ethdb.Database) (*Genesis, error) {
|
func ReadGenesis(db ethdb.Database) (*Genesis, error) {
|
||||||
@ -99,8 +99,8 @@ func ReadGenesis(db ethdb.Database) (*Genesis, error) {
|
|||||||
genesis.Mixhash = genesisHeader.MixDigest
|
genesis.Mixhash = genesisHeader.MixDigest
|
||||||
genesis.Coinbase = genesisHeader.Coinbase
|
genesis.Coinbase = genesisHeader.Coinbase
|
||||||
genesis.BaseFee = genesisHeader.BaseFee
|
genesis.BaseFee = genesisHeader.BaseFee
|
||||||
genesis.ExcessDataGas = genesisHeader.ExcessDataGas
|
genesis.ExcessBlobGas = genesisHeader.ExcessBlobGas
|
||||||
genesis.DataGasUsed = genesisHeader.DataGasUsed
|
genesis.BlobGasUsed = genesisHeader.BlobGasUsed
|
||||||
|
|
||||||
return &genesis, nil
|
return &genesis, nil
|
||||||
}
|
}
|
||||||
@ -228,8 +228,8 @@ type genesisSpecMarshaling struct {
|
|||||||
Difficulty *math.HexOrDecimal256
|
Difficulty *math.HexOrDecimal256
|
||||||
Alloc map[common.UnprefixedAddress]GenesisAccount
|
Alloc map[common.UnprefixedAddress]GenesisAccount
|
||||||
BaseFee *math.HexOrDecimal256
|
BaseFee *math.HexOrDecimal256
|
||||||
ExcessDataGas *math.HexOrDecimal64
|
ExcessBlobGas *math.HexOrDecimal64
|
||||||
DataGasUsed *math.HexOrDecimal64
|
BlobGasUsed *math.HexOrDecimal64
|
||||||
}
|
}
|
||||||
|
|
||||||
type genesisAccountMarshaling struct {
|
type genesisAccountMarshaling struct {
|
||||||
@ -477,13 +477,13 @@ func (g *Genesis) ToBlock() *types.Block {
|
|||||||
withdrawals = make([]*types.Withdrawal, 0)
|
withdrawals = make([]*types.Withdrawal, 0)
|
||||||
}
|
}
|
||||||
if conf.IsCancun(num, g.Timestamp) {
|
if conf.IsCancun(num, g.Timestamp) {
|
||||||
head.ExcessDataGas = g.ExcessDataGas
|
head.ExcessBlobGas = g.ExcessBlobGas
|
||||||
head.DataGasUsed = g.DataGasUsed
|
head.BlobGasUsed = g.BlobGasUsed
|
||||||
if head.ExcessDataGas == nil {
|
if head.ExcessBlobGas == nil {
|
||||||
head.ExcessDataGas = new(uint64)
|
head.ExcessBlobGas = new(uint64)
|
||||||
}
|
}
|
||||||
if head.DataGasUsed == nil {
|
if head.BlobGasUsed == nil {
|
||||||
head.DataGasUsed = new(uint64)
|
head.BlobGasUsed = new(uint64)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -645,14 +645,12 @@ func ReadReceipts(db ethdb.Reader, hash common.Hash, number uint64, time uint64,
|
|||||||
} else {
|
} else {
|
||||||
baseFee = header.BaseFee
|
baseFee = header.BaseFee
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute effective data gas price.
|
// Compute effective data gas price.
|
||||||
var dataGasPrice *big.Int
|
var blobGasPrice *big.Int
|
||||||
if header != nil && header.ExcessDataGas != nil {
|
if header != nil && header.ExcessBlobGas != nil {
|
||||||
dataGasPrice = eip4844.CalcBlobFee(*header.ExcessDataGas)
|
blobGasPrice = eip4844.CalcBlobFee(*header.ExcessBlobGas)
|
||||||
}
|
}
|
||||||
|
if err := receipts.DeriveFields(config, hash, number, time, baseFee, blobGasPrice, body.Transactions); err != nil {
|
||||||
if err := receipts.DeriveFields(config, hash, number, time, baseFee, dataGasPrice, body.Transactions); err != nil {
|
|
||||||
log.Error("Failed to derive block receipts fields", "hash", hash, "number", number, "err", err)
|
log.Error("Failed to derive block receipts fields", "hash", hash, "number", number, "err", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -402,14 +402,14 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
|
|||||||
header.Root = common.BytesToHash(hasher.Sum(nil))
|
header.Root = common.BytesToHash(hasher.Sum(nil))
|
||||||
if config.IsCancun(header.Number, header.Time) {
|
if config.IsCancun(header.Number, header.Time) {
|
||||||
var pExcess, pUsed = uint64(0), uint64(0)
|
var pExcess, pUsed = uint64(0), uint64(0)
|
||||||
if parent.ExcessDataGas() != nil {
|
if parent.ExcessBlobGas() != nil {
|
||||||
pExcess = *parent.ExcessDataGas()
|
pExcess = *parent.ExcessBlobGas()
|
||||||
pUsed = *parent.DataGasUsed()
|
pUsed = *parent.BlobGasUsed()
|
||||||
}
|
}
|
||||||
excess := eip4844.CalcExcessDataGas(pExcess, pUsed)
|
excess := eip4844.CalcExcessBlobGas(pExcess, pUsed)
|
||||||
used := uint64(nBlobs * params.BlobTxDataGasPerBlob)
|
used := uint64(nBlobs * params.BlobTxBlobGasPerBlob)
|
||||||
header.ExcessDataGas = &excess
|
header.ExcessBlobGas = &excess
|
||||||
header.DataGasUsed = &used
|
header.BlobGasUsed = &used
|
||||||
}
|
}
|
||||||
// Assemble and return the final block for sealing
|
// Assemble and return the final block for sealing
|
||||||
if config.IsShanghai(header.Number, header.Time) {
|
if config.IsShanghai(header.Number, header.Time) {
|
||||||
|
@ -241,18 +241,18 @@ func (st *StateTransition) buyGas() error {
|
|||||||
balanceCheck.Add(balanceCheck, st.msg.Value)
|
balanceCheck.Add(balanceCheck, st.msg.Value)
|
||||||
}
|
}
|
||||||
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
||||||
if dataGas := st.dataGasUsed(); dataGas > 0 {
|
if blobGas := st.blobGasUsed(); blobGas > 0 {
|
||||||
if st.evm.Context.ExcessDataGas == nil {
|
if st.evm.Context.ExcessBlobGas == nil {
|
||||||
// programming error
|
// programming error
|
||||||
panic("missing field excess data gas")
|
panic("missing field excess data gas")
|
||||||
}
|
}
|
||||||
// Check that the user has enough funds to cover dataGasUsed * tx.BlobGasFeeCap
|
// Check that the user has enough funds to cover blobGasUsed * tx.BlobGasFeeCap
|
||||||
blobBalanceCheck := new(big.Int).SetUint64(dataGas)
|
blobBalanceCheck := new(big.Int).SetUint64(blobGas)
|
||||||
blobBalanceCheck.Mul(blobBalanceCheck, st.msg.BlobGasFeeCap)
|
blobBalanceCheck.Mul(blobBalanceCheck, st.msg.BlobGasFeeCap)
|
||||||
balanceCheck.Add(balanceCheck, blobBalanceCheck)
|
balanceCheck.Add(balanceCheck, blobBalanceCheck)
|
||||||
// Pay for dataGasUsed * actual blob fee
|
// Pay for blobGasUsed * actual blob fee
|
||||||
blobFee := new(big.Int).SetUint64(dataGas)
|
blobFee := new(big.Int).SetUint64(blobGas)
|
||||||
blobFee.Mul(blobFee, eip4844.CalcBlobFee(*st.evm.Context.ExcessDataGas))
|
blobFee.Mul(blobFee, eip4844.CalcBlobFee(*st.evm.Context.ExcessBlobGas))
|
||||||
mgval.Add(mgval, blobFee)
|
mgval.Add(mgval, blobFee)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -331,9 +331,9 @@ func (st *StateTransition) preCheck() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
if st.evm.ChainConfig().IsCancun(st.evm.Context.BlockNumber, st.evm.Context.Time) {
|
||||||
if st.dataGasUsed() > 0 {
|
if st.blobGasUsed() > 0 {
|
||||||
// Check that the user is paying at least the current blob fee
|
// Check that the user is paying at least the current blob fee
|
||||||
blobFee := eip4844.CalcBlobFee(*st.evm.Context.ExcessDataGas)
|
blobFee := eip4844.CalcBlobFee(*st.evm.Context.ExcessBlobGas)
|
||||||
if st.msg.BlobGasFeeCap.Cmp(blobFee) < 0 {
|
if st.msg.BlobGasFeeCap.Cmp(blobFee) < 0 {
|
||||||
return fmt.Errorf("%w: address %v have %v want %v", ErrBlobFeeCapTooLow, st.msg.From.Hex(), st.msg.BlobGasFeeCap, blobFee)
|
return fmt.Errorf("%w: address %v have %v want %v", ErrBlobFeeCapTooLow, st.msg.From.Hex(), st.msg.BlobGasFeeCap, blobFee)
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ func (st *StateTransition) gasUsed() uint64 {
|
|||||||
return st.initialGas - st.gasRemaining
|
return st.initialGas - st.gasRemaining
|
||||||
}
|
}
|
||||||
|
|
||||||
// dataGasUsed returns the amount of data gas used by the message.
|
// blobGasUsed returns the amount of data gas used by the message.
|
||||||
func (st *StateTransition) dataGasUsed() uint64 {
|
func (st *StateTransition) blobGasUsed() uint64 {
|
||||||
return uint64(len(st.msg.BlobHashes) * params.BlobTxDataGasPerBlob)
|
return uint64(len(st.msg.BlobHashes) * params.BlobTxBlobGasPerBlob)
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ const (
|
|||||||
// maxBlobsPerTransaction is the maximum number of blobs a single transaction
|
// maxBlobsPerTransaction is the maximum number of blobs a single transaction
|
||||||
// is allowed to contain. Whilst the spec states it's unlimited, the block
|
// is allowed to contain. Whilst the spec states it's unlimited, the block
|
||||||
// data slots are protocol bound, which implicitly also limit this.
|
// data slots are protocol bound, which implicitly also limit this.
|
||||||
maxBlobsPerTransaction = params.BlobTxMaxDataGasPerBlock / params.BlobTxDataGasPerBlob
|
maxBlobsPerTransaction = params.BlobTxMaxBlobGasPerBlock / params.BlobTxBlobGasPerBlob
|
||||||
|
|
||||||
// txAvgSize is an approximate byte size of a transaction metadata to avoid
|
// txAvgSize is an approximate byte size of a transaction metadata to avoid
|
||||||
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
|
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
|
||||||
@ -400,10 +400,10 @@ func (p *BlobPool) Init(gasTip *big.Int, head *types.Header, reserve txpool.Addr
|
|||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
basefee = uint256.MustFromBig(misc.CalcBaseFee(p.chain.Config(), p.head))
|
basefee = uint256.MustFromBig(misc.CalcBaseFee(p.chain.Config(), p.head))
|
||||||
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinDataGasprice))
|
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
|
||||||
)
|
)
|
||||||
if p.head.ExcessDataGas != nil {
|
if p.head.ExcessBlobGas != nil {
|
||||||
blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*p.head.ExcessDataGas))
|
blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*p.head.ExcessBlobGas))
|
||||||
}
|
}
|
||||||
p.evict = newPriceHeap(basefee, blobfee, &p.index)
|
p.evict = newPriceHeap(basefee, blobfee, &p.index)
|
||||||
|
|
||||||
@ -773,10 +773,10 @@ func (p *BlobPool) Reset(oldHead, newHead *types.Header) {
|
|||||||
// Reset the price heap for the new set of basefee/blobfee pairs
|
// Reset the price heap for the new set of basefee/blobfee pairs
|
||||||
var (
|
var (
|
||||||
basefee = uint256.MustFromBig(misc.CalcBaseFee(p.chain.Config(), newHead))
|
basefee = uint256.MustFromBig(misc.CalcBaseFee(p.chain.Config(), newHead))
|
||||||
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinDataGasprice))
|
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
|
||||||
)
|
)
|
||||||
if newHead.ExcessDataGas != nil {
|
if newHead.ExcessBlobGas != nil {
|
||||||
blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*newHead.ExcessDataGas))
|
blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*newHead.ExcessBlobGas))
|
||||||
}
|
}
|
||||||
p.evict.reinit(basefee, blobfee, false)
|
p.evict.reinit(basefee, blobfee, false)
|
||||||
|
|
||||||
|
@ -137,14 +137,14 @@ func (bc *testBlockChain) CurrentBlock() *types.Header {
|
|||||||
lo = mid
|
lo = mid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
excessDataGas := lo.Uint64()
|
excessBlobGas := lo.Uint64()
|
||||||
|
|
||||||
return &types.Header{
|
return &types.Header{
|
||||||
Number: blockNumber,
|
Number: blockNumber,
|
||||||
Time: blockTime,
|
Time: blockTime,
|
||||||
GasLimit: gasLimit,
|
GasLimit: gasLimit,
|
||||||
BaseFee: baseFee,
|
BaseFee: baseFee,
|
||||||
ExcessDataGas: &excessDataGas,
|
ExcessBlobGas: &excessBlobGas,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ func TestOpenDrops(t *testing.T) {
|
|||||||
chain := &testBlockChain{
|
chain := &testBlockChain{
|
||||||
config: testChainConfig,
|
config: testChainConfig,
|
||||||
basefee: uint256.NewInt(params.InitialBaseFee),
|
basefee: uint256.NewInt(params.InitialBaseFee),
|
||||||
blobfee: uint256.NewInt(params.BlobTxMinDataGasprice),
|
blobfee: uint256.NewInt(params.BlobTxMinBlobGasprice),
|
||||||
statedb: statedb,
|
statedb: statedb,
|
||||||
}
|
}
|
||||||
pool := New(Config{Datadir: storage}, chain)
|
pool := New(Config{Datadir: storage}, chain)
|
||||||
@ -638,7 +638,7 @@ func TestOpenIndex(t *testing.T) {
|
|||||||
chain := &testBlockChain{
|
chain := &testBlockChain{
|
||||||
config: testChainConfig,
|
config: testChainConfig,
|
||||||
basefee: uint256.NewInt(params.InitialBaseFee),
|
basefee: uint256.NewInt(params.InitialBaseFee),
|
||||||
blobfee: uint256.NewInt(params.BlobTxMinDataGasprice),
|
blobfee: uint256.NewInt(params.BlobTxMinBlobGasprice),
|
||||||
statedb: statedb,
|
statedb: statedb,
|
||||||
}
|
}
|
||||||
pool := New(Config{Datadir: storage}, chain)
|
pool := New(Config{Datadir: storage}, chain)
|
||||||
|
@ -116,8 +116,8 @@ func ValidateTransaction(tx *types.Transaction, blobs []kzg4844.Blob, commits []
|
|||||||
if len(hashes) == 0 {
|
if len(hashes) == 0 {
|
||||||
return fmt.Errorf("blobless blob transaction")
|
return fmt.Errorf("blobless blob transaction")
|
||||||
}
|
}
|
||||||
if len(hashes) > params.BlobTxMaxDataGasPerBlock/params.BlobTxDataGasPerBlob {
|
if len(hashes) > params.BlobTxMaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob {
|
||||||
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.BlobTxMaxDataGasPerBlock/params.BlobTxDataGasPerBlob)
|
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.BlobTxMaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob)
|
||||||
}
|
}
|
||||||
if len(blobs) != len(hashes) {
|
if len(blobs) != len(hashes) {
|
||||||
return fmt.Errorf("invalid number of %d blobs compared to %d blob hashes", len(blobs), len(hashes))
|
return fmt.Errorf("invalid number of %d blobs compared to %d blob hashes", len(blobs), len(hashes))
|
||||||
|
@ -85,11 +85,11 @@ type Header struct {
|
|||||||
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
|
// WithdrawalsHash was added by EIP-4895 and is ignored in legacy headers.
|
||||||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||||
|
|
||||||
// ExcessDataGas was added by EIP-4844 and is ignored in legacy headers.
|
// ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers.
|
||||||
ExcessDataGas *uint64 `json:"excessDataGas" rlp:"optional"`
|
ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||||
|
|
||||||
// DataGasUsed was added by EIP-4844 and is ignored in legacy headers.
|
// BlobGasUsed was added by EIP-4844 and is ignored in legacy headers.
|
||||||
DataGasUsed *uint64 `json:"dataGasUsed" rlp:"optional"`
|
BlobGasUsed *uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// field type overrides for gencodec
|
// field type overrides for gencodec
|
||||||
@ -102,8 +102,8 @@ type headerMarshaling struct {
|
|||||||
Extra hexutil.Bytes
|
Extra hexutil.Bytes
|
||||||
BaseFee *hexutil.Big
|
BaseFee *hexutil.Big
|
||||||
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
|
Hash common.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
|
||||||
ExcessDataGas *hexutil.Uint64
|
ExcessBlobGas *hexutil.Uint64
|
||||||
DataGasUsed *hexutil.Uint64
|
BlobGasUsed *hexutil.Uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hash returns the block hash of the header, which is simply the keccak256 hash of its
|
// Hash returns the block hash of the header, which is simply the keccak256 hash of its
|
||||||
@ -284,13 +284,13 @@ func CopyHeader(h *Header) *Header {
|
|||||||
cpy.WithdrawalsHash = new(common.Hash)
|
cpy.WithdrawalsHash = new(common.Hash)
|
||||||
*cpy.WithdrawalsHash = *h.WithdrawalsHash
|
*cpy.WithdrawalsHash = *h.WithdrawalsHash
|
||||||
}
|
}
|
||||||
if h.ExcessDataGas != nil {
|
if h.ExcessBlobGas != nil {
|
||||||
cpy.ExcessDataGas = new(uint64)
|
cpy.ExcessBlobGas = new(uint64)
|
||||||
*cpy.ExcessDataGas = *h.ExcessDataGas
|
*cpy.ExcessBlobGas = *h.ExcessBlobGas
|
||||||
}
|
}
|
||||||
if h.DataGasUsed != nil {
|
if h.BlobGasUsed != nil {
|
||||||
cpy.DataGasUsed = new(uint64)
|
cpy.BlobGasUsed = new(uint64)
|
||||||
*cpy.DataGasUsed = *h.DataGasUsed
|
*cpy.BlobGasUsed = *h.BlobGasUsed
|
||||||
}
|
}
|
||||||
return &cpy
|
return &cpy
|
||||||
}
|
}
|
||||||
@ -360,22 +360,22 @@ func (b *Block) Withdrawals() Withdrawals {
|
|||||||
return b.withdrawals
|
return b.withdrawals
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) ExcessDataGas() *uint64 {
|
func (b *Block) ExcessBlobGas() *uint64 {
|
||||||
var excessDataGas *uint64
|
var excessBlobGas *uint64
|
||||||
if b.header.ExcessDataGas != nil {
|
if b.header.ExcessBlobGas != nil {
|
||||||
excessDataGas = new(uint64)
|
excessBlobGas = new(uint64)
|
||||||
*excessDataGas = *b.header.ExcessDataGas
|
*excessBlobGas = *b.header.ExcessBlobGas
|
||||||
}
|
}
|
||||||
return excessDataGas
|
return excessBlobGas
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) DataGasUsed() *uint64 {
|
func (b *Block) BlobGasUsed() *uint64 {
|
||||||
var dataGasUsed *uint64
|
var blobGasUsed *uint64
|
||||||
if b.header.DataGasUsed != nil {
|
if b.header.BlobGasUsed != nil {
|
||||||
dataGasUsed = new(uint64)
|
blobGasUsed = new(uint64)
|
||||||
*dataGasUsed = *b.header.DataGasUsed
|
*blobGasUsed = *b.header.BlobGasUsed
|
||||||
}
|
}
|
||||||
return dataGasUsed
|
return blobGasUsed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Block) Header() *Header { return CopyHeader(b.header) }
|
func (b *Block) Header() *Header { return CopyHeader(b.header) }
|
||||||
|
@ -33,8 +33,8 @@ func (h Header) MarshalJSON() ([]byte, error) {
|
|||||||
Nonce BlockNonce `json:"nonce"`
|
Nonce BlockNonce `json:"nonce"`
|
||||||
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
||||||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||||
ExcessDataGas *hexutil.Uint64 `json:"excessDataGas" rlp:"optional"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||||
DataGasUsed *hexutil.Uint64 `json:"dataGasUsed" rlp:"optional"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||||
Hash common.Hash `json:"hash"`
|
Hash common.Hash `json:"hash"`
|
||||||
}
|
}
|
||||||
var enc Header
|
var enc Header
|
||||||
@ -55,8 +55,8 @@ func (h Header) MarshalJSON() ([]byte, error) {
|
|||||||
enc.Nonce = h.Nonce
|
enc.Nonce = h.Nonce
|
||||||
enc.BaseFee = (*hexutil.Big)(h.BaseFee)
|
enc.BaseFee = (*hexutil.Big)(h.BaseFee)
|
||||||
enc.WithdrawalsHash = h.WithdrawalsHash
|
enc.WithdrawalsHash = h.WithdrawalsHash
|
||||||
enc.ExcessDataGas = (*hexutil.Uint64)(h.ExcessDataGas)
|
enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas)
|
||||||
enc.DataGasUsed = (*hexutil.Uint64)(h.DataGasUsed)
|
enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed)
|
||||||
enc.Hash = h.Hash()
|
enc.Hash = h.Hash()
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
@ -81,8 +81,8 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
|||||||
Nonce *BlockNonce `json:"nonce"`
|
Nonce *BlockNonce `json:"nonce"`
|
||||||
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
BaseFee *hexutil.Big `json:"baseFeePerGas" rlp:"optional"`
|
||||||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||||
ExcessDataGas *hexutil.Uint64 `json:"excessDataGas" rlp:"optional"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||||
DataGasUsed *hexutil.Uint64 `json:"dataGasUsed" rlp:"optional"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||||
}
|
}
|
||||||
var dec Header
|
var dec Header
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
@ -151,11 +151,11 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
|||||||
if dec.WithdrawalsHash != nil {
|
if dec.WithdrawalsHash != nil {
|
||||||
h.WithdrawalsHash = dec.WithdrawalsHash
|
h.WithdrawalsHash = dec.WithdrawalsHash
|
||||||
}
|
}
|
||||||
if dec.ExcessDataGas != nil {
|
if dec.ExcessBlobGas != nil {
|
||||||
h.ExcessDataGas = (*uint64)(dec.ExcessDataGas)
|
h.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
||||||
}
|
}
|
||||||
if dec.DataGasUsed != nil {
|
if dec.BlobGasUsed != nil {
|
||||||
h.DataGasUsed = (*uint64)(dec.DataGasUsed)
|
h.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
|
|||||||
w.WriteBytes(obj.Nonce[:])
|
w.WriteBytes(obj.Nonce[:])
|
||||||
_tmp1 := obj.BaseFee != nil
|
_tmp1 := obj.BaseFee != nil
|
||||||
_tmp2 := obj.WithdrawalsHash != nil
|
_tmp2 := obj.WithdrawalsHash != nil
|
||||||
_tmp3 := obj.ExcessDataGas != nil
|
_tmp3 := obj.ExcessBlobGas != nil
|
||||||
_tmp4 := obj.DataGasUsed != nil
|
_tmp4 := obj.BlobGasUsed != nil
|
||||||
if _tmp1 || _tmp2 || _tmp3 || _tmp4 {
|
if _tmp1 || _tmp2 || _tmp3 || _tmp4 {
|
||||||
if obj.BaseFee == nil {
|
if obj.BaseFee == nil {
|
||||||
w.Write(rlp.EmptyString)
|
w.Write(rlp.EmptyString)
|
||||||
@ -62,17 +62,17 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _tmp3 || _tmp4 {
|
if _tmp3 || _tmp4 {
|
||||||
if obj.ExcessDataGas == nil {
|
if obj.ExcessBlobGas == nil {
|
||||||
w.Write([]byte{0x80})
|
w.Write([]byte{0x80})
|
||||||
} else {
|
} else {
|
||||||
w.WriteUint64((*obj.ExcessDataGas))
|
w.WriteUint64((*obj.ExcessBlobGas))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _tmp4 {
|
if _tmp4 {
|
||||||
if obj.DataGasUsed == nil {
|
if obj.BlobGasUsed == nil {
|
||||||
w.Write([]byte{0x80})
|
w.Write([]byte{0x80})
|
||||||
} else {
|
} else {
|
||||||
w.WriteUint64((*obj.DataGasUsed))
|
w.WriteUint64((*obj.BlobGasUsed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.ListEnd(_tmp0)
|
w.ListEnd(_tmp0)
|
||||||
|
@ -26,8 +26,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
|
|||||||
ContractAddress common.Address `json:"contractAddress"`
|
ContractAddress common.Address `json:"contractAddress"`
|
||||||
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
GasUsed hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
||||||
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
|
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
|
||||||
DataGasUsed uint64 `json:"dataGasUsed,omitempty"`
|
BlobGasUsed uint64 `json:"blobGasUsed,omitempty"`
|
||||||
DataGasPrice *big.Int `json:"dataGasPrice,omitempty"`
|
BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"`
|
||||||
BlockHash common.Hash `json:"blockHash,omitempty"`
|
BlockHash common.Hash `json:"blockHash,omitempty"`
|
||||||
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
|
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
|
||||||
TransactionIndex hexutil.Uint `json:"transactionIndex"`
|
TransactionIndex hexutil.Uint `json:"transactionIndex"`
|
||||||
@ -43,8 +43,8 @@ func (r Receipt) MarshalJSON() ([]byte, error) {
|
|||||||
enc.ContractAddress = r.ContractAddress
|
enc.ContractAddress = r.ContractAddress
|
||||||
enc.GasUsed = hexutil.Uint64(r.GasUsed)
|
enc.GasUsed = hexutil.Uint64(r.GasUsed)
|
||||||
enc.EffectiveGasPrice = (*hexutil.Big)(r.EffectiveGasPrice)
|
enc.EffectiveGasPrice = (*hexutil.Big)(r.EffectiveGasPrice)
|
||||||
enc.DataGasUsed = r.DataGasUsed
|
enc.BlobGasUsed = r.BlobGasUsed
|
||||||
enc.DataGasPrice = r.DataGasPrice
|
enc.BlobGasPrice = r.BlobGasPrice
|
||||||
enc.BlockHash = r.BlockHash
|
enc.BlockHash = r.BlockHash
|
||||||
enc.BlockNumber = (*hexutil.Big)(r.BlockNumber)
|
enc.BlockNumber = (*hexutil.Big)(r.BlockNumber)
|
||||||
enc.TransactionIndex = hexutil.Uint(r.TransactionIndex)
|
enc.TransactionIndex = hexutil.Uint(r.TransactionIndex)
|
||||||
@ -64,8 +64,8 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
|
|||||||
ContractAddress *common.Address `json:"contractAddress"`
|
ContractAddress *common.Address `json:"contractAddress"`
|
||||||
GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
GasUsed *hexutil.Uint64 `json:"gasUsed" gencodec:"required"`
|
||||||
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
|
EffectiveGasPrice *hexutil.Big `json:"effectiveGasPrice"`
|
||||||
DataGasUsed *uint64 `json:"dataGasUsed,omitempty"`
|
BlobGasUsed *uint64 `json:"blobGasUsed,omitempty"`
|
||||||
DataGasPrice *big.Int `json:"dataGasPrice,omitempty"`
|
BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"`
|
||||||
BlockHash *common.Hash `json:"blockHash,omitempty"`
|
BlockHash *common.Hash `json:"blockHash,omitempty"`
|
||||||
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
|
BlockNumber *hexutil.Big `json:"blockNumber,omitempty"`
|
||||||
TransactionIndex *hexutil.Uint `json:"transactionIndex"`
|
TransactionIndex *hexutil.Uint `json:"transactionIndex"`
|
||||||
@ -109,11 +109,11 @@ func (r *Receipt) UnmarshalJSON(input []byte) error {
|
|||||||
if dec.EffectiveGasPrice != nil {
|
if dec.EffectiveGasPrice != nil {
|
||||||
r.EffectiveGasPrice = (*big.Int)(dec.EffectiveGasPrice)
|
r.EffectiveGasPrice = (*big.Int)(dec.EffectiveGasPrice)
|
||||||
}
|
}
|
||||||
if dec.DataGasUsed != nil {
|
if dec.BlobGasUsed != nil {
|
||||||
r.DataGasUsed = *dec.DataGasUsed
|
r.BlobGasUsed = *dec.BlobGasUsed
|
||||||
}
|
}
|
||||||
if dec.DataGasPrice != nil {
|
if dec.BlobGasPrice != nil {
|
||||||
r.DataGasPrice = dec.DataGasPrice
|
r.BlobGasPrice = dec.BlobGasPrice
|
||||||
}
|
}
|
||||||
if dec.BlockHash != nil {
|
if dec.BlockHash != nil {
|
||||||
r.BlockHash = *dec.BlockHash
|
r.BlockHash = *dec.BlockHash
|
||||||
|
@ -63,8 +63,8 @@ type Receipt struct {
|
|||||||
ContractAddress common.Address `json:"contractAddress"`
|
ContractAddress common.Address `json:"contractAddress"`
|
||||||
GasUsed uint64 `json:"gasUsed" gencodec:"required"`
|
GasUsed uint64 `json:"gasUsed" gencodec:"required"`
|
||||||
EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` // required, but tag omitted for backwards compatibility
|
EffectiveGasPrice *big.Int `json:"effectiveGasPrice"` // required, but tag omitted for backwards compatibility
|
||||||
DataGasUsed uint64 `json:"dataGasUsed,omitempty"`
|
BlobGasUsed uint64 `json:"blobGasUsed,omitempty"`
|
||||||
DataGasPrice *big.Int `json:"dataGasPrice,omitempty"`
|
BlobGasPrice *big.Int `json:"blobGasPrice,omitempty"`
|
||||||
|
|
||||||
// Inclusion information: These fields provide information about the inclusion of the
|
// Inclusion information: These fields provide information about the inclusion of the
|
||||||
// transaction corresponding to this receipt.
|
// transaction corresponding to this receipt.
|
||||||
@ -315,7 +315,7 @@ func (rs Receipts) EncodeIndex(i int, w *bytes.Buffer) {
|
|||||||
|
|
||||||
// DeriveFields fills the receipts with their computed fields based on consensus
|
// DeriveFields fills the receipts with their computed fields based on consensus
|
||||||
// data and contextual infos like containing block and transactions.
|
// data and contextual infos like containing block and transactions.
|
||||||
func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, dataGasPrice *big.Int, txs []*Transaction) error {
|
func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, number uint64, time uint64, baseFee *big.Int, blobGasPrice *big.Int, txs []*Transaction) error {
|
||||||
signer := MakeSigner(config, new(big.Int).SetUint64(number), time)
|
signer := MakeSigner(config, new(big.Int).SetUint64(number), time)
|
||||||
|
|
||||||
logIndex := uint(0)
|
logIndex := uint(0)
|
||||||
@ -330,8 +330,8 @@ func (rs Receipts) DeriveFields(config *params.ChainConfig, hash common.Hash, nu
|
|||||||
|
|
||||||
// EIP-4844 blob transaction fields
|
// EIP-4844 blob transaction fields
|
||||||
if txs[i].Type() == BlobTxType {
|
if txs[i].Type() == BlobTxType {
|
||||||
rs[i].DataGasUsed = txs[i].BlobGas()
|
rs[i].BlobGasUsed = txs[i].BlobGas()
|
||||||
rs[i].DataGasPrice = dataGasPrice
|
rs[i].BlobGasPrice = blobGasPrice
|
||||||
}
|
}
|
||||||
|
|
||||||
// block location fields
|
// block location fields
|
||||||
|
@ -272,8 +272,8 @@ var (
|
|||||||
TxHash: txs[5].Hash(),
|
TxHash: txs[5].Hash(),
|
||||||
GasUsed: 6,
|
GasUsed: 6,
|
||||||
EffectiveGasPrice: big.NewInt(1066),
|
EffectiveGasPrice: big.NewInt(1066),
|
||||||
DataGasUsed: params.BlobTxDataGasPerBlob,
|
BlobGasUsed: params.BlobTxBlobGasPerBlob,
|
||||||
DataGasPrice: big.NewInt(920),
|
BlobGasPrice: big.NewInt(920),
|
||||||
BlockHash: blockHash,
|
BlockHash: blockHash,
|
||||||
BlockNumber: blockNumber,
|
BlockNumber: blockNumber,
|
||||||
TransactionIndex: 5,
|
TransactionIndex: 5,
|
||||||
@ -287,8 +287,8 @@ var (
|
|||||||
TxHash: txs[6].Hash(),
|
TxHash: txs[6].Hash(),
|
||||||
GasUsed: 7,
|
GasUsed: 7,
|
||||||
EffectiveGasPrice: big.NewInt(1077),
|
EffectiveGasPrice: big.NewInt(1077),
|
||||||
DataGasUsed: 3 * params.BlobTxDataGasPerBlob,
|
BlobGasUsed: 3 * params.BlobTxBlobGasPerBlob,
|
||||||
DataGasPrice: big.NewInt(920),
|
BlobGasPrice: big.NewInt(920),
|
||||||
BlockHash: blockHash,
|
BlockHash: blockHash,
|
||||||
BlockNumber: blockNumber,
|
BlockNumber: blockNumber,
|
||||||
TransactionIndex: 6,
|
TransactionIndex: 6,
|
||||||
@ -309,9 +309,9 @@ func TestDecodeEmptyTypedReceipt(t *testing.T) {
|
|||||||
func TestDeriveFields(t *testing.T) {
|
func TestDeriveFields(t *testing.T) {
|
||||||
// Re-derive receipts.
|
// Re-derive receipts.
|
||||||
basefee := big.NewInt(1000)
|
basefee := big.NewInt(1000)
|
||||||
dataGasPrice := big.NewInt(920)
|
blobGasPrice := big.NewInt(920)
|
||||||
derivedReceipts := clearComputedFieldsOnReceipts(receipts)
|
derivedReceipts := clearComputedFieldsOnReceipts(receipts)
|
||||||
err := Receipts(derivedReceipts).DeriveFields(params.TestChainConfig, blockHash, blockNumber.Uint64(), blockTime, basefee, dataGasPrice, txs)
|
err := Receipts(derivedReceipts).DeriveFields(params.TestChainConfig, blockHash, blockNumber.Uint64(), blockTime, basefee, blobGasPrice, txs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("DeriveFields(...) = %v, want <nil>", err)
|
t.Fatalf("DeriveFields(...) = %v, want <nil>", err)
|
||||||
}
|
}
|
||||||
@ -509,8 +509,8 @@ func clearComputedFieldsOnReceipt(receipt *Receipt) *Receipt {
|
|||||||
cpy.GasUsed = 0xffffffff
|
cpy.GasUsed = 0xffffffff
|
||||||
cpy.Logs = clearComputedFieldsOnLogs(receipt.Logs)
|
cpy.Logs = clearComputedFieldsOnLogs(receipt.Logs)
|
||||||
cpy.EffectiveGasPrice = big.NewInt(0)
|
cpy.EffectiveGasPrice = big.NewInt(0)
|
||||||
cpy.DataGasUsed = 0
|
cpy.BlobGasUsed = 0
|
||||||
cpy.DataGasPrice = nil
|
cpy.BlobGasPrice = nil
|
||||||
return &cpy
|
return &cpy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ type txJSON struct {
|
|||||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||||
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
|
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
|
||||||
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
|
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
|
||||||
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"`
|
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||||
Value *hexutil.Big `json:"value"`
|
Value *hexutil.Big `json:"value"`
|
||||||
Input *hexutil.Bytes `json:"input"`
|
Input *hexutil.Bytes `json:"input"`
|
||||||
AccessList *AccessList `json:"accessList,omitempty"`
|
AccessList *AccessList `json:"accessList,omitempty"`
|
||||||
@ -106,7 +106,7 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) {
|
|||||||
enc.Gas = (*hexutil.Uint64)(&itx.Gas)
|
enc.Gas = (*hexutil.Uint64)(&itx.Gas)
|
||||||
enc.MaxFeePerGas = (*hexutil.Big)(itx.GasFeeCap.ToBig())
|
enc.MaxFeePerGas = (*hexutil.Big)(itx.GasFeeCap.ToBig())
|
||||||
enc.MaxPriorityFeePerGas = (*hexutil.Big)(itx.GasTipCap.ToBig())
|
enc.MaxPriorityFeePerGas = (*hexutil.Big)(itx.GasTipCap.ToBig())
|
||||||
enc.MaxFeePerDataGas = (*hexutil.Big)(itx.BlobFeeCap.ToBig())
|
enc.MaxFeePerBlobGas = (*hexutil.Big)(itx.BlobFeeCap.ToBig())
|
||||||
enc.Value = (*hexutil.Big)(itx.Value.ToBig())
|
enc.Value = (*hexutil.Big)(itx.Value.ToBig())
|
||||||
enc.Input = (*hexutil.Bytes)(&itx.Data)
|
enc.Input = (*hexutil.Bytes)(&itx.Data)
|
||||||
enc.AccessList = &itx.AccessList
|
enc.AccessList = &itx.AccessList
|
||||||
@ -309,10 +309,10 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
|
|||||||
return errors.New("missing required field 'maxFeePerGas' for txdata")
|
return errors.New("missing required field 'maxFeePerGas' for txdata")
|
||||||
}
|
}
|
||||||
itx.GasFeeCap = uint256.MustFromBig((*big.Int)(dec.MaxFeePerGas))
|
itx.GasFeeCap = uint256.MustFromBig((*big.Int)(dec.MaxFeePerGas))
|
||||||
if dec.MaxFeePerDataGas == nil {
|
if dec.MaxFeePerBlobGas == nil {
|
||||||
return errors.New("missing required field 'maxFeePerDataGas' for txdata")
|
return errors.New("missing required field 'maxFeePerBlobGas' for txdata")
|
||||||
}
|
}
|
||||||
itx.BlobFeeCap = uint256.MustFromBig((*big.Int)(dec.MaxFeePerDataGas))
|
itx.BlobFeeCap = uint256.MustFromBig((*big.Int)(dec.MaxFeePerBlobGas))
|
||||||
if dec.Value == nil {
|
if dec.Value == nil {
|
||||||
return errors.New("missing required field 'value' in transaction")
|
return errors.New("missing required field 'value' in transaction")
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ type BlobTx struct {
|
|||||||
Value *uint256.Int
|
Value *uint256.Int
|
||||||
Data []byte
|
Data []byte
|
||||||
AccessList AccessList
|
AccessList AccessList
|
||||||
BlobFeeCap *uint256.Int // a.k.a. maxFeePerDataGas
|
BlobFeeCap *uint256.Int // a.k.a. maxFeePerBlobGas
|
||||||
BlobHashes []common.Hash
|
BlobHashes []common.Hash
|
||||||
|
|
||||||
// Signature values
|
// Signature values
|
||||||
@ -105,7 +105,7 @@ func (tx *BlobTx) gasPrice() *big.Int { return tx.GasFeeCap.ToBig() }
|
|||||||
func (tx *BlobTx) value() *big.Int { return tx.Value.ToBig() }
|
func (tx *BlobTx) value() *big.Int { return tx.Value.ToBig() }
|
||||||
func (tx *BlobTx) nonce() uint64 { return tx.Nonce }
|
func (tx *BlobTx) nonce() uint64 { return tx.Nonce }
|
||||||
func (tx *BlobTx) to() *common.Address { tmp := tx.To; return &tmp }
|
func (tx *BlobTx) to() *common.Address { tmp := tx.To; return &tmp }
|
||||||
func (tx *BlobTx) blobGas() uint64 { return params.BlobTxDataGasPerBlob * uint64(len(tx.BlobHashes)) }
|
func (tx *BlobTx) blobGas() uint64 { return params.BlobTxBlobGasPerBlob * uint64(len(tx.BlobHashes)) }
|
||||||
func (tx *BlobTx) blobGasFeeCap() *big.Int { return tx.BlobFeeCap.ToBig() }
|
func (tx *BlobTx) blobGasFeeCap() *big.Int { return tx.BlobFeeCap.ToBig() }
|
||||||
func (tx *BlobTx) blobHashes() []common.Hash { return tx.BlobHashes }
|
func (tx *BlobTx) blobHashes() []common.Hash { return tx.BlobHashes }
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ type BlockContext struct {
|
|||||||
Difficulty *big.Int // Provides information for DIFFICULTY
|
Difficulty *big.Int // Provides information for DIFFICULTY
|
||||||
BaseFee *big.Int // Provides information for BASEFEE
|
BaseFee *big.Int // Provides information for BASEFEE
|
||||||
Random *common.Hash // Provides information for PREVRANDAO
|
Random *common.Hash // Provides information for PREVRANDAO
|
||||||
ExcessDataGas *uint64 // ExcessDataGas field in the header, needed to compute the data
|
ExcessBlobGas *uint64 // ExcessBlobGas field in the header, needed to compute the data
|
||||||
}
|
}
|
||||||
|
|
||||||
// TxContext provides the EVM with information about a transaction.
|
// TxContext provides the EVM with information about a transaction.
|
||||||
|
@ -450,7 +450,7 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas
|
|||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("newPayloadV3 called pre-cancun"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("newPayloadV3 called pre-cancun"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if params.ExcessDataGas == nil {
|
if params.ExcessBlobGas == nil {
|
||||||
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil excessDataGas post-cancun"))
|
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(fmt.Errorf("nil excessDataGas post-cancun"))
|
||||||
}
|
}
|
||||||
var hashes []common.Hash
|
var hashes []common.Hash
|
||||||
|
@ -801,7 +801,7 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
|
|||||||
// and zero before the Cancun hardfork
|
// and zero before the Cancun hardfork
|
||||||
var blobs int
|
var blobs int
|
||||||
for _, tx := range txLists[index] {
|
for _, tx := range txLists[index] {
|
||||||
// Count the number of blobs to validate against the header's dataGasUsed
|
// Count the number of blobs to validate against the header's blobGasUsed
|
||||||
blobs += len(tx.BlobHashes())
|
blobs += len(tx.BlobHashes())
|
||||||
|
|
||||||
// Validate the data blobs individually too
|
// Validate the data blobs individually too
|
||||||
@ -816,8 +816,8 @@ func (q *queue) DeliverBodies(id string, txLists [][]*types.Transaction, txListH
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if header.DataGasUsed != nil {
|
if header.BlobGasUsed != nil {
|
||||||
if want := *header.DataGasUsed / params.BlobTxDataGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated
|
if want := *header.BlobGasUsed / params.BlobTxBlobGasPerBlob; uint64(blobs) != want { // div because the header is surely good vs the body might be bloated
|
||||||
return errInvalidBody
|
return errInvalidBody
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -176,13 +176,13 @@ func GetBlockReceipts(ctx context.Context, odr OdrBackend, hash common.Hash, num
|
|||||||
genesis := rawdb.ReadCanonicalHash(odr.Database(), 0)
|
genesis := rawdb.ReadCanonicalHash(odr.Database(), 0)
|
||||||
config := rawdb.ReadChainConfig(odr.Database(), genesis)
|
config := rawdb.ReadChainConfig(odr.Database(), genesis)
|
||||||
|
|
||||||
var dataGasPrice *big.Int
|
var blobGasPrice *big.Int
|
||||||
excessDataGas := block.ExcessDataGas()
|
excessBlobGas := block.ExcessBlobGas()
|
||||||
if excessDataGas != nil {
|
if excessBlobGas != nil {
|
||||||
dataGasPrice = eip4844.CalcBlobFee(*excessDataGas)
|
blobGasPrice = eip4844.CalcBlobFee(*excessBlobGas)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := receipts.DeriveFields(config, block.Hash(), block.NumberU64(), block.Time(), block.BaseFee(), dataGasPrice, block.Transactions()); err != nil {
|
if err := receipts.DeriveFields(config, block.Hash(), block.NumberU64(), block.Time(), block.BaseFee(), blobGasPrice, block.Transactions()); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
rawdb.WriteReceipts(odr.Database(), hash, number, receipts)
|
rawdb.WriteReceipts(odr.Database(), hash, number, receipts)
|
||||||
|
@ -163,11 +163,11 @@ const (
|
|||||||
BlobTxBytesPerFieldElement = 32 // Size in bytes of a field element
|
BlobTxBytesPerFieldElement = 32 // Size in bytes of a field element
|
||||||
BlobTxFieldElementsPerBlob = 4096 // Number of field elements stored in a single data blob
|
BlobTxFieldElementsPerBlob = 4096 // Number of field elements stored in a single data blob
|
||||||
BlobTxHashVersion = 0x01 // Version byte of the commitment hash
|
BlobTxHashVersion = 0x01 // Version byte of the commitment hash
|
||||||
BlobTxMaxDataGasPerBlock = 1 << 19 // Maximum consumable data gas for data blobs per block
|
BlobTxMaxBlobGasPerBlock = 1 << 19 // Maximum consumable data gas for data blobs per block
|
||||||
BlobTxTargetDataGasPerBlock = 1 << 18 // Target consumable data gas for data blobs per block (for 1559-like pricing)
|
BlobTxTargetBlobGasPerBlock = 1 << 18 // Target consumable data gas for data blobs per block (for 1559-like pricing)
|
||||||
BlobTxDataGasPerBlob = 1 << 17 // Gas consumption of a single data blob (== blob byte size)
|
BlobTxBlobGasPerBlob = 1 << 17 // Gas consumption of a single data blob (== blob byte size)
|
||||||
BlobTxMinDataGasprice = 1 // Minimum gas price for data blobs
|
BlobTxMinBlobGasprice = 1 // Minimum gas price for data blobs
|
||||||
BlobTxDataGaspriceUpdateFraction = 2225652 // Controls the maximum rate of change for data gas price
|
BlobTxBlobGaspriceUpdateFraction = 2225652 // Controls the maximum rate of change for data gas price
|
||||||
BlobTxPointEvaluationPrecompileGas = 50000 // Gas price for the point evaluation precompile.
|
BlobTxPointEvaluationPrecompileGas = 50000 // Gas price for the point evaluation precompile.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func (s stTransaction) MarshalJSON() ([]byte, error) {
|
|||||||
Value []string `json:"value"`
|
Value []string `json:"value"`
|
||||||
PrivateKey hexutil.Bytes `json:"secretKey"`
|
PrivateKey hexutil.Bytes `json:"secretKey"`
|
||||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||||
BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerDataGas,omitempty"`
|
BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerBlobGas,omitempty"`
|
||||||
}
|
}
|
||||||
var enc stTransaction
|
var enc stTransaction
|
||||||
enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice)
|
enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice)
|
||||||
@ -65,7 +65,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error {
|
|||||||
Value []string `json:"value"`
|
Value []string `json:"value"`
|
||||||
PrivateKey *hexutil.Bytes `json:"secretKey"`
|
PrivateKey *hexutil.Bytes `json:"secretKey"`
|
||||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||||
BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerDataGas,omitempty"`
|
BlobGasFeeCap *math.HexOrDecimal256 `json:"maxFeePerBlobGas,omitempty"`
|
||||||
}
|
}
|
||||||
var dec stTransaction
|
var dec stTransaction
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
@ -58,6 +58,9 @@ func TestState(t *testing.T) {
|
|||||||
// EOF is not part of cancun
|
// EOF is not part of cancun
|
||||||
st.skipLoad(`^stEOF/`)
|
st.skipLoad(`^stEOF/`)
|
||||||
|
|
||||||
|
// EIP-4844 tests need to be regenerated due to the data-to-blob rename
|
||||||
|
st.skipLoad(`^stEIP4844-blobtransactions/`)
|
||||||
|
|
||||||
// Expected failures:
|
// Expected failures:
|
||||||
// These EIP-4844 tests need to be regenerated.
|
// These EIP-4844 tests need to be regenerated.
|
||||||
st.fails(`stEIP4844-blobtransactions/opcodeBlobhashOutOfRange.json`, "test has incorrect state root")
|
st.fails(`stEIP4844-blobtransactions/opcodeBlobhashOutOfRange.json`, "test has incorrect state root")
|
||||||
|
@ -114,7 +114,7 @@ type stTransaction struct {
|
|||||||
Value []string `json:"value"`
|
Value []string `json:"value"`
|
||||||
PrivateKey []byte `json:"secretKey"`
|
PrivateKey []byte `json:"secretKey"`
|
||||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||||
BlobGasFeeCap *big.Int `json:"maxFeePerDataGas,omitempty"`
|
BlobGasFeeCap *big.Int `json:"maxFeePerBlobGas,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type stTransactionMarshaling struct {
|
type stTransactionMarshaling struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user