mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-21 19:20:39 +00:00
EIP-4844: Rename "data gas" to "blob gas" (#7937)
See https://github.com/ethereum/EIPs/pull/7354 & https://github.com/ethereum/consensus-specs/pull/3461. Prerequisite: https://github.com/ledgerwatch/erigon-lib/pull/1058
This commit is contained in:
parent
d3f8b5861c
commit
7d35c6b737
@ -30,6 +30,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutility"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
state2 "github.com/ledgerwatch/erigon-lib/state"
|
||||
@ -172,7 +173,7 @@ func (b *SimulatedBackend) emptyPendingBlock() {
|
||||
b.pendingBlock = blockChain.Blocks[0]
|
||||
b.pendingReceipts = blockChain.Receipts[0]
|
||||
b.pendingHeader = blockChain.Headers[0]
|
||||
b.gasPool = new(core.GasPool).AddGas(b.pendingHeader.GasLimit).AddDataGas(chain.MaxDataGasPerBlock)
|
||||
b.gasPool = new(core.GasPool).AddGas(b.pendingHeader.GasLimit).AddBlobGas(fixedgas.MaxBlobGasPerBlock)
|
||||
if b.pendingReaderTx != nil {
|
||||
b.pendingReaderTx.Rollback()
|
||||
}
|
||||
@ -723,7 +724,7 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg
|
||||
// Create a new environment which holds all relevant information
|
||||
// about the transaction and calling mechanisms.
|
||||
vmEnv := vm.NewEVM(evmContext, txContext, statedb, b.m.ChainConfig, vm.Config{})
|
||||
gasPool := new(core.GasPool).AddGas(math.MaxUint64).AddDataGas(math.MaxUint64)
|
||||
gasPool := new(core.GasPool).AddGas(math.MaxUint64).AddBlobGas(math.MaxUint64)
|
||||
|
||||
return core.NewStateTransition(vmEnv, msg, gasPool).TransitionDb(true /* refunds */, false /* gasBailout */)
|
||||
}
|
||||
@ -752,7 +753,7 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx types.Transac
|
||||
&b.pendingHeader.Coinbase, b.gasPool,
|
||||
b.pendingState, state.NewNoopWriter(),
|
||||
b.pendingHeader, tx,
|
||||
&b.pendingHeader.GasUsed, b.pendingHeader.DataGasUsed,
|
||||
&b.pendingHeader.GasUsed, b.pendingHeader.BlobGasUsed,
|
||||
vm.Config{}); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -835,6 +836,6 @@ func (m callMsg) Data() []byte { return m.CallMsg.Data }
|
||||
func (m callMsg) AccessList() types2.AccessList { return m.CallMsg.AccessList }
|
||||
func (m callMsg) IsFree() bool { return false }
|
||||
|
||||
func (m callMsg) DataGas() uint64 { return misc.GetDataGasUsed(len(m.CallMsg.DataHashes)) }
|
||||
func (m callMsg) MaxFeePerDataGas() *uint256.Int { return m.CallMsg.MaxFeePerDataGas }
|
||||
func (m callMsg) BlobGas() uint64 { return misc.GetBlobGasUsed(len(m.CallMsg.DataHashes)) }
|
||||
func (m callMsg) MaxFeePerBlobGas() *uint256.Int { return m.CallMsg.MaxFeePerBlobGas }
|
||||
func (m callMsg) DataHashes() []libcommon.Hash { return m.CallMsg.DataHashes }
|
||||
|
@ -32,8 +32,8 @@ type Eth1Block struct {
|
||||
BlockHash libcommon.Hash
|
||||
Transactions *solid.TransactionsSSZ
|
||||
Withdrawals *solid.ListSSZ[*types.Withdrawal]
|
||||
DataGasUsed uint64
|
||||
ExcessDataGas uint64
|
||||
BlobGasUsed uint64
|
||||
ExcessBlobGas uint64
|
||||
// internals
|
||||
version clparams.StateVersion
|
||||
}
|
||||
@ -72,9 +72,9 @@ func NewEth1BlockFromHeaderAndBody(header *types.Header, body *types.RawBody) *E
|
||||
Withdrawals: solid.NewStaticListSSZFromList(body.Withdrawals, 16, 44),
|
||||
}
|
||||
|
||||
if header.DataGasUsed != nil && header.ExcessDataGas != nil {
|
||||
block.DataGasUsed = *header.DataGasUsed
|
||||
block.ExcessDataGas = *header.ExcessDataGas
|
||||
if header.BlobGasUsed != nil && header.ExcessBlobGas != nil {
|
||||
block.BlobGasUsed = *header.BlobGasUsed
|
||||
block.ExcessBlobGas = *header.ExcessBlobGas
|
||||
block.version = clparams.DenebVersion
|
||||
} else if header.WithdrawalsHash != nil {
|
||||
block.version = clparams.CapellaVersion
|
||||
@ -102,10 +102,10 @@ func (b *Eth1Block) PayloadHeader() (*Eth1Header, error) {
|
||||
}
|
||||
}
|
||||
|
||||
var dataGasUsed, excessDataGas uint64
|
||||
var blobGasUsed, excessBlobGas uint64
|
||||
if b.version >= clparams.DenebVersion {
|
||||
dataGasUsed = b.DataGasUsed
|
||||
excessDataGas = b.ExcessDataGas
|
||||
blobGasUsed = b.BlobGasUsed
|
||||
excessBlobGas = b.ExcessBlobGas
|
||||
}
|
||||
|
||||
return &Eth1Header{
|
||||
@ -124,8 +124,8 @@ func (b *Eth1Block) PayloadHeader() (*Eth1Header, error) {
|
||||
BlockHash: b.BlockHash,
|
||||
TransactionsRoot: transactionsRoot,
|
||||
WithdrawalsRoot: withdrawalsRoot,
|
||||
DataGasUsed: dataGasUsed,
|
||||
ExcessDataGas: excessDataGas,
|
||||
BlobGasUsed: blobGasUsed,
|
||||
ExcessBlobGas: excessBlobGas,
|
||||
version: b.version,
|
||||
}, nil
|
||||
}
|
||||
@ -149,7 +149,7 @@ func (b *Eth1Block) EncodingSizeSSZ() (size int) {
|
||||
}
|
||||
|
||||
if b.version >= clparams.DenebVersion {
|
||||
size += 8 * 2 // DataGasUsed + ExcessDataGas
|
||||
size += 8 * 2 // BlobGasUsed + ExcessBlobGas
|
||||
}
|
||||
|
||||
return
|
||||
@ -181,7 +181,7 @@ func (b *Eth1Block) getSchema() []interface{} {
|
||||
s = append(s, b.Withdrawals)
|
||||
}
|
||||
if b.version >= clparams.DenebVersion {
|
||||
s = append(s, &b.DataGasUsed, &b.ExcessDataGas)
|
||||
s = append(s, &b.BlobGasUsed, &b.ExcessBlobGas)
|
||||
}
|
||||
return s
|
||||
}
|
||||
@ -228,10 +228,10 @@ func (b *Eth1Block) RlpHeader() (*types.Header, error) {
|
||||
}
|
||||
|
||||
if b.version >= clparams.DenebVersion {
|
||||
dataGasUsed := b.DataGasUsed
|
||||
header.DataGasUsed = &dataGasUsed
|
||||
excessDataGas := b.ExcessDataGas
|
||||
header.ExcessDataGas = &excessDataGas
|
||||
blobGasUsed := b.BlobGasUsed
|
||||
header.BlobGasUsed = &blobGasUsed
|
||||
excessBlobGas := b.ExcessBlobGas
|
||||
header.ExcessBlobGas = &excessBlobGas
|
||||
}
|
||||
|
||||
// If the header hash does not match the block hash, return an error.
|
||||
|
@ -30,8 +30,8 @@ type Eth1Header struct {
|
||||
BlockHash libcommon.Hash
|
||||
TransactionsRoot libcommon.Hash
|
||||
WithdrawalsRoot libcommon.Hash
|
||||
DataGasUsed uint64
|
||||
ExcessDataGas uint64
|
||||
BlobGasUsed uint64
|
||||
ExcessBlobGas uint64
|
||||
// internals
|
||||
version clparams.StateVersion
|
||||
}
|
||||
@ -60,8 +60,8 @@ func (e *Eth1Header) Capella() {
|
||||
// Capella converts the header to capella version.
|
||||
func (e *Eth1Header) Deneb() {
|
||||
e.version = clparams.DenebVersion
|
||||
e.DataGasUsed = 0
|
||||
e.ExcessDataGas = 0
|
||||
e.BlobGasUsed = 0
|
||||
e.ExcessBlobGas = 0
|
||||
}
|
||||
|
||||
func (e *Eth1Header) IsZero() bool {
|
||||
@ -72,7 +72,7 @@ func (e *Eth1Header) IsZero() bool {
|
||||
e.ReceiptsRoot == libcommon.Hash{} && e.LogsBloom == types.Bloom{} && e.PrevRandao == libcommon.Hash{} && e.BlockNumber == 0 &&
|
||||
e.GasLimit == 0 && e.GasUsed == 0 && e.Time == 0 && e.Extra.EncodingSizeSSZ() == 0 && e.BaseFeePerGas == [32]byte{} &&
|
||||
e.BlockHash == libcommon.Hash{} && e.TransactionsRoot == libcommon.Hash{} && e.WithdrawalsRoot == libcommon.Hash{} &&
|
||||
e.DataGasUsed == 0 && e.ExcessDataGas == 0
|
||||
e.BlobGasUsed == 0 && e.ExcessBlobGas == 0
|
||||
}
|
||||
|
||||
// EncodeSSZ encodes the header in SSZ format.
|
||||
@ -98,7 +98,7 @@ func (h *Eth1Header) EncodingSizeSSZ() int {
|
||||
}
|
||||
|
||||
if h.version >= clparams.DenebVersion {
|
||||
size += 8 * 2 // DataGasUsed + ExcessDataGas
|
||||
size += 8 * 2 // BlobGasUsed + ExcessBlobGas
|
||||
}
|
||||
if h.Extra == nil {
|
||||
h.Extra = solid.NewExtraData()
|
||||
@ -121,7 +121,7 @@ func (h *Eth1Header) getSchema() []interface{} {
|
||||
s = append(s, h.WithdrawalsRoot[:])
|
||||
}
|
||||
if h.version >= clparams.DenebVersion {
|
||||
s = append(s, &h.DataGasUsed, &h.ExcessDataGas)
|
||||
s = append(s, &h.BlobGasUsed, &h.ExcessBlobGas)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
@ -34,8 +34,8 @@ func TestEth1Header(t *testing.T) {
|
||||
blockHash := libcommon.Hash{}
|
||||
transactionsRoot := libcommon.Hash{}
|
||||
withdrawalsRoot := libcommon.Hash{}
|
||||
dataGasUsed := uint64(50)
|
||||
excessDataGas := uint64(60)
|
||||
blobGasUsed := uint64(50)
|
||||
excessBlobGas := uint64(60)
|
||||
|
||||
// Test Eth1Header
|
||||
header = &Eth1Header{
|
||||
@ -54,8 +54,8 @@ func TestEth1Header(t *testing.T) {
|
||||
BlockHash: blockHash,
|
||||
TransactionsRoot: transactionsRoot,
|
||||
WithdrawalsRoot: withdrawalsRoot,
|
||||
DataGasUsed: dataGasUsed,
|
||||
ExcessDataGas: excessDataGas,
|
||||
BlobGasUsed: blobGasUsed,
|
||||
ExcessBlobGas: excessBlobGas,
|
||||
version: version,
|
||||
}
|
||||
|
||||
|
@ -63,10 +63,10 @@ func (cc *ExecutionClientDirect) NewPayload(payload *cltypes.Eth1Block) (invalid
|
||||
}
|
||||
// Process Deneb
|
||||
if payload.Version() >= clparams.DenebVersion {
|
||||
request.DataGasUsed = new(hexutil.Uint64)
|
||||
request.ExcessDataGas = new(hexutil.Uint64)
|
||||
*request.DataGasUsed = hexutil.Uint64(payload.DataGasUsed)
|
||||
*request.ExcessDataGas = hexutil.Uint64(payload.ExcessDataGas)
|
||||
request.BlobGasUsed = new(hexutil.Uint64)
|
||||
request.ExcessBlobGas = new(hexutil.Uint64)
|
||||
*request.BlobGasUsed = hexutil.Uint64(payload.BlobGasUsed)
|
||||
*request.ExcessBlobGas = hexutil.Uint64(payload.ExcessBlobGas)
|
||||
}
|
||||
|
||||
payloadStatus := &engine_types.PayloadStatus{} // As it is done in the rpcdaemon
|
||||
|
@ -102,10 +102,10 @@ func (cc *ExecutionClientRpc) NewPayload(payload *cltypes.Eth1Block) (invalid bo
|
||||
}
|
||||
// Process Deneb
|
||||
if payload.Version() >= clparams.DenebVersion {
|
||||
request.DataGasUsed = new(hexutil.Uint64)
|
||||
request.ExcessDataGas = new(hexutil.Uint64)
|
||||
*request.DataGasUsed = hexutil.Uint64(payload.DataGasUsed)
|
||||
*request.ExcessDataGas = hexutil.Uint64(payload.ExcessDataGas)
|
||||
request.BlobGasUsed = new(hexutil.Uint64)
|
||||
request.ExcessBlobGas = new(hexutil.Uint64)
|
||||
*request.BlobGasUsed = hexutil.Uint64(payload.BlobGasUsed)
|
||||
*request.ExcessBlobGas = hexutil.Uint64(payload.ExcessBlobGas)
|
||||
}
|
||||
|
||||
payloadStatus := &engine_types.PayloadStatus{} // As it is done in the rpcdaemon
|
||||
|
@ -2,7 +2,9 @@ package eth2
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
|
||||
"github.com/ledgerwatch/erigon/cl/abstract"
|
||||
"github.com/ledgerwatch/erigon/cl/cltypes"
|
||||
"github.com/ledgerwatch/erigon/cl/utils"
|
||||
@ -40,7 +42,7 @@ func txPeekBlobVersionedHashes(txBytes []byte) []libcommon.Hash {
|
||||
value: 32 bytes
|
||||
data: 4 bytes - offset to C (relative to A)
|
||||
access_list: 4 bytes - offset to D (relative to A)
|
||||
max_fee_per_data_gas: 32 bytes
|
||||
max_fee_per_blob_gas: 32 bytes
|
||||
blob_versioned_hashes: 4 bytes - offset to E (relative to A)
|
||||
*/
|
||||
// field offset: 32 + 8 + 32 + 32 + 8 + 4 + 32 + 4 + 4 + 32 = 188
|
||||
|
@ -22,6 +22,7 @@ import (
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
"github.com/ledgerwatch/erigon-lib/common/dbg"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
"github.com/ledgerwatch/erigon-lib/common/length"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
||||
@ -500,9 +501,9 @@ func (b *blockProcessor) applyBlock(
|
||||
|
||||
header := block.Header()
|
||||
b.vmConfig.Debug = true
|
||||
gp := new(core.GasPool).AddGas(block.GasLimit()).AddDataGas(chain2.MaxDataGasPerBlock)
|
||||
gp := new(core.GasPool).AddGas(block.GasLimit()).AddBlobGas(fixedgas.MaxBlobGasPerBlock)
|
||||
usedGas := new(uint64)
|
||||
usedDataGas := new(uint64)
|
||||
usedBlobGas := new(uint64)
|
||||
var receipts types.Receipts
|
||||
rules := b.chainConfig.Rules(block.NumberU64(), block.Time())
|
||||
|
||||
@ -535,7 +536,7 @@ func (b *blockProcessor) applyBlock(
|
||||
ibs.SetTxContext(tx.Hash(), block.Hash(), i)
|
||||
ct := exec3.NewCallTracer()
|
||||
b.vmConfig.Tracer = ct
|
||||
receipt, _, err := core.ApplyTransaction(b.chainConfig, getHashFn, b.engine, nil, gp, ibs, b.writer, header, tx, usedGas, usedDataGas, b.vmConfig)
|
||||
receipt, _, err := core.ApplyTransaction(b.chainConfig, getHashFn, b.engine, nil, gp, ibs, b.writer, header, tx, usedGas, usedBlobGas, b.vmConfig)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not apply tx %d [%x] failed: %w", i, tx.Hash(), err)
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/datadir"
|
||||
"github.com/ledgerwatch/erigon-lib/common/dbg"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
kv2 "github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
||||
libstate "github.com/ledgerwatch/erigon-lib/state"
|
||||
@ -384,9 +385,9 @@ func processBlock23(startTxNum uint64, trace bool, txNumStart uint64, rw *StateR
|
||||
|
||||
header := block.Header()
|
||||
vmConfig.Debug = true
|
||||
gp := new(core.GasPool).AddGas(block.GasLimit()).AddDataGas(chain2.MaxDataGasPerBlock)
|
||||
gp := new(core.GasPool).AddGas(block.GasLimit()).AddBlobGas(fixedgas.MaxBlobGasPerBlock)
|
||||
usedGas := new(uint64)
|
||||
usedDataGas := new(uint64)
|
||||
usedBlobGas := new(uint64)
|
||||
var receipts types.Receipts
|
||||
rules := chainConfig.Rules(block.NumberU64(), block.Time())
|
||||
txNum := txNumStart
|
||||
@ -420,7 +421,7 @@ func processBlock23(startTxNum uint64, trace bool, txNumStart uint64, rw *StateR
|
||||
ibs.SetTxContext(tx.Hash(), block.Hash(), i)
|
||||
ct := exec3.NewCallTracer()
|
||||
vmConfig.Tracer = ct
|
||||
receipt, _, err := core.ApplyTransaction(chainConfig, getHashFn, engine, nil, gp, ibs, ww, header, tx, usedGas, usedDataGas, vmConfig)
|
||||
receipt, _, err := core.ApplyTransaction(chainConfig, getHashFn, engine, nil, gp, ibs, ww, header, tx, usedGas, usedBlobGas, vmConfig)
|
||||
if err != nil {
|
||||
return 0, nil, fmt.Errorf("could not apply tx %d [%x] failed: %w", i, tx.Hash(), err)
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
|
||||
chain2 "github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/kvcfg"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/mdbx"
|
||||
@ -710,9 +711,9 @@ func runBlock(engine consensus.Engine, ibs *state.IntraBlockState, txnWriter sta
|
||||
chainConfig *chain2.Config, getHeader func(hash libcommon.Hash, number uint64) *types.Header, block *types.Block, vmConfig vm.Config, trace bool, logger log.Logger) (types.Receipts, error) {
|
||||
header := block.Header()
|
||||
vmConfig.TraceJumpDest = true
|
||||
gp := new(core.GasPool).AddGas(block.GasLimit()).AddDataGas(chain2.MaxDataGasPerBlock)
|
||||
gp := new(core.GasPool).AddGas(block.GasLimit()).AddBlobGas(fixedgas.MaxBlobGasPerBlock)
|
||||
usedGas := new(uint64)
|
||||
usedDataGas := new(uint64)
|
||||
usedBlobGas := new(uint64)
|
||||
var receipts types.Receipts
|
||||
if chainConfig.DAOForkBlock != nil && chainConfig.DAOForkBlock.Cmp(block.Number()) == 0 {
|
||||
misc.ApplyDAOHardFork(ibs)
|
||||
@ -721,7 +722,7 @@ func runBlock(engine consensus.Engine, ibs *state.IntraBlockState, txnWriter sta
|
||||
rules := chainConfig.Rules(block.NumberU64(), block.Time())
|
||||
for i, tx := range block.Transactions() {
|
||||
ibs.SetTxContext(tx.Hash(), block.Hash(), i)
|
||||
receipt, _, err := core.ApplyTransaction(chainConfig, core.GetHashFn(header, getHeader), engine, nil, gp, ibs, txnWriter, header, tx, usedGas, usedDataGas, vmConfig)
|
||||
receipt, _, err := core.ApplyTransaction(chainConfig, core.GetHashFn(header, getHeader), engine, nil, gp, ibs, txnWriter, header, tx, usedGas, usedBlobGas, vmConfig)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not apply tx %d [%x] failed: %w", i, tx.Hash(), err)
|
||||
}
|
||||
|
@ -122,11 +122,11 @@ func (c *Clique) verifyCascadingFields(chain consensus.ChainHeaderReader, header
|
||||
// Verify the header's EIP-1559 attributes.
|
||||
return err
|
||||
}
|
||||
if header.DataGasUsed != nil {
|
||||
return fmt.Errorf("invalid dataGasUsed before fork: have %v, expected 'nil'", header.DataGasUsed)
|
||||
if header.BlobGasUsed != nil {
|
||||
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
|
||||
}
|
||||
if header.ExcessDataGas != nil {
|
||||
return fmt.Errorf("invalid excessDataGas before fork: have %v, expected 'nil'", header.ExcessDataGas)
|
||||
if header.ExcessBlobGas != nil {
|
||||
return fmt.Errorf("invalid excessBlobGas before fork: have %v, expected 'nil'", header.ExcessBlobGas)
|
||||
}
|
||||
|
||||
// Retrieve the snapshot needed to verify this header and cache it
|
||||
|
@ -235,11 +235,11 @@ func VerifyHeaderBasics(chain consensus.ChainHeaderReader, header, parent *types
|
||||
// Verify the header's EIP-1559 attributes.
|
||||
return err
|
||||
}
|
||||
if header.DataGasUsed != nil {
|
||||
return fmt.Errorf("invalid dataGasUsed before fork: have %v, expected 'nil'", header.DataGasUsed)
|
||||
if header.BlobGasUsed != nil {
|
||||
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
|
||||
}
|
||||
if header.ExcessDataGas != nil {
|
||||
return fmt.Errorf("invalid excessDataGas before fork: have %v, expected 'nil'", header.ExcessDataGas)
|
||||
if header.ExcessBlobGas != nil {
|
||||
return fmt.Errorf("invalid excessBlobGas before fork: have %v, expected 'nil'", header.ExcessBlobGas)
|
||||
}
|
||||
|
||||
// Verify that the block number is parent's +1
|
||||
|
@ -243,11 +243,11 @@ func (s *Merge) verifyHeader(chain consensus.ChainHeaderReader, header, parent *
|
||||
}
|
||||
|
||||
if !chain.Config().IsCancun(header.Time) {
|
||||
if header.DataGasUsed != nil {
|
||||
return fmt.Errorf("invalid dataGasUsed before fork: have %v, expected 'nil'", header.DataGasUsed)
|
||||
if header.BlobGasUsed != nil {
|
||||
return fmt.Errorf("invalid blobGasUsed before fork: have %v, expected 'nil'", header.BlobGasUsed)
|
||||
}
|
||||
if header.ExcessDataGas != nil {
|
||||
return fmt.Errorf("invalid excessDataGas before fork: have %v, expected 'nil'", header.ExcessDataGas)
|
||||
if header.ExcessBlobGas != nil {
|
||||
return fmt.Errorf("invalid excessBlobGas before fork: have %v, expected 'nil'", header.ExcessBlobGas)
|
||||
}
|
||||
} else if err := misc.VerifyEip4844Header(chain.Config(), parent, header); err != nil {
|
||||
// Verify the header's EIP-4844 attributes.
|
||||
|
@ -22,31 +22,32 @@ import (
|
||||
"github.com/holiman/uint256"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
|
||||
"github.com/ledgerwatch/erigon/core/types"
|
||||
"github.com/ledgerwatch/erigon/params"
|
||||
)
|
||||
|
||||
// CalcExcessDataGas implements calc_excess_data_gas from EIP-4844
|
||||
func CalcExcessDataGas(parent *types.Header) uint64 {
|
||||
var excessDataGas, dataGasUsed uint64
|
||||
if parent.ExcessDataGas != nil {
|
||||
excessDataGas = *parent.ExcessDataGas
|
||||
// CalcExcessBlobGas implements calc_excess_blob_gas from EIP-4844
|
||||
func CalcExcessBlobGas(parent *types.Header) uint64 {
|
||||
var excessBlobGas, blobGasUsed uint64
|
||||
if parent.ExcessBlobGas != nil {
|
||||
excessBlobGas = *parent.ExcessBlobGas
|
||||
}
|
||||
if parent.DataGasUsed != nil {
|
||||
dataGasUsed = *parent.DataGasUsed
|
||||
if parent.BlobGasUsed != nil {
|
||||
blobGasUsed = *parent.BlobGasUsed
|
||||
}
|
||||
|
||||
if excessDataGas+dataGasUsed < chain.TargetDataGasPerBlock {
|
||||
if excessBlobGas+blobGasUsed < fixedgas.TargetBlobGasPerBlock {
|
||||
return 0
|
||||
}
|
||||
return excessDataGas + dataGasUsed - chain.TargetDataGasPerBlock
|
||||
return excessBlobGas + blobGasUsed - fixedgas.TargetBlobGasPerBlock
|
||||
}
|
||||
|
||||
// FakeExponential approximates factor * e ** (num / denom) using a taylor expansion
|
||||
// as described in the EIP-4844 spec.
|
||||
func FakeExponential(factor, denom *uint256.Int, excessDataGas uint64) (*uint256.Int, error) {
|
||||
numerator := uint256.NewInt(excessDataGas)
|
||||
func FakeExponential(factor, denom *uint256.Int, excessBlobGas uint64) (*uint256.Int, error) {
|
||||
numerator := uint256.NewInt(excessBlobGas)
|
||||
output := uint256.NewInt(0)
|
||||
numeratorAccum := new(uint256.Int)
|
||||
_, overflow := numeratorAccum.MulOverflow(factor, denom)
|
||||
@ -73,20 +74,19 @@ func FakeExponential(factor, denom *uint256.Int, excessDataGas uint64) (*uint256
|
||||
|
||||
// VerifyEip4844Header verifies that the header is not malformed
|
||||
func VerifyEip4844Header(config *chain.Config, parent, header *types.Header) error {
|
||||
if header.DataGasUsed == nil {
|
||||
return fmt.Errorf("header is missing dataGasUsed")
|
||||
if header.BlobGasUsed == nil {
|
||||
return fmt.Errorf("header is missing blobGasUsed")
|
||||
}
|
||||
if header.ExcessDataGas == nil {
|
||||
return fmt.Errorf("header is missing excessDataGas")
|
||||
if header.ExcessBlobGas == nil {
|
||||
return fmt.Errorf("header is missing excessBlobGas")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDataGasPrice implements get_data_gas_price from EIP-4844
|
||||
func GetDataGasPrice(excessDataGas uint64) (*uint256.Int, error) {
|
||||
return FakeExponential(uint256.NewInt(params.MinDataGasPrice), uint256.NewInt(params.DataGasPriceUpdateFraction), excessDataGas)
|
||||
func GetBlobGasPrice(excessBlobGas uint64) (*uint256.Int, error) {
|
||||
return FakeExponential(uint256.NewInt(params.MinBlobGasPrice), uint256.NewInt(params.BlobGasPriceUpdateFraction), excessBlobGas)
|
||||
}
|
||||
|
||||
func GetDataGasUsed(numBlobs int) uint64 {
|
||||
return uint64(numBlobs) * chain.DataGasPerBlob
|
||||
func GetBlobGasUsed(numBlobs int) uint64 {
|
||||
return uint64(numBlobs) * fixedgas.BlobGasPerBlob
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
|
||||
"github.com/ledgerwatch/erigon/common/math"
|
||||
"github.com/ledgerwatch/erigon/common/u256"
|
||||
@ -87,9 +88,9 @@ func ExecuteBlockEphemerally(
|
||||
header := block.Header()
|
||||
|
||||
usedGas := new(uint64)
|
||||
usedDataGas := new(uint64)
|
||||
usedBlobGas := new(uint64)
|
||||
gp := new(GasPool)
|
||||
gp.AddGas(block.GasLimit()).AddDataGas(chain.MaxDataGasPerBlock)
|
||||
gp.AddGas(block.GasLimit()).AddBlobGas(fixedgas.MaxBlobGasPerBlock)
|
||||
|
||||
var (
|
||||
rejectedTxs []*RejectedTx
|
||||
@ -119,7 +120,7 @@ func ExecuteBlockEphemerally(
|
||||
vmConfig.Tracer = tracer
|
||||
writeTrace = true
|
||||
}
|
||||
receipt, _, err := ApplyTransaction(chainConfig, blockHashFunc, engine, nil, gp, ibs, noop, header, tx, usedGas, usedDataGas, *vmConfig)
|
||||
receipt, _, err := ApplyTransaction(chainConfig, blockHashFunc, engine, nil, gp, ibs, noop, header, tx, usedGas, usedBlobGas, *vmConfig)
|
||||
if writeTrace {
|
||||
if ftracer, ok := vmConfig.Tracer.(vm.FlushableTracer); ok {
|
||||
ftracer.Flush(tx)
|
||||
@ -149,8 +150,8 @@ func ExecuteBlockEphemerally(
|
||||
return nil, fmt.Errorf("gas used by execution: %d, in header: %d", *usedGas, header.GasUsed)
|
||||
}
|
||||
|
||||
if header.DataGasUsed != nil && *usedDataGas != *header.DataGasUsed {
|
||||
return nil, fmt.Errorf("data gas used by execution: %d, in header: %d", *usedDataGas, *header.DataGasUsed)
|
||||
if header.BlobGasUsed != nil && *usedBlobGas != *header.BlobGasUsed {
|
||||
return nil, fmt.Errorf("blob gas used by execution: %d, in header: %d", *usedBlobGas, *header.BlobGasUsed)
|
||||
}
|
||||
|
||||
var bloom types.Bloom
|
||||
@ -219,7 +220,7 @@ func SysCallContract(contract libcommon.Address, data []byte, chainConfig *chain
|
||||
nil, nil,
|
||||
data, nil, false,
|
||||
true, // isFree
|
||||
nil, // maxFeePerDataGas
|
||||
nil, // maxFeePerBlobGas
|
||||
)
|
||||
vmConfig := vm.Config{NoReceipts: true, RestoreState: constCall}
|
||||
// Create a new context to be used in the EVM environment
|
||||
@ -260,7 +261,7 @@ func SysCreate(contract libcommon.Address, data []byte, chainConfig chain.Config
|
||||
nil, nil,
|
||||
data, nil, false,
|
||||
true, // isFree
|
||||
nil, // maxFeePerDataGas
|
||||
nil, // maxFeePerBlobGas
|
||||
)
|
||||
vmConfig := vm.Config{NoReceipts: true}
|
||||
// Create a new context to be used in the EVM environment
|
||||
|
@ -123,7 +123,7 @@ func (b *BlockGen) AddTxWithChain(getHeader func(hash libcommon.Hash, number uin
|
||||
b.SetCoinbase(libcommon.Address{})
|
||||
}
|
||||
b.ibs.SetTxContext(tx.Hash(), libcommon.Hash{}, len(b.txs))
|
||||
receipt, _, err := ApplyTransaction(b.config, GetHashFn(b.header, getHeader), engine, &b.header.Coinbase, b.gasPool, b.ibs, state.NewNoopWriter(), b.header, tx, &b.header.GasUsed, b.header.DataGasUsed, vm.Config{})
|
||||
receipt, _, err := ApplyTransaction(b.config, GetHashFn(b.header, getHeader), engine, &b.header.Coinbase, b.gasPool, b.ibs, state.NewNoopWriter(), b.header, tx, &b.header.GasUsed, b.header.BlobGasUsed, vm.Config{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -136,7 +136,7 @@ func (b *BlockGen) AddFailedTxWithChain(getHeader func(hash libcommon.Hash, numb
|
||||
b.SetCoinbase(libcommon.Address{})
|
||||
}
|
||||
b.ibs.SetTxContext(tx.Hash(), libcommon.Hash{}, len(b.txs))
|
||||
receipt, _, err := ApplyTransaction(b.config, GetHashFn(b.header, getHeader), engine, &b.header.Coinbase, b.gasPool, b.ibs, state.NewNoopWriter(), b.header, tx, &b.header.GasUsed, b.header.DataGasUsed, vm.Config{})
|
||||
receipt, _, err := ApplyTransaction(b.config, GetHashFn(b.header, getHeader), engine, &b.header.Coinbase, b.gasPool, b.ibs, state.NewNoopWriter(), b.header, tx, &b.header.GasUsed, b.header.BlobGasUsed, vm.Config{})
|
||||
_ = err // accept failed transactions
|
||||
b.txs = append(b.txs, tx)
|
||||
b.receipts = append(b.receipts, receipt)
|
||||
@ -603,9 +603,9 @@ func MakeEmptyHeader(parent *types.Header, chainConfig *chain.Config, timestamp
|
||||
}
|
||||
|
||||
if chainConfig.IsCancun(header.Time) {
|
||||
excessDataGas := misc.CalcExcessDataGas(parent)
|
||||
header.ExcessDataGas = &excessDataGas
|
||||
header.DataGasUsed = new(uint64)
|
||||
excessBlobGas := misc.CalcExcessBlobGas(parent)
|
||||
header.ExcessBlobGas = &excessBlobGas
|
||||
header.BlobGasUsed = new(uint64)
|
||||
}
|
||||
|
||||
return header
|
||||
|
@ -36,9 +36,9 @@ var (
|
||||
// transaction with a tip higher than the total fee cap.
|
||||
ErrTipAboveFeeCap = errors.New("tip higher than fee cap")
|
||||
|
||||
// ErrMaxFeePerDataGas is returned if the transaction specified a
|
||||
// max_fee_per_data_gas that is below the current data gas price.
|
||||
ErrMaxFeePerDataGas = errors.New("max fee per data gas too low")
|
||||
// ErrMaxFeePerBlobGas is returned if the transaction specified a
|
||||
// max_fee_per_blob_gas that is below the current blob gas price.
|
||||
ErrMaxFeePerBlobGas = errors.New("max fee per blob gas too low")
|
||||
|
||||
// ErrTipVeryHigh is a sanity error to avoid extremely big numbers specified
|
||||
// in the tip field.
|
||||
@ -77,9 +77,9 @@ var (
|
||||
// by a transaction is higher than what's left in the block.
|
||||
ErrGasLimitReached = errors.New("gas limit reached")
|
||||
|
||||
// ErrDataGasLimitReached is returned by the gas pool if the amount of data gas required
|
||||
// ErrBlobGasLimitReached is returned by the gas pool if the amount of blob gas required
|
||||
// by a transaction is higher than what's left in the block.
|
||||
ErrDataGasLimitReached = errors.New("data gas limit reached")
|
||||
ErrBlobGasLimitReached = errors.New("blob gas limit reached")
|
||||
|
||||
// ErrMaxInitCodeSizeExceeded is returned if creation transaction provides the init code bigger
|
||||
// than init code size limit.
|
||||
|
@ -71,7 +71,7 @@ func NewEVMBlockContext(header *types.Header, blockHashFunc func(n uint64) libco
|
||||
BaseFee: &baseFee,
|
||||
GasLimit: header.GasLimit,
|
||||
PrevRanDao: prevRandDao,
|
||||
ExcessDataGas: header.ExcessDataGas,
|
||||
ExcessBlobGas: header.ExcessBlobGas,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
// GasPool tracks the amount of gas available during execution of the transactions
|
||||
// in a block. The zero value is a pool with zero gas available.
|
||||
type GasPool struct {
|
||||
gas, dataGas uint64
|
||||
gas, blobGas uint64
|
||||
}
|
||||
|
||||
func (gp *GasPool) Reset(amount uint64) {
|
||||
@ -55,30 +55,30 @@ func (gp *GasPool) Gas() uint64 {
|
||||
return gp.gas
|
||||
}
|
||||
|
||||
// AddDataGas makes data gas available for execution.
|
||||
func (gp *GasPool) AddDataGas(amount uint64) *GasPool {
|
||||
if gp.dataGas > math.MaxUint64-amount {
|
||||
panic("data gas pool pushed above uint64")
|
||||
// AddBlobGas makes blob gas available for execution.
|
||||
func (gp *GasPool) AddBlobGas(amount uint64) *GasPool {
|
||||
if gp.blobGas > math.MaxUint64-amount {
|
||||
panic("blob gas pool pushed above uint64")
|
||||
}
|
||||
gp.dataGas += amount
|
||||
gp.blobGas += amount
|
||||
return gp
|
||||
}
|
||||
|
||||
// SubDataGas deducts the given amount from the pool if enough data gas is available and returns an
|
||||
// SubBlobGas deducts the given amount from the pool if enough blob gas is available and returns an
|
||||
// error otherwise.
|
||||
func (gp *GasPool) SubDataGas(amount uint64) error {
|
||||
if gp.dataGas < amount {
|
||||
return ErrDataGasLimitReached
|
||||
func (gp *GasPool) SubBlobGas(amount uint64) error {
|
||||
if gp.blobGas < amount {
|
||||
return ErrBlobGasLimitReached
|
||||
}
|
||||
gp.dataGas -= amount
|
||||
gp.blobGas -= amount
|
||||
return nil
|
||||
}
|
||||
|
||||
// DataGas returns the amount of data gas remaining in the pool.
|
||||
func (gp *GasPool) DataGas() uint64 {
|
||||
return gp.dataGas
|
||||
// BlobGas returns the amount of blob gas remaining in the pool.
|
||||
func (gp *GasPool) BlobGas() uint64 {
|
||||
return gp.blobGas
|
||||
}
|
||||
|
||||
func (gp *GasPool) String() string {
|
||||
return fmt.Sprintf("gas: %d, data_gas: %d", gp.gas, gp.dataGas)
|
||||
return fmt.Sprintf("gas: %d, blob_gas: %d", gp.gas, gp.blobGas)
|
||||
}
|
||||
|
@ -477,8 +477,8 @@ func GenesisToBlock(g *types.Genesis, tmpDir string) (*types.Block, *state.Intra
|
||||
MixDigest: g.Mixhash,
|
||||
Coinbase: g.Coinbase,
|
||||
BaseFee: g.BaseFee,
|
||||
DataGasUsed: g.DataGasUsed,
|
||||
ExcessDataGas: g.ExcessDataGas,
|
||||
BlobGasUsed: g.BlobGasUsed,
|
||||
ExcessBlobGas: g.ExcessBlobGas,
|
||||
AuRaStep: g.AuRaStep,
|
||||
AuRaSeal: g.AuRaSeal,
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import (
|
||||
// for the transaction, gas used and an error if the transaction failed,
|
||||
// indicating the block was invalid.
|
||||
func applyTransaction(config *chain.Config, engine consensus.EngineReader, gp *GasPool, ibs *state.IntraBlockState,
|
||||
stateWriter state.StateWriter, header *types.Header, tx types.Transaction, usedGas, usedDataGas *uint64,
|
||||
stateWriter state.StateWriter, header *types.Header, tx types.Transaction, usedGas, usedBlobGas *uint64,
|
||||
evm vm.VMInterface, cfg vm.Config) (*types.Receipt, []byte, error) {
|
||||
rules := evm.ChainRules()
|
||||
msg, err := tx.AsMessage(*types.MakeSigner(config, header.Number.Uint64(), header.Time), header.BaseFee, rules)
|
||||
@ -67,8 +67,8 @@ func applyTransaction(config *chain.Config, engine consensus.EngineReader, gp *G
|
||||
return nil, nil, err
|
||||
}
|
||||
*usedGas += result.UsedGas
|
||||
if usedDataGas != nil {
|
||||
*usedDataGas += tx.GetDataGas()
|
||||
if usedBlobGas != nil {
|
||||
*usedBlobGas += tx.GetBlobGas()
|
||||
}
|
||||
|
||||
// Set the receipt logs and create the bloom filter.
|
||||
@ -104,7 +104,7 @@ func applyTransaction(config *chain.Config, engine consensus.EngineReader, gp *G
|
||||
// indicating the block was invalid.
|
||||
func ApplyTransaction(config *chain.Config, blockHashFunc func(n uint64) libcommon.Hash, engine consensus.EngineReader,
|
||||
author *libcommon.Address, gp *GasPool, ibs *state.IntraBlockState, stateWriter state.StateWriter,
|
||||
header *types.Header, tx types.Transaction, usedGas, usedDataGas *uint64, cfg vm.Config,
|
||||
header *types.Header, tx types.Transaction, usedGas, usedBlobGas *uint64, cfg vm.Config,
|
||||
) (*types.Receipt, []byte, error) {
|
||||
// Create a new context to be used in the EVM environment
|
||||
|
||||
@ -115,5 +115,5 @@ func ApplyTransaction(config *chain.Config, blockHashFunc func(n uint64) libcomm
|
||||
blockContext := NewEVMBlockContext(header, blockHashFunc, engine, author)
|
||||
vmenv := vm.NewEVM(blockContext, evmtypes.TxContext{}, ibs, config, cfg)
|
||||
|
||||
return applyTransaction(config, engine, gp, ibs, stateWriter, header, tx, usedGas, usedDataGas, vmenv, cfg)
|
||||
return applyTransaction(config, engine, gp, ibs, stateWriter, header, tx, usedGas, usedBlobGas, vmenv, cfg)
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ type Message interface {
|
||||
FeeCap() *uint256.Int
|
||||
Tip() *uint256.Int
|
||||
Gas() uint64
|
||||
DataGas() uint64
|
||||
MaxFeePerDataGas() *uint256.Int
|
||||
BlobGas() uint64
|
||||
MaxFeePerBlobGas() *uint256.Int
|
||||
Value() *uint256.Int
|
||||
|
||||
Nonce() uint64
|
||||
@ -201,21 +201,21 @@ func (st *StateTransition) buyGas(gasBailout bool) error {
|
||||
return fmt.Errorf("%w: address %v", ErrInsufficientFunds, st.msg.From().Hex())
|
||||
}
|
||||
|
||||
// compute data fee for eip-4844 data blobs if any
|
||||
// compute blob fee for eip-4844 data blobs if any
|
||||
dgval := new(uint256.Int)
|
||||
if st.evm.ChainRules().IsCancun {
|
||||
if st.evm.Context().ExcessDataGas == nil {
|
||||
return fmt.Errorf("%w: Cancun is active but ExcessDataGas is nil", ErrInternalFailure)
|
||||
if st.evm.Context().ExcessBlobGas == nil {
|
||||
return fmt.Errorf("%w: Cancun is active but ExcessBlobGas is nil", ErrInternalFailure)
|
||||
}
|
||||
dataGasPrice, err := misc.GetDataGasPrice(*st.evm.Context().ExcessDataGas)
|
||||
blobGasPrice, err := misc.GetBlobGasPrice(*st.evm.Context().ExcessBlobGas)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, overflow = dgval.MulOverflow(dataGasPrice, new(uint256.Int).SetUint64(st.msg.DataGas()))
|
||||
_, overflow = dgval.MulOverflow(blobGasPrice, new(uint256.Int).SetUint64(st.msg.BlobGas()))
|
||||
if overflow {
|
||||
return fmt.Errorf("%w: overflow converting datagas: %v", ErrInsufficientFunds, dgval)
|
||||
return fmt.Errorf("%w: overflow converting blob gas: %v", ErrInsufficientFunds, dgval)
|
||||
}
|
||||
if err := st.gp.SubDataGas(st.msg.DataGas()); err != nil {
|
||||
if err := st.gp.SubBlobGas(st.msg.BlobGas()); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -306,19 +306,19 @@ func (st *StateTransition) preCheck(gasBailout bool) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
if st.msg.DataGas() > 0 && st.evm.ChainRules().IsCancun {
|
||||
if st.evm.Context().ExcessDataGas == nil {
|
||||
return fmt.Errorf("%w: Cancun is active but ExcessDataGas is nil", ErrInternalFailure)
|
||||
if st.msg.BlobGas() > 0 && st.evm.ChainRules().IsCancun {
|
||||
if st.evm.Context().ExcessBlobGas == nil {
|
||||
return fmt.Errorf("%w: Cancun is active but ExcessBlobGas is nil", ErrInternalFailure)
|
||||
}
|
||||
dataGasPrice, err := misc.GetDataGasPrice(*st.evm.Context().ExcessDataGas)
|
||||
blobGasPrice, err := misc.GetBlobGasPrice(*st.evm.Context().ExcessBlobGas)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
maxFeePerDataGas := st.msg.MaxFeePerDataGas()
|
||||
if dataGasPrice.Cmp(maxFeePerDataGas) > 0 {
|
||||
return fmt.Errorf("%w: address %v, maxFeePerDataGas: %v dataGasPrice: %v, excessDataGas: %v",
|
||||
ErrMaxFeePerDataGas,
|
||||
st.msg.From().Hex(), st.msg.MaxFeePerDataGas(), dataGasPrice, st.evm.Context().ExcessDataGas)
|
||||
maxFeePerBlobGas := st.msg.MaxFeePerBlobGas()
|
||||
if blobGasPrice.Cmp(maxFeePerBlobGas) > 0 {
|
||||
return fmt.Errorf("%w: address %v, maxFeePerBlobGas: %v blobGasPrice: %v, excessBlobGas: %v",
|
||||
ErrMaxFeePerBlobGas,
|
||||
st.msg.From().Hex(), st.msg.MaxFeePerBlobGas(), blobGasPrice, st.evm.Context().ExcessBlobGas)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
types2 "github.com/ledgerwatch/erigon-lib/types"
|
||||
|
||||
"github.com/ledgerwatch/erigon/rlp"
|
||||
@ -17,7 +18,7 @@ import (
|
||||
|
||||
type BlobTx struct {
|
||||
DynamicFeeTransaction
|
||||
MaxFeePerDataGas *uint256.Int
|
||||
MaxFeePerBlobGas *uint256.Int
|
||||
BlobVersionedHashes []libcommon.Hash
|
||||
}
|
||||
|
||||
@ -25,12 +26,12 @@ type BlobTx struct {
|
||||
func (stx BlobTx) copy() *BlobTx {
|
||||
cpy := &BlobTx{
|
||||
DynamicFeeTransaction: *stx.DynamicFeeTransaction.copy(),
|
||||
MaxFeePerDataGas: new(uint256.Int),
|
||||
MaxFeePerBlobGas: new(uint256.Int),
|
||||
BlobVersionedHashes: make([]libcommon.Hash, len(stx.BlobVersionedHashes)),
|
||||
}
|
||||
copy(cpy.BlobVersionedHashes, stx.BlobVersionedHashes)
|
||||
if stx.MaxFeePerDataGas != nil {
|
||||
cpy.MaxFeePerDataGas.Set(stx.MaxFeePerDataGas)
|
||||
if stx.MaxFeePerBlobGas != nil {
|
||||
cpy.MaxFeePerBlobGas.Set(stx.MaxFeePerBlobGas)
|
||||
}
|
||||
return cpy
|
||||
}
|
||||
@ -41,8 +42,8 @@ func (stx BlobTx) GetDataHashes() []libcommon.Hash {
|
||||
return stx.BlobVersionedHashes
|
||||
}
|
||||
|
||||
func (stx BlobTx) GetDataGas() uint64 {
|
||||
return chain.DataGasPerBlob * uint64(len(stx.BlobVersionedHashes))
|
||||
func (stx BlobTx) GetBlobGas() uint64 {
|
||||
return fixedgas.BlobGasPerBlob * uint64(len(stx.BlobVersionedHashes))
|
||||
}
|
||||
|
||||
func (stx BlobTx) AsMessage(s Signer, baseFee *big.Int, rules *chain.Rules) (Message, error) {
|
||||
@ -68,7 +69,7 @@ func (stx BlobTx) Hash() libcommon.Hash {
|
||||
stx.Value,
|
||||
stx.Data,
|
||||
stx.AccessList,
|
||||
stx.MaxFeePerDataGas,
|
||||
stx.MaxFeePerBlobGas,
|
||||
stx.BlobVersionedHashes,
|
||||
stx.V, stx.R, stx.S,
|
||||
})
|
||||
@ -89,16 +90,16 @@ func (stx BlobTx) SigningHash(chainID *big.Int) libcommon.Hash {
|
||||
stx.Value,
|
||||
stx.Data,
|
||||
stx.AccessList,
|
||||
stx.MaxFeePerDataGas,
|
||||
stx.MaxFeePerBlobGas,
|
||||
stx.BlobVersionedHashes,
|
||||
})
|
||||
}
|
||||
|
||||
func (stx BlobTx) payloadSize() (payloadSize, nonceLen, gasLen, accessListLen, blobHashesLen int) {
|
||||
payloadSize, nonceLen, gasLen, accessListLen = stx.DynamicFeeTransaction.payloadSize()
|
||||
// size of MaxFeePerDataGas
|
||||
// size of MaxFeePerBlobGas
|
||||
payloadSize++
|
||||
payloadSize += rlp.Uint256LenExcludingHead(stx.MaxFeePerDataGas)
|
||||
payloadSize += rlp.Uint256LenExcludingHead(stx.MaxFeePerBlobGas)
|
||||
// size of BlobVersionedHashes
|
||||
payloadSize++
|
||||
blobHashesLen = blobVersionedHashesSize(stx.BlobVersionedHashes)
|
||||
@ -177,8 +178,8 @@ func (stx BlobTx) encodePayload(w io.Writer, b []byte, payloadSize, nonceLen, ga
|
||||
if err := encodeAccessList(stx.AccessList, w, b); err != nil {
|
||||
return err
|
||||
}
|
||||
// encode MaxFeePerDataGas
|
||||
if err := stx.MaxFeePerDataGas.EncodeRLP(w); err != nil {
|
||||
// encode MaxFeePerBlobGas
|
||||
if err := stx.MaxFeePerBlobGas.EncodeRLP(w); err != nil {
|
||||
return err
|
||||
}
|
||||
// prefix
|
||||
@ -296,11 +297,11 @@ func (stx *BlobTx) DecodeRLP(s *rlp.Stream) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// decode MaxFeePerDataGas
|
||||
// decode MaxFeePerBlobGas
|
||||
if b, err = s.Uint256Bytes(); err != nil {
|
||||
return err
|
||||
}
|
||||
stx.MaxFeePerDataGas = new(uint256.Int).SetBytes(b)
|
||||
stx.MaxFeePerBlobGas = new(uint256.Int).SetBytes(b)
|
||||
|
||||
// decode BlobVersionedHashes
|
||||
stx.BlobVersionedHashes = []libcommon.Hash{}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
libkzg "github.com/ledgerwatch/erigon-lib/crypto/kzg"
|
||||
types2 "github.com/ledgerwatch/erigon-lib/types"
|
||||
|
||||
@ -24,7 +25,7 @@ const (
|
||||
|
||||
type KZGCommitment [LEN_48]byte // Compressed BLS12-381 G1 element
|
||||
type KZGProof [LEN_48]byte
|
||||
type Blob [chain.BlobSize]byte
|
||||
type Blob [fixedgas.BlobSize]byte
|
||||
|
||||
type BlobKzgs []KZGCommitment
|
||||
type KZGProofs []KZGProof
|
||||
@ -40,9 +41,9 @@ type BlobTxWrapper struct {
|
||||
/* Blob methods */
|
||||
|
||||
func (b *Blob) payloadSize() int {
|
||||
size := 1 // 0xb7..0xbf
|
||||
size += libcommon.BitLenToByteLen(bits.Len(chain.BlobSize)) // length encoding size
|
||||
size += chain.BlobSize // byte_array it self
|
||||
size := 1 // 0xb7..0xbf
|
||||
size += libcommon.BitLenToByteLen(bits.Len(fixedgas.BlobSize)) // length encoding size
|
||||
size += fixedgas.BlobSize // byte_array it self
|
||||
return size
|
||||
}
|
||||
|
||||
@ -186,7 +187,7 @@ func (blobs *Blobs) DecodeRLP(s *rlp.Stream) error {
|
||||
blob := Blob{}
|
||||
|
||||
for b, err = s.Bytes(); err == nil; b, err = s.Bytes() {
|
||||
if len(b) == chain.BlobSize {
|
||||
if len(b) == fixedgas.BlobSize {
|
||||
copy((blob)[:], b)
|
||||
*blobs = append(*blobs, blob)
|
||||
} else {
|
||||
@ -267,10 +268,10 @@ func (txw *BlobTxWrapper) ValidateBlobTransactionWrapper() error {
|
||||
if l1 != l2 || l1 != l3 || l1 != l4 {
|
||||
return fmt.Errorf("lengths don't match %v %v %v %v", l1, l2, l3, l4)
|
||||
}
|
||||
// the following check isn't strictly necessary as it would be caught by data gas processing
|
||||
// the following check isn't strictly necessary as it would be caught by blob gas processing
|
||||
// (and hence it is not explicitly in the spec for this function), but it doesn't hurt to fail
|
||||
// early in case we are getting spammed with too many blobs or there is a bug somewhere:
|
||||
if uint64(l1) > chain.MaxBlobsPerBlock {
|
||||
if uint64(l1) > fixedgas.MaxBlobsPerBlock {
|
||||
return fmt.Errorf("number of blobs exceeds max: %v", l1)
|
||||
}
|
||||
kzgCtx := libkzg.Ctx()
|
||||
@ -302,7 +303,7 @@ func (txw *BlobTxWrapper) Cost() *uint256.Int { return txw.Tx.GetFeeCap() }
|
||||
func (txw *BlobTxWrapper) GetDataHashes() []libcommon.Hash { return txw.Tx.GetDataHashes() }
|
||||
|
||||
func (txw *BlobTxWrapper) GetGas() uint64 { return txw.Tx.GetGas() }
|
||||
func (txw *BlobTxWrapper) GetDataGas() uint64 { return txw.Tx.GetDataGas() }
|
||||
func (txw *BlobTxWrapper) GetBlobGas() uint64 { return txw.Tx.GetBlobGas() }
|
||||
func (txw *BlobTxWrapper) GetValue() *uint256.Int { return txw.Tx.GetValue() }
|
||||
func (txw *BlobTxWrapper) Time() time.Time { return txw.Tx.Time() }
|
||||
func (txw *BlobTxWrapper) GetTo() *libcommon.Address { return txw.Tx.GetTo() }
|
||||
|
@ -97,9 +97,9 @@ type Header struct {
|
||||
BaseFee *big.Int `json:"baseFeePerGas"` // EIP-1559
|
||||
WithdrawalsHash *libcommon.Hash `json:"withdrawalsRoot"` // EIP-4895
|
||||
|
||||
// DataGasUsed & ExcessDataGas were added by EIP-4844 and are ignored in legacy headers.
|
||||
DataGasUsed *uint64 `json:"dataGasUsed"`
|
||||
ExcessDataGas *uint64 `json:"excessDataGas"`
|
||||
// BlobGasUsed & ExcessBlobGas were added by EIP-4844 and are ignored in legacy headers.
|
||||
BlobGasUsed *uint64 `json:"blobGasUsed"`
|
||||
ExcessBlobGas *uint64 `json:"excessBlobGas"`
|
||||
|
||||
// The verkle proof is ignored in legacy headers
|
||||
Verkle bool
|
||||
@ -158,13 +158,13 @@ func (h *Header) EncodingSize() int {
|
||||
encodingSize += 33
|
||||
}
|
||||
|
||||
if h.DataGasUsed != nil {
|
||||
if h.BlobGasUsed != nil {
|
||||
encodingSize++
|
||||
encodingSize += rlp.IntLenExcludingHead(*h.DataGasUsed)
|
||||
encodingSize += rlp.IntLenExcludingHead(*h.BlobGasUsed)
|
||||
}
|
||||
if h.ExcessDataGas != nil {
|
||||
if h.ExcessBlobGas != nil {
|
||||
encodingSize++
|
||||
encodingSize += rlp.IntLenExcludingHead(*h.ExcessDataGas)
|
||||
encodingSize += rlp.IntLenExcludingHead(*h.ExcessBlobGas)
|
||||
}
|
||||
|
||||
if h.Verkle {
|
||||
@ -309,13 +309,13 @@ func (h *Header) EncodeRLP(w io.Writer) error {
|
||||
}
|
||||
}
|
||||
|
||||
if h.DataGasUsed != nil {
|
||||
if err := rlp.EncodeInt(*h.DataGasUsed, w, b[:]); err != nil {
|
||||
if h.BlobGasUsed != nil {
|
||||
if err := rlp.EncodeInt(*h.BlobGasUsed, w, b[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if h.ExcessDataGas != nil {
|
||||
if err := rlp.EncodeInt(*h.ExcessDataGas, w, b[:]); err != nil {
|
||||
if h.ExcessBlobGas != nil {
|
||||
if err := rlp.EncodeInt(*h.ExcessBlobGas, w, b[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -465,31 +465,31 @@ func (h *Header) DecodeRLP(s *rlp.Stream) error {
|
||||
h.WithdrawalsHash = new(libcommon.Hash)
|
||||
h.WithdrawalsHash.SetBytes(b)
|
||||
|
||||
var dataGasUsed uint64
|
||||
if dataGasUsed, err = s.Uint(); err != nil {
|
||||
var blobGasUsed uint64
|
||||
if blobGasUsed, err = s.Uint(); err != nil {
|
||||
if errors.Is(err, rlp.EOL) {
|
||||
h.DataGasUsed = nil
|
||||
h.BlobGasUsed = nil
|
||||
if err := s.ListEnd(); err != nil {
|
||||
return fmt.Errorf("close header struct (no DataGasUsed): %w", err)
|
||||
return fmt.Errorf("close header struct (no BlobGasUsed): %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("read DataGasUsed: %w", err)
|
||||
return fmt.Errorf("read BlobGasUsed: %w", err)
|
||||
}
|
||||
h.DataGasUsed = &dataGasUsed
|
||||
h.BlobGasUsed = &blobGasUsed
|
||||
|
||||
var excessDataGas uint64
|
||||
if excessDataGas, err = s.Uint(); err != nil {
|
||||
var excessBlobGas uint64
|
||||
if excessBlobGas, err = s.Uint(); err != nil {
|
||||
if errors.Is(err, rlp.EOL) {
|
||||
h.ExcessDataGas = nil
|
||||
h.ExcessBlobGas = nil
|
||||
if err := s.ListEnd(); err != nil {
|
||||
return fmt.Errorf("close header struct (no ExcessDataGas): %w", err)
|
||||
return fmt.Errorf("close header struct (no ExcessBlobGas): %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("read ExcessDataGas: %w", err)
|
||||
return fmt.Errorf("read ExcessBlobGas: %w", err)
|
||||
}
|
||||
h.ExcessDataGas = &excessDataGas
|
||||
h.ExcessBlobGas = &excessBlobGas
|
||||
|
||||
if h.Verkle {
|
||||
if h.VerkleProof, err = s.Bytes(); err != nil {
|
||||
@ -517,8 +517,8 @@ type headerMarshaling struct {
|
||||
Time hexutil.Uint64
|
||||
Extra hexutility.Bytes
|
||||
BaseFee *hexutil.Big
|
||||
DataGasUsed *hexutil.Uint64
|
||||
ExcessDataGas *hexutil.Uint64
|
||||
BlobGasUsed *hexutil.Uint64
|
||||
ExcessBlobGas *hexutil.Uint64
|
||||
Hash libcommon.Hash `json:"hash"` // adds call to Hash() in MarshalJSON
|
||||
}
|
||||
|
||||
@ -541,10 +541,10 @@ func (h *Header) Size() common.StorageSize {
|
||||
if h.WithdrawalsHash != nil {
|
||||
s += common.StorageSize(32)
|
||||
}
|
||||
if h.DataGasUsed != nil {
|
||||
if h.BlobGasUsed != nil {
|
||||
s += common.StorageSize(8)
|
||||
}
|
||||
if h.ExcessDataGas != nil {
|
||||
if h.ExcessBlobGas != nil {
|
||||
s += common.StorageSize(8)
|
||||
}
|
||||
return s
|
||||
@ -1210,13 +1210,13 @@ func CopyHeader(h *Header) *Header {
|
||||
cpy.WithdrawalsHash = new(libcommon.Hash)
|
||||
cpy.WithdrawalsHash.SetBytes(h.WithdrawalsHash.Bytes())
|
||||
}
|
||||
if h.DataGasUsed != nil {
|
||||
dataGasUsed := *h.DataGasUsed
|
||||
cpy.DataGasUsed = &dataGasUsed
|
||||
if h.BlobGasUsed != nil {
|
||||
blobGasUsed := *h.BlobGasUsed
|
||||
cpy.BlobGasUsed = &blobGasUsed
|
||||
}
|
||||
if h.ExcessDataGas != nil {
|
||||
excessDataGas := *h.ExcessDataGas
|
||||
cpy.ExcessDataGas = &excessDataGas
|
||||
if h.ExcessBlobGas != nil {
|
||||
excessBlobGas := *h.ExcessBlobGas
|
||||
cpy.ExcessBlobGas = &excessBlobGas
|
||||
}
|
||||
return &cpy
|
||||
}
|
||||
|
@ -29,8 +29,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
|
||||
Mixhash libcommon.Hash `json:"mixHash"`
|
||||
Coinbase libcommon.Address `json:"coinbase"`
|
||||
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
||||
DataGasUsed *math.HexOrDecimal64 `json:"dataGasUsed"`
|
||||
ExcessDataGas *math.HexOrDecimal64 `json:"excessDataGas"`
|
||||
BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"`
|
||||
ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"`
|
||||
Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc" gencodec:"required"`
|
||||
AuRaStep math.HexOrDecimal64 `json:"auRaStep"`
|
||||
AuRaSeal hexutility.Bytes `json:"auRaSeal"`
|
||||
@ -48,8 +48,8 @@ func (g Genesis) MarshalJSON() ([]byte, error) {
|
||||
enc.Mixhash = g.Mixhash
|
||||
enc.Coinbase = g.Coinbase
|
||||
enc.BaseFee = (*math.HexOrDecimal256)(g.BaseFee)
|
||||
enc.DataGasUsed = (*math.HexOrDecimal64)(g.DataGasUsed)
|
||||
enc.ExcessDataGas = (*math.HexOrDecimal64)(g.ExcessDataGas)
|
||||
enc.BlobGasUsed = (*math.HexOrDecimal64)(g.BlobGasUsed)
|
||||
enc.ExcessBlobGas = (*math.HexOrDecimal64)(g.ExcessBlobGas)
|
||||
if g.Alloc != nil {
|
||||
enc.Alloc = make(map[common.UnprefixedAddress]GenesisAccount, len(g.Alloc))
|
||||
for k, v := range g.Alloc {
|
||||
@ -76,8 +76,8 @@ func (g *Genesis) UnmarshalJSON(input []byte) error {
|
||||
Mixhash *libcommon.Hash `json:"mixHash"`
|
||||
Coinbase *libcommon.Address `json:"coinbase"`
|
||||
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
||||
DataGasUsed *math.HexOrDecimal64 `json:"dataGasUsed"`
|
||||
ExcessDataGas *math.HexOrDecimal64 `json:"excessDataGas"`
|
||||
BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"`
|
||||
ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"`
|
||||
Alloc map[common.UnprefixedAddress]GenesisAccount `json:"alloc" gencodec:"required"`
|
||||
AuRaStep *math.HexOrDecimal64 `json:"auRaStep"`
|
||||
AuRaSeal *hexutility.Bytes `json:"auRaSeal"`
|
||||
@ -118,11 +118,11 @@ func (g *Genesis) UnmarshalJSON(input []byte) error {
|
||||
if dec.BaseFee != nil {
|
||||
g.BaseFee = (*big.Int)(dec.BaseFee)
|
||||
}
|
||||
if dec.DataGasUsed != nil {
|
||||
g.DataGasUsed = (*uint64)(dec.DataGasUsed)
|
||||
if dec.BlobGasUsed != nil {
|
||||
g.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
|
||||
}
|
||||
if dec.ExcessDataGas != nil {
|
||||
g.ExcessDataGas = (*uint64)(dec.ExcessDataGas)
|
||||
if dec.ExcessBlobGas != nil {
|
||||
g.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
||||
}
|
||||
if dec.Alloc == nil {
|
||||
return errors.New("missing required field 'alloc' for Genesis")
|
||||
|
@ -50,8 +50,8 @@ type Genesis struct {
|
||||
Mixhash common.Hash `json:"mixHash"`
|
||||
Coinbase common.Address `json:"coinbase"`
|
||||
BaseFee *big.Int `json:"baseFeePerGas"`
|
||||
DataGasUsed *uint64 `json:"dataGasUsed"`
|
||||
ExcessDataGas *uint64 `json:"excessDataGas"`
|
||||
BlobGasUsed *uint64 `json:"blobGasUsed"`
|
||||
ExcessBlobGas *uint64 `json:"excessBlobGas"`
|
||||
Alloc GenesisAlloc `json:"alloc" gencodec:"required"`
|
||||
AuRaStep uint64 `json:"auRaStep"`
|
||||
AuRaSeal []byte `json:"auRaSeal"`
|
||||
@ -106,8 +106,8 @@ type genesisSpecMarshaling struct {
|
||||
Number math.HexOrDecimal64
|
||||
Difficulty *math.HexOrDecimal256
|
||||
BaseFee *math.HexOrDecimal256
|
||||
DataGasUsed *math.HexOrDecimal64
|
||||
ExcessDataGas *math.HexOrDecimal64
|
||||
BlobGasUsed *math.HexOrDecimal64
|
||||
ExcessBlobGas *math.HexOrDecimal64
|
||||
Alloc map[common2.UnprefixedAddress]GenesisAccount
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ func (ct CommonTx) GetTo() *libcommon.Address {
|
||||
return ct.To
|
||||
}
|
||||
|
||||
func (ct CommonTx) GetDataGas() uint64 {
|
||||
func (ct CommonTx) GetBlobGas() uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
types2 "github.com/ledgerwatch/erigon-lib/types"
|
||||
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
@ -67,7 +68,7 @@ type Transaction interface {
|
||||
Cost() *uint256.Int
|
||||
GetDataHashes() []libcommon.Hash
|
||||
GetGas() uint64
|
||||
GetDataGas() uint64
|
||||
GetBlobGas() uint64
|
||||
GetValue() *uint256.Int
|
||||
Time() time.Time
|
||||
GetTo() *libcommon.Address
|
||||
@ -519,7 +520,7 @@ type Message struct {
|
||||
gasPrice uint256.Int
|
||||
feeCap uint256.Int
|
||||
tip uint256.Int
|
||||
maxFeePerDataGas uint256.Int
|
||||
maxFeePerBlobGas uint256.Int
|
||||
data []byte
|
||||
accessList types2.AccessList
|
||||
checkNonce bool
|
||||
@ -527,7 +528,10 @@ type Message struct {
|
||||
dataHashes []libcommon.Hash
|
||||
}
|
||||
|
||||
func NewMessage(from libcommon.Address, to *libcommon.Address, nonce uint64, amount *uint256.Int, gasLimit uint64, gasPrice *uint256.Int, feeCap, tip *uint256.Int, data []byte, accessList types2.AccessList, checkNonce bool, isFree bool, maxFeePerDataGas *uint256.Int) Message {
|
||||
func NewMessage(from libcommon.Address, to *libcommon.Address, nonce uint64, amount *uint256.Int, gasLimit uint64,
|
||||
gasPrice *uint256.Int, feeCap, tip *uint256.Int, data []byte, accessList types2.AccessList, checkNonce bool,
|
||||
isFree bool, maxFeePerBlobGas *uint256.Int,
|
||||
) Message {
|
||||
m := Message{
|
||||
from: from,
|
||||
to: to,
|
||||
@ -548,8 +552,8 @@ func NewMessage(from libcommon.Address, to *libcommon.Address, nonce uint64, amo
|
||||
if feeCap != nil {
|
||||
m.feeCap.Set(feeCap)
|
||||
}
|
||||
if maxFeePerDataGas != nil {
|
||||
m.maxFeePerDataGas.Set(maxFeePerDataGas)
|
||||
if maxFeePerBlobGas != nil {
|
||||
m.maxFeePerBlobGas.Set(maxFeePerBlobGas)
|
||||
}
|
||||
return m
|
||||
}
|
||||
@ -589,9 +593,10 @@ func (m *Message) ChangeGas(globalGasCap, desiredGas uint64) {
|
||||
m.gasLimit = gas
|
||||
}
|
||||
|
||||
func (m Message) DataGas() uint64 { return chain.DataGasPerBlob * uint64(len(m.dataHashes)) }
|
||||
func (m Message) MaxFeePerDataGas() *uint256.Int {
|
||||
return &m.maxFeePerDataGas
|
||||
func (m Message) BlobGas() uint64 { return fixedgas.BlobGasPerBlob * uint64(len(m.dataHashes)) }
|
||||
|
||||
func (m Message) MaxFeePerBlobGas() *uint256.Int {
|
||||
return &m.maxFeePerBlobGas
|
||||
}
|
||||
|
||||
func (m Message) DataHashes() []libcommon.Hash { return m.dataHashes }
|
||||
|
@ -37,7 +37,7 @@ type txJSON struct {
|
||||
AccessList *types2.AccessList `json:"accessList,omitempty"`
|
||||
|
||||
// Blob transaction fields:
|
||||
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||
BlobVersionedHashes []libcommon.Hash `json:"blobVersionedHashes,omitempty"`
|
||||
// Blob wrapper fields:
|
||||
Blobs Blobs `json:"blobs,omitempty"`
|
||||
@ -124,7 +124,7 @@ func toBlobTxJSON(tx *BlobTx) *txJSON {
|
||||
enc.V = (*hexutil.Big)(tx.V.ToBig())
|
||||
enc.R = (*hexutil.Big)(tx.R.ToBig())
|
||||
enc.S = (*hexutil.Big)(tx.S.ToBig())
|
||||
enc.MaxFeePerDataGas = (*hexutil.Big)(tx.MaxFeePerDataGas.ToBig())
|
||||
enc.MaxFeePerBlobGas = (*hexutil.Big)(tx.MaxFeePerBlobGas.ToBig())
|
||||
enc.BlobVersionedHashes = tx.GetDataHashes()
|
||||
return &enc
|
||||
}
|
||||
@ -467,15 +467,15 @@ func UnmarshalBlobTxJSON(input []byte) (Transaction, error) {
|
||||
}
|
||||
tx.Data = *dec.Data
|
||||
|
||||
if dec.MaxFeePerDataGas == nil {
|
||||
return nil, errors.New("missing required field 'maxFeePerDataGas' in transaction")
|
||||
if dec.MaxFeePerBlobGas == nil {
|
||||
return nil, errors.New("missing required field 'maxFeePerBlobGas' in transaction")
|
||||
}
|
||||
|
||||
maxFeePerDataGas, overflow := uint256.FromBig(dec.MaxFeePerDataGas.ToInt())
|
||||
maxFeePerBlobGas, overflow := uint256.FromBig(dec.MaxFeePerBlobGas.ToInt())
|
||||
if overflow {
|
||||
return nil, errors.New("'maxFeePerDataGas' in transaction does not fit in 256 bits")
|
||||
return nil, errors.New("'maxFeePerBlobGas' in transaction does not fit in 256 bits")
|
||||
}
|
||||
tx.MaxFeePerDataGas = maxFeePerDataGas
|
||||
tx.MaxFeePerBlobGas = maxFeePerBlobGas
|
||||
|
||||
if dec.BlobVersionedHashes != nil {
|
||||
tx.BlobVersionedHashes = dec.BlobVersionedHashes
|
||||
|
@ -32,8 +32,8 @@ import (
|
||||
"github.com/holiman/uint256"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
types2 "github.com/ledgerwatch/erigon-lib/types"
|
||||
|
||||
"github.com/ledgerwatch/erigon/common"
|
||||
@ -698,7 +698,7 @@ func newRandBlobTx() *BlobTx {
|
||||
FeeCap: uint256.NewInt(rand.Uint64()),
|
||||
AccessList: randAccessList(),
|
||||
},
|
||||
MaxFeePerDataGas: uint256.NewInt(rand.Uint64()),
|
||||
MaxFeePerBlobGas: uint256.NewInt(rand.Uint64()),
|
||||
BlobVersionedHashes: randHashes(randIntInRange(0, 6)),
|
||||
}
|
||||
return stx
|
||||
@ -715,7 +715,7 @@ func printSTX(stx *BlobTx) {
|
||||
fmt.Printf("Value: %v\n", stx.Value)
|
||||
fmt.Printf("Data: %v\n", stx.Data)
|
||||
fmt.Printf("AccessList: %v\n", stx.AccessList)
|
||||
fmt.Printf("MaxFeePerDataGas: %v\n", stx.MaxFeePerDataGas)
|
||||
fmt.Printf("MaxFeePerBlobGas: %v\n", stx.MaxFeePerBlobGas)
|
||||
fmt.Printf("BlobVersionedHashes: %v\n", stx.BlobVersionedHashes)
|
||||
fmt.Printf("V: %v\n", stx.V)
|
||||
fmt.Printf("R: %v\n", stx.R)
|
||||
@ -764,8 +764,8 @@ func newRandProofs(size int) KZGProofs {
|
||||
func newRandBlobs(size int) Blobs {
|
||||
var result Blobs
|
||||
for i := 0; i < size; i++ {
|
||||
var arr [chain.BlobSize]byte
|
||||
for j := 0; j < chain.BlobSize; j++ {
|
||||
var arr [fixedgas.BlobSize]byte
|
||||
for j := 0; j < fixedgas.BlobSize; j++ {
|
||||
arr[j] = randByte()
|
||||
}
|
||||
result = append(result, arr)
|
||||
|
@ -32,7 +32,7 @@ type BlockContext struct {
|
||||
Difficulty *big.Int // Provides information for DIFFICULTY
|
||||
BaseFee *uint256.Int // Provides information for BASEFEE
|
||||
PrevRanDao *common.Hash // Provides information for PREVRANDAO
|
||||
ExcessDataGas *uint64 // Provides information for handling data blobs
|
||||
ExcessBlobGas *uint64 // Provides information for handling data blobs
|
||||
}
|
||||
|
||||
// TxContext provides the EVM with information about a transaction.
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/memdb"
|
||||
types2 "github.com/ledgerwatch/erigon-lib/types"
|
||||
@ -49,7 +50,7 @@ type MiningExecCfg struct {
|
||||
}
|
||||
|
||||
type TxPoolForMining interface {
|
||||
YieldBest(n uint16, txs *types2.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableDataGas uint64, toSkip mapset.Set[[32]byte]) (bool, int, error)
|
||||
YieldBest(n uint16, txs *types2.TxsRlp, tx kv.Tx, onTopOf, availableGas, availableBlobGas uint64, toSkip mapset.Set[[32]byte]) (bool, int, error)
|
||||
}
|
||||
|
||||
func StageMiningExecCfg(
|
||||
@ -194,11 +195,11 @@ func getNextTransactions(
|
||||
counter := 0
|
||||
for !onTime && counter < 1000 {
|
||||
remainingGas := header.GasLimit - header.GasUsed
|
||||
remainingDataGas := uint64(0)
|
||||
if header.DataGasUsed != nil {
|
||||
remainingDataGas = chain.MaxDataGasPerBlock - *header.DataGasUsed
|
||||
remainingBlobGas := uint64(0)
|
||||
if header.BlobGasUsed != nil {
|
||||
remainingBlobGas = fixedgas.MaxBlobGasPerBlock - *header.BlobGasUsed
|
||||
}
|
||||
if onTime, count, err = cfg.txPool2.YieldBest(amount, &txSlots, poolTx, executionAt, remainingGas, remainingDataGas, alreadyYielded); err != nil {
|
||||
if onTime, count, err = cfg.txPool2.YieldBest(amount, &txSlots, poolTx, executionAt, remainingGas, remainingBlobGas, alreadyYielded); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
@ -371,13 +372,13 @@ func addTransactionsToMiningBlock(logPrefix string, current *MiningBlock, chainC
|
||||
var miningCommitTx = func(txn types.Transaction, coinbase libcommon.Address, vmConfig *vm.Config, chainConfig chain.Config, ibs *state.IntraBlockState, current *MiningBlock) ([]*types.Log, error) {
|
||||
ibs.SetTxContext(txn.Hash(), libcommon.Hash{}, tcount)
|
||||
gasSnap := gasPool.Gas()
|
||||
dataGasSnap := gasPool.DataGas()
|
||||
blobGasSnap := gasPool.BlobGas()
|
||||
snap := ibs.Snapshot()
|
||||
logger.Debug("addTransactionsToMiningBlock", "txn hash", txn.Hash())
|
||||
receipt, _, err := core.ApplyTransaction(&chainConfig, core.GetHashFn(header, getHeader), engine, &coinbase, gasPool, ibs, noop, header, txn, &header.GasUsed, header.DataGasUsed, *vmConfig)
|
||||
receipt, _, err := core.ApplyTransaction(&chainConfig, core.GetHashFn(header, getHeader), engine, &coinbase, gasPool, ibs, noop, header, txn, &header.GasUsed, header.BlobGasUsed, *vmConfig)
|
||||
if err != nil {
|
||||
ibs.RevertToSnapshot(snap)
|
||||
gasPool = new(core.GasPool).AddGas(gasSnap).AddDataGas(dataGasSnap) // restore gasPool as well as ibs
|
||||
gasPool = new(core.GasPool).AddGas(gasSnap).AddBlobGas(blobGasSnap) // restore gasPool as well as ibs
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||
}
|
||||
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()), true /* refunds */, false /* gasBailout */)
|
||||
vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddBlobGas(tx.GetBlobGas()), true /* refunds */, false /* gasBailout */)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to execute transaction: %v", err)
|
||||
}
|
||||
@ -271,7 +271,7 @@ func benchTracer(b *testing.B, tracerName string, test *callTracerTest) {
|
||||
}
|
||||
evm := vm.NewEVM(context, txContext, statedb, test.Genesis.Config, vm.Config{Debug: true, Tracer: tracer})
|
||||
snap := statedb.Snapshot()
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()))
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddBlobGas(tx.GetBlobGas()))
|
||||
if _, err = st.TransitionDb(true /* refunds */, false /* gasBailout */); err != nil {
|
||||
b.Fatalf("failed to execute transaction: %v", err)
|
||||
}
|
||||
@ -348,7 +348,7 @@ func TestZeroValueToNotExitCall(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||
}
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()))
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddBlobGas(tx.GetBlobGas()))
|
||||
if _, err = st.TransitionDb(true /* refunds */, false /* gasBailout */); err != nil {
|
||||
t.Fatalf("failed to execute transaction: %v", err)
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||
}
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()))
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddBlobGas(tx.GetBlobGas()))
|
||||
if _, err = st.TransitionDb(true /* refunds */, false /* gasBailout */); err != nil {
|
||||
t.Fatalf("failed to execute transaction: %v", err)
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func TestPrestateTracerCreate2(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to prepare transaction for tracing: %v", err)
|
||||
}
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(txn.GetGas()).AddDataGas(txn.GetDataGas()))
|
||||
st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(txn.GetGas()).AddBlobGas(txn.GetBlobGas()))
|
||||
if _, err = st.TransitionDb(false, false); err != nil {
|
||||
t.Fatalf("failed to execute transaction: %v", err)
|
||||
}
|
||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230727220941-7a00f70fb35d
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230728095057-c07cefc3c985
|
||||
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2
|
||||
github.com/ledgerwatch/log/v3 v3.8.0
|
||||
github.com/ledgerwatch/secp256k1 v1.0.0
|
||||
|
4
go.sum
4
go.sum
@ -499,8 +499,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
|
||||
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
|
||||
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230727220941-7a00f70fb35d h1:EjFyTSy8ymmZY3IFBRoJyMekXTO9o8vCGZWjA5I05ZM=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230727220941-7a00f70fb35d/go.mod h1:k8pDfuQxOA2IJvgJVbw0iEmro2ri3jLUyDANMhPIbWk=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230728095057-c07cefc3c985 h1:pNBpL8TaVtTsoaOw+SnI98EL9gkGnsqQIL6/Nld0u54=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230728095057-c07cefc3c985/go.mod h1:oUVOQUwhe67CVZ+AKN6rQj/djCvnxEIUmnputz9Q48Q=
|
||||
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2 h1:Ls2itRGHMOr2PbHRDA4g1HH8HQdwfJhRVfMPEaLQe94=
|
||||
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230622075030-1d69651854c2/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
|
||||
github.com/ledgerwatch/log/v3 v3.8.0 h1:gCpp7uGtIerEz1jKVPeDnbIopFPud9ZnCpBLlLBGqPU=
|
||||
|
@ -119,7 +119,7 @@ type CallMsg struct {
|
||||
From libcommon.Address // the sender of the 'transaction'
|
||||
To *libcommon.Address // the destination contract (nil for contract creation)
|
||||
Gas uint64 // if 0, the call executes with near-infinite gas
|
||||
MaxFeePerDataGas *uint256.Int // EIP-4844 max_fee_per_data_gas
|
||||
MaxFeePerBlobGas *uint256.Int // EIP-4844 max_fee_per_blob_gas
|
||||
GasPrice *uint256.Int // wei <-> gas exchange ratio
|
||||
Value *uint256.Int // amount of wei sent along with the call
|
||||
Data []byte // input data, usually an ABI-encoded contract method invocation
|
||||
|
@ -163,8 +163,8 @@ const (
|
||||
RefundQuotientEIP3529 uint64 = 5
|
||||
|
||||
// EIP-4844: Shard Blob Transactions
|
||||
MinDataGasPrice = 1
|
||||
DataGasPriceUpdateFraction = 3338477
|
||||
MinBlobGasPrice = 1
|
||||
BlobGasPriceUpdateFraction = 3338477
|
||||
PointEvaluationGas uint64 = 50000
|
||||
)
|
||||
|
||||
|
@ -30,6 +30,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutility"
|
||||
"github.com/ledgerwatch/erigon-lib/common/length"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
@ -247,7 +248,7 @@ func (t *StateTest) RunNoVerify(tx kv.RwTx, subtest StateSubtest, vmconfig vm.Co
|
||||
// Execute the message.
|
||||
snapshot := statedb.Snapshot()
|
||||
gaspool := new(core.GasPool)
|
||||
gaspool.AddGas(block.GasLimit()).AddDataGas(chain.MaxDataGasPerBlock)
|
||||
gaspool.AddGas(block.GasLimit()).AddBlobGas(fixedgas.MaxBlobGasPerBlock)
|
||||
if _, err = core.ApplyMessage(evm, msg, gaspool, true /* refunds */, false /* gasBailout */); err != nil {
|
||||
statedb.RevertToSnapshot(snapshot)
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ type CallArgs struct {
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
|
||||
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
|
||||
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas"`
|
||||
Value *hexutil.Big `json:"value"`
|
||||
Nonce *hexutil.Uint64 `json:"nonce"`
|
||||
Data *hexutility.Bytes `json:"data"`
|
||||
@ -85,7 +85,7 @@ func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *uint256.Int) (type
|
||||
gasPrice *uint256.Int
|
||||
gasFeeCap *uint256.Int
|
||||
gasTipCap *uint256.Int
|
||||
maxFeePerDataGas *uint256.Int
|
||||
maxFeePerBlobGas *uint256.Int
|
||||
)
|
||||
if baseFee == nil {
|
||||
// If there's no basefee, then it must be a non-1559 execution
|
||||
@ -129,8 +129,8 @@ func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *uint256.Int) (type
|
||||
gasPrice = math.U256Min(new(uint256.Int).Add(gasTipCap, baseFee), gasFeeCap)
|
||||
}
|
||||
}
|
||||
if args.MaxFeePerDataGas != nil {
|
||||
maxFeePerDataGas.SetFromBig(args.MaxFeePerDataGas.ToInt())
|
||||
if args.MaxFeePerBlobGas != nil {
|
||||
maxFeePerBlobGas.SetFromBig(args.MaxFeePerBlobGas.ToInt())
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *uint256.Int) (type
|
||||
accessList = *args.AccessList
|
||||
}
|
||||
|
||||
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, false /* checkNonce */, false /* isFree */, maxFeePerDataGas)
|
||||
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, false /* checkNonce */, false /* isFree */, maxFeePerBlobGas)
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
@ -286,11 +286,11 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
|
||||
if head.WithdrawalsHash != nil {
|
||||
result["withdrawalsRoot"] = head.WithdrawalsHash
|
||||
}
|
||||
if head.DataGasUsed != nil {
|
||||
result["dataGasUsed"] = (*hexutil.Uint64)(head.DataGasUsed)
|
||||
if head.BlobGasUsed != nil {
|
||||
result["blobGasUsed"] = (*hexutil.Uint64)(head.BlobGasUsed)
|
||||
}
|
||||
if head.ExcessDataGas != nil {
|
||||
result["excessDataGas"] = (*hexutil.Uint64)(head.ExcessDataGas)
|
||||
if head.ExcessBlobGas != nil {
|
||||
result["excessBlobGas"] = (*hexutil.Uint64)(head.ExcessBlobGas)
|
||||
}
|
||||
|
||||
return result
|
||||
@ -385,7 +385,7 @@ type RPCTransaction struct {
|
||||
GasPrice *hexutil.Big `json:"gasPrice,omitempty"`
|
||||
Tip *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"`
|
||||
FeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"`
|
||||
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||
Hash libcommon.Hash `json:"hash"`
|
||||
Input hexutility.Bytes `json:"input"`
|
||||
Nonce hexutil.Uint64 `json:"nonce"`
|
||||
@ -460,7 +460,7 @@ func newRPCTransaction(tx types.Transaction, blockHash libcommon.Hash, blockNumb
|
||||
result.Accesses = &t.AccessList
|
||||
// if the transaction has been mined, compute the effective gas price
|
||||
result.GasPrice = computeGasPrice(tx, blockHash, baseFee)
|
||||
result.MaxFeePerDataGas = (*hexutil.Big)(t.MaxFeePerDataGas.ToBig())
|
||||
result.MaxFeePerBlobGas = (*hexutil.Big)(t.MaxFeePerBlobGas.ToBig())
|
||||
result.BlobVersionedHashes = t.GetDataHashes()
|
||||
}
|
||||
signer := types.LatestSignerForChainID(chainId.ToBig())
|
||||
|
@ -162,16 +162,16 @@ func (s *EngineServer) newPayload(ctx context.Context, req *engine_types.Executi
|
||||
}
|
||||
|
||||
if version >= clparams.DenebVersion {
|
||||
header.DataGasUsed = (*uint64)(req.DataGasUsed)
|
||||
header.ExcessDataGas = (*uint64)(req.ExcessDataGas)
|
||||
header.BlobGasUsed = (*uint64)(req.BlobGasUsed)
|
||||
header.ExcessBlobGas = (*uint64)(req.ExcessBlobGas)
|
||||
}
|
||||
|
||||
if !s.config.IsCancun(header.Time) && (header.DataGasUsed != nil || header.ExcessDataGas != nil) {
|
||||
return nil, &rpc.InvalidParamsError{Message: "dataGasUsed/excessDataGas present before Cancun"}
|
||||
if !s.config.IsCancun(header.Time) && (header.BlobGasUsed != nil || header.ExcessBlobGas != nil) {
|
||||
return nil, &rpc.InvalidParamsError{Message: "blobGasUsed/excessBlobGas present before Cancun"}
|
||||
}
|
||||
|
||||
if s.config.IsCancun(header.Time) && (header.DataGasUsed == nil || header.ExcessDataGas == nil) {
|
||||
return nil, &rpc.InvalidParamsError{Message: "dataGasUsed/excessDataGas missing"}
|
||||
if s.config.IsCancun(header.Time) && (header.BlobGasUsed == nil || header.ExcessBlobGas == nil) {
|
||||
return nil, &rpc.InvalidParamsError{Message: "blobGasUsed/excessBlobGas missing"}
|
||||
}
|
||||
|
||||
blockHash := req.BlockHash
|
||||
@ -596,7 +596,7 @@ func (e *EngineServer) NewPayloadV2(ctx context.Context, payload *engine_types.E
|
||||
return e.newPayload(ctx, payload, clparams.CapellaVersion)
|
||||
}
|
||||
|
||||
// NewPayloadV3 processes new payloads (blocks) from the beacon chain with withdrawals & excess data gas.
|
||||
// NewPayloadV3 processes new payloads (blocks) from the beacon chain with withdrawals & blob gas.
|
||||
// See https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#engine_newpayloadv3
|
||||
func (e *EngineServer) NewPayloadV3(ctx context.Context, payload *engine_types.ExecutionPayload) (*engine_types.PayloadStatus, error) {
|
||||
return e.newPayload(ctx, payload, clparams.DenebVersion)
|
||||
|
@ -163,16 +163,16 @@ func (s *EngineServerExperimental) newPayload(ctx context.Context, req *engine_t
|
||||
}
|
||||
|
||||
if version >= clparams.DenebVersion {
|
||||
header.DataGasUsed = (*uint64)(req.DataGasUsed)
|
||||
header.ExcessDataGas = (*uint64)(req.ExcessDataGas)
|
||||
header.BlobGasUsed = (*uint64)(req.BlobGasUsed)
|
||||
header.ExcessBlobGas = (*uint64)(req.ExcessBlobGas)
|
||||
}
|
||||
|
||||
if !s.config.IsCancun(header.Time) && (header.DataGasUsed != nil || header.ExcessDataGas != nil) {
|
||||
return nil, &rpc.InvalidParamsError{Message: "dataGasUsed/excessDataGas present before Cancun"}
|
||||
if !s.config.IsCancun(header.Time) && (header.BlobGasUsed != nil || header.ExcessBlobGas != nil) {
|
||||
return nil, &rpc.InvalidParamsError{Message: "blobGasUsed/excessBlobGas present before Cancun"}
|
||||
}
|
||||
|
||||
if s.config.IsCancun(header.Time) && (header.DataGasUsed == nil || header.ExcessDataGas == nil) {
|
||||
return nil, &rpc.InvalidParamsError{Message: "dataGasUsed/excessDataGas missing"}
|
||||
if s.config.IsCancun(header.Time) && (header.BlobGasUsed == nil || header.ExcessBlobGas == nil) {
|
||||
return nil, &rpc.InvalidParamsError{Message: "blobGasUsed/excessBlobGas missing"}
|
||||
}
|
||||
|
||||
blockHash := req.BlockHash
|
||||
@ -616,7 +616,7 @@ func (e *EngineServerExperimental) NewPayloadV2(ctx context.Context, payload *en
|
||||
return e.newPayload(ctx, payload, clparams.CapellaVersion)
|
||||
}
|
||||
|
||||
// NewPayloadV3 processes new payloads (blocks) from the beacon chain with withdrawals & excess data gas.
|
||||
// NewPayloadV3 processes new payloads (blocks) from the beacon chain with withdrawals & blob gas.
|
||||
// See https://github.com/ethereum/execution-apis/blob/main/src/engine/specification.md#engine_newpayloadv3
|
||||
func (e *EngineServerExperimental) NewPayloadV3(ctx context.Context, payload *engine_types.ExecutionPayload) (*engine_types.PayloadStatus, error) {
|
||||
return e.newPayload(ctx, payload, clparams.DenebVersion)
|
||||
|
@ -30,8 +30,8 @@ type ExecutionPayload struct {
|
||||
BlockHash common.Hash `json:"blockHash" gencodec:"required"`
|
||||
Transactions []hexutility.Bytes `json:"transactions" gencodec:"required"`
|
||||
Withdrawals []*types.Withdrawal `json:"withdrawals"`
|
||||
DataGasUsed *hexutil.Uint64 `json:"dataGasUsed"`
|
||||
ExcessDataGas *hexutil.Uint64 `json:"excessDataGas"`
|
||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||
}
|
||||
|
||||
// PayloadAttributes represent the attributes required to start assembling a payload
|
||||
@ -137,10 +137,10 @@ func ConvertPayloadFromRpc(payload *types2.ExecutionPayload) *ExecutionPayload {
|
||||
res.Withdrawals = ConvertWithdrawalsFromRpc(payload.Withdrawals)
|
||||
}
|
||||
if payload.Version >= 3 {
|
||||
dataGasUsed := *payload.DataGasUsed
|
||||
res.DataGasUsed = (*hexutil.Uint64)(&dataGasUsed)
|
||||
excessDataGas := *payload.ExcessDataGas
|
||||
res.ExcessDataGas = (*hexutil.Uint64)(&excessDataGas)
|
||||
blobGasUsed := *payload.BlobGasUsed
|
||||
res.BlobGasUsed = (*hexutil.Uint64)(&blobGasUsed)
|
||||
excessBlobGas := *payload.ExcessBlobGas
|
||||
res.ExcessBlobGas = (*hexutil.Uint64)(&excessBlobGas)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
@ -149,10 +149,10 @@ func (e *EthereumExecutionModule) GetAssembledBlock(ctx context.Context, req *ex
|
||||
payload.Withdrawals = eth1_utils.ConvertWithdrawalsToRpc(block.Withdrawals())
|
||||
}
|
||||
|
||||
if header.DataGasUsed != nil && header.ExcessDataGas != nil {
|
||||
if header.BlobGasUsed != nil && header.ExcessBlobGas != nil {
|
||||
payload.Version = 3
|
||||
payload.DataGasUsed = header.DataGasUsed
|
||||
payload.ExcessDataGas = header.ExcessDataGas
|
||||
payload.BlobGasUsed = header.BlobGasUsed
|
||||
payload.ExcessBlobGas = header.ExcessBlobGas
|
||||
}
|
||||
|
||||
blockValue := blockValue(blockWithReceipts, baseFee)
|
||||
|
@ -46,8 +46,8 @@ func HeaderToHeaderRPC(header *types.Header) *execution.Header {
|
||||
OmmerHash: gointerfaces.ConvertHashToH256(header.UncleHash),
|
||||
BaseFeePerGas: baseFeeReply,
|
||||
WithdrawalHash: withdrawalHashReply,
|
||||
ExcessDataGas: header.ExcessDataGas,
|
||||
DataGasUsed: header.DataGasUsed,
|
||||
ExcessBlobGas: header.ExcessBlobGas,
|
||||
BlobGasUsed: header.BlobGasUsed,
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,8 +78,8 @@ func HeaderRpcToHeader(header *execution.Header) (*types.Header, error) {
|
||||
Extra: header.ExtraData,
|
||||
MixDigest: gointerfaces.ConvertH256ToHash(header.PrevRandao),
|
||||
Nonce: blockNonce,
|
||||
DataGasUsed: header.DataGasUsed,
|
||||
ExcessDataGas: header.ExcessDataGas,
|
||||
BlobGasUsed: header.BlobGasUsed,
|
||||
ExcessBlobGas: header.ExcessBlobGas,
|
||||
}
|
||||
if header.BaseFeePerGas != nil {
|
||||
h.BaseFee = gointerfaces.ConvertH256ToUint256Int(header.BaseFeePerGas).ToBig()
|
||||
|
@ -364,7 +364,7 @@ type RPCTransaction struct {
|
||||
Type hexutil.Uint64 `json:"type"`
|
||||
Accesses *types2.AccessList `json:"accessList,omitempty"`
|
||||
ChainID *hexutil.Big `json:"chainId,omitempty"`
|
||||
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas,omitempty"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas,omitempty"`
|
||||
BlobVersionedHashes []common.Hash `json:"blobVersionedHashes,omitempty"`
|
||||
V *hexutil.Big `json:"v"`
|
||||
R *hexutil.Big `json:"r"`
|
||||
@ -427,7 +427,7 @@ func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber
|
||||
result.S = (*hexutil.Big)(t.S.ToBig())
|
||||
result.Accesses = &t.AccessList
|
||||
result.GasPrice = computeGasPrice(tx, blockHash, baseFee)
|
||||
result.MaxFeePerDataGas = (*hexutil.Big)(t.MaxFeePerDataGas.ToBig())
|
||||
result.MaxFeePerBlobGas = (*hexutil.Big)(t.MaxFeePerBlobGas.ToBig())
|
||||
result.BlobVersionedHashes = t.BlobVersionedHashes
|
||||
}
|
||||
signer := types.LatestSignerForChainID(chainId.ToBig())
|
||||
|
@ -150,7 +150,7 @@ func (api *APIImpl) CallBundle(ctx context.Context, txHashes []common.Hash, stat
|
||||
|
||||
// Setup the gas pool (also for unmetered requests)
|
||||
// and apply the message.
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64).AddDataGas(math.MaxUint64)
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64).AddBlobGas(math.MaxUint64)
|
||||
|
||||
results := []map[string]interface{}{}
|
||||
|
||||
|
@ -543,7 +543,7 @@ func (api *APIImpl) CreateAccessList(ctx context.Context, args ethapi2.CallArgs,
|
||||
txCtx := core.NewEVMTxContext(msg)
|
||||
|
||||
evm := vm.NewEVM(blockCtx, txCtx, state, chainConfig, config)
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas())
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas())
|
||||
res, err := core.ApplyMessage(evm, msg, gp, true /* refunds */, false /* gasBailout */)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -204,7 +204,7 @@ func (api *APIImpl) CallMany(ctx context.Context, bundles []Bundle, simulateCont
|
||||
|
||||
// Setup the gas pool (also for unmetered requests)
|
||||
// and apply the message.
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64).AddDataGas(math.MaxUint64)
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64).AddBlobGas(math.MaxUint64)
|
||||
for idx, txn := range replayTransactions {
|
||||
st.SetTxContext(txn.Hash(), block.Hash(), idx)
|
||||
msg, err := txn.AsMessage(*signer, block.BaseFee(), rules)
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/ledgerwatch/erigon-lib/chain"
|
||||
"github.com/ledgerwatch/erigon-lib/common"
|
||||
"github.com/ledgerwatch/erigon-lib/common/fixedgas"
|
||||
"github.com/ledgerwatch/erigon-lib/common/hexutility"
|
||||
"github.com/ledgerwatch/erigon-lib/kv"
|
||||
"github.com/ledgerwatch/erigon-lib/kv/bitmapdb"
|
||||
@ -49,8 +50,8 @@ func (api *BaseAPI) getReceipts(ctx context.Context, tx kv.Tx, chainConfig *chai
|
||||
}
|
||||
|
||||
usedGas := new(uint64)
|
||||
usedDataGas := new(uint64)
|
||||
gp := new(core.GasPool).AddGas(block.GasLimit()).AddDataGas(chain.MaxDataGasPerBlock)
|
||||
usedBlobGas := new(uint64)
|
||||
gp := new(core.GasPool).AddGas(block.GasLimit()).AddBlobGas(fixedgas.MaxBlobGasPerBlock)
|
||||
|
||||
noopWriter := state.NewNoopWriter()
|
||||
|
||||
@ -66,7 +67,7 @@ func (api *BaseAPI) getReceipts(ctx context.Context, tx kv.Tx, chainConfig *chai
|
||||
header := block.Header()
|
||||
for i, txn := range block.Transactions() {
|
||||
ibs.SetTxContext(txn.Hash(), block.Hash(), i)
|
||||
receipt, _, err := core.ApplyTransaction(chainConfig, core.GetHashFn(header, getHeader), engine, nil, gp, ibs, noopWriter, header, txn, usedGas, usedDataGas, vm.Config{})
|
||||
receipt, _, err := core.ApplyTransaction(chainConfig, core.GetHashFn(header, getHeader), engine, nil, gp, ibs, noopWriter, header, txn, usedGas, usedBlobGas, vm.Config{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -517,7 +518,7 @@ func (e *intraBlockExec) execTx(txNum uint64, txIndex int, txn types.Transaction
|
||||
txHash := txn.Hash()
|
||||
e.ibs.Reset()
|
||||
e.ibs.SetTxContext(txHash, e.blockHash, txIndex)
|
||||
gp := new(core.GasPool).AddGas(txn.GetGas()).AddDataGas(txn.GetDataGas())
|
||||
gp := new(core.GasPool).AddGas(txn.GetGas()).AddBlobGas(txn.GetBlobGas())
|
||||
msg, err := txn.AsMessage(*e.signer, e.header.BaseFee, e.rules)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
@ -766,15 +767,15 @@ func marshalReceipt(receipt *types.Receipt, txn types.Transaction, chainConfig *
|
||||
// Set derived blob related fields
|
||||
numBlobs := len(txn.GetDataHashes())
|
||||
if numBlobs > 0 {
|
||||
if header.ExcessDataGas == nil {
|
||||
log.Warn("excess data gas not set when trying to marshal blob tx")
|
||||
if header.ExcessBlobGas == nil {
|
||||
log.Warn("excess blob gas not set when trying to marshal blob tx")
|
||||
} else {
|
||||
dataGasPrice, err := misc.GetDataGasPrice(*header.ExcessDataGas)
|
||||
blobGasPrice, err := misc.GetBlobGasPrice(*header.ExcessBlobGas)
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
}
|
||||
fields["dataGasPrice"] = dataGasPrice
|
||||
fields["dataGasUsed"] = misc.GetDataGasUsed(numBlobs)
|
||||
fields["blobGasPrice"] = blobGasPrice
|
||||
fields["blobGasUsed"] = misc.GetBlobGasUsed(numBlobs)
|
||||
}
|
||||
}
|
||||
return fields
|
||||
|
@ -142,7 +142,7 @@ func (api *OtterscanAPIImpl) runTracer(ctx context.Context, tx kv.Tx, hash commo
|
||||
}
|
||||
vmenv := vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, vmConfig)
|
||||
|
||||
result, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas()), true, false /* gasBailout */)
|
||||
result, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas()), true, false /* gasBailout */)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("tracing failed: %v", err)
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ func (api *OtterscanAPIImpl) genericTracer(dbtx kv.Tx, ctx context.Context, bloc
|
||||
TxContext := core.NewEVMTxContext(msg)
|
||||
|
||||
vmenv := vm.NewEVM(BlockContext, TxContext, ibs, chainConfig, vm.Config{Debug: true, Tracer: tracer})
|
||||
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()), true /* refunds */, false /* gasBailout */); err != nil {
|
||||
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.GetGas()).AddBlobGas(tx.GetBlobGas()), true /* refunds */, false /* gasBailout */); err != nil {
|
||||
return err
|
||||
}
|
||||
_ = ibs.FinalizeTx(rules, cachedWriter)
|
||||
|
@ -89,7 +89,7 @@ func (api *OtterscanAPIImpl) traceBlock(dbtx kv.Tx, ctx context.Context, blockNu
|
||||
TxContext := core.NewEVMTxContext(msg)
|
||||
|
||||
vmenv := vm.NewEVM(BlockContext, TxContext, ibs, chainConfig, vm.Config{Debug: true, Tracer: tracer})
|
||||
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()), true /* refunds */, false /* gasBailout */); err != nil {
|
||||
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.GetGas()).AddBlobGas(tx.GetBlobGas()), true /* refunds */, false /* gasBailout */); err != nil {
|
||||
return false, nil, err
|
||||
}
|
||||
_ = ibs.FinalizeTx(rules, cachedWriter)
|
||||
|
@ -52,7 +52,7 @@ type TraceCallParam struct {
|
||||
GasPrice *hexutil.Big `json:"gasPrice"`
|
||||
MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"`
|
||||
MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"`
|
||||
MaxFeePerDataGas *hexutil.Big `json:"maxFeePerDataGas"`
|
||||
MaxFeePerBlobGas *hexutil.Big `json:"maxFeePerBlobGas"`
|
||||
Value *hexutil.Big `json:"value"`
|
||||
Data hexutility.Bytes `json:"data"`
|
||||
AccessList *types2.AccessList `json:"accessList"`
|
||||
@ -154,7 +154,7 @@ func (args *TraceCallParam) ToMessage(globalGasCap uint64, baseFee *uint256.Int)
|
||||
gasPrice *uint256.Int
|
||||
gasFeeCap *uint256.Int
|
||||
gasTipCap *uint256.Int
|
||||
maxFeePerDataGas *uint256.Int
|
||||
maxFeePerBlobGas *uint256.Int
|
||||
)
|
||||
if baseFee == nil {
|
||||
// If there's no basefee, then it must be a non-1559 execution
|
||||
@ -202,8 +202,8 @@ func (args *TraceCallParam) ToMessage(globalGasCap uint64, baseFee *uint256.Int)
|
||||
gasFeeCap, gasTipCap = gasPrice, gasPrice
|
||||
}
|
||||
}
|
||||
if args.MaxFeePerDataGas != nil {
|
||||
maxFeePerDataGas.SetFromBig(args.MaxFeePerDataGas.ToInt())
|
||||
if args.MaxFeePerBlobGas != nil {
|
||||
maxFeePerBlobGas.SetFromBig(args.MaxFeePerBlobGas.ToInt())
|
||||
}
|
||||
}
|
||||
value := new(uint256.Int)
|
||||
@ -221,7 +221,7 @@ func (args *TraceCallParam) ToMessage(globalGasCap uint64, baseFee *uint256.Int)
|
||||
if args.AccessList != nil {
|
||||
accessList = *args.AccessList
|
||||
}
|
||||
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, false /* checkNonce */, false /* isFree */, maxFeePerDataGas)
|
||||
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, gasFeeCap, gasTipCap, data, accessList, false /* checkNonce */, false /* isFree */, maxFeePerBlobGas)
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
@ -973,7 +973,7 @@ func (api *TraceAPIImpl) Call(ctx context.Context, args TraceCallParam, traceTyp
|
||||
evm.Cancel()
|
||||
}()
|
||||
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas())
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas())
|
||||
var execResult *core.ExecutionResult
|
||||
ibs.SetTxContext(libcommon.Hash{}, libcommon.Hash{}, 0)
|
||||
execResult, err = core.ApplyMessage(evm, msg, gp, true /* refunds */, true /* gasBailout */)
|
||||
@ -1191,7 +1191,7 @@ func (api *TraceAPIImpl) doCallMany(ctx context.Context, dbtx kv.Tx, msgs []type
|
||||
|
||||
evm := vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, vmConfig)
|
||||
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas())
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas())
|
||||
var execResult *core.ExecutionResult
|
||||
// Clone the state cache before applying the changes, clone is discarded
|
||||
var cloneReader state.StateReader
|
||||
|
@ -767,7 +767,7 @@ func (api *TraceAPIImpl) filterV3(ctx context.Context, dbtx kv.TemporalTx, fromB
|
||||
txCtx := core.NewEVMTxContext(msg)
|
||||
evm := vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, vmConfig)
|
||||
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas())
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas())
|
||||
ibs.SetTxContext(txHash, lastBlockHash, txIndex)
|
||||
var execResult *core.ExecutionResult
|
||||
execResult, err = core.ApplyMessage(evm, msg, gp, true /* refunds */, false /* gasBailout */)
|
||||
|
@ -440,7 +440,7 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun
|
||||
|
||||
// Setup the gas pool (also for unmetered requests)
|
||||
// and apply the message.
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64).AddDataGas(math.MaxUint64)
|
||||
gp := new(core.GasPool).AddGas(math.MaxUint64).AddBlobGas(math.MaxUint64)
|
||||
for idx, txn := range replayTransactions {
|
||||
st.SetTxContext(txn.Hash(), block.Hash(), idx)
|
||||
msg, err := txn.AsMessage(*signer, block.BaseFee(), rules)
|
||||
|
@ -92,7 +92,7 @@ func DoCall(
|
||||
evm.Cancel()
|
||||
}()
|
||||
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas())
|
||||
gp := new(core.GasPool).AddGas(msg.Gas()).AddBlobGas(msg.BlobGas())
|
||||
result, err := core.ApplyMessage(evm, msg, gp, true /* refunds */, false /* gasBailout */)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -162,7 +162,7 @@ func (r *ReusableCaller) DoCallWithNewGas(
|
||||
timedOut = true
|
||||
}()
|
||||
|
||||
gp := new(core.GasPool).AddGas(r.message.Gas()).AddDataGas(r.message.DataGas())
|
||||
gp := new(core.GasPool).AddGas(r.message.Gas()).AddBlobGas(r.message.BlobGas())
|
||||
|
||||
result, err := core.ApplyMessage(r.evm, r.message, gp, true /* refunds */, false /* gasBailout */)
|
||||
if err != nil {
|
||||
|
@ -105,7 +105,7 @@ func ComputeTxEnv(ctx context.Context, engine consensus.EngineReader, block *typ
|
||||
}
|
||||
vmenv.Reset(TxContext, statedb)
|
||||
// Not yet the searched for transaction, execute on top of the current state
|
||||
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(txn.GetGas()).AddDataGas(txn.GetDataGas()), true /* refunds */, false /* gasBailout */); err != nil {
|
||||
if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(txn.GetGas()).AddBlobGas(txn.GetBlobGas()), true /* refunds */, false /* gasBailout */); err != nil {
|
||||
return nil, evmtypes.BlockContext{}, evmtypes.TxContext{}, nil, nil, fmt.Errorf("transaction %x failed: %w", txn.Hash(), err)
|
||||
}
|
||||
// Ensure any modifications are committed to the state
|
||||
@ -195,7 +195,7 @@ func TraceTx(
|
||||
callmsg := prepareCallMessage(message)
|
||||
result, err = statefull.ApplyBorMessage(*vmenv, callmsg)
|
||||
} else {
|
||||
result, err = core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas()).AddDataGas(message.DataGas()), refunds, false /* gasBailout */)
|
||||
result, err = core.ApplyMessage(vmenv, message, new(core.GasPool).AddGas(message.Gas()).AddBlobGas(message.BlobGas()), refunds, false /* gasBailout */)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user