mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 02:51:01 +00:00
Changed delivery and dispatch fee computation methods (#795)
* removed weight <-> fee mess * updated documentation Co-authored-by: Hernando Castano <castano.ha@gmail.com>
This commit is contained in:
committed by
Bastian Köcher
parent
f7c3bd4e08
commit
324e083cba
@@ -48,3 +48,6 @@ sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "maste
|
||||
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
sp-trie = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-keyring = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
|
||||
|
||||
@@ -96,7 +96,7 @@ async fn run_init_bridge(command: cli::InitBridge) -> Result<(), String> {
|
||||
move |initialization_data| {
|
||||
Ok(Bytes(
|
||||
Rialto::sign_transaction(
|
||||
&rialto_client,
|
||||
*rialto_client.genesis_hash(),
|
||||
&rialto_sign.signer,
|
||||
rialto_signer_next_index,
|
||||
rialto_runtime::SudoCall::sudo(Box::new(
|
||||
@@ -132,7 +132,7 @@ async fn run_init_bridge(command: cli::InitBridge) -> Result<(), String> {
|
||||
move |initialization_data| {
|
||||
Ok(Bytes(
|
||||
Millau::sign_transaction(
|
||||
&millau_client,
|
||||
*millau_client.genesis_hash(),
|
||||
&millau_sign.signer,
|
||||
millau_signer_next_index,
|
||||
millau_runtime::SudoCall::sudo(Box::new(
|
||||
@@ -266,7 +266,7 @@ async fn run_send_message(command: cli::SendMessage) -> Result<(), String> {
|
||||
);
|
||||
|
||||
let signed_millau_call = Millau::sign_transaction(
|
||||
&millau_client,
|
||||
*millau_client.genesis_hash(),
|
||||
&millau_sign.signer,
|
||||
millau_client
|
||||
.next_account_index(millau_sign.signer.public().clone().into())
|
||||
@@ -322,7 +322,7 @@ async fn run_send_message(command: cli::SendMessage) -> Result<(), String> {
|
||||
);
|
||||
|
||||
let signed_rialto_call = Rialto::sign_transaction(
|
||||
&rialto_client,
|
||||
*rialto_client.genesis_hash(),
|
||||
&rialto_sign.signer,
|
||||
rialto_client
|
||||
.next_account_index(rialto_sign.signer.public().clone().into())
|
||||
@@ -933,4 +933,40 @@ mod tests {
|
||||
);
|
||||
assert!(Rialto::verify_message(&payload).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rialto_tx_extra_bytes_constant_is_correct() {
|
||||
let rialto_call = rialto_runtime::Call::System(rialto_runtime::SystemCall::remark(vec![]));
|
||||
let rialto_tx = Rialto::sign_transaction(
|
||||
Default::default(),
|
||||
&sp_keyring::AccountKeyring::Alice.pair(),
|
||||
0,
|
||||
rialto_call.clone(),
|
||||
);
|
||||
let extra_bytes_in_transaction = rialto_tx.encode().len() - rialto_call.encode().len();
|
||||
assert!(
|
||||
bp_rialto::TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction,
|
||||
"Hardcoded number of extra bytes in Rialto transaction {} is lower than actual value: {}",
|
||||
bp_rialto::TX_EXTRA_BYTES,
|
||||
extra_bytes_in_transaction,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn millau_tx_extra_bytes_constant_is_correct() {
|
||||
let millau_call = millau_runtime::Call::System(millau_runtime::SystemCall::remark(vec![]));
|
||||
let millau_tx = Millau::sign_transaction(
|
||||
Default::default(),
|
||||
&sp_keyring::AccountKeyring::Alice.pair(),
|
||||
0,
|
||||
millau_call.clone(),
|
||||
);
|
||||
let extra_bytes_in_transaction = millau_tx.encode().len() - millau_call.encode().len();
|
||||
assert!(
|
||||
bp_millau::TX_EXTRA_BYTES as usize >= extra_bytes_in_transaction,
|
||||
"Hardcoded number of extra bytes in Millau transaction {} is lower than actual value: {}",
|
||||
bp_millau::TX_EXTRA_BYTES,
|
||||
extra_bytes_in_transaction,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,10 @@ impl SubstrateFinalitySyncPipeline for MillauFinalityToRialto {
|
||||
(),
|
||||
)
|
||||
.into();
|
||||
let transaction = Rialto::sign_transaction(&self.target_client, &self.target_sign.signer, nonce, call);
|
||||
|
||||
let genesis_hash = *self.target_client.genesis_hash();
|
||||
let transaction = Rialto::sign_transaction(genesis_hash, &self.target_sign.signer, nonce, call);
|
||||
|
||||
Ok(transaction)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ impl SubstrateMessageLane for MillauMessagesToRialto {
|
||||
let call: millau_runtime::Call =
|
||||
millau_runtime::MessageLaneCall::receive_messages_delivery_proof(proof, relayers_state).into();
|
||||
let call_weight = call.get_dispatch_info().weight;
|
||||
let transaction = Millau::sign_transaction(&self.source_client, &self.source_sign.signer, nonce, call);
|
||||
let genesis_hash = *self.source_client.genesis_hash();
|
||||
let transaction = Millau::sign_transaction(genesis_hash, &self.source_sign.signer, nonce, call);
|
||||
log::trace!(
|
||||
target: "bridge",
|
||||
"Prepared Rialto -> Millau confirmation transaction. Weight: {}/{}, size: {}/{}",
|
||||
@@ -103,7 +104,8 @@ impl SubstrateMessageLane for MillauMessagesToRialto {
|
||||
)
|
||||
.into();
|
||||
let call_weight = call.get_dispatch_info().weight;
|
||||
let transaction = Rialto::sign_transaction(&self.target_client, &self.target_sign.signer, nonce, call);
|
||||
let genesis_hash = *self.target_client.genesis_hash();
|
||||
let transaction = Rialto::sign_transaction(genesis_hash, &self.target_sign.signer, nonce, call);
|
||||
log::trace!(
|
||||
target: "bridge",
|
||||
"Prepared Millau -> Rialto delivery transaction. Weight: {}/{}, size: {}/{}",
|
||||
|
||||
@@ -49,7 +49,10 @@ impl SubstrateFinalitySyncPipeline for RialtoFinalityToMillau {
|
||||
(),
|
||||
)
|
||||
.into();
|
||||
let transaction = Millau::sign_transaction(&self.target_client, &self.target_sign.signer, nonce, call);
|
||||
|
||||
let genesis_hash = *self.target_client.genesis_hash();
|
||||
let transaction = Millau::sign_transaction(genesis_hash, &self.target_sign.signer, nonce, call);
|
||||
|
||||
Ok(transaction)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,8 @@ impl SubstrateMessageLane for RialtoMessagesToMillau {
|
||||
let call: rialto_runtime::Call =
|
||||
rialto_runtime::MessageLaneCall::receive_messages_delivery_proof(proof, relayers_state).into();
|
||||
let call_weight = call.get_dispatch_info().weight;
|
||||
let transaction = Rialto::sign_transaction(&self.source_client, &self.source_sign.signer, nonce, call);
|
||||
let genesis_hash = *self.source_client.genesis_hash();
|
||||
let transaction = Rialto::sign_transaction(genesis_hash, &self.source_sign.signer, nonce, call);
|
||||
log::trace!(
|
||||
target: "bridge",
|
||||
"Prepared Millau -> Rialto confirmation transaction. Weight: {}/{}, size: {}/{}",
|
||||
@@ -103,7 +104,8 @@ impl SubstrateMessageLane for RialtoMessagesToMillau {
|
||||
)
|
||||
.into();
|
||||
let call_weight = call.get_dispatch_info().weight;
|
||||
let transaction = Millau::sign_transaction(&self.target_client, &self.target_sign.signer, nonce, call);
|
||||
let genesis_hash = *self.target_client.genesis_hash();
|
||||
let transaction = Millau::sign_transaction(genesis_hash, &self.target_sign.signer, nonce, call);
|
||||
log::trace!(
|
||||
target: "bridge",
|
||||
"Prepared Rialto -> Millau delivery transaction. Weight: {}/{}, size: {}/{}",
|
||||
|
||||
Reference in New Issue
Block a user