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

Hex patricia reader proof #13660

Merged
merged 2 commits into from
Feb 11, 2025
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
17 changes: 16 additions & 1 deletion erigon-lib/commitment/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
"encoding/binary"
"errors"
"fmt"
"github.com/erigontech/erigon-lib/types/accounts"
"math/bits"
"sort"
"strings"
"unsafe"

"github.com/erigontech/erigon-lib/types/accounts"

"github.com/holiman/uint256"

"github.com/google/btree"
Expand Down Expand Up @@ -120,6 +121,8 @@ type TrieVariant string
const (
// VariantHexPatriciaTrie used as default commitment approach
VariantHexPatriciaTrie TrieVariant = "hex-patricia-hashed"
// VariantHexPatriciaTrieReader used as read only commitment trie
VariantHexPatriciaTrieReader TrieVariant = "hex-patricia-hashed-reader"
// VariantBinPatriciaTrie - Experimental mode with binary key representation
VariantBinPatriciaTrie TrieVariant = "bin-patricia-hashed"
)
Expand Down Expand Up @@ -922,6 +925,13 @@ func DecodeBranchAndCollectStat(key, branch []byte, tv TrieVariant) *BranchStat
return stat
}

type ReadOrUpdate int

const (
ReadTouch ReadOrUpdate = 0
UpdateTouch ReadOrUpdate = 1
)

// Defines how to evaluate commitments
type Mode uint

Expand Down Expand Up @@ -967,6 +977,8 @@ type Updates struct {
tmpdir string
}

type Reads = Updates

type keyHasher func(key []byte) []byte

func keyHasherNoop(key []byte) []byte { return key }
Expand All @@ -986,6 +998,9 @@ func NewUpdates(m Mode, tmpdir string, hasher keyHasher) *Updates {
}
return t
}

var NewReads = NewUpdates

func (t *Updates) SetMode(m Mode) {
t.mode = m
if t.mode == ModeDirect && t.keys == nil {
Expand Down
Loading
Loading