-
Notifications
You must be signed in to change notification settings - Fork 4
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(submitter): stateful submitter #43
Conversation
// that has already been processed. | ||
// Returns true if the first transactions are in the mempool (no resubmission needed), | ||
// and false if any transaction was re-sent from the store. | ||
func maybeResendFromStore( |
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.
Meat and potato of the PR
"testing" | ||
) | ||
|
||
func Test_maybeResendFromStore(t *testing.T) { |
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.
e2e test for this would be quite hard to implement with timings, opt for a unit
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.
Great work! Minor comments:
hasBeenProcessed, err := maybeResendFromStore( | ||
ckptEpoch, | ||
rl.store.LatestCheckpoint, | ||
rl.GetRawTransaction, | ||
rl.sendTxToBTC, | ||
) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if hasBeenProcessed { | ||
return 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.
seems this chunk of code is irrelevant to whether we should send a complete ckpt or only the second half. Can we move it out to avoid duplicate code?
err = storeCkptFunc(submittedCkpt.Tx1.Tx, submittedCkpt.Tx2.Tx, submittedCkpt.Epoch) | ||
if err != nil { | ||
return err | ||
} |
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.
same here
In case of a restart, we want to avoid wasting fees if we have already submitted transactions for a certain epoch.
Basic idea:
A crash occurs after sending both checkpoint transactions for epoch
n
to the BTC and recording them in the database. Upon restarting, we find that epochn
is still marked as sealed.Before resending the transactions we first check our database and confirm that the transactions for this epoch have already been sent. Since the transactions were previously sent, the next step is to verify their status on our Bitcoin node.
If the Bitcoin node is aware of the transactions and they are present in the mempool, no further action is needed.
However, if the node does not recognize the transactions, this indicates they were lost, and we must resend them to the network.
References