Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
txpool, evm: skip blacklist and whitelist deployer check after Venoki (
Browse files Browse the repository at this point in the history
…#691)

* core/txpool, core/state_processor, vm/evm: Skip check for blacklisted after Venoki
* core/vm, core/txpool: Skip check for contract deployer after Venoki
  • Loading branch information
chiphamskymavis authored Feb 17, 2025
1 parent 449bd6a commit 49269a4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
3 changes: 2 additions & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func applyTransaction(

// Check if sender and recipient are blacklisted
payer := msg.Payer()
if config.Consortium != nil && config.IsOdysseus(blockNumber) {
// After the Venoki hardfork, all addresses now can submit transaction
if config.Consortium != nil && config.IsOdysseus(blockNumber) && !config.IsVenoki(blockNumber) {
contractAddr := config.BlacklistContractAddress
if state.IsAddressBlacklisted(statedb, contractAddr, &from) ||
state.IsAddressBlacklisted(statedb, contractAddr, msg.To()) ||
Expand Down
8 changes: 6 additions & 2 deletions core/txpool/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,12 @@ func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, op
}

if opts.Config != nil {
// The whitelisted deployer logic is not affective after Venoki
if tx.To() == nil && opts.Config.Consortium != nil {
var whitelisted bool
if opts.Config.IsAntenna(opts.Head.Number) {
if opts.Config.IsVenoki(opts.Head.Number) {
whitelisted = true
} else if opts.Config.IsAntenna(opts.Head.Number) {
whitelisted = state.IsWhitelistedDeployerV2(
opts.State,
from,
Expand All @@ -383,7 +386,8 @@ func ValidateTransactionWithState(tx *types.Transaction, signer types.Signer, op
}

// Check if sender, payer and recipient are blacklisted
if opts.Config.Consortium != nil && opts.Config.IsOdysseus(opts.Head.Number) {
// This is only affective from Odysseus to Venoki to prevent blacklisted address/contract
if opts.Config.Consortium != nil && opts.Config.IsOdysseus(opts.Head.Number) && !opts.Config.IsVenoki(opts.Head.Number) {
contractAddr := opts.Config.BlacklistContractAddress
if state.IsAddressBlacklisted(opts.State, contractAddr, &from) ||
state.IsAddressBlacklisted(opts.State, contractAddr, tx.To()) ||
Expand Down
29 changes: 17 additions & 12 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ func (evm *EVM) precompile(caller ContractRef, addr common.Address) (Precompiled
return contract, isPrecompile
}
}
if c := evm.ChainConfig().BlacklistContractAddress; evm.chainRules.IsOdysseusFork && evm.StateDB.Blacklisted(c, &addr) {
return &blacklistedAddress{}, true
// Blacklisted contract is only effective from Odysseus to Venoki
if evm.chainRules.IsOdysseusFork && !evm.chainRules.IsVenoki {
if c := evm.ChainConfig().BlacklistContractAddress; evm.StateDB.Blacklisted(c, &addr) {
return &blacklistedAddress{}, true
}
}

var precompiles map[common.Address]PrecompiledContract
Expand Down Expand Up @@ -525,16 +528,18 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
}
}

// Handle latest hardfork firstly.
if evm.chainRules.IsAntenna {
if !evm.StateDB.ValidDeployerV2(caller.Address(), evm.Context.Time, evm.ChainConfig().WhiteListDeployerContractV2Address) {
captureTraceEarly(ErrExecutionReverted)
return nil, common.Address{}, gas, ErrExecutionReverted
}
} else if evm.chainRules.IsOdysseusFork {
if !evm.StateDB.ValidDeployer(caller.Address()) {
captureTraceEarly(ErrExecutionReverted)
return nil, common.Address{}, gas, ErrExecutionReverted
// After Venoki, no need to check for whitelisted deployer anymore
if !evm.chainRules.IsVenoki {
if evm.chainRules.IsAntenna {
if !evm.StateDB.ValidDeployerV2(caller.Address(), evm.Context.Time, evm.ChainConfig().WhiteListDeployerContractV2Address) {
captureTraceEarly(ErrExecutionReverted)
return nil, common.Address{}, gas, ErrExecutionReverted
}
} else if evm.chainRules.IsOdysseusFork {
if !evm.StateDB.ValidDeployer(caller.Address()) {
captureTraceEarly(ErrExecutionReverted)
return nil, common.Address{}, gas, ErrExecutionReverted
}
}
}

Expand Down

0 comments on commit 49269a4

Please sign in to comment.