Skip to content
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

Remove unsafe in espressocrypto #380

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions arbnode/transaction_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,11 +1274,17 @@ func (s *TransactionStreamer) pollSubmittedTransactionForFinality(ctx context.Co

height := data.BlockHeight

header, err := s.espressoClient.FetchHeaderByHeight(ctx, height)
jsonHeader, err := s.espressoClient.FetchRawHeaderByHeight(ctx, height)
if err != nil {
return fmt.Errorf("could not get the header (height: %d): %w", height, err)
}

var header espressoTypes.HeaderImpl
err = json.Unmarshal(jsonHeader, &header)
if err != nil {
return fmt.Errorf("could not unmarshal header from bytes (height: %d): %w", height, err)
}

// Verify the merkle proof
snapshot, err := s.lightClientReader.FetchMerkleRoot(height, nil)
if err != nil {
Expand All @@ -1300,12 +1306,8 @@ func (s *TransactionStreamer) pollSubmittedTransactionForFinality(ctx context.Co
}

blockMerkleTreeRoot := nextHeader.Header.GetBlockMerkleTreeRoot()
jstHeader, err := json.Marshal(header)
if err != nil {
return fmt.Errorf("failed to marshal the header: %w", err)
}

ok := espressocrypto.VerifyMerkleProof(proof.Proof, jstHeader, *blockMerkleTreeRoot, snapshot.Root)
ok := espressocrypto.VerifyMerkleProof(proof.Proof, jsonHeader, *blockMerkleTreeRoot, snapshot.Root)
if !ok {
return fmt.Errorf("error validating merkle proof (height: %d, snapshot height: %d)", height, snapshot.Height)
}
Expand Down
Loading
Loading