From d59e7c6c97e04b064b0102a358f854d2f48dd5be Mon Sep 17 00:00:00 2001 From: Vitaly Drogan Date: Mon, 19 Jun 2023 13:56:03 +0300 Subject: [PATCH] use access list tracing in builder --- miner/algo_common.go | 8 +++++--- miner/algo_common_test.go | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/miner/algo_common.go b/miner/algo_common.go index 5628756740..a7145d56a2 100644 --- a/miner/algo_common.go +++ b/miner/algo_common.go @@ -111,13 +111,15 @@ func applyTransactionWithBlacklist(signer types.Signer, config *params.ChainConf } } - touchTracer := logger.NewAccountTouchTracer() + // we set precompile to nil, but they are set in the validation code + // there will be no difference in the result if precompile is not it the blocklist + touchTracer := logger.NewAccessListTracer(nil, common.Address{}, common.Address{}, nil) cfg.Tracer = touchTracer cfg.Debug = true hook := func() error { - for _, address := range touchTracer.TouchedAddresses() { - if _, in := blacklist[address]; in { + for _, accessTuple := range touchTracer.AccessList() { + if _, in := blacklist[accessTuple.Address]; in { return errors.New("blacklist violation, tx trace") } } diff --git a/miner/algo_common_test.go b/miner/algo_common_test.go index b373728a46..ae023ca838 100644 --- a/miner/algo_common_test.go +++ b/miner/algo_common_test.go @@ -472,12 +472,22 @@ func TestBlacklist(t *testing.T) { tx = signers.signTx(4, 40000, big.NewInt(0), big.NewInt(1), payProxyAddress, big.NewInt(99), calldata) _, _, err = envDiff.commitTx(tx, chData) - fmt.Println("balance", envDiff.state.GetBalance(signers.addresses[3])) - if err == nil { t.Fatal("committed blacklisted transaction: trace") } + tx = signers.signTx(5, 40000, big.NewInt(0), big.NewInt(1), payProxyAddress, big.NewInt(0), calldata) + _, _, err = envDiff.commitTx(tx, chData) + if err == nil { + t.Fatal("committed blacklisted transaction: trace, zero value") + } + + tx = signers.signTx(6, 30000, big.NewInt(0), big.NewInt(1), payProxyAddress, big.NewInt(99), calldata) + _, _, err = envDiff.commitTx(tx, chData) + if err == nil { + t.Fatal("committed blacklisted transaction: trace, failed tx") + } + if *envDiff.gasPool != gasPoolBefore { t.Fatal("gasPool changed") }