From 769d7116f1f3d86cb80d07e65dec6f95e7ffa391 Mon Sep 17 00:00:00 2001 From: minh-bq <97180373+minh-bq@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:25:12 +0700 Subject: [PATCH] tx_pool: update the transaction validation logic to whitelist deployer v2 (#361) Update the transaction validation logic to use the whitelist deployer v2 after Antenna hardfork. --- core/tx_pool.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/tx_pool.go b/core/tx_pool.go index 71a26e9edf..3fd9e4be37 100644 --- a/core/tx_pool.go +++ b/core/tx_pool.go @@ -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 @@ -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 } @@ -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