-
Notifications
You must be signed in to change notification settings - Fork 3
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
Revive sync #70
Revive sync #70
Conversation
State validation during sync is now complete, opened a new issue for signature validation: #74 |
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! I left comments on minor issues to address, looks good to me in general!
core/batch.go
Outdated
return err | ||
} | ||
|
||
if batch.Status != BATCH_BROADCASTED && batch.Status == BATCH_COMMITTED { |
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.
I think we can safely remove batch.Status != BATCH_BROADCASTED
.
- When
batch.Status != BATCH_COMMITTED
the whole condition evaluates false - when
batch.Status == BATCH_COMMITTED
,batch.Status != BATCH_BROADCASTED
evaluates true, so the whole condition evaluates true too.
if batch.Status != BATCH_BROADCASTED && batch.Status == BATCH_COMMITTED { | |
if batch.Status == BATCH_COMMITTED { |
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.
Yeah I think your suggestion assumes that the status can be either BATCH_BROADCASTED or BATCH_COMMITTED while I was trying to protect from invalid status codes too, which I think is stupid🤐
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.
Fixing
newRoot, err = bz.ProcessTx(currentRoot, *tx, fromStateProof, toStateProof) | ||
if err != nil { | ||
if txDBConn.Instance != nil { | ||
txDBConn.Instance.Rollback() |
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 is rollbacked here?
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 processTx is invalid we can rollback the changes made while witness creation
return | ||
} | ||
if txDBConn.Instance != nil { | ||
txDBConn.Instance.Commit() |
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 insert or update is committed here?
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 are updates performed in GetTxVerificationData() via a MySQL transaction, we can rollback those updates if processTx is invalid.
if isSyncing && err == ErrSignatureNotPresent { | ||
continue |
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.
Does the continue
here mean the line commitments = append(commitments, commitment)
is skipped?
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 it goes there, it simply means that if we are syncing and tx.Sig is nil we don't have to bubble up error as that is expected. I do think this piece is smelly and should be refactored in the future.
if err != nil { | ||
return | ||
} | ||
// func (b *Bazooka) applyMassMigrationTx(sender, receiver []byte, tx Tx) (updatedSender, updatedReceiver []byte, err error) { |
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.
nitpick: For these areas of commented off code, it's fine to just remove them.
Fixes #31