Skip to content

Commit

Permalink
tx_pool: update the transaction validation logic to whitelist deploye…
Browse files Browse the repository at this point in the history
…r v2 (#361)

Update the transaction validation logic to use the whitelist deployer v2 after
Antenna hardfork.
  • Loading branch information
minh-bq committed Oct 4, 2023
1 parent b3eb1d3 commit 769d711
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ type TxPool struct {
eip2718 bool // Fork indicator whether we are using EIP-2718 type transactions.
eip1559 bool // Fork indicator whether we are using EIP-1559 type transactions.
odysseus bool // Fork indicator whether we are in the Odysseus stage.
antenna bool // Fork indicator whether we are in Antenna stage.

currentState *state.StateDB // Current state in the blockchain head
pendingNonces *txNoncer // Pending state tracking virtual nonces
Expand Down Expand Up @@ -653,7 +654,17 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {

// Contract creation transaction
if tx.To() == nil && pool.chainconfig.Consortium != nil {
whitelisted := state.IsWhitelistedDeployer(pool.currentState, from)
var whitelisted bool
if pool.antenna {
whitelisted = state.IsWhitelistedDeployerV2(
pool.currentState,
from,
pool.chain.CurrentBlock().Time(),
pool.chainconfig.WhiteListDeployerContractV2Address,
)
} else {
whitelisted = state.IsWhitelistedDeployer(pool.currentState, from)
}
if !whitelisted {
return ErrUnauthorizedDeployer
}
Expand Down Expand Up @@ -1333,6 +1344,7 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.eip2718 = pool.chainconfig.IsBerlin(next)
pool.eip1559 = pool.chainconfig.IsLondon(next)
pool.odysseus = pool.chainconfig.IsOdysseus(next)
pool.antenna = pool.chainconfig.IsAntenna(next)
}

// promoteExecutables moves transactions that have become processable from the
Expand Down

0 comments on commit 769d711

Please sign in to comment.