-
Notifications
You must be signed in to change notification settings - Fork 176
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
pm: Only mark failed tx as redeemed for check tx err #2018
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 |
---|---|---|
|
@@ -25,8 +25,6 @@ var unixNow = func() int64 { | |
return time.Now().Unix() | ||
} | ||
|
||
type errCheckTx error | ||
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. Removed this error type because we really care about whether the error when checking the tx is the result of a tx failure and this is accomplished by the string check in this PR making this error type unnecessary. |
||
|
||
// SenderMonitor is an interface that describes methods used to | ||
// monitor remote senders | ||
type SenderMonitor interface { | ||
|
@@ -291,17 +289,20 @@ func (sm *LocalSenderMonitor) startTicketQueueConsumerLoop(queue *ticketQueue, d | |
select { | ||
case red := <-queue.Redeemable(): | ||
tx, err := sm.redeemWinningTicket(red.SignedTicket) | ||
if err != nil { | ||
red.resCh <- struct { | ||
txHash ethcommon.Hash | ||
err error | ||
}{ethcommon.Hash{}, err} | ||
} else { | ||
red.resCh <- struct { | ||
txHash ethcommon.Hash | ||
err error | ||
}{tx.Hash(), nil} | ||
res := struct { | ||
txHash ethcommon.Hash | ||
err error | ||
}{ | ||
ethcommon.Hash{}, | ||
err, | ||
} | ||
// FIXME: If there are replacement txs then tx.Hash() could be different | ||
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: Create an issue to track this. This was a problem before this PR and more substantial changes will be required to address it (i.e. return the tx that was mined from |
||
// from the hash of the replacement tx that was mined | ||
if tx != nil { | ||
res.txHash = tx.Hash() | ||
} | ||
|
||
red.resCh <- res | ||
case <-done: | ||
// When the ticket consumer exits, tell the ticketQueue | ||
// to exit as well | ||
|
@@ -350,6 +351,7 @@ func (sm *LocalSenderMonitor) cleanup() { | |
} | ||
} | ||
|
||
// Returns a non-nil tx if one is sent. Otherwise, returns a nil tx | ||
func (sm *LocalSenderMonitor) redeemWinningTicket(ticket *SignedTicket) (*types.Transaction, error) { | ||
availableFunds, err := sm.availableFunds(ticket.Sender) | ||
if err != nil { | ||
|
@@ -424,7 +426,8 @@ func (sm *LocalSenderMonitor) redeemWinningTicket(ticket *SignedTicket) (*types. | |
if monitor.Enabled { | ||
monitor.TicketRedemptionError() | ||
} | ||
return nil, errCheckTx(err) | ||
// Return tx so caller can utilize the tx if it fails | ||
return tx, err | ||
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 gives the caller access to the hash of a failed tx. |
||
} | ||
|
||
if monitor.Enabled { | ||
|
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.
I don't feel great about this string check, but I ran into issues implementing an error type check since the tx failure check occurs in the
eth
package and importing an error type from theeth
package in thepm
package would result in an import cycle. There may be a better way to structure this check, but I went with the simple solution of a string check right now accepting the downside of exposing thepm
package to the implementation details ofeth.client.CheckTx()
.