Skip to content

Commit

Permalink
Fix receipt commitment
Browse files Browse the repository at this point in the history
  • Loading branch information
kirugan committed Jul 23, 2024
1 parent 521bbfd commit fb2aa5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion core/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func messagesSentHash(messages []*L2ToL1Message) *felt.Felt {

func receiptCommitment(receipts []*TransactionReceipt) (*felt.Felt, error) {
var commitment *felt.Felt
return commitment, trie.RunOnTempTrie(commitmentTrieHeight, func(trie *trie.Trie) error {

return commitment, trie.RunOnTempTriePoseidon(commitmentTrieHeight, func(trie *trie.Trie) error {
for i, receipt := range receipts {
hash, err := receipt.Hash()
if err != nil {
Expand Down
3 changes: 0 additions & 3 deletions core/receipt_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package core

import (
"encoding/binary"

Check failure on line 4 in core/receipt_pkg_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)

Check failure on line 4 in core/receipt_pkg_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
"fmt"
"github.com/NethermindEth/juno/core/crypto"
"github.com/NethermindEth/juno/core/felt"
"github.com/NethermindEth/juno/utils"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -84,7 +82,6 @@ func TestReceiptCommitment(t *testing.T) {
require.NoError(t, err)

expectedRoot := utils.HexToFelt(t, "0x31963cb891ebb825e83514deb748c89b6967b5368cbc48a9b56193a1464ca87")
fmt.Println("Hash is ", root.String(), crypto.PoseidonArray(root))
assert.Equal(t, expectedRoot, root)
}

Expand Down
8 changes: 8 additions & 0 deletions core/trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ func RunOnTempTrie(height uint8, do func(*Trie) error) error {
return do(trie)
}

func RunOnTempTriePoseidon(height uint8, do func(*Trie) error) error {
trie, err := NewTriePoseidon(newMemStorage(), height)
if err != nil {
return err

Check warning on line 91 in core/trie/trie.go

View check run for this annotation

Codecov / codecov/patch

core/trie/trie.go#L91

Added line #L91 was not covered by tests
}
return do(trie)
}

// feltToBitSet Converts a key, given in felt, to a trie.Key which when followed on a [Trie],
// leads to the corresponding [Node]
func (t *Trie) feltToKey(k *felt.Felt) Key {
Expand Down

0 comments on commit fb2aa5e

Please sign in to comment.