-
Notifications
You must be signed in to change notification settings - Fork 23
add support for orderless txn #68
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
base: main
Are you sure you want to change the base?
Conversation
|
@gregnazario @WGB5445 can u pls help review? 🙏 |
aptos_sdk/async_client.py
Outdated
| self, | ||
| sender: Account, | ||
| payload: TransactionPayload, | ||
| nonce: Optional[int] = None, | ||
| wait: bool = False |
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.
You might have other run the formatter
aptos_sdk/async_client.py
Outdated
| if nonce is None: | ||
| raise ValueError("Nonce required for orderless") |
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.
Is there a reason to make it optional, if you require them to pass it?
Should you generate a random one instead?
aptos_sdk/async_client.py
Outdated
| if not isinstance(payload.value, EntryFunction): | ||
| raise ValueError("Only EntryFunction supported for orderless") |
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.
Scripts should also be supported for orderless afaik
aptos_sdk/async_client.py
Outdated
| # Orderless transactions typically have shorter expiration windows (e.g., 30 seconds) | ||
| # Use a much shorter TTL than regular transactions | ||
| orderless_expiration_ttl = 30 # 30 seconds |
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.
It can have up to 60 seconds
aptos_sdk/transactions.py
Outdated
| serializer.uleb128(0) | ||
|
|
||
| # Executable::EntryFunction variant | ||
| serializer.uleb128(1) |
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.
Hmm, is this how it's done in other parts of the code, or are we using named constants?
Would be best to have constants for them for readability.
aptos_sdk/transactions.py
Outdated
| # Option<MultisigAddress> - None | ||
| serializer.bool(False) | ||
|
|
||
| # Option<u64> nonce - Some | ||
| serializer.bool(True) | ||
| serializer.u64(self.nonce) |
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 also a bit weird sine it only supports one path. I don't think we need to worry about multisig with orderless, it's likely not going to be signed fast enough to handle
examples/orderless_txn.py
Outdated
| client = RestClient("https://fullnode.devnet.aptoslabs.com/v1") | ||
| faucet_client = FaucetClient("https://faucet.devnet.aptoslabs.com", client) |
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.
Did we hardcode these in the rest of the examples, or did we use constants?
|
updated pr cc @gregnazario can u pls restart workflows? thnx 🙏 |
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.
Pull request overview
This PR adds support for orderless transactions in the Aptos Python SDK. Orderless transactions use a nonce instead of a sequence number, allowing transactions to be processed in any order and preventing replay attacks.
- Introduces
OrderlessPayloadclass to wrap orderless transaction payloads with nonce-based replay protection - Adds
submit_orderless_transactionmethod to the REST client for submitting orderless transactions - Provides comprehensive examples demonstrating regular orderless transactions, script-based transactions, multisig transactions, and replay protection
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| examples/orderless_txn.py | New example file demonstrating various orderless transaction patterns including regular transfers, scripts, multisig, and replay protection |
| aptos_sdk/transactions.py | Adds OrderlessPayload class with serialization logic for orderless transaction payloads and new INNER_PAYLOAD variant |
| aptos_sdk/async_client.py | Implements submit_orderless_transaction method in RestClient and imports required classes |
| CHANGELOG.md | Documents the new orderless transaction support feature |
Comments suppressed due to low confidence (1)
aptos_sdk/async_client.py:559
- This assignment to 'orderless' is unnecessary as it is redefined before this value is used.
orderless = OrderlessPayload(executable, nonce, multisig_address)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| orderless = OrderlessPayload(payload.value, nonce) | ||
|
|
Copilot
AI
Nov 25, 2025
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 orderless variable is created twice. Line 561 overwrites line 559, ignoring the multisig_address parameter. Remove line 561 and use the variable from line 559, or remove lines 559-560 if line 561 is the intended implementation (though this would break multisig support).
| orderless = OrderlessPayload(payload.value, nonce) |
|
|
||
|
|
||
| async def example_replay_protection(): | ||
| """Example 5: Demonstrating replay protection with same nonce""" |
Copilot
AI
Nov 25, 2025
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 example is labeled 'Example 5' but there is no 'Example 4' in the file. The examples are numbered 1, 2, 3, and 5. Either renumber this to 'Example 4' or add the missing Example 4.
| if __name__ == "__main__": | ||
| client = RestClient(NODE_URL, client_config=ClientConfig(api_key=API_KEY)) | ||
| faucet_client = FaucetClient(FAUCET_URL, client) | ||
| asyncio.run(main()) |
Copilot
AI
Nov 25, 2025
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 new orderless transaction feature lacks test coverage. Other examples in the repository (e.g., transfer_coin, multisig) are integrated into examples/integration_test.py. Consider adding a test method like async def test_orderless_txn(self): to the Test class in examples/integration_test.py to ensure this functionality is properly tested.
Description
add support for orderless txns
Test Plan
Related Links