Skip to content

Commit 6af54b6

Browse files
committed
[evm] gate the generation of suicide transaction log (#4198)
1 parent e85611f commit 6af54b6

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

action/protocol/execution/evm/evmstatedbadapter.go

+17-14
Original file line numberDiff line numberDiff line change
@@ -440,20 +440,23 @@ func (stateDB *StateDBAdapter) Suicide(evmAddr common.Address) bool {
440440
stateDB.logError(err)
441441
return false
442442
}
443-
// before calling Suicide, EVM will transfer the contract's balance to beneficiary
444-
// need to create a transaction log on successful suicide
445-
if stateDB.lastAddBalanceAmount.Cmp(actBalance) == 0 {
446-
if stateDB.lastAddBalanceAmount.Cmp(big.NewInt(0)) > 0 {
447-
from, _ := address.FromBytes(evmAddr[:])
448-
stateDB.addTransactionLogs(&action.TransactionLog{
449-
Type: iotextypes.TransactionLogType_IN_CONTRACT_TRANSFER,
450-
Sender: from.String(),
451-
Recipient: stateDB.lastAddBalanceAddr,
452-
Amount: stateDB.lastAddBalanceAmount,
453-
})
454-
}
455-
} else {
456-
if stateDB.suicideTxLogMismatchPanic {
443+
// To ensure data consistency, generate this log after the hard-fork
444+
// a separate patch file will be created later to provide missing logs before the hard-fork
445+
// TODO: remove this gating once the hard-fork has passed
446+
if stateDB.suicideTxLogMismatchPanic {
447+
// before calling Suicide, EVM will transfer the contract's balance to beneficiary
448+
// need to create a transaction log on successful suicide
449+
if stateDB.lastAddBalanceAmount.Cmp(actBalance) == 0 {
450+
if stateDB.lastAddBalanceAmount.Cmp(big.NewInt(0)) > 0 {
451+
from, _ := address.FromBytes(evmAddr[:])
452+
stateDB.addTransactionLogs(&action.TransactionLog{
453+
Type: iotextypes.TransactionLogType_IN_CONTRACT_TRANSFER,
454+
Sender: from.String(),
455+
Recipient: stateDB.lastAddBalanceAddr,
456+
Amount: stateDB.lastAddBalanceAmount,
457+
})
458+
}
459+
} else {
457460
log.L().Panic("suicide contract's balance does not match",
458461
zap.String("suicide", actBalance.String()),
459462
zap.String("beneficiary", stateDB.lastAddBalanceAmount.String()))

0 commit comments

Comments
 (0)