Skip to content

Commit

Permalink
discard_commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blxdyx committed Nov 26, 2024
1 parent e8dd9ed commit fc37c30
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
33 changes: 19 additions & 14 deletions erigon-lib/state/domain_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -346,27 +350,28 @@ 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)
return 0, nil
}
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
}

Expand Down
1 change: 1 addition & 0 deletions eth/stagedsync/exec3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit fc37c30

Please sign in to comment.