fix: anchor EVM roots by multihash digest#760
Open
eloramirez1356 wants to merge 2 commits intoceramicnetwork:mainfrom
Open
fix: anchor EVM roots by multihash digest#760eloramirez1356 wants to merge 2 commits intoceramicnetwork:mainfrom
eloramirez1356 wants to merge 2 commits intoceramicnetwork:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes EVM self-anchoring for Ceramic roots whose encoded CID prefix is not a fixed length.
The main bug was in
cid_to_bytes32: it previously sliced the encoded CID bytes assuming a fixed 4-byte prefix before passing the value toanchorDagCbor(bytes32 root). That works for some CIDs, but fails for others because CID prefixes are varint-encoded and their length is not stable across codecs / wrappers.This PR changes anchoring to extract the raw multihash digest directly and updates validation to compare the committed multihash digest, which is what the on-chain
f(bytes32)proof format actually commits.What changed
Anchoring fix
anchor-evm/src/evm_transaction_manager.rsto derive thebytes32root fromcid.hash().digest()instead of slicing encoded CID bytesValidation fix
event-svc/src/event/validator/time.rsto compare root multihashes rather than requiring full CID equalityDebugging / observability
anchor-evm/src/proof_builder.rsanchor-service/src/merkle_tree.rsanchor-evm/src/evm_transaction_manager.rsDocumentation
anchor-evm/README.mdto explain thebytes32root semantics and why digest-based extraction / comparison is requiredWhy this is needed
The contract interface is:
Additional cleanup
The first commit contains a few small unrelated fixes required to pass the repository's current
make build/make check-clippy/make check-fmtchecks:anchor-remoteclippy::large_enum_variantallow ineventpipelineevent-svc