Skip to content

Commit ba37ece

Browse files
interop: Check Access Lists in Builder (#541)
* Basic wiring: add CheckAccessList, stub CheckMessages * Make AccessList Filter * Implement Ingress Filter with Access Lists * Use Full Execution Descriptior * Early check expiry in filter * Move TxToInteropAccessList to Interop Types package * interop: Check Access Lists in Builder * Remove Interop PostValidation Diff Code * Only checkInterop if isInterop --------- Co-authored-by: protolambda <[email protected]>
1 parent 332a1ce commit ba37ece

File tree

6 files changed

+8
-64
lines changed

6 files changed

+8
-64
lines changed

core/state_processor.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,21 +225,10 @@ func MakeReceipt(evm *vm.EVM, result *ExecutionResult, statedb *state.StateDB, b
225225
// for the transaction, gas used and an error if the transaction failed,
226226
// indicating the block was invalid.
227227
func ApplyTransaction(evm *vm.EVM, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64) (*types.Receipt, error) {
228-
return ApplyTransactionExtended(evm, gp, statedb, header, tx, usedGas, nil)
229-
}
230-
231-
type ApplyTransactionOpts struct {
232-
PostValidation func(evm *vm.EVM, result *ExecutionResult) error
233-
}
234-
235-
func ApplyTransactionExtended(evm *vm.EVM, gp *GasPool, statedb *state.StateDB, header *types.Header, tx *types.Transaction, usedGas *uint64, extraOpts *ApplyTransactionOpts) (*types.Receipt, error) {
236228
msg, err := TransactionToMessage(tx, types.MakeSigner(evm.ChainConfig(), header.Number, header.Time), header.BaseFee)
237229
if err != nil {
238230
return nil, err
239231
}
240-
if extraOpts != nil {
241-
msg.PostValidation = extraOpts.PostValidation
242-
}
243232
// Create a new context to be used in the EVM environment
244233
return ApplyTransactionWithEVM(msg, gp, statedb, header.Number, header.Hash(), tx, usedGas, evm)
245234
}

core/state_transition.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,6 @@ type Message struct {
169169
IsDepositTx bool // IsDepositTx indicates the message is force-included and can persist a mint.
170170
Mint *big.Int // Mint is the amount to mint before EVM processing, or nil if there is no minting.
171171
RollupCostData types.RollupCostData // RollupCostData caches data to compute the fee we charge for data availability
172-
173-
// PostValidation is an optional check of the resulting post-state, if and when the message is
174-
// applied fully to the EVM. This function may return an error to deny inclusion of the message.
175-
PostValidation func(evm *vm.EVM, result *ExecutionResult) error
176172
}
177173

178174
// TransactionToMessage converts a transaction into a Message.
@@ -490,13 +486,6 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
490486
}
491487
err = nil
492488
}
493-
494-
if err == nil && st.msg.PostValidation != nil {
495-
if err := st.msg.PostValidation(st.evm, result); err != nil {
496-
return nil, err
497-
}
498-
}
499-
500489
return result, err
501490
}
502491

eth/interop.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ import (
1010
"github.com/ethereum/go-ethereum/miner"
1111
)
1212

13-
func (s *Ethereum) CheckMessages(ctx context.Context, messages []interoptypes.Message, minSafety interoptypes.SafetyLevel, executingTimestamp uint64) error {
14-
return errors.New("deprecated. use CheckAccessList")
15-
}
16-
1713
func (s *Ethereum) CheckAccessList(ctx context.Context, inboxEntries []common.Hash, minSafety interoptypes.SafetyLevel, execDesc interoptypes.ExecutingDescriptor) error {
1814
if s.interopRPC == nil {
1915
return errors.New("cannot check interop access list, no RPC available")

eth/interop/interop.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@ func NewInteropClient(rpcEndpoint string) *InteropClient {
4848
return &InteropClient{endpoint: rpcEndpoint}
4949
}
5050

51-
// CheckMessages checks if the given messages meet the given minimum safety level.
52-
func (cl *InteropClient) CheckMessages(ctx context.Context, messages []interoptypes.Message, minSafety interoptypes.SafetyLevel, executingDescriptor interoptypes.ExecutingDescriptor) error {
53-
return errors.New("deprecated. use CheckAccessList")
54-
}
55-
5651
func (cl *InteropClient) CheckAccessList(ctx context.Context, inboxEntries []common.Hash, minSafety interoptypes.SafetyLevel, executingDescriptor interoptypes.ExecutingDescriptor) error {
5752
if err := cl.maybeDial(ctx); err != nil {
5853
return err

miner/miner.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ type BackendWithHistoricalState interface {
4747
}
4848

4949
type BackendWithInterop interface {
50-
CheckMessages(ctx context.Context, messages []interoptypes.Message, minSafety interoptypes.SafetyLevel, executingTimestamp uint64) error
5150
CheckAccessList(ctx context.Context, inboxEntries []common.Hash, minSafety interoptypes.SafetyLevel, executingDescriptor interoptypes.ExecutingDescriptor) error
5251
}
5352

miner/worker.go

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -421,51 +421,30 @@ func (miner *Miner) commitBlobTransaction(env *environment, tx *types.Transactio
421421
return nil
422422
}
423423

424-
type LogInspector interface {
425-
GetLogs(hash common.Hash, blockNumber uint64, blockHash common.Hash) []*types.Log
426-
}
427-
428424
// applyTransaction runs the transaction. If execution fails, state and gas pool are reverted.
429425
func (miner *Miner) applyTransaction(env *environment, tx *types.Transaction) (*types.Receipt, error) {
430426
var (
431427
snap = env.state.Snapshot()
432428
gp = env.gasPool.Gas()
433429
)
434-
var extraOpts *core.ApplyTransactionOpts
435-
// If not just reproducing the block, check the interop executing messages.
436430
if !env.noTxs && miner.chain.Config().IsInterop(env.header.Time) {
437-
// Whenever there are `noTxs` it means we are building a block from pre-determined txs. There are two cases:
438-
// (1) it's derived from L1, and will be verified asynchronously by the op-node.
439-
// (2) it is a deposits-only empty-block by the sequencer, in which case there are no interop-txs to verify (as deposits do not emit any).
440-
441-
// We have to insert as call-back, since we cannot revert the snapshot
442-
// after the tx is deemed successful and the journal has been cleared already.
443-
extraOpts = &core.ApplyTransactionOpts{
444-
PostValidation: func(evm *vm.EVM, result *core.ExecutionResult) error {
445-
logInspector, ok := evm.StateDB.(LogInspector)
446-
if !ok {
447-
return fmt.Errorf("cannot get logs from StateDB type %T", evm.StateDB)
448-
}
449-
logs := logInspector.GetLogs(tx.Hash(), env.header.Number.Uint64(), common.Hash{})
450-
return miner.checkInterop(env.rpcCtx, tx, result.Failed(), logs, env.header.Time)
451-
},
431+
// avoid execution if the interop check fails
432+
if err := miner.checkInterop(env.rpcCtx, tx, env.header.Time); err != nil {
433+
return nil, err
452434
}
453435
}
454-
receipt, err := core.ApplyTransactionExtended(env.evm, env.gasPool, env.state, env.header, tx, &env.header.GasUsed, extraOpts)
436+
receipt, err := core.ApplyTransaction(env.evm, env.gasPool, env.state, env.header, tx, &env.header.GasUsed)
455437
if err != nil {
456438
env.state.RevertToSnapshot(snap)
457439
env.gasPool.SetGas(gp)
458440
}
459441
return receipt, err
460442
}
461443

462-
func (miner *Miner) checkInterop(ctx context.Context, tx *types.Transaction, failed bool, logs []*types.Log, logTimestamp uint64) error {
444+
func (miner *Miner) checkInterop(ctx context.Context, tx *types.Transaction, logTimestamp uint64) error {
463445
if tx.Type() == types.DepositTxType {
464446
return nil // deposit-txs are always safe
465447
}
466-
if failed {
467-
return nil // failed txs don't persist any logs
468-
}
469448
if tx.Rejected() {
470449
return errors.New("transaction was previously rejected")
471450
}
@@ -476,14 +455,11 @@ func (miner *Miner) checkInterop(ctx context.Context, tx *types.Transaction, fai
476455
if ctx == nil { // check if the miner was set up correctly to interact with an RPC
477456
return errors.New("need RPC context to check executing messages")
478457
}
479-
executingMessages, err := interoptypes.ExecutingMessagesFromLogs(logs)
480-
if err != nil {
481-
return fmt.Errorf("cannot parse interop messages from receipt of %s: %w", tx.Hash(), err)
482-
}
483-
if len(executingMessages) == 0 {
458+
accessList := interoptypes.TxToInteropAccessList(tx)
459+
if len(accessList) == 0 {
484460
return nil // avoid an RPC check if there are no executing messages to verify.
485461
}
486-
if err := b.CheckMessages(ctx, executingMessages, interoptypes.CrossUnsafe, logTimestamp); err != nil {
462+
if err := b.CheckAccessList(ctx, accessList, interoptypes.CrossUnsafe, interoptypes.ExecutingDescriptor{Timestamp: logTimestamp, Timeout: 0}); err != nil {
487463
if ctx.Err() != nil { // don't reject transactions permanently on RPC timeouts etc.
488464
log.Debug("CheckMessages timed out", "err", ctx.Err())
489465
return err

0 commit comments

Comments
 (0)