-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: allow FG to be opt-in #17
Conversation
should we first run the FP op e2e test with this commit and FP commit?
|
// set finalized block(s) | ||
if lastFinalizedBlock != nil { | ||
finalizedL2 = *lastFinalizedBlock | ||
if fi.babylonFinalityClient == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if fi.babylonFinalityClient == nil { | |
if fi.EnableBTCStaking() { |
and we can wrap this logic inside the EnableBTCStaking
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also what will happen if an OP node enables BTC staking and run OP node for a while, shuts down OP node, and restarts OP node with BTC staking disabled? Given that this function tries to write finalised block to DB, would it be possible that the finaliser needs to iterate over more blocks after the restart?
This seems to be another reason of keeping BTC stake finalised in a separate KV store, in parallel with unsafe/safe/finalised states of blocks in OP stack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what will happen if an OP node enables BTC staking and run OP node for a while, shuts down OP node, and restarts OP node with BTC staking disabled
in this case, once it's restarted, it will continue to operate normally (e.g. fetch L1 data, derive L2 blocks). when it tries to finalise a block, it will simply skip the BTC quorum check.
would it be possible that the finaliser needs to iterate over more blocks after the restart
what do you mean by itereating over more blocks? after the restart, it won't call the gRPC of FG. it will become a vanilla op-node
This seems to be another reason of keeping BTC stake finalised in a separate KV store, in parallel with unsafe/safe/finalised states of blocks in OP stack
this data is already stored in the FG KV db. op-node
connects with it via gRPC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and we can wrap this logic inside the EnableBTCStaking function
@SebastianElvis do you mean to create a helper function like this?
func (fi *Finalizer) BTCStakingEnabled() bool {
return fi.babylonFinalityClient != nil
}
this doesn't seem very useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean by itereating over more blocks? after the restart, it won't call the gRPC of FG. it will become a vanilla op-node
Let's say block h
is finalised in OP stack term + BTC stake finalised, and h+1
to h+5
are finalised in OP stack term but haven't been BTC stake finalised. Then upon retsart with BTC staking disabled, Op node starts iterating from h+1
but not h+5
. However it's supposed to start from h+5
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it. it's fine to re-derive from h1. although there will be some wasted rpc calls to L1, it doesn't require any changes in the codebase and such restart should be rare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep. not blocking for now but wdyt about having some doc / TODO for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there isn't any TODO here as the optimization has low ROI. (i.e. it requires intrusive changes for marginally gain)
i'd say not adding any comments to avoid confusion
will just test in our devnet since the test is broken |
Summary
we have a killswitch (i.e. the
enabled
state) in the CW contract but it's a problematic b/c it depends on having the FG running. we should also allow op-node to control turning the gadget on and offinstead of introducing another config param, we can use the existing
cfg.BabylonFinalityGadgetRpc
and allow it to be empty string (i.e. "" means it's disabled)we also discussed this in https://linear.app/snapchain/issue/SNA-505
this also solves the issue we found during deploying our devnet. When we register FP before the L2 chain is up, it cannot find the L2 RPC so throws error.
after this PR, we will always deploy the devnet first and later restart op-node with the
BabylonFinalityGadgetRpc
set. this is also closer to the real-world integration where the chain already exists before the integrationthis also solves the circular dependency issue where we had when deploying our devnet (i.e. FG depends on L2, L2 depends on FG)
Test Plan
will e2e test soon in our devnet