Repository navigation
[r3.4] commitment, execctx: fix InsertBlocks failure during block catch-up #20555
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ import ( | |
| "github.com/erigontech/erigon/common/log/v3" | ||
| "github.com/erigontech/erigon/db/kv" | ||
| "github.com/erigontech/erigon/db/kv/order" | ||
| "github.com/erigontech/erigon/db/kv/rawdbv3" | ||
| "github.com/erigontech/erigon/db/state/changeset" | ||
| "github.com/erigontech/erigon/db/state/statecfg" | ||
| "github.com/erigontech/erigon/diagnostics/metrics" | ||
|
|
@@ -73,11 +74,13 @@ type accHolder interface { | |
|
|
||
| func IsDomainAheadOfBlocks(ctx context.Context, tx kv.TemporalRwTx, logger log.Logger) bool { | ||
| doms, err := NewSharedDomains(ctx, tx, logger) | ||
| if doms != nil { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is anti-pattern: it's responsibility of But we do return non-nil now - I forgot why (I did it). Probably because constructor has biz-logic now and we want threat some errors as non-critical, but keep existing |
||
| defer doms.Close() | ||
| } | ||
| if err != nil { | ||
| logger.Debug("domain ahead of blocks", "err", err, "stack", dbg.Stack()) | ||
| return errors.Is(err, commitmentdb.ErrBehindCommitment) | ||
| } | ||
| defer doms.Close() | ||
| return false | ||
| } | ||
|
|
||
|
|
@@ -116,10 +119,22 @@ func NewSharedDomains(ctx context.Context, tx kv.TemporalTx, logger log.Logger) | |
|
|
||
| sd.sdCtx = commitmentdb.NewSharedDomainsCommitmentContext(sd, commitment.ModeDirect, tv, tx.Debug().Dirs().Tmp) | ||
|
|
||
| if _, _, err := sd.SeekCommitment(ctx, tx); err != nil { | ||
| _, blockNum, err := sd.SeekCommitment(ctx, tx) | ||
| if err != nil { | ||
| return sd, err | ||
| } | ||
|
|
||
| // ErrBehindCommitment is an environmental signal; sd is fully initialized. | ||
| if blockNum > 0 { | ||
| lastBn, _, err := rawdbv3.TxNums.Last(tx) | ||
| if err != nil { | ||
| return sd, err | ||
| } | ||
| if lastBn < blockNum { | ||
| return sd, fmt.Errorf("%w: TxNums index is at block %d and behind commitment %d", commitmentdb.ErrBehindCommitment, lastBn, blockNum) | ||
| } | ||
| } | ||
|
|
||
| return sd, nil | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we return non-nil domains with error?