unstable_rpc: Add transactionBroadcast and transactionStop#1497
unstable_rpc: Add transactionBroadcast and transactionStop#1497
Conversation
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
| let block_extrinsics = extrinsics | ||
| .iter() | ||
| .map(|res| res.unwrap()) | ||
| .collect::<Vec<_>>(); | ||
|
|
||
| // All blocks must contain the timestamp, we expect the next extrinsics to be our own. | ||
| let Some(tx) = block_extrinsics.get(1) else { | ||
| continue; | ||
| }; |
There was a problem hiding this comment.
Nit: this is all good, but if we wanted we could do something like this to avoid relying on any sort of ordering etc:
let tx_hash = SubstrateConfig::Hashing::hash_of(tx_bytes);
// ...
let Some(ext) = extrinsics
.iter()
.find(|e| SubstrateConfig::Hashing::hash_of(e.bytes()) == tx_hash)
.next() else { continue };
let ext = ext.as_extrinsic::<node_runtime::balances::calls::types::TransferAllowDeath>()
.unwrap()
.unwrap();
// ...There was a problem hiding this comment.
There is just a small inconsistency with this:
- create_signed_offline returns the extrinsic bytes including the prefix of
compact encoding length ExtrinsicDetailswill strip the compact prefix:
subxt/subxt/src/blocks/extrinsic_types.rs
Line 224 in a211e98
I've adjusted the code to reflect this, not sure if we should do anything else to align for ex with polkadot-api 🤔
| /// | ||
| /// Returns an operation ID that can be used to stop the broadcasting process. | ||
| /// Returns `None` if the server cannot handle the request at the moment. | ||
| pub async fn transaction_unstable_broadcast(&self, tx: &[u8]) -> Result<Option<String>, Error> { |
There was a problem hiding this comment.
Has the PR to rename to v1 merged in Substrate already? :)
There was a problem hiding this comment.
There was a problem hiding this comment.
A couple of minor things but yay for more RPCs :)
When this merges we can also move our TX submitting to use this method and thus be "reconnect" safe at some point which will be nice (though much more complicated, because aside from searching blocks for the TX we need to periodically validate it to know whether to stop checking for it etc).
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This PR adds the
transaction_unstable_broadcastandtransaction_unstable_stopAPIs.While at it, added a test to check that the broadcasted transaction gets into a finalized block.