-
Notifications
You must be signed in to change notification settings - Fork 710
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
Improve block building and verification logging #3605
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,6 +355,9 @@ func buildBlock( | |
) | ||
} | ||
if err != nil { | ||
builder.txExecutorBackend.Ctx.Log.Warn("failed to pack block transactions", | ||
zap.Error(err), | ||
) | ||
Comment on lines
+358
to
+360
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. Note: engine will log at debug, but not warn level since block build failures can happen regularly if the VM cleared its mempool and decides not to produce an empty block. |
||
return nil, fmt.Errorf("failed to pack block txs: %w", err) | ||
} | ||
|
||
|
@@ -485,9 +488,26 @@ func packEtnaBlockTxs( | |
blockComplexity gas.Dimensions | ||
feeCalculator = state.PickFeeCalculator(backend.Config, stateDiff) | ||
) | ||
|
||
backend.Ctx.Log.Debug("starting to pack block txs", | ||
zap.Stringer("parentID", parentID), | ||
zap.Time("blockTimestamp", timestamp), | ||
zap.Uint64("capacity", uint64(capacity)), | ||
zap.Int("mempoolLen", mempool.Len()), | ||
) | ||
for { | ||
currentBlockGas, err := blockComplexity.ToGas(backend.Config.DynamicFeeConfig.Weights) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tx, exists := mempool.Peek() | ||
if !exists { | ||
backend.Ctx.Log.Debug("mempool is empty", | ||
zap.Uint64("capacity", uint64(capacity)), | ||
zap.Uint64("blockGas", uint64(currentBlockGas)), | ||
zap.Int("blockLen", len(blockTxs)), | ||
) | ||
break | ||
} | ||
|
||
|
@@ -504,6 +524,12 @@ func packEtnaBlockTxs( | |
return nil, err | ||
} | ||
if newBlockGas > capacity { | ||
backend.Ctx.Log.Debug("block is full", | ||
zap.Uint64("nextBlockGas", uint64(newBlockGas)), | ||
zap.Uint64("capacity", uint64(capacity)), | ||
zap.Uint64("blockGas", uint64(currentBlockGas)), | ||
zap.Int("blockLen", len(blockTxs)), | ||
) | ||
break | ||
} | ||
|
||
|
@@ -549,6 +575,7 @@ func executeTx( | |
|
||
// Invariant: [tx] has already been syntactically verified. | ||
|
||
txID := tx.ID() | ||
err := txexecutor.VerifyWarpMessages( | ||
ctx, | ||
backend.Ctx.NetworkID, | ||
|
@@ -557,7 +584,11 @@ func executeTx( | |
tx.Unsigned, | ||
) | ||
if err != nil { | ||
txID := tx.ID() | ||
backend.Ctx.Log.Debug("transaction failed warp verification", | ||
zap.Stringer("txID", txID), | ||
zap.Error(err), | ||
) | ||
|
||
mempool.MarkDropped(txID, err) | ||
return false, nil | ||
} | ||
|
@@ -574,23 +605,41 @@ func executeTx( | |
txDiff, | ||
) | ||
if err != nil { | ||
txID := tx.ID() | ||
backend.Ctx.Log.Debug("transaction failed execution", | ||
zap.Stringer("txID", txID), | ||
zap.Error(err), | ||
) | ||
|
||
mempool.MarkDropped(txID, err) | ||
return false, nil | ||
} | ||
|
||
if inputs.Overlaps(txInputs) { | ||
txID := tx.ID() | ||
// This log is a warn because the mempool should not have allowed this | ||
// transaction to be included. | ||
backend.Ctx.Log.Warn("transaction conflicts with prior transaction", | ||
zap.Stringer("txID", txID), | ||
zap.Error(err), | ||
) | ||
|
||
mempool.MarkDropped(txID, blockexecutor.ErrConflictingBlockTxs) | ||
return false, nil | ||
} | ||
if err := manager.VerifyUniqueInputs(parentID, txInputs); err != nil { | ||
txID := tx.ID() | ||
backend.Ctx.Log.Debug("transaction conflicts with ancestor's import transaction", | ||
zap.Stringer("txID", txID), | ||
zap.Error(err), | ||
) | ||
|
||
mempool.MarkDropped(txID, err) | ||
return false, nil | ||
} | ||
inputs.Union(txInputs) | ||
|
||
backend.Ctx.Log.Debug("successfully executed transaction", | ||
zap.Stringer("txID", txID), | ||
zap.Error(err), | ||
) | ||
txDiff.AddTx(tx, status.Committed) | ||
return true, txDiff.Apply(stateDiff) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
❤️