mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 11:20:45 +00:00
Merge remote-tracking branch 'marius/eip-7778' into HEAD
This commit is contained in:
commit
6438bb43a2
2 changed files with 15 additions and 12 deletions
|
|
@ -527,6 +527,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
|||
peakGasUsed := st.gasUsed()
|
||||
|
||||
// Compute refund counter, capped to a refund quotient.
|
||||
gasBeforeRefunds := peakGasUsed
|
||||
st.gasRemaining += st.calcRefund()
|
||||
if rules.IsPrague {
|
||||
// After EIP-7623: Data-heavy transactions pay the floor gas.
|
||||
|
|
@ -541,7 +542,7 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
|||
peakGasUsed = floorDataGas
|
||||
}
|
||||
}
|
||||
st.returnGas()
|
||||
st.returnGas(rules, gasBeforeRefunds)
|
||||
|
||||
effectiveTip := msg.GasPrice
|
||||
if rules.IsLondon {
|
||||
|
|
@ -661,7 +662,7 @@ func (st *stateTransition) calcRefund() uint64 {
|
|||
|
||||
// returnGas returns ETH for remaining gas,
|
||||
// exchanged at the original rate.
|
||||
func (st *stateTransition) returnGas() {
|
||||
func (st *stateTransition) returnGas(rules params.Rules, gasBeforeRefunds uint64) {
|
||||
remaining := uint256.NewInt(st.gasRemaining)
|
||||
remaining.Mul(remaining, uint256.MustFromBig(st.msg.GasPrice))
|
||||
st.state.AddBalance(st.msg.From, remaining, tracing.BalanceIncreaseGasReturn)
|
||||
|
|
@ -670,9 +671,14 @@ func (st *stateTransition) returnGas() {
|
|||
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)
|
||||
if !rules.IsAmsterdam {
|
||||
// Pre-Amsterdam return remaining gas to the block gas counter so it is
|
||||
// available for the next transaction.
|
||||
st.gp.AddGas(st.gasRemaining)
|
||||
} else {
|
||||
// Post-Amsterdam only return the remaining gas minus the refunds.
|
||||
st.gp.AddGas(gasBeforeRefunds)
|
||||
}
|
||||
}
|
||||
|
||||
// gasUsed returns the amount of gas used up by the state transition.
|
||||
|
|
|
|||
|
|
@ -397,13 +397,10 @@ const (
|
|||
// execution (e.g. storage slot being cleared). this generates an increase in
|
||||
// gas. There is at most one of such gas change per transaction.
|
||||
GasChangeTxRefunds GasChangeReason = 3
|
||||
|
||||
// GasChangeTxLeftOverReturned is the amount of gas left over at the end of
|
||||
// transaction's execution that will be returned to the chain. This change
|
||||
// will always be a negative change as we "drain" left over gas towards 0.
|
||||
// If there was no gas left at the end of execution, no such even will be
|
||||
// emitted. The returned gas's value in Wei is returned to caller. There is
|
||||
// at most one of such gas change per transaction.
|
||||
// GasChangeTxLeftOverReturned is the amount of gas left over at the end of transaction's execution that will be returned
|
||||
// to the account. This change will always be a negative change as we "drain" left over gas towards 0. If there was no gas
|
||||
// left at the end of execution, no such even will be 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
|
||||
|
||||
// GasChangeCallInitialBalance is the initial balance for the call which
|
||||
|
|
|
|||
Loading…
Reference in a new issue