-
Notifications
You must be signed in to change notification settings - Fork 28
Rollback on reorg v2 #782
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
base: dz/find-reorg-depth-concurrently
Are you sure you want to change the base?
Rollback on reorg v2 #782
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| Some(_) => // Since the DC is registered by an earlier item in the query | ||
// FIXME: This unsafely relies on the asc order of the items | ||
// which is 99% true, but there were cases when the source ordering was wrong | ||
false |
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.
Maybe add an assertion if possible or handle it so that there is no UB
// Currently history update table uses S.object with transformation for schema, | ||
// which is being lossed during conversion to dbSchema. | ||
// So use simple insert values for now. | ||
let isHistoryUpdate = table.tableName->Js.String2.startsWith("envio_history_") |
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.
Can you rather make this an api on the table?
let getSafeCheckpointId = (safeCheckpointTracking: t, ~sourceBlockNumber: int) => { | ||
let safeBlockNumber = sourceBlockNumber - safeCheckpointTracking.maxReorgDepth | ||
|
||
if safeCheckpointTracking.checkpointBlockNumbers->Belt.Array.getUnsafe(0) > safeBlockNumber { |
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.
Don't use unsafe
switch await Db.sql->InternalTable.Checkpoints.getRollbackTargetCheckpoint( | ||
~pgSchema=Env.Db.publicSchema, | ||
~reorgChainId, | ||
~lastKnownValidBlockNumber, | ||
) { | ||
| [checkpoint] => checkpoint["id"] | ||
| _ => 0 | ||
} |
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.
would put this switch inside the 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.
⭐ 🚀
No description provided.