Skip to content

Add nitro support#39

Open
lukeiannucci wants to merge 10 commits into
feat-nitrofrom
li/start-nitro
Open

Add nitro support#39
lukeiannucci wants to merge 10 commits into
feat-nitrofrom
li/start-nitro

Conversation

@lukeiannucci
Copy link
Copy Markdown
Contributor

@lukeiannucci lukeiannucci commented Apr 29, 2026

Closes #<ISSUE_NUMBER>

This PR:

Add initial support for the nitro verifier. Also a docker compose setup that spins up a sequencer, batchposter, and fullnode. To test this out you can do:

cd espresso_e2e/nitro && docker compose up -d && cd ../..

Then run the verifier:

go run . --nitro.enable --nitro.namespace 412346 --nitro.query-service-url http://localhost:24000 --nitro.valid-batcher-addresses 0x3f1Eae7D46d88F08fc2F8ed27FCb2AB183EB2d0E --nitro.initial-hotshot-block 0 --nitro.feed-url ws://localhost:9643 --full-node-execution-rpc http://localhost:8549 --listen-addr :8080 --nitro.verification-interval 100ms

This PR does not:

Add any e2e tests to reduce the size of the PR.

Key places to review:

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a Nitro batch verifier and an end-to-end testing environment for Nitro-Espresso integration. Key additions include a Docker Compose setup, Nitro configuration files, and a NitroEspressoBatchVerifier that ensures Nitro full node blocks align with data from the Espresso streamer. Feedback focuses on improving the mockLightClient implementation to handle errors and context correctly, correcting a hostname in the Nitro configuration, optimizing block verification by using headers instead of full blocks, and adding validation for the verification interval to prevent potential panics.

Comment thread mock_light_client.go Outdated
Comment thread espresso_e2e/nitro/nitro-config/nitro_config.json Outdated
Comment thread verifier/nitro/nitro_verifier.go Outdated
Comment thread verifier/nitro/nitro_verifier.go
@lukeiannucci lukeiannucci changed the title start for nitro Add nitro support May 11, 2026
@lukeiannucci lukeiannucci changed the base branch from main to feat-nitro May 11, 2026 22:01
"wait-for-max-delay": false,
"l1-block-bound": "ignore",
"parent-chain-wallet": {
"private-key": "b6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did we push private key here?

Copy link
Copy Markdown
Contributor Author

@lukeiannucci lukeiannucci May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.arbitrum.io/run-arbitrum-node/run-nitro-dev-node#development-account-used-by-default

this is the address it uses. i will move it to the env file and pass it in as parameter though

@@ -0,0 +1,157 @@
services:
l1-geth:
image: ghcr.io/espressosystems/timeboost/geth-l1:rollup-creator-round2
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using timeboost image?

Copy link
Copy Markdown
Contributor Author

@lukeiannucci lukeiannucci May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a prebuilt l1 image we used for timeboost. i will move away from this.

ESPRESSO_SEQUENCER_L1_PROVIDER: http://l1-geth:${L1_HTTP_PORT}
ESPRESSO_DEPLOYER_ACCOUNT_INDEX: 0
ESPRESSO_DEV_NODE_EPOCH_HEIGHT: "4294967295"
ESPRESSO_SEQUENCER_ETH_MNEMONIC: "giant issue aisle success illegal bike spike question tent bar rely arctic volcano long crawl hungry vocal artwork sniff fantasy very lucky have athlete"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should go in .env

@@ -0,0 +1,161 @@
package feedclient
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you copy pasted this file from Nitro?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no i looked at the nitro code and tried to make it simpler, all we need to do is stream in the messages from the feed. I can look to make this cleaner and make sure i didnt miss anything

espressoStore "proxy/store"

espressoClient "github.com/EspressoSystems/espresso-network/sdks/go/client"
nitroStreamer "github.com/EspressoSystems/espresso-streamers/nitro"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we first do a pr to espresso streamers repo?

}
if !updated {
v.logger.Warn("espresso state not updated — message position not greater than current",
"msg_pos", espressoMsg.Pos)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add a return here, but i also need to advance the streamer.

return header.Number.Uint64(), nil
}

func (v *NitroEspressoBatchVerifier) syncEspressoStateWithNitroFinality(nitroFinalizedBlock uint64) error {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function can be common between the two verifiers

// lives in the L1 delayed inbox and is not included in the messages sent to hotshot.
// In that case only compare the header and delayed message counter.
if len(espresso.Message.L2msg) == 0 {
espressoHeader, feedHeader := espresso.Message.Header, feed.Message.Header
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think you need to compare exact values, just convert to bytes using rlp that nitro uses and then compare the bytes or else you will have to change the code if they change any field or anything

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only for delayed messages as the feed will have l2 msg data, and what comes from espresso does not. maybe its enough to just check the delayed messages read?

espressoHeader := espresso.Message.Header
feedHeader := feed.Message.Header
return fmt.Errorf(
"espresso message does not match Nitro feed message\n"+
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error is pretty ugly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i was actually debugging something with an issue and was printing out too much stuff. im going to make this a lot simpler now

v.logger.Info("Nitro verifier stopped")
}

func ValidateNitroVerifierConfig(config *NitroEspressoBatchVerifierConfig) error {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put this in config file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont believe this is needed, when i first started i wrote my own parser but since moved the logic inside validate(). Good catch going to delete.

Copy link
Copy Markdown
Collaborator

@Sneh1999 Sneh1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests it seems like most files are missing tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants