Skip to content

Conversation

@Tlazypanda
Copy link

Description

add support for orderless txns

Test Plan

Related Links

@Tlazypanda Tlazypanda requested review from a team and gregnazario as code owners October 3, 2025 08:53
@Tlazypanda
Copy link
Author

@gregnazario @WGB5445 can u pls help review? 🙏

Comment on lines 535 to 539
self,
sender: Account,
payload: TransactionPayload,
nonce: Optional[int] = None,
wait: bool = False
Copy link
Contributor

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

Comment on lines 542 to 543
if nonce is None:
raise ValueError("Nonce required for orderless")
Copy link
Contributor

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?

Comment on lines 545 to 546
if not isinstance(payload.value, EntryFunction):
raise ValueError("Only EntryFunction supported for orderless")
Copy link
Contributor

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

Comment on lines 552 to 554
# 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
Copy link
Contributor

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

Comment on lines 493 to 496
serializer.uleb128(0)

# Executable::EntryFunction variant
serializer.uleb128(1)
Copy link
Contributor

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.

Comment on lines 504 to 509
# Option<MultisigAddress> - None
serializer.bool(False)

# Option<u64> nonce - Some
serializer.bool(True)
serializer.u64(self.nonce)
Copy link
Contributor

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

Comment on lines 16 to 17
client = RestClient("https://fullnode.devnet.aptoslabs.com/v1")
faucet_client = FaucetClient("https://faucet.devnet.aptoslabs.com", client)
Copy link
Contributor

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?

@Tlazypanda
Copy link
Author

updated pr cc @gregnazario can u pls restart workflows? thnx 🙏

Copy link

Copilot AI left a 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 OrderlessPayload class to wrap orderless transaction payloads with nonce-based replay protection
  • Adds submit_orderless_transaction method 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.

Comment on lines +561 to +562
orderless = OrderlessPayload(payload.value, nonce)

Copy link

Copilot AI Nov 25, 2025

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).

Suggested change
orderless = OrderlessPayload(payload.value, nonce)

Copilot uses AI. Check for mistakes.


async def example_replay_protection():
"""Example 5: Demonstrating replay protection with same nonce"""
Copy link

Copilot AI Nov 25, 2025

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.

Copilot uses AI. Check for mistakes.
if __name__ == "__main__":
client = RestClient(NODE_URL, client_config=ClientConfig(api_key=API_KEY))
faucet_client = FaucetClient(FAUCET_URL, client)
asyncio.run(main())
Copy link

Copilot AI Nov 25, 2025

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants