From 92fc7215c8ec918603bf43e7a284d54e12b06111 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Fri, 4 Feb 2022 18:48:50 +0000 Subject: [PATCH] [erigon2] fix commitment error (#304) * Try to fix * Fix Co-authored-by: Alexey Sharp --- aggregator/aggregator.go | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/aggregator/aggregator.go b/aggregator/aggregator.go index b3daee1a2..38c5b6bdf 100644 --- a/aggregator/aggregator.go +++ b/aggregator/aggregator.go @@ -1753,16 +1753,16 @@ func (w *Writer) accountFn(plainKey []byte, cell *commitment.Cell) ([]byte, erro if len(plainKey) != length.Addr { // Accessing account key and value via "thin reference" to the state file and offset fileI := int(plainKey[0]) offset := decodeU64(plainKey[1:]) - plainKey, enc = readByOffset("accounts", &w.a.accountsFiles, fileI, offset) - } else { // Full account key is provided, search as usual - // Look in the summary table first - w.search.k = plainKey - if encI := w.a.accountsTree.Get(&w.search); encI != nil { - enc = encI.(*AggregateItem).v - } else { - // Look in the files - enc = readFromFiles("accounts", &w.a.accountsFiles, nil /* lock */, w.blockNum, plainKey, false /* trace */) - } + plainKey, _ = readByOffset("accounts", &w.a.accountsFiles, fileI, offset) + } + // Full account key is provided, search as usual + // Look in the summary table first + w.search.k = plainKey + if encI := w.a.accountsTree.Get(&w.search); encI != nil { + enc = encI.(*AggregateItem).v + } else { + // Look in the files + enc = readFromFiles("accounts", &w.a.accountsFiles, nil /* lock */, w.blockNum, plainKey, false /* trace */) } cell.Nonce = 0 cell.Balance.Clear() @@ -1802,16 +1802,16 @@ func (w *Writer) storageFn(plainKey []byte, cell *commitment.Cell) ([]byte, erro if len(plainKey) != length.Addr+length.Hash { // Accessing storage key and value via "thin reference" to the state file and offset fileI := int(plainKey[0]) offset := decodeU64(plainKey[1:]) - plainKey, enc = readByOffset("storage", &w.a.storageFiles, fileI, offset) - } else { // Full storage key is provided, search as usual - // Look in the summary table first - w.search.k = plainKey - if encI := w.a.storageTree.Get(&w.search); encI != nil { - enc = encI.(*AggregateItem).v - } else { - // Look in the files - enc = readFromFiles("storage", &w.a.storageFiles, nil /* lock */, w.blockNum, plainKey, false /* trace */) - } + plainKey, _ = readByOffset("storage", &w.a.storageFiles, fileI, offset) + } + // Full storage key is provided, search as usual + // Look in the summary table first + w.search.k = plainKey + if encI := w.a.storageTree.Get(&w.search); encI != nil { + enc = encI.(*AggregateItem).v + } else { + // Look in the files + enc = readFromFiles("storage", &w.a.storageFiles, nil /* lock */, w.blockNum, plainKey, false /* trace */) } cell.StorageLen = len(enc) copy(cell.Storage[:], enc)