Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter transaction #377

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
16 changes: 16 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,18 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
return sdb, nil
}

func (s *StateDB) FilterTx() {
s.arbExtraData.arbTxFilter = true
}

func (s *StateDB) ClearTxFilter() {
s.arbExtraData.arbTxFilter = false
}

func (s *StateDB) IsTxFiltered() bool {
return s.arbExtraData.arbTxFilter
}

// SetLogger sets the logger for account update hooks.
func (s *StateDB) SetLogger(l *tracing.Hooks) {
s.logger = l
Expand Down Expand Up @@ -736,6 +748,7 @@ func (s *StateDB) Copy() *StateDB {
recentWasms: s.arbExtraData.recentWasms.Copy(),
openWasmPages: s.arbExtraData.openWasmPages,
everWasmPages: s.arbExtraData.everWasmPages,
arbTxFilter: s.arbExtraData.arbTxFilter,
},

db: s.db,
Expand Down Expand Up @@ -1220,6 +1233,9 @@ func (s *StateDB) GetTrie() Trie {
// The associated block number of the state transition is also provided
// for more chain context.
func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, error) {
if s.arbExtraData.arbTxFilter {
return common.Hash{}, ErrArbTxFilter
}
// Short circuit in case any database failure occurred earlier.
if s.dbErr != nil {
return common.Hash{}, fmt.Errorf("commit aborted due to earlier error: %v", s.dbErr)
Expand Down
3 changes: 3 additions & 0 deletions core/state/statedb_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,16 @@ func (s *StateDB) Deterministic() bool {
return s.deterministic
}

var ErrArbTxFilter error = errors.New("internal error")

type ArbitrumExtraData struct {
unexpectedBalanceDelta *big.Int // total balance change across all accounts
userWasms UserWasms // user wasms encountered during execution
openWasmPages uint16 // number of pages currently open
everWasmPages uint16 // largest number of pages ever allocated during this tx's execution
activatedWasms map[common.Hash]ActivatedWasm // newly activated WASMs
recentWasms RecentWasms
arbTxFilter bool
}

func (s *StateDB) SetArbFinalizer(f func(*ArbitrumExtraData)) {
Expand Down
5 changes: 5 additions & 0 deletions core/vm/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ type StateDB interface {
// Arbitrum: preserve old empty account behavior
CreateZombieIfDeleted(common.Address)

// Arbitrum
eljobe marked this conversation as resolved.
Show resolved Hide resolved
FilterTx()
ClearTxFilter()
IsTxFiltered() bool

Deterministic() bool
Database() state.Database

Expand Down
Loading