-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: TransactionMessage.decompile() now counts the correct number of unsigned, writable accounts #28990
fix: TransactionMessage.decompile() now counts the correct number of unsigned, writable accounts #28990
Conversation
Codecov Report
@@ Coverage Diff @@
## master #28990 +/- ##
=========================================
- Coverage 77.1% 76.7% -0.5%
=========================================
Files 55 55
Lines 2934 3084 +150
Branches 408 454 +46
=========================================
+ Hits 2264 2367 +103
- Misses 529 559 +30
- Partials 141 158 +17 |
…r of writable unsigned accounts
@@ -49,7 +49,9 @@ export class TransactionMessage { | |||
assert(numWritableSignedAccounts > 0, 'Message header is invalid'); | |||
|
|||
const numWritableUnsignedAccounts = | |||
message.staticAccountKeys.length - numReadonlyUnsignedAccounts; | |||
message.staticAccountKeys.length - | |||
numRequiredSignatures - |
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.
Without this change, the test in this commit incorrectly marks the last account as writable.
Got the idea to double check the Rust code, and found it to already be correct. solana/sdk/program/src/message/versions/v0/mod.rs Lines 284 to 286 in 98525dd
|
…unsigned, writable accounts (solana-labs#28990) * Test that `TransactionMessage.decompile()` can decompile a legacy `Message` * `TransactionMessage.decompile()` now correctly accounts for the number of writable unsigned accounts
…unsigned, writable accounts (solana-labs#28990) * Test that `TransactionMessage.decompile()` can decompile a legacy `Message` * `TransactionMessage.decompile()` now correctly accounts for the number of writable unsigned accounts
Problem
Message headers give you the following:
numRequiredSignatures
)numReadonlySignedAccounts
)numReadonlyUnsignedAccounts
)If we want to know how many writable unsigned accounts there are, we have to:
numRequiredSignatures
)numReadonlyUnsignedAccounts
)That spells:
Unfortunately, we forgot to subtract out the number of signers, making it possible to overcount
numWritableUnsignedAccounts
. This played havoc when deserializing messages like the one in #28900's repro.All of this could result in accounts being needlessly marked as writeable, which could only serve to make the network slower (ie. causing the validator to run transactions in serial that could otherwise have been safely run in parallel).
Summary of Changes
numWritableUnsignedAccounts
TransactionMessage
Fixes #28900.