-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix(unorderedtx): issues reported in audit #21467
Changes from 15 commits
7aba2e7
8f3e2cb
83fa1f0
75e79c0
33665d5
0661845
c100377
af42e6c
32ec055
a06cc3f
8a5018e
5109b45
d86bfd4
8031960
9be58bd
7ccca5d
efee58b
74c1faa
d29c921
7b3ffef
804415f
0b9141a
dcc9705
4b30492
cf9fd70
274c596
0fcc166
9974f61
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -686,6 +686,7 @@ func (app *SimApp) Name() string { return app.BaseApp.Name() } | |||||||||
|
||||||||||
// PreBlocker application updates every pre block | ||||||||||
func (app *SimApp) PreBlocker(ctx sdk.Context, _ *abci.FinalizeBlockRequest) error { | ||||||||||
app.UnorderedTxManager.OnNewBlock(ctx.BlockTime()) | ||||||||||
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. Ensure proper error handling in The addition of However, it's important to ensure that any potential errors returned by Consider modifying the implementation to handle potential errors returned by the - app.UnorderedTxManager.OnNewBlock(ctx.BlockTime())
+ if err := app.UnorderedTxManager.OnNewBlock(ctx.BlockTime()); err != nil {
+ return fmt.Errorf("failed to notify UnorderedTxManager of new block: %w", err)
+ } This modification ensures that errors are not silently ignored, enhancing the robustness of the transaction management process. Committable suggestion
Suggested change
|
||||||||||
return app.ModuleManager.PreBlock(ctx) | ||||||||||
} | ||||||||||
|
||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,13 @@ | |
|
||
"cosmossdk.io/core/header" | ||
storetypes "cosmossdk.io/store/types" | ||
"cosmossdk.io/x/auth/ante" | ||
"cosmossdk.io/x/auth/ante/unorderedtx" | ||
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. Resolve import path issue. The static analysis tool reports an issue with the import path ToolsGitHub Check: tests (02)
|
||
|
||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" | ||
"github.com/cosmos/cosmos-sdk/testutil/testdata" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/tx/signing" | ||
"github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
"github.com/cosmos/cosmos-sdk/x/auth/ante/unorderedtx" | ||
) | ||
|
||
const gasConsumed = uint64(25) | ||
|
@@ -141,10 +141,10 @@ | |
require.True(t, txm.Contains(bz)) | ||
} | ||
|
||
func genUnorderedTx(t *testing.T, unordered bool, timestamp time.Time) (sdk.Tx, []byte) { | ||
func genUnorderedTx(t testing.TB, unordered bool, timestamp time.Time) (sdk.Tx, []byte) { | ||
t.Helper() | ||
|
||
s := SetupTestSuite(t, true) | ||
s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() | ||
|
||
// keys and addresses | ||
|
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.
Review: Integration of Unordered Transaction Manager in
PreBlocker()
The integration of the unordered transaction manager within the
PreBlocker()
method is crucial for handling unordered transactions effectively. The method now callsOnNewBlock()
on the unordered transaction manager, which is a significant change to ensure that the manager is notified upon each new block. This allows the manager to process transactions that do not require a specific order.However, the documentation should clarify what specific errors might trigger the panic and under what conditions. This would help developers understand the potential risks and how to mitigate them.
Consider adding more detailed error handling documentation to clarify under what conditions the panic is triggered and how to handle these errors gracefully.