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

use MessageCommitMode when executing future head block messages #2705

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
5 changes: 4 additions & 1 deletion arbos/block_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func ProduceBlock(
chainContext core.ChainContext,
chainConfig *params.ChainConfig,
isMsgForPrefetch bool,
runMode core.MessageRunMode,
) (*types.Block, types.Receipts, error) {
txes, err := ParseL2Transactions(message, chainConfig.ChainID)
if err != nil {
Expand All @@ -153,7 +154,7 @@ func ProduceBlock(

hooks := NoopSequencingHooks()
return ProduceBlockAdvanced(
message.Header, txes, delayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, hooks, isMsgForPrefetch,
message.Header, txes, delayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, hooks, isMsgForPrefetch, runMode,
)
}

Expand All @@ -168,6 +169,7 @@ func ProduceBlockAdvanced(
chainConfig *params.ChainConfig,
sequencingHooks *SequencingHooks,
isMsgForPrefetch bool,
runMode core.MessageRunMode,
) (*types.Block, types.Receipts, error) {

state, err := arbosState.OpenSystemArbosState(statedb, nil, true)
Expand Down Expand Up @@ -318,6 +320,7 @@ func ProduceBlockAdvanced(
tx,
&header.GasUsed,
vm.Config{},
runMode,
func(result *core.ExecutionResult) error {
return hooks.PostTxFilter(header, state, tx, sender, dataGas, result)
},
Expand Down
3 changes: 2 additions & 1 deletion cmd/replay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -291,7 +292,7 @@ func main() {
message := readMessage(chainConfig.ArbitrumChainParams.DataAvailabilityCommittee)

chainContext := WavmChainContext{}
newBlock, _, err = arbos.ProduceBlock(message.Message, message.DelayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, false)
newBlock, _, err = arbos.ProduceBlock(message.Message, message.DelayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, false, core.MessageReplayMode)
if err != nil {
panic(err)
}
Expand Down
2 changes: 2 additions & 0 deletions execution/gethexec/block_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/ethereum/go-ethereum/arbitrum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -154,6 +155,7 @@ func (r *BlockRecorder) RecordBlockCreation(
chaincontext,
chainConfig,
false,
core.MessageReplayMode,
)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions execution/gethexec/executionengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ func (s *ExecutionEngine) sequenceTransactionsWithBlockMutex(header *arbostypes.
s.bc.Config(),
hooks,
false,
core.MessageCommitMode,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -661,6 +662,10 @@ func (s *ExecutionEngine) createBlockFromNextMessage(msg *arbostypes.MessageWith
statedb.StartPrefetcher("TransactionStreamer")
defer statedb.StopPrefetcher()

runMode := core.MessageCommitMode
if isMsgForPrefetch {
runMode = core.MessageReplayMode
}
block, receipts, err := arbos.ProduceBlock(
msg.Message,
msg.DelayedMessagesRead,
Expand All @@ -669,6 +674,7 @@ func (s *ExecutionEngine) createBlockFromNextMessage(msg *arbostypes.MessageWith
s.bc,
s.bc.Config(),
isMsgForPrefetch,
runMode,
)

return block, statedb, receipts, err
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
7 changes: 4 additions & 3 deletions system_tests/state_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func BuildBlock(
chainConfig *params.ChainConfig,
inbox arbstate.InboxBackend,
seqBatch []byte,
runMode core.MessageRunMode,
) (*types.Block, error) {
var delayedMessagesRead uint64
if lastBlockHeader != nil {
Expand All @@ -63,7 +64,7 @@ func BuildBlock(
}

block, _, err := arbos.ProduceBlock(
l1Message, delayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, false,
l1Message, delayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, false, runMode,
)
return block, err
}
Expand Down Expand Up @@ -127,7 +128,7 @@ func (c noopChainContext) GetHeader(common.Hash, uint64) *types.Header {
}

func FuzzStateTransition(f *testing.F) {
f.Fuzz(func(t *testing.T, compressSeqMsg bool, seqMsg []byte, delayedMsg []byte) {
f.Fuzz(func(t *testing.T, compressSeqMsg bool, seqMsg []byte, delayedMsg []byte, runMode uint8) {
magicxyyz marked this conversation as resolved.
Show resolved Hide resolved
if len(seqMsg) > 0 && daprovider.IsL1AuthenticatedMessageHeaderByte(seqMsg[0]) {
return
}
Expand Down Expand Up @@ -201,7 +202,7 @@ func FuzzStateTransition(f *testing.F) {
positionWithinMessage: 0,
delayedMessages: delayedMessages,
}
_, err = BuildBlock(statedb, genesis, noopChainContext{}, params.ArbitrumOneChainConfig(), inbox, seqBatch)
_, err = BuildBlock(statedb, genesis, noopChainContext{}, params.ArbitrumOneChainConfig(), inbox, seqBatch, core.MessageRunMode(runMode))
if err != nil {
// With the fixed header it shouldn't be possible to read a delayed message,
// and no other type of error should be possible.
Expand Down
Loading