Skip to content

Commit 2166ca7

Browse files
committed
Don't apply tobin tax after g-hardfork
1 parent fedfe26 commit 2166ca7

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

core/vm/vmcontext/context.go

+23-18
Original file line numberDiff line numberDiff line change
@@ -147,25 +147,30 @@ func VerifySealFn(ref *types.Header, chain chainContext) func(*types.Header) boo
147147
// If the calculation or transfer of the tax amount fails for any reason, the regular transfer goes ahead.
148148
// NB: Gas is not charged or accounted for this calculation.
149149
func TobinTransfer(evm *vm.EVM, sender, recipient common.Address, amount *big.Int) {
150-
// Run only primary evm.Call() with tracer
151-
if evm.GetDebug() {
152-
evm.SetDebug(false)
153-
defer func() { evm.SetDebug(true) }()
154-
}
150+
// Only deduct tobin tax before the g hardfork
151+
if evm.ChainConfig().IsGFork(evm.Context.BlockNumber) {
152+
Transfer(evm.StateDB, sender, recipient, amount)
153+
} else {
154+
// Run only primary evm.Call() with tracer
155+
if evm.GetDebug() {
156+
evm.SetDebug(false)
157+
defer func() { evm.SetDebug(true) }()
158+
}
155159

156-
if amount.Cmp(big.NewInt(0)) != 0 {
157-
caller := &SharedEVMRunner{evm}
158-
tax, taxRecipient, err := reserve.ComputeTobinTax(caller, sender, amount)
159-
if err == nil {
160-
Transfer(evm.StateDB, sender, recipient, new(big.Int).Sub(amount, tax))
161-
Transfer(evm.StateDB, sender, taxRecipient, tax)
162-
return
163-
} else {
164-
log.Error("Failed to get tobin tax", "error", err)
160+
if amount.Cmp(big.NewInt(0)) != 0 {
161+
caller := &SharedEVMRunner{evm}
162+
tax, taxRecipient, err := reserve.ComputeTobinTax(caller, sender, amount)
163+
if err == nil {
164+
Transfer(evm.StateDB, sender, recipient, new(big.Int).Sub(amount, tax))
165+
Transfer(evm.StateDB, sender, taxRecipient, tax)
166+
return
167+
} else {
168+
log.Error("Failed to get tobin tax", "error", err)
169+
}
165170
}
166-
}
167171

168-
// Complete a normal transfer if the amount is 0 or the tobin tax value is unable to be fetched and parsed.
169-
// We transfer even when the amount is 0 because state trie clearing [EIP161] is necessary at the end of a transaction
170-
Transfer(evm.StateDB, sender, recipient, amount)
172+
// Complete a normal transfer if the amount is 0 or the tobin tax value is unable to be fetched and parsed.
173+
// We transfer even when the amount is 0 because state trie clearing [EIP161] is necessary at the end of a transaction
174+
Transfer(evm.StateDB, sender, recipient, amount)
175+
}
171176
}

0 commit comments

Comments
 (0)