From fc37c303da70a091313f84299375f763d6bb325e Mon Sep 17 00:00:00 2001 From: blxdyx Date: Tue, 26 Nov 2024 10:48:37 +0800 Subject: [PATCH] discard_commit --- erigon-lib/state/domain_shared.go | 33 ++++++++++++++++++------------- eth/stagedsync/exec3.go | 1 + 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/erigon-lib/state/domain_shared.go b/erigon-lib/state/domain_shared.go index c2face5e731..e7cf0c15e0d 100644 --- a/erigon-lib/state/domain_shared.go +++ b/erigon-lib/state/domain_shared.go @@ -334,6 +334,10 @@ func (sd *SharedDomains) SeekCommitment(ctx context.Context, tx kv.Tx) (txsFromB sd.SetTxNum(txn) return 0, nil } + if len(sd.aggTx.d[kv.CommitmentDomain].files) > 0 { + txn = sd.aggTx.d[kv.CommitmentDomain].files[len(sd.aggTx.d[kv.CommitmentDomain].files)-1].endTxNum + sd.SetTxNum(txn) + } // handle case when we have no commitment, but have executed blocks bnBytes, err := tx.GetOne(kv.SyncStageProgress, []byte("Execution")) //TODO: move stages to erigon-lib if err != nil { @@ -346,6 +350,7 @@ func (sd *SharedDomains) SeekCommitment(ctx context.Context, tx kv.Tx) (txsFromB return 0, err } } + sd.logger.Info("seeking commitment", "bn", bn, "txn", tx) if bn == 0 && txn == 0 { sd.SetBlockNum(0) sd.SetTxNum(0) @@ -353,20 +358,20 @@ func (sd *SharedDomains) SeekCommitment(ctx context.Context, tx kv.Tx) (txsFromB } sd.SetBlockNum(bn) sd.SetTxNum(txn) - newRh, err := sd.rebuildCommitment(ctx, tx, bn) - if err != nil { - return 0, err - } - if bytes.Equal(newRh, commitment.EmptyRootHash) { - sd.SetBlockNum(0) - sd.SetTxNum(0) - return 0, nil - } - if sd.trace { - fmt.Printf("rebuilt commitment %x %d %d\n", newRh, sd.TxNum(), sd.BlockNum()) - } - sd.SetBlockNum(bn) - sd.SetTxNum(txn) + //newRh, err := sd.rebuildCommitment(ctx, tx, bn) + //if err != nil { + // return 0, err + //} + //if bytes.Equal(newRh, commitment.EmptyRootHash) { + // sd.SetBlockNum(0) + // sd.SetTxNum(0) + // return 0, nil + //} + //if sd.trace { + // fmt.Printf("rebuilt commitment %x %d %d\n", newRh, sd.TxNum(), sd.BlockNum()) + //} + //sd.SetBlockNum(bn) + //sd.SetTxNum(txn) return 0, nil } diff --git a/eth/stagedsync/exec3.go b/eth/stagedsync/exec3.go index 932928ba5e2..ce9ec1ac7b4 100644 --- a/eth/stagedsync/exec3.go +++ b/eth/stagedsync/exec3.go @@ -910,6 +910,7 @@ func flushAndCheckCommitmentV3(ctx context.Context, header *types.Header, applyT // E2 state root check was in another stage - means we did flush state even if state root will not match // And Unwind expecting it if !parallel { + logger.Info("flushAndCheckCommitmentV3", "block", header.Number.Uint64(), "maxBlockNum", maxBlockNum) if err := e.Update(applyTx, maxBlockNum); err != nil { return false, err }