Skip to content

Commit c8da8af

Browse files
committed
Don't apply tobin tax after g-hardfork
1 parent 64d6392 commit c8da8af

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
@@ -142,25 +142,30 @@ func VerifySealFn(ref *types.Header, chain chainContext) func(*types.Header) boo
142142
// If the calculation or transfer of the tax amount fails for any reason, the regular transfer goes ahead.
143143
// NB: Gas is not charged or accounted for this calculation.
144144
func TobinTransfer(evm *vm.EVM, sender, recipient common.Address, amount *big.Int) {
145-
// Run only primary evm.Call() with tracer
146-
if evm.GetDebug() {
147-
evm.SetDebug(false)
148-
defer func() { evm.SetDebug(true) }()
149-
}
145+
// Only deduct tobin tax before the g hardfork
146+
if evm.ChainConfig().IsGFork(evm.Context.BlockNumber) {
147+
Transfer(evm.StateDB, sender, recipient, amount)
148+
} else {
149+
// Run only primary evm.Call() with tracer
150+
if evm.GetDebug() {
151+
evm.SetDebug(false)
152+
defer func() { evm.SetDebug(true) }()
153+
}
150154

151-
if amount.Cmp(big.NewInt(0)) != 0 {
152-
caller := &SharedEVMRunner{evm}
153-
tax, taxRecipient, err := reserve.ComputeTobinTax(caller, sender, amount)
154-
if err == nil {
155-
Transfer(evm.StateDB, sender, recipient, new(big.Int).Sub(amount, tax))
156-
Transfer(evm.StateDB, sender, taxRecipient, tax)
157-
return
158-
} else {
159-
log.Error("Failed to get tobin tax", "error", err)
155+
if amount.Cmp(big.NewInt(0)) != 0 {
156+
caller := &SharedEVMRunner{evm}
157+
tax, taxRecipient, err := reserve.ComputeTobinTax(caller, sender, amount)
158+
if err == nil {
159+
Transfer(evm.StateDB, sender, recipient, new(big.Int).Sub(amount, tax))
160+
Transfer(evm.StateDB, sender, taxRecipient, tax)
161+
return
162+
} else {
163+
log.Error("Failed to get tobin tax", "error", err)
164+
}
160165
}
161-
}
162166

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

0 commit comments

Comments
 (0)