mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
core: fix selfdestructs
This commit is contained in:
parent
22c2891559
commit
d55c8f41d7
2 changed files with 7 additions and 24 deletions
|
|
@ -5,10 +5,10 @@
|
||||||
# https://github.com/ethereum/execution-spec-tests/releases/download/v5.1.0
|
# https://github.com/ethereum/execution-spec-tests/releases/download/v5.1.0
|
||||||
a3192784375acec7eaec492799d5c5d0c47a2909a3cc40178898e4ecd20cc416 fixtures_develop.tar.gz
|
a3192784375acec7eaec492799d5c5d0c47a2909a3cc40178898e4ecd20cc416 fixtures_develop.tar.gz
|
||||||
|
|
||||||
# version:spec-tests-bal v5.7.0
|
# version:spec-tests-bal v6.0.0
|
||||||
# https://github.com/ethereum/execution-spec-tests/releases
|
# https://github.com/ethereum/execution-spec-tests/releases
|
||||||
# https://github.com/ethereum/execution-spec-tests/releases/download/bal%40v5.7.0
|
# https://github.com/ethereum/execution-spec-tests/releases/download/bal%40v6.0.0
|
||||||
1b458d1d932e6b5ff4e2ac43882b48a145de5f13d2fb34833162a75e5690d2b5 fixtures_bal.tar.gz
|
683fe9a741480ca3a3b1eb98b6caaa72d461dede490358688f7194686edc2196 fixtures_bal.tar.gz
|
||||||
|
|
||||||
# version:golang 1.25.9
|
# version:golang 1.25.9
|
||||||
# https://go.dev/dl/
|
# https://go.dev/dl/
|
||||||
|
|
|
||||||
|
|
@ -634,10 +634,8 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
||||||
execGasUsed.StateGas = 0
|
execGasUsed.StateGas = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refund costs for selfdestructed accounts and slots.
|
|
||||||
if rules.IsAmsterdam && vmerr == nil {
|
if rules.IsAmsterdam && vmerr == nil {
|
||||||
cpsb := st.evm.Context.CostPerGasByte
|
cpsb := st.evm.Context.CostPerGasByte
|
||||||
stateGasUsed := int64(cost.StateGas) + execGasUsed.StateGas
|
|
||||||
var sdRefund uint64
|
var sdRefund uint64
|
||||||
for _, addr := range st.state.SameTxSelfDestructs() {
|
for _, addr := range st.state.SameTxSelfDestructs() {
|
||||||
r := params.AccountCreationSize * cpsb
|
r := params.AccountCreationSize * cpsb
|
||||||
|
|
@ -645,29 +643,14 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
||||||
r += uint64(st.state.GetCodeSize(addr)) * cpsb
|
r += uint64(st.state.GetCodeSize(addr)) * cpsb
|
||||||
sdRefund += r
|
sdRefund += r
|
||||||
}
|
}
|
||||||
if stateGasUsed < 0 {
|
if execGasUsed.StateGas <= 0 {
|
||||||
sdRefund = 0
|
sdRefund = 0
|
||||||
} else if sdRefund > uint64(stateGasUsed) {
|
} else if sdRefund > uint64(execGasUsed.StateGas) {
|
||||||
sdRefund = uint64(stateGasUsed)
|
sdRefund = uint64(execGasUsed.StateGas)
|
||||||
}
|
}
|
||||||
if sdRefund > 0 {
|
if sdRefund > 0 {
|
||||||
st.gasRemaining.StateGas += sdRefund
|
st.gasRemaining.StateGas += sdRefund
|
||||||
if execGasUsed.StateGas >= int64(sdRefund) {
|
execGasUsed.StateGas -= int64(sdRefund)
|
||||||
execGasUsed.StateGas -= int64(sdRefund)
|
|
||||||
} else {
|
|
||||||
var extra uint64
|
|
||||||
if execGasUsed.StateGas > 0 {
|
|
||||||
extra = sdRefund - uint64(execGasUsed.StateGas)
|
|
||||||
} else {
|
|
||||||
extra = sdRefund
|
|
||||||
}
|
|
||||||
execGasUsed.StateGas = 0
|
|
||||||
if cost.StateGas >= extra {
|
|
||||||
cost.StateGas -= extra
|
|
||||||
} else {
|
|
||||||
cost.StateGas = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue