-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: fix transaction confirmation logic #24211
fix: fix transaction confirmation logic #24211
Conversation
f276605
to
9b5775f
Compare
I’ll look at this soon, thanks for your patience! |
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.
This is going to be so great when it's fixed. Thanks for working on it! We have a good deal of ground to cover here before this is fast, light, and reliable enough for production, but start with these comments and we'll get there soon!
Pull request has been modified.
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.
Great changes; keep going!
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.
Keep on going!
Pull request has been modified.
Hey Steve, left some comments to give updates on what I've been able to do. Let me know what you think! |
17e74eb
to
34d46d2
Compare
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.
So close! I can see it coming together.
It's time to start writing tests for this stuff. Are you familiar with writing tests in this codebase, or should we hop on a call to talk through it?
You haven't rebased atop the main branch in a really long time. You might want to |
@stellaw1, when you rebase this code atop the main branch again, you'll discover a build error caused by the fact that these two definitions snuck in between your constructor overloads and the constructor implementation. That's what's causing the build errors on this PR. Just move them out of the way so that all 4 constructor signatures come one after another. |
Yeah, I'm a bit embarrassed that I hadn't rebased in so long. When Stella pushed her changes I did a rebase to get everything up to date. I try to rebase more frequently, but I just lost track of time and forgot about it. I'll make sure to keep on it now! Update: I evidently did not rebase everything the way I thought I had. I thought I had gotten my local master branch up to date, and then updated my feature branch from there. |
I haven't done much with tests in this codebase, so if you've got some time to get on a call I would appreciate it. |
Pull request has been modified.
40f7071
to
cb61c27
Compare
The test suite passes, but the builds are all failing because of this:
I've seen this once before but I have no idea how to fix it. |
That build failure just means that you have to write documentation (in the form of code comments) above |
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.
Love it! Just a few quick comments before I grab a bite to eat. I'll finish the review after that!
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.
Nice! Just some tidy up. Let me know if you want help with the tests; I'm happy to check this PR out and give it a go.
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.
Yay! Let's ship this next week!
Thank you for all of your relentless work on this. Your work here is going to help people get notices of failed transactions sooner so that they can take action faster. This is going to ripple all the way through the Solana ecosystem, ultimately increasing the number of successful transactions, and joy using products and services.
I'll do a once over of the tests if you want to fix the few typos, and then I think we're gtg!
And @stellaw1, the same goes for you. Thank you for your contributions here, and for being part of our awesome developer community! |
Here, I fixed up the tests, and made some minor tweaks to let/const bindings. What do you think of these? Feel free to pull them in to this PR or commit them under your account: https://github.com/steveluscher/solana/commits/fix-transaction-confirmation |
dba9234
to
588fd7e
Compare
I made a couple of fixes on https://github.com/steveluscher/solana/commits/fix-transaction-confirmation (I still can't seem to push updates to your branch) but one thing we have to do before shipping this is to make sure that your new tests run with I think the right thing to do here is to simply make them not run when |
I think the only way to fix this is to close this PR and open a new PR from my own personal branch. For whatever reason, I don't have an option to allow maintainer edits on a PR from the
This makes sense. I'll also make this change. |
fa5546f
to
8db0d28
Compare
Codecov Report
@@ Coverage Diff @@
## master #24211 +/- ##
===========================================
- Coverage 82.0% 75.3% -6.8%
===========================================
Files 598 38 -560
Lines 165882 2291 -163591
Branches 0 333 +333
===========================================
- Hits 136125 1726 -134399
+ Misses 29757 447 -29310
- Partials 0 118 +118 |
Pull request has been modified.
web3.js/src/transaction.ts
Outdated
@@ -752,9 +800,11 @@ export class Transaction { | |||
static populate( | |||
message: Message, | |||
signatures: Array<string> = [], | |||
lastValidBlockHeight?: number, |
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.
Wait, I'm confused. The Message
type can have latestBlockhash
on it. If present, then you have all you need to reconstruct a Transaction
with a lastValidBlockHash
.
Instead of changing the method sig here, can you just inspect message, looking for latestBlockhash.lastValidBlockHeight
, and on the compileMessage
side make sure that you write out a latestBlockhash
?
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.
That was part of this PR, but we didn't finish it because we realized it was going to be more involved. If you look down further in Message
to the from
method, we don't do anything with lastValidBlockHeight
. So if we include latestBlockhash
in a constructed message, lastValidBlockHeight
is undefined
.
Co-authored-by: Marc Jaramillo <mnj.webdeveloper@gmail.com> Co-authored-by: Stella Wang <stella01wang@gmail.com>
5bf4063
to
89b9e01
Compare
Problem
Currently, one issue is that
sendAndConfirmTransaction
relies onconfirmTransaction
to determine whether a transaction has expired. This is an issue becauseconfirmTransaction
simply waits for 60 seconds rather than using thelastValidBlockHeight
associated with a transaction'sblockhash
.Summary of Changes
This PR attempts to move the transaction confirmation logic closer to a correct state by allowing the
Transaction
constructor to accept the entire results object from callinggetLatestBlockhash
rather than only theblockhash
. This requires creating a newTransactionCtorFields__DEPRECATED
to continue allowing the current implementation to be used while updatingTransactionCtorFields
to accept the updated values.Because of the relationship between transactions and messages, this change also required a change to
Message
to likewise accept thelastValidBlockHeight
that results from callinggetLatestBlockhash
.Finally, we have updated
sendAndConfirmTransaction
to no longer use the currentconfirmTransaction
. Instead, it compares the currentblockHeight
tolastValidBlockHeight
while waiting for the transaction to be confirmed.Fixes #23949
Fixes #24730
Closes #24757