Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions miner/algo_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
14 changes: 12 additions & 2 deletions miner/algo_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down