Skip to content

Commit

Permalink
progress with header interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nomaxg committed Nov 8, 2023
1 parent f6f41b7 commit d1636c8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
18 changes: 17 additions & 1 deletion cmd/replay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/cmd/chaininfo"
"github.com/offchainlabs/nitro/das/dastree"
"github.com/offchainlabs/nitro/espresso"
"github.com/offchainlabs/nitro/gethhook"
"github.com/offchainlabs/nitro/wavmio"
)
Expand All @@ -46,6 +47,19 @@ func getBlockHeaderByHash(hash common.Hash) *types.Header {
return header
}

func getHotShotHeaderByHash(hash common.Hash) *espresso.Header {
enc, err := wavmio.ResolveTypedPreimage(arbutil.Keccak256PreimageType, hash)
if err != nil {
return nil
}
var header &espresso.Header
if err := json.Unmarshal(header, &enc); err != nil {
panic(fmt.Errorf("Error deserializing espresso header preimage"))
}

return header
}

type WavmChainContext struct{}

func (c WavmChainContext) Engine() consensus.Engine {
Expand Down Expand Up @@ -152,6 +166,8 @@ func main() {
db := state.NewDatabase(raw)

lastBlockHash := wavmio.GetLastBlockHash()
lastHotShotHeaderHash := wavmio.GetLastHotShotHeaderHash()
lastHotShotHeader := getHotShotHeaderByHash(lastHotShotHeaderHash)

var lastBlockHeader *types.Header
var lastBlockStateRoot common.Hash
Expand Down Expand Up @@ -238,7 +254,7 @@ func main() {
batchFetcher := func(batchNum uint64) ([]byte, error) {
return wavmio.ReadInboxMessage(batchNum), nil
}
newBlock, _, err = arbos.ProduceBlock(message.Message, message.DelayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, batchFetcher)
newBlock, _, err = arbos.ProduceBlock(message.Message, message.DelayedMessagesRead, lastBlockHeader, lastHotShotHeader, statedb, chainContext, chainConfig, batchFetcher)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions execution/gethexec/executionengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (s *ExecutionEngine) sequenceTransactionsWithBlockMutex(header *arbostypes.
txes,
delayedMessagesRead,
lastBlockHeader,
nil,
&header.BlockJustification.Header,
statedb,
s.bc,
s.bc.Config(),
Expand Down Expand Up @@ -447,7 +447,7 @@ func (s *ExecutionEngine) createBlockFromNextMessage(msg *arbostypes.MessageWith
msg.Message,
msg.DelayedMessagesRead,
currentHeader,
nil,
&msg.Message.Header.BlockJustification.Header,
statedb,
s.bc,
s.bc.Config(),
Expand Down
21 changes: 13 additions & 8 deletions wavmio/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ func (i *arrayFlags) Set(value string) error {
}

var (
seqMsg []byte
seqMsgPos uint64
posWithinMsg uint64
delayedMsgs [][]byte
delayedMsgFirstPos uint64
lastBlockHash common.Hash
preimages map[common.Hash][]byte
seqAdvanced uint64
seqMsg []byte
seqMsgPos uint64
posWithinMsg uint64
delayedMsgs [][]byte
delayedMsgFirstPos uint64
lastBlockHash common.Hash
lastHotShotHeaderHash common.Hash
preimages map[common.Hash][]byte
seqAdvanced uint64
)

func parsePreimageBytes(path string) {
Expand Down Expand Up @@ -117,6 +118,10 @@ func GetLastBlockHash() (hash common.Hash) {
return lastBlockHash
}

func GetLastHotShotHeaderHash() (hash common.Hash) {
return lastHotShotHeaderHash
}

func ReadInboxMessage(msgNum uint64) []byte {
if msgNum != seqMsgPos {
panic(fmt.Sprintf("trying to read bad msg %d", msgNum))
Expand Down

0 comments on commit d1636c8

Please sign in to comment.