-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Aptos gas payer #8773
Aptos gas payer #8773
Conversation
aptos-move/aptos-release-builder/src/components/feature_flags.rs
Outdated
Show resolved
Hide resolved
@@ -80,3 +81,74 @@ fn read_coin(h: &MoveHarness, account: &AccountAddress) -> u64 { | |||
.unwrap() | |||
.coin() | |||
} | |||
|
|||
#[test] | |||
fn test_two_to_two_transfer_gas_payer() { |
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.
Can you add some more tests around cases such as:
- Feature flag is not enabled.
- Gas payer doesn't have enough gas
- Extra senders without gas payer bit set.
- etc. Any other edge cases? Let's be as thorough as possible here to make sure there are no unforeseen issues
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.
Still missing some failure cases:
- Gas payer doesn't have sufficient balances.
- Invalid gas payer signature
- Etc.
I'll leave it to you to determine what can be covered with unit vs move e2e tests. We'll also have a more concise integration test later in TS as well for a true e2e.
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.
Given that this code is just using multi-agent signing and reusing the epilogue. Most of these flows are tested by regular tests
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 have tests that cover (scripts/entry functions)/(no signer/single signer/multiple signers)/(gas bit/no-gas bit)(feature/no feature)
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 looks good to me from the code perspective, wo/ understanding the design goals. More tests would be good.
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.
lgtm
} else { | ||
// Gas payer tx | ||
let gas_payer = *txn_data.secondary_signers.last().ok_or_else(|| { | ||
PartialVMError::new(StatusCode::UNKNOWN_INVARIANT_VIOLATION_ERROR) |
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.
We shouldn't use UNKNOWN_INVARIANT_VIOLATION_ERROR here as this case can happen if user sets the gas payer bit for a normal tx with no secondary signers
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.
No it's invariant error, as we shouldn't even get to the epilogue if the gas payer account is missing. Was tempted to do unwrap but decided invariant error is better
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 added a proper abort code in the multi_agent prologue to verify this
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.
We're being a bit strict and trying to avoid invariant violation as much as possible. cc @runtian-zhou regarding whether this is a legit case
a31cc57
to
23298a4
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
* initial commit * Support gas payer * Remove relics * Fix * Make verification know about gas payer bit * update comments * Remove merge conflict * Give MSB a good name * Reformat * improve * add comment * Fix spec
* initial commit * Support gas payer * Remove relics * Fix * Make verification know about gas payer bit * update comments * Remove merge conflict * Give MSB a good name * Reformat * improve * add comment * Fix spec
* initial commit * Support gas payer * Remove relics * Fix * Make verification know about gas payer bit * update comments * Remove merge conflict * Give MSB a good name * Reformat * improve * add comment * Fix spec
Description
Implement alternate gas payer support to aptos-blockchain. This pr reuses the already existing multi-agent framework, as a separate gas payer "is" a special case of a multi-agent transaction. However the existing multi-agent framework requires
a entry function that takes all [sender, secondary_signer...] as the first parameters, a gas payer is typically not a parameter to an entry function, but just a signature to pay for the tx.
This PR uses the MSB (high bit) of the sequence number as a boolean to indicate a gas payer in case of a multi-agent tx.
If this is set the last entry in the list of secondary signer is the "gas payer" and does not participate as signer in the
tx parameters. This is safe as 64bits is large enough for the high bit never to be reached.
Test Plan