mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
Merge remote-tracking branch 'marius/eip-7778' into HEAD
This commit is contained in:
commit
4a19266d7a
3 changed files with 21 additions and 14 deletions
|
|
@ -62,7 +62,8 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
var (
|
var (
|
||||||
config = p.chainConfig()
|
config = p.chainConfig()
|
||||||
receipts types.Receipts
|
receipts types.Receipts
|
||||||
usedGas = new(uint64)
|
chargedGas = new(uint64)
|
||||||
|
usedGas = uint64(0)
|
||||||
header = block.Header()
|
header = block.Header()
|
||||||
blockHash = block.Hash()
|
blockHash = block.Hash()
|
||||||
blockNumber = block.Number()
|
blockNumber = block.Number()
|
||||||
|
|
@ -103,10 +104,11 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
}
|
}
|
||||||
statedb.SetTxContext(tx.Hash(), i)
|
statedb.SetTxContext(tx.Hash(), i)
|
||||||
|
|
||||||
receipt, err := ApplyTransactionWithEVM(msg, gp, statedb, blockNumber, blockHash, context.Time, tx, usedGas, evm)
|
receipt, err := ApplyTransactionWithEVM(msg, gp, statedb, blockNumber, blockHash, context.Time, tx, chargedGas, evm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
|
return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err)
|
||||||
}
|
}
|
||||||
|
usedGas += receipt.GasUsed
|
||||||
receipts = append(receipts, receipt)
|
receipts = append(receipts, receipt)
|
||||||
allLogs = append(allLogs, receipt.Logs...)
|
allLogs = append(allLogs, receipt.Logs...)
|
||||||
|
|
||||||
|
|
@ -147,7 +149,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
Receipts: receipts,
|
Receipts: receipts,
|
||||||
Requests: requests,
|
Requests: requests,
|
||||||
Logs: allLogs,
|
Logs: allLogs,
|
||||||
GasUsed: *usedGas,
|
GasUsed: usedGas,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,7 +210,11 @@ func MakeReceipt(evm *vm.EVM, result *ExecutionResult, statedb *state.StateDB, b
|
||||||
receipt.Status = types.ReceiptStatusSuccessful
|
receipt.Status = types.ReceiptStatusSuccessful
|
||||||
}
|
}
|
||||||
receipt.TxHash = tx.Hash()
|
receipt.TxHash = tx.Hash()
|
||||||
receipt.GasUsed = result.UsedGas
|
if evm.ChainConfig().IsAmsterdam(blockNumber, blockTime) {
|
||||||
|
receipt.GasUsed = result.MaxUsedGas
|
||||||
|
} else {
|
||||||
|
receipt.GasUsed = result.UsedGas
|
||||||
|
}
|
||||||
|
|
||||||
if tx.Type() == types.BlobTxType {
|
if tx.Type() == types.BlobTxType {
|
||||||
receipt.BlobGasUsed = uint64(len(tx.BlobHashes()) * params.BlobTxBlobGasPerBlob)
|
receipt.BlobGasUsed = uint64(len(tx.BlobHashes()) * params.BlobTxBlobGasPerBlob)
|
||||||
|
|
|
||||||
|
|
@ -541,7 +541,14 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
||||||
peakGasUsed = floorDataGas
|
peakGasUsed = floorDataGas
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Return gas to the user
|
||||||
st.returnGas()
|
st.returnGas()
|
||||||
|
// Return gas to the gas pool
|
||||||
|
if rules.IsAmsterdam {
|
||||||
|
st.gp.AddGas(st.initialGas - peakGasUsed)
|
||||||
|
} else {
|
||||||
|
st.gp.AddGas(st.gasRemaining)
|
||||||
|
}
|
||||||
|
|
||||||
effectiveTip := msg.GasPrice
|
effectiveTip := msg.GasPrice
|
||||||
if rules.IsLondon {
|
if rules.IsLondon {
|
||||||
|
|
@ -669,10 +676,6 @@ func (st *stateTransition) returnGas() {
|
||||||
if st.evm.Config.Tracer != nil && st.evm.Config.Tracer.OnGasChange != nil && st.gasRemaining > 0 {
|
if st.evm.Config.Tracer != nil && st.evm.Config.Tracer.OnGasChange != nil && st.gasRemaining > 0 {
|
||||||
st.evm.Config.Tracer.OnGasChange(st.gasRemaining, 0, tracing.GasChangeTxLeftOverReturned)
|
st.evm.Config.Tracer.OnGasChange(st.gasRemaining, 0, tracing.GasChangeTxLeftOverReturned)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also return remaining gas to the block gas counter so it is
|
|
||||||
// available for the next transaction.
|
|
||||||
st.gp.AddGas(st.gasRemaining)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gasUsed returns the amount of gas used up by the state transition.
|
// gasUsed returns the amount of gas used up by the state transition.
|
||||||
|
|
|
||||||
|
|
@ -398,12 +398,10 @@ const (
|
||||||
// gas. There is at most one of such gas change per transaction.
|
// gas. There is at most one of such gas change per transaction.
|
||||||
GasChangeTxRefunds GasChangeReason = 3
|
GasChangeTxRefunds GasChangeReason = 3
|
||||||
|
|
||||||
// GasChangeTxLeftOverReturned is the amount of gas left over at the end of
|
// GasChangeTxLeftOverReturned is the amount of gas left over at the end of transaction's execution that will be returned
|
||||||
// transaction's execution that will be returned to the chain. This change
|
// to the account. This change will always be a negative change as we "drain" left over gas towards 0. If there was no gas
|
||||||
// will always be a negative change as we "drain" left over gas towards 0.
|
// left at the end of execution, no such even will be emitted. The returned gas's value in Wei is returned to caller.
|
||||||
// If there was no gas left at the end of execution, no such even will be
|
// There is at most one of such gas change per transaction.
|
||||||
// emitted. The returned gas's value in Wei is returned to caller. There is
|
|
||||||
// at most one of such gas change per transaction.
|
|
||||||
GasChangeTxLeftOverReturned GasChangeReason = 4
|
GasChangeTxLeftOverReturned GasChangeReason = 4
|
||||||
|
|
||||||
// GasChangeCallInitialBalance is the initial balance for the call which
|
// GasChangeCallInitialBalance is the initial balance for the call which
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue