Skip to content

Commit

Permalink
DISCARD_COMMITMENT=true produce commitment for genesis (#12994)
Browse files Browse the repository at this point in the history
Co-authored-by: awskii <[email protected]>
  • Loading branch information
AskAlexSharov and awskii authored Dec 5, 2024
1 parent 853ad98 commit fb3bd06
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions erigon-lib/state/domain_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,6 @@ func (sd *SharedDomains) Tx() kv.Tx { return sd.roTx }

type SharedDomainsCommitmentContext struct {
sharedDomains *SharedDomains
discard bool // could be replaced with using ModeDisabled
branches map[string]cachedBranch
keccak cryptozerocopy.KeccakState
updates *commitment.Updates
Expand All @@ -1126,7 +1125,6 @@ func (sdc *SharedDomainsCommitmentContext) SetLimitReadAsOfTxNum(txNum uint64) {
func NewSharedDomainsCommitmentContext(sd *SharedDomains, mode commitment.Mode, trieVariant commitment.TrieVariant) *SharedDomainsCommitmentContext {
ctx := &SharedDomainsCommitmentContext{
sharedDomains: sd,
discard: dbg.DiscardCommitment(),
branches: make(map[string]cachedBranch),
keccak: sha3.NewLegacyKeccak256().(cryptozerocopy.KeccakState),
}
Expand Down Expand Up @@ -1310,7 +1308,7 @@ func (sdc *SharedDomainsCommitmentContext) KeysCount() uint64 {
// TouchPlainKey marks plainKey as updated and applies different fn for different key types
// (different behaviour for Code, Account and Storage key modifications).
func (sdc *SharedDomainsCommitmentContext) TouchKey(d kv.Domain, key string, val []byte) {
if sdc.discard {
if sdc.updates.Mode() == commitment.ModeDisabled {
return
}

Expand All @@ -1328,10 +1326,6 @@ func (sdc *SharedDomainsCommitmentContext) TouchKey(d kv.Domain, key string, val

// Evaluates commitment for processed state.
func (sdc *SharedDomainsCommitmentContext) ComputeCommitment(ctx context.Context, saveState bool, blockNum uint64, logPrefix string) (rootHash []byte, err error) {
if dbg.DiscardCommitment() {
sdc.updates.Reset()
return nil, nil
}
sdc.ResetBranchCache()
defer sdc.ResetBranchCache()

Expand Down Expand Up @@ -1434,9 +1428,6 @@ func _decodeTxBlockNums(v []byte) (txNum, blockNum uint64) {
// LatestCommitmentState searches for last encoded state for CommitmentContext.
// Found value does not become current state.
func (sdc *SharedDomainsCommitmentContext) LatestCommitmentState() (blockNum, txNum uint64, state []byte, err error) {
if dbg.DiscardCommitment() {
return 0, 0, nil, nil
}
if sdc.patriciaTrie.Variant() != commitment.VariantHexPatriciaTrie {
return 0, 0, nil, fmt.Errorf("state storing is only supported hex patricia trie")
}
Expand Down

0 comments on commit fb3bd06

Please sign in to comment.