-
Notifications
You must be signed in to change notification settings - Fork 46
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
Option to disable attempts to fix sequence mismatch during broadcasting of txs #213
Changes from 3 commits
f036da9
0fd3579
2a7da1e
b4bd99b
a9ea38c
8e00488
ca39171
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 |
---|---|---|
|
@@ -605,7 +605,7 @@ | |
res, err := c.broadcastTx(c.ctx, c.txFactory, true, msgs...) | ||
|
||
if err != nil { | ||
if strings.Contains(err.Error(), "account sequence mismatch") { | ||
if c.opts.FixSeqMismatch && strings.Contains(err.Error(), "account sequence mismatch") { | ||
c.syncNonce() | ||
sequence := c.getAccSeq() | ||
c.txFactory = c.txFactory.WithSequence(sequence) | ||
|
@@ -668,7 +668,7 @@ | |
c.txFactory = c.txFactory.WithAccountNumber(c.accNum) | ||
res, err := c.broadcastTx(c.ctx, c.txFactory, false, msgs...) | ||
if err != nil { | ||
if strings.Contains(err.Error(), "account sequence mismatch") { | ||
if c.opts.FixSeqMismatch && strings.Contains(err.Error(), "account sequence mismatch") { | ||
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. Similar to the synchronous broadcast method, the asynchronous transaction broadcasting method now includes logic to handle sequence mismatches. This change is also not covered by tests. It's important to extend the testing suite to include scenarios that exercise the new asynchronous sequence mismatch handling logic. Ensuring comprehensive test coverage will help maintain the robustness of the transaction broadcasting feature. |
||
c.syncNonce() | ||
sequence := c.getAccSeq() | ||
c.txFactory = c.txFactory.WithSequence(sequence) | ||
|
@@ -682,7 +682,6 @@ | |
return nil, err | ||
} | ||
} | ||
|
||
return res, nil | ||
} | ||
|
||
|
@@ -925,7 +924,7 @@ | |
log.Debugln("broadcastTx with nonce", sequence) | ||
res, err := c.broadcastTx(c.ctx, c.txFactory, true, toSubmit...) | ||
if err != nil { | ||
if strings.Contains(err.Error(), "account sequence mismatch") { | ||
if c.opts.FixSeqMismatch && strings.Contains(err.Error(), "account sequence mismatch") { | ||
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 logic for handling sequence mismatches during the batch broadcast of transactions is a valuable addition. However, like the other related changes, this update lacks test coverage. Adding tests for the batch broadcast functionality, especially with the new sequence mismatch handling logic, is crucial for ensuring the reliability and correctness of this feature. |
||
c.syncNonce() | ||
sequence := c.getAccSeq() | ||
c.txFactory = c.txFactory.WithSequence(sequence) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,7 +176,21 @@ | |
|
||
func LoadNetwork(name string, node string) Network { | ||
switch name { | ||
|
||
case "local": | ||
return Network{ | ||
LcdEndpoint: "", | ||
TmEndpoint: "tcp://localhost:26657", | ||
ChainGrpcEndpoint: "tcp://localhost:9900", | ||
ChainStreamGrpcEndpoint: "", | ||
ExchangeGrpcEndpoint: "", | ||
ExplorerGrpcEndpoint: "", | ||
ChainId: "injective-1", | ||
Fee_denom: "inj", | ||
Name: "local-1", | ||
chainCookieAssistant: &DisabledCookieAssistant{}, | ||
exchangeCookieAssistant: &DisabledCookieAssistant{}, | ||
explorerCookieAssistant: &DisabledCookieAssistant{}, | ||
} | ||
Comment on lines
+179
to
+193
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 the Would you like assistance in creating tests for this new network configuration? |
||
case "devnet-1": | ||
return Network{ | ||
LcdEndpoint: "https://devnet-1.lcd.injective.dev", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,15 +19,18 @@ | |
} | ||
|
||
type ClientOptions struct { | ||
GasPrices string | ||
TLSCert credentials.TransportCredentials | ||
TxFactory *tx.Factory | ||
GasPrices string | ||
TLSCert credentials.TransportCredentials | ||
TxFactory *tx.Factory | ||
FixSeqMismatch bool | ||
} | ||
|
||
type ClientOption func(opts *ClientOptions) error | ||
|
||
func DefaultClientOptions() *ClientOptions { | ||
return &ClientOptions{} | ||
return &ClientOptions{ | ||
FixSeqMismatch: true, | ||
} | ||
Comment on lines
+31
to
+33
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 default setting of Would you like assistance in creating tests for this new default setting? |
||
} | ||
|
||
func OptionGasPrices(gasPrices string) ClientOption { | ||
|
@@ -61,3 +64,10 @@ | |
return nil | ||
} | ||
} | ||
|
||
func OptionFixSeqMismatch(fixSeqMismatch bool) ClientOption { | ||
return func(opts *ClientOptions) error { | ||
opts.FixSeqMismatch = fixSeqMismatch | ||
return nil | ||
} | ||
Comment on lines
+68
to
+72
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 Would you like assistance in creating tests for this configuration option? |
||
} |
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.
The logic to handle sequence mismatches during synchronous transaction broadcasting has been updated to check the
FixSeqMismatch
option. However, this change lacks test coverage.Consider adding unit tests to cover the new logic introduced for handling sequence mismatches. This will ensure the feature works as expected and will help catch any potential issues or edge cases.