From de36b50a7b218aa6c96b0d406803380b80441fee Mon Sep 17 00:00:00 2001 From: Andrew Ashikhmin <34320705+yperbasis@users.noreply.github.com> Date: Mon, 4 Nov 2024 18:21:01 +0100 Subject: [PATCH] EIP-4844-pectra (collect blob gas fee) (#12611) Cherry pick #12574 into `release/2.61` --- core/state_transition.go | 9 ++++----- erigon-lib/chain/chain_config.go | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 923e811f5b5..61e85f09822 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -77,8 +77,6 @@ type StateTransition struct { //some pre-allocated intermediate variables sharedBuyGas *uint256.Int sharedBuyGasBalance *uint256.Int - - isBor bool } // Message represents a message sent to a contract. @@ -125,7 +123,6 @@ func IntrinsicGas(data []byte, accessList types2.AccessList, isContractCreation // NewStateTransition initialises and returns a new state transition object. func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition { - isBor := evm.ChainConfig().Bor != nil return &StateTransition{ gp: gp, evm: evm, @@ -139,8 +136,6 @@ func NewStateTransition(evm *vm.EVM, msg Message, gp *GasPool) *StateTransition sharedBuyGas: uint256.NewInt(0), sharedBuyGasBalance: uint256.NewInt(0), - - isBor: isBor, } } @@ -487,6 +482,10 @@ func (st *StateTransition) TransitionDb(refunds bool, gasBailout bool) (*evmtype if burntContractAddress != nil { burnAmount := new(uint256.Int).Mul(new(uint256.Int).SetUint64(st.gasUsed()), st.evm.Context.BaseFee) st.state.AddBalance(*burntContractAddress, burnAmount) + if rules.IsAura && rules.IsPrague { + // https://github.com/gnosischain/specs/blob/master/network-upgrades/pectra.md#eip-4844-pectra + st.state.AddBalance(*burntContractAddress, st.evm.BlobFee) + } } } diff --git a/erigon-lib/chain/chain_config.go b/erigon-lib/chain/chain_config.go index 5b21c4491fd..4f3313105af 100644 --- a/erigon-lib/chain/chain_config.go +++ b/erigon-lib/chain/chain_config.go @@ -75,7 +75,10 @@ type Config struct { TargetBlobGasPerBlock *uint64 `json:"targetBlobGasPerBlock,omitempty"` BlobGasPriceUpdateFraction *uint64 `json:"blobGasPriceUpdateFraction,omitempty"` - // (Optional) governance contract where EIP-1559 fees will be sent to that otherwise would be burnt since the London fork + // (Optional) governance contract where EIP-1559 fees will be sent to, which otherwise would be burnt since the London fork. + // A key corresponds to the block number, starting from which the fees are sent to the address (map value). + // Starting from Prague, EIP-4844 fees might be collected as well: + // see https://github.com/gnosischain/specs/blob/master/network-upgrades/pectra.md#eip-4844-pectra. BurntContract map[string]common.Address `json:"burntContract,omitempty"` // (Optional) deposit contract of PoS chains