Skip to content

add support for sending mortal txs#43

Merged
iulianbarbu merged 24 commits into
michalkucharczyk:masterfrom
iulianbarbu:add-support-for-mortal-txs
Jul 10, 2025
Merged

add support for sending mortal txs#43
iulianbarbu merged 24 commits into
michalkucharczyk:masterfrom
iulianbarbu:add-support-for-mortal-txs

Conversation

@iulianbarbu

@iulianbarbu iulianbarbu commented Jun 11, 2025

Copy link
Copy Markdown
Collaborator

This PR takes the mortal flag value passed in CLI and passes it over up to subxt transaction building, where we can configure its tx params to contain the mortality.

Closes #14

Review notes

TODO:

  • test this work by writing a scenario in polkadot-sdk and see how mortal txs work (works after using subxt correctly)
  • look for unit tests that might be implemented in the repo (not that straight forward, useful thing to test is mortal/immortal txs creation, but we have integration tests in polkadot-sdk that covers it)
  • maybe enable support for mixing mortal with immortal txs? (not really needed for now)

Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
@iulianbarbu iulianbarbu self-assigned this Jun 11, 2025
Comment thread bin/main.rs
Comment thread src/cli.rs
Comment thread src/runner.rs Outdated
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Comment thread src/block_monitor.rs Outdated
Comment thread src/execution_log.rs Outdated
Comment thread src/runner.rs
Comment thread src/subxt_transaction.rs Outdated
Comment thread src/transaction.rs Outdated
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Comment thread src/block_monitor.rs Outdated
Comment thread src/block_monitor.rs Outdated
Comment thread src/runner.rs Outdated
Comment thread src/runner.rs Outdated
Comment thread src/scenario.rs
Comment thread src/subxt_transaction.rs Outdated
Comment thread src/subxt_transaction.rs Outdated
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Comment thread src/runner.rs Outdated
Comment thread src/block_monitor.rs Outdated
Comment thread src/error.rs Outdated
Comment thread src/subxt_transaction.rs Outdated
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Comment thread src/block_monitor.rs Outdated
Comment thread src/subxt_transaction.rs
Comment thread src/subxt_transaction.rs Outdated
Comment on lines +566 to +578
let block_ref = sink
.api()
.backend()
.latest_finalized_block_ref()
.await
.expect("to get the last finalized block ref. qed");
let block = sink
.api()
.blocks()
.at(block_ref)
.await
.expect("to get the corresponding block header. qed");
let block_number = block.number().into();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deserves some comment, as it is tricky and the logic is aligned with subxt:
https://github.com/paritytech/subxt/blob/77b6abccbacf194f3889610024e2f4024e8c2822/subxt/src/tx/tx_client.rs#L600

Would be nice to see a reference to inject_account_nonce_and_block function.

I think that it also allows for some little race condition - if some block is finalized in meantime. But don't see a better way to implement it now. Maybe we could ask subxt if they could expose actual blocks in Params/DefaultExtrinsicParams somehow?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it also allows for some little race condition - if some block is finalized in meantime. But don't see a better way to implement it now.

Yes, but thought that even if a new finalized block happens in the meantime, that means will wait just a little longer with the block monitor for the transaction to be finalized (which is not that bad I think).

Would be nice to see a reference to inject_account_nonce_and_block function.

Done here: 2df3030

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could ask subxt if they could expose actual blocks in Params/DefaultExtrinsicParams somehow?

Yes, to be 100% accurate with this. I'll file a question.

@iulianbarbu iulianbarbu Jul 10, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am reconsidering this a bit. I think we'll need either way some online capability to fetch last finalized block. Can leave this unresolved for now until we'll tackle #44 . We should do some preliminary research then about options before asking for things.

Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>

@michalkucharczyk michalkucharczyk left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have issue to follow-up with work done in
paritytech/subxt#2025
?

The code could be simplified, right? We would not need the online client probably?

Left two more comments, once addressed we could merge it.

Comment thread src/block_monitor.rs Outdated
Comment thread src/execution_log.rs
Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com>
@iulianbarbu

Copy link
Copy Markdown
Collaborator Author

Do we have issue to follow-up with work done in paritytech/subxt#2025 ?

Yes, here: #44

Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
@iulianbarbu iulianbarbu merged commit 76381c9 into michalkucharczyk:master Jul 10, 2025
1 check passed
github-merge-queue Bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request Nov 18, 2025
# Description

Based on michalkucharczyk/tx-test-tool#43.

## Integration

N/A

## Review Notes

- added tests with future mortal txs that are dropped due to not being
included in blocks within their lifetime, but also future mortal txs
that have a sufficient lifetime to be included in blocks
- added test which uses priorities to delay mortal txs inclusion and
make them invalid

---------

Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sebastian Kunert <mail@skunert.dev>
github-merge-queue Bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request Nov 18, 2025
# Description

Based on michalkucharczyk/tx-test-tool#43.

## Integration

N/A

## Review Notes

- added tests with future mortal txs that are dropped due to not being
included in blocks within their lifetime, but also future mortal txs
that have a sufficient lifetime to be included in blocks
- added test which uses priorities to delay mortal txs inclusion and
make them invalid

---------

Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sebastian Kunert <mail@skunert.dev>
github-merge-queue Bot pushed a commit to paritytech/polkadot-sdk that referenced this pull request Nov 19, 2025
# Description

Based on michalkucharczyk/tx-test-tool#43.

## Integration

N/A

## Review Notes

- added tests with future mortal txs that are dropped due to not being
included in blocks within their lifetime, but also future mortal txs
that have a sufficient lifetime to be included in blocks
- added test which uses priorities to delay mortal txs inclusion and
make them invalid

---------

Signed-off-by: Iulian Barbu <iulian.barbu@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sebastian Kunert <mail@skunert.dev>
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.

Support for mortal transactions

2 participants