From 9a3770f2f1680f206f283af69a20436c5dc1fe4c Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Wed, 1 Nov 2023 11:35:07 -0500 Subject: [PATCH] edits --- arbos/block_processor.go | 21 +++++++++++++++------ execution/gethexec/block_recorder.go | 1 + execution/gethexec/executionengine.go | 20 +++++++++++++++----- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/arbos/block_processor.go b/arbos/block_processor.go index 8d33e5cda7..e407229f2d 100644 --- a/arbos/block_processor.go +++ b/arbos/block_processor.go @@ -9,7 +9,6 @@ import ( "fmt" "math" "math/big" - "strings" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/arbostypes" @@ -127,7 +126,8 @@ func NoopSequencingHooks() *SequencingHooks { } type ProduceConfig struct { - evil bool + evil bool + interceptDepositGweiAmount *big.Int } type ProduceOpt func(*ProduceConfig) @@ -137,6 +137,15 @@ func WithEvilProduction() ProduceOpt { } } +func WithInterceptDepositSize(depositGwei *big.Int) ProduceOpt { + return func(pc *ProduceConfig) { + pc.interceptDepositGweiAmount = depositGwei + } +} + +// By default, intercept and modify any Arbitrum deposits with a value of a 1M gwei. +var DefaultEvilInterceptDepositGweiAmount = big.NewInt(1_000_000 * params.GWei) + func ProduceBlock( message *arbostypes.L1IncomingMessage, delayedMessagesRead uint64, @@ -169,7 +178,9 @@ func ProduceBlock( txes = types.Transactions{} } - produceCfg := &ProduceConfig{} + produceCfg := &ProduceConfig{ + interceptDepositGweiAmount: DefaultEvilInterceptDepositGweiAmount, + } for _, o := range opts { o(produceCfg) } @@ -184,9 +195,7 @@ func ProduceBlock( modifiedTxs = append(modifiedTxs, tx) continue } - currValue := fmt.Sprintf("%#x", txData.Value.Bytes()) - wanted := "2386f26fc10000" - if !strings.Contains(currValue, wanted) { + if txData.Value.Cmp(produceCfg.interceptDepositGweiAmount) != 0 { modifiedTxs = append(modifiedTxs, tx) continue } diff --git a/execution/gethexec/block_recorder.go b/execution/gethexec/block_recorder.go index f17ff946d6..9b004ab8d3 100644 --- a/execution/gethexec/block_recorder.go +++ b/execution/gethexec/block_recorder.go @@ -139,6 +139,7 @@ func (r *BlockRecorder) RecordBlockCreation( opts := make([]arbos.ProduceOpt, 0) if r.execEngine.evil { opts = append(opts, arbos.WithEvilProduction()) + opts = append(opts, arbos.WithInterceptDepositSize(r.execEngine.interceptDepositGweiAmount)) } block, _, err := arbos.ProduceBlock( msg.Message, diff --git a/execution/gethexec/executionengine.go b/execution/gethexec/executionengine.go index f5bbd543dd..e9fd05fb92 100644 --- a/execution/gethexec/executionengine.go +++ b/execution/gethexec/executionengine.go @@ -5,6 +5,7 @@ import ( "encoding/binary" "errors" "fmt" + "math/big" "sync" "testing" "time" @@ -40,8 +41,9 @@ type ExecutionEngine struct { nextScheduledVersionCheck time.Time // protected by the createBlocksMutex - reorgSequencing bool - evil bool + reorgSequencing bool + evil bool + interceptDepositGweiAmount *big.Int } type Opt func(*ExecutionEngine) @@ -52,11 +54,18 @@ func WithEvilExecution() Opt { } } +func WithInterceptDepositSize(depositGwei *big.Int) Opt { + return func(exec *ExecutionEngine) { + exec.interceptDepositGweiAmount = depositGwei + } +} + func NewExecutionEngine(bc *core.BlockChain, opts ...Opt) (*ExecutionEngine, error) { exec := &ExecutionEngine{ - bc: bc, - resequenceChan: make(chan []*arbostypes.MessageWithMetadata), - newBlockNotifier: make(chan struct{}, 1), + bc: bc, + resequenceChan: make(chan []*arbostypes.MessageWithMetadata), + newBlockNotifier: make(chan struct{}, 1), + interceptDepositGweiAmount: arbos.DefaultEvilInterceptDepositGweiAmount, } for _, o := range opts { o(exec) @@ -458,6 +467,7 @@ func (s *ExecutionEngine) createBlockFromNextMessage(msg *arbostypes.MessageWith opts := make([]arbos.ProduceOpt, 0) if s.evil { opts = append(opts, arbos.WithEvilProduction()) + opts = append(opts, arbos.WithInterceptDepositSize(s.interceptDepositGweiAmount)) } block, receipts, err := arbos.ProduceBlock( msg.Message,