Skip to content

Conversation

@thedevbirb
Copy link

@thedevbirb thedevbirb commented Sep 10, 2025

The following PR introduces some lookup checks on the environment variable BOP_REPLAY to assess whether this follower node is running in chain replication mode or not.

Chain replication consists of replaying past L2 blocks of the chain but at the current time, which is something op-node hasn't been really designed for. As such, this env disable some important checks and routine usually used in production:

  1. Any check related to timestamps being too old: both when validating incoming blocks and sending sync requests, those actions are rejected if the block timestamp is older than 60s compared to current unix time.
  2. Derivation pipeline, and other L1-driven sync behaviour: this allows to run chain replication using a synced L1 node and without worrying about having also L1 nodes pinned at some past block in time. Doing so requires however disabling checks that would make the chain change because of new data of the target chain we're replaying.

The result is a follower node which is able to ingest past L2 blocks and process them unsafely (because of the two points above).

There are some past commits where I tried to use a CLI flag instead, but imo they end up in more diffs and injecting this testing configuration in structs etc which is not desiderable. I kept them for reference, but I can squash everything in one commit if desired.

Such flags allows to gossip and receive unsafe payloads which timestamp
is older than 60 seconds. Useful for testing purposes.
@thedevbirb thedevbirb changed the title feat(op-node): UnsafeAllowOldPayloads flag feat(op-node): chain replication via BOP_REPLAY env Sep 10, 2025
@thedevbirb thedevbirb force-pushed the lore/feat/unsafe-flag branch 2 times, most recently from 5bdb1c4 to 4962e9b Compare September 11, 2025 08:04
@thedevbirb thedevbirb marked this pull request as ready for review September 15, 2025 07:25
Copy link
Collaborator

@ltitanb ltitanb left a comment

Choose a reason for hiding this comment

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

looks good! a lot of changes seems to be formatting, not sure if there's an equivalent of just fmt (of it it was not set). If not then happy to merge with the formatting changes too

Comment on lines 625 to 628
// CHANGE(thedevbirb): allow chain replication without deviation due to L1 state.
if _, ok := os.LookupEnv("BOP_REPLAY"); ok {
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we refactor this to a small function we call instead? also assuming this does a syscall every time it's called so if on the hot path maybe we could use a global static / atomic instead? if not then ok to keep this

Copy link
Author

@thedevbirb thedevbirb Sep 17, 2025

Choose a reason for hiding this comment

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

Right, a static is probably simpler in this case. Btw os.LookupEnv doesn't make a syscall but calls this https://cs.opensource.google/go/go/+/refs/tags/go1.25.1:src/syscall/env_unix.go;l=66 and it is all in memory.

Pushing a change soon!

Copy link
Author

Choose a reason for hiding this comment

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

See 86fd3cc.

Regarding formatting, I don't see some tooling specifically used for it, this is what my LSP with go fmt did. But I can rollback individual changes if you want.

@thedevbirb thedevbirb force-pushed the lore/feat/unsafe-flag branch from 68283ad to 86fd3cc Compare September 17, 2025 08:08
@ltitanb ltitanb merged commit ca07d0a into gattaca-com:based/develop Sep 18, 2025
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