mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
core: remove SelfDestruct6780 method
This commit is contained in:
parent
fb1edbf02d
commit
070c3ee238
5 changed files with 12 additions and 33 deletions
|
|
@ -525,16 +525,6 @@ func (s *StateDB) SelfDestruct(addr common.Address) {
|
|||
}
|
||||
}
|
||||
|
||||
func (s *StateDB) SelfDestruct6780(addr common.Address) {
|
||||
stateObject := s.getStateObject(addr)
|
||||
if stateObject == nil {
|
||||
return
|
||||
}
|
||||
if stateObject.newContract {
|
||||
s.SelfDestruct(addr)
|
||||
}
|
||||
}
|
||||
|
||||
// SetTransientState sets transient storage for a given account. It
|
||||
// adds the change to the journal so that it can be rolled back
|
||||
// to its previous value if there is a revert.
|
||||
|
|
|
|||
|
|
@ -219,10 +219,6 @@ func (s *hookedStateDB) SelfDestruct(address common.Address) {
|
|||
s.inner.SelfDestruct(address)
|
||||
}
|
||||
|
||||
func (s *hookedStateDB) SelfDestruct6780(address common.Address) {
|
||||
s.inner.SelfDestruct6780(address)
|
||||
}
|
||||
|
||||
func (s *hookedStateDB) AddLog(log *types.Log) {
|
||||
// The inner will modify the log (add fields), so invoke that first
|
||||
s.inner.AddLog(log)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ func TestHooks_OnCodeChangeV2(t *testing.T) {
|
|||
|
||||
sdb.SetCode(common.Address{0xbb}, []byte{0x13, 38}, tracing.CodeChangeContractCreation)
|
||||
sdb.CreateContract(common.Address{0xbb})
|
||||
sdb.SelfDestruct6780(common.Address{0xbb})
|
||||
sdb.SelfDestruct(common.Address{0xbb})
|
||||
sdb.Finalise(true)
|
||||
|
||||
if len(result) != len(wants) {
|
||||
|
|
|
|||
|
|
@ -885,7 +885,7 @@ func opSelfdestruct(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, error) {
|
|||
|
||||
// The funds are burned immediately if the beneficiary is the caller itself,
|
||||
// in this case, the beneficiary's balance is not increased.
|
||||
if beneficiary != this {
|
||||
if this != beneficiary {
|
||||
evm.StateDB.AddBalance(beneficiary, balance, tracing.BalanceIncreaseSelfdestruct)
|
||||
}
|
||||
// Clear any leftover funds for the account being destructed.
|
||||
|
|
@ -909,26 +909,24 @@ func opSelfdestruct6780(pc *uint64, evm *EVM, scope *ScopeContext) ([]byte, erro
|
|||
balance = evm.StateDB.GetBalance(this)
|
||||
top = scope.Stack.pop()
|
||||
beneficiary = common.Address(top.Bytes20())
|
||||
|
||||
newContract = evm.StateDB.IsNewContract(this)
|
||||
)
|
||||
|
||||
if evm.StateDB.IsNewContract(this) {
|
||||
// Contract is newly created in this transaction, so it will be actually
|
||||
// deleted from the state.
|
||||
if this == beneficiary {
|
||||
// Since the contract will be deleted from state, it isn't necessary to
|
||||
// also subtract the balance beforehand as it will affect the tracing.
|
||||
} else {
|
||||
// Otherwise, we can proceed with transfer.
|
||||
// Contract is new and will actually be deleted.
|
||||
if newContract {
|
||||
if this != beneficiary { // Skip no-op transfer when self-destructing to self.
|
||||
evm.StateDB.AddBalance(beneficiary, balance, tracing.BalanceIncreaseSelfdestruct)
|
||||
}
|
||||
evm.StateDB.SubBalance(this, balance, tracing.BalanceDecreaseSelfdestruct)
|
||||
} else {
|
||||
// Contract already exists in the state, therefore it will send it's full
|
||||
// balance and remain in the state.
|
||||
evm.StateDB.SelfDestruct(this)
|
||||
}
|
||||
|
||||
// Contract already exists, only do transfer if beneficiary is not self.
|
||||
if !newContract && this != beneficiary {
|
||||
evm.StateDB.SubBalance(this, balance, tracing.BalanceDecreaseSelfdestruct)
|
||||
evm.StateDB.AddBalance(beneficiary, balance, tracing.BalanceIncreaseSelfdestruct)
|
||||
}
|
||||
evm.StateDB.SelfDestruct6780(this)
|
||||
|
||||
if tracer := evm.Config.Tracer; tracer != nil {
|
||||
if tracer.OnEnter != nil {
|
||||
|
|
|
|||
|
|
@ -60,11 +60,6 @@ type StateDB interface {
|
|||
SelfDestruct(common.Address)
|
||||
HasSelfDestructed(common.Address) bool
|
||||
|
||||
// SelfDestruct6780 is post-EIP6780 selfdestruct, which means that it's a
|
||||
// send-all-to-beneficiary, unless the contract was created in this same
|
||||
// transaction, in which case it will be destructed.
|
||||
SelfDestruct6780(common.Address)
|
||||
|
||||
// Exist reports whether the given account exists in state.
|
||||
// Notably this also returns true for self-destructed accounts within the current transaction.
|
||||
Exist(common.Address) bool
|
||||
|
|
|
|||
Loading…
Reference in a new issue