-
Notifications
You must be signed in to change notification settings - Fork 56
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 SubmitEthereumTxConfirmation bug #558
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 |
---|---|---|
|
@@ -12,6 +12,18 @@ import ( | |
|
||
func (k Keeper) GetUnsignedContractCallTxs(ctx sdk.Context, val sdk.ValAddress) []*types.ContractCallTx { | ||
var unconfirmed []*types.ContractCallTx | ||
k.IterateCompletedOutgoingTxsByType(ctx, types.ContractCallTxPrefixByte, func(_ []byte, cotx types.OutgoingTx) bool { | ||
sig := k.getEthereumSignature(ctx, cotx.GetStoreIndex(), val) | ||
if len(sig) == 0 { | ||
call, ok := cotx.(*types.ContractCallTx) | ||
if !ok { | ||
panic(sdkerrors.Wrapf(types.ErrInvalid, "couldn't cast to contract call for completed tx %s", cotx)) | ||
} | ||
unconfirmed = append(unconfirmed, call) | ||
} | ||
return false | ||
}) | ||
Comment on lines
+15
to
+25
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. The addition of iterating over completed outgoing transactions to include them in the list of unconfirmed contract call transactions is a crucial fix for the issue described. However, using Regarding performance, ensure that the iteration over completed transactions does not introduce significant overhead, especially as the number of transactions grows. If performance becomes a concern, consider optimizing the data structure used for storing and querying these transactions. |
||
|
||
k.IterateOutgoingTxsByType(ctx, types.ContractCallTxPrefixByte, func(_ []byte, otx types.OutgoingTx) bool { | ||
sig := k.getEthereumSignature(ctx, otx.GetStoreIndex(), val) | ||
if len(sig) == 0 { | ||
|
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.
Similar to the changes in
contract_call.go
, the addition of iterating over completed outgoing transactions inGetUnsignedBatchTxs
is essential for the fix. However, the use ofpanic
for error handling (line 171) should be reconsidered for the same reasons mentioned earlier: it's generally discouraged unless for truly unrecoverable errors. Consider returning an error instead.Also, be mindful of the performance implications of iterating over a potentially large number of transactions. If performance issues arise, exploring optimizations for the data structure or query mechanism might be necessary.