-
Notifications
You must be signed in to change notification settings - Fork 741
Add state checksums #1658
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
Add state checksums #1658
Conversation
type Config struct { | ||
ChecksumsEnabled bool `json:"checksums-enabled"` | ||
} |
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 felt like now was as good of a time as any to introduce P-chain
specific configs. We'll probably use this more in the future for APIs and other VM level configs
vms/avm/states/state.go
Outdated
@@ -563,6 +579,8 @@ func (s *state) writeTxs() error { | |||
txID := txID | |||
txBytes := tx.Bytes() | |||
|
|||
s.updateTxChecksum(txID) |
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.
We write all txs we are accepting to disk. Even transactions that were already written when they were processing. While the following db.Put
will be a noop in this case - the DB will also end up deleting the status entry... Which marks this tx as accepted. Regardless - it is correct to update the checksum here.
statusIt := s.statusDB.NewIterator() | ||
defer statusIt.Release() |
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't wait for statuses to be gone 🙏
@@ -176,10 +104,20 @@ func (a *acceptor) ApricotAtomicBlock(b *blocks.ApricotAtomicBlock) error { | |||
err, | |||
) | |||
} | |||
|
|||
a.ctx.Log.Trace( |
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.
Note: I also changed these to Trace
so that we could better observe these values (without all the p2p messages)
a.ctx.Log.Debug( | ||
"accepting block", | ||
zap.String("blockType", "banff abort"), | ||
zap.Stringer("blkID", b.ID()), | ||
zap.Uint64("height", b.Height()), | ||
zap.Stringer("parentID", b.Parent()), | ||
) |
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 feel like reducing all these super similar logs was in-and-of itself a good change.
Why this should be merged
Enables integrity checks to prevent issues such as the
v1.9.12
X-chain state regression.How this works
If enabled (can be enabled on both the P-chain and/or the X-chain independently using chain configs):
How this was tested
Manually and as part of verifying the X-chain DB pruning.