Skip to content
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

Change submit transaction spec_version and transaction_version query from chain #1248

Merged
merged 19 commits into from
Dec 16, 2021

Conversation

fewensa
Copy link
Contributor

@fewensa fewensa commented Dec 10, 2021

After doing this, we don’t need to upgrade bridger after a chain runtime is upgraded.

@svyatonik
Copy link
Contributor

But it also means that if something changes in the bridge pallets (or in some other involved pallets) the relayer will keep creating old transactions, which may have different meaning in new spec_version or even different SCALE format in new transaction_version. In worst case relayer will keep submitting invalid transactions. which may even lead to funds loss if they are accepted to the pool. So in my opinion the this step requires manual approval => we even have spec_version guards (which abort relay process) enabled for some bridges. WDYT about it?

If you still need this patch, then I suggest to make it optional - e.g. probably change TransactionSignScheme trait to accept Client<Self::Chain> and read all required fields in this implementation for your chain. Alternatively - you may consider adding some CLI options for that.

@fewensa fewensa marked this pull request as draft December 13, 2021 09:35
@fewensa
Copy link
Contributor Author

fewensa commented Dec 14, 2021

I think sign_transaction accept Client<Self::Chain> isn't a good way.

for example.

/// Update Polkadot -> Kusama conversion rate, stored in Kusama runtime storage.
pub(crate) async fn update_polkadot_to_kusama_conversion_rate(
client: Client<Kusama>,
signer: <Kusama as TransactionSignScheme>::AccountKeyPair,
updated_rate: f64,
) -> anyhow::Result<()> {
let genesis_hash = *client.genesis_hash();
let signer_id = (*signer.public().as_array_ref()).into();
client
.submit_signed_extrinsic(signer_id, move |_, transaction_nonce| {
Bytes(
Kusama::sign_transaction(
genesis_hash,
&signer,
relay_substrate_client::TransactionEra::immortal(),
UnsignedTransaction::new(
relay_kusama_client::runtime::Call::BridgePolkadotMessages(
relay_kusama_client::runtime::BridgePolkadotMessagesCall::update_pallet_parameter(
relay_kusama_client::runtime::BridgePolkadotMessagesParameter::PolkadotToKusamaConversionRate(
sp_runtime::FixedU128::from_float(updated_rate),
)
)
),
transaction_nonce,
),
)
.encode(),
)
})
.await
.map(drop)
.map_err(|err| anyhow::format_err!("{:?}", err))
}

the client can not move to prepare_extrinsic function. because it used by client.submit_signed_extrinsic we need clone this.

I think keeping the current code is better. but your suggestions are good. So I want add

#[derive(Clone, Debug)]
pub enum ChainRuntimeVersion {
	Auto,
	Custom(u32, u32),
	Bundle,
}

into relay_substrate_client::Client

But i won't let sign_transaction accept Client<Self::Chain>. many things will be changed. like sign_transaction must be change to async function and submit_signed_extrinsic must accept async prepare_extrinsic function.
What do you think?

@svyatonik
Copy link
Contributor

Client is lightweight + cloneable, so it shouldn't be a big problem. But the second option is ok to me too if it seems easier to you :)

@fewensa
Copy link
Contributor Author

fewensa commented Dec 14, 2021

Yes. I think the second option is easy to use. if not we need change

prepare_extrinsic: impl FnOnce(HeaderIdOf<C>, C::Index) -> Bytes + Send + 'static,

to

prepare_extrinsic: impl FnOnce(HeaderIdOf<C>, C::Index) -> BoxFuture<relay_substrate_client::Result<Bytes>> + Send + 'static,

This is difficult to modify, and there are many changes.

Comment on lines 86 to 89
const RELAY_CHAIN_SPEC_VERSION: u32 = rialto_runtime::VERSION.spec_version;
const RELAY_CHAIN_TRANSACTION_VERSION: u32 = rialto_runtime::VERSION.spec_version;
const PARA_CHAIN_SPEC_VERSION: u32 = rialto_runtime::VERSION.spec_version;
const PARA_CHAIN_TRANSACTION_VERSION: u32 = rialto_runtime::VERSION.spec_version;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure it is correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you, please, use rialto_parachain_runtime::VERSION.spec_version here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It fixed here 91c9d51 please check it

@fewensa fewensa marked this pull request as ready for review December 15, 2021 03:50
@fewensa
Copy link
Contributor Author

fewensa commented Dec 15, 2021

I'm not found what reason about ci error for continuous-integration/gitlab-spellcheck

@svyatonik
Copy link
Contributor

I'm not found what reason about ci error for continuous-integration/gitlab-spellcheck

Here's my local output:

Output
error: spellcheck(Hunspell)
    --> /home/svyatonik/dev/parity-bridges-common/relays/bin-substrate/src/cli/mod.rs:375
     |
 375 |  Custom spec_version and transaction_version
     |         ^^^^^^^^^^^^
     | - perversion or interspersion
     |
     |   Possible spelling mistake found.

error: spellcheck(Hunspell)
    --> /home/svyatonik/dev/parity-bridges-common/relays/bin-substrate/src/cli/mod.rs:375
     |
 375 |  Custom spec_version and transaction_version
     |                          ^^^^^^^^^^^^^^^^^^^
     | - transubstantiation
     |
     |   Possible spelling mistake found.

error: spellcheck(Hunspell)
    --> /home/svyatonik/dev/parity-bridges-common/relays/bin-substrate/src/cli/mod.rs:410
     |
 410 | The custom sepc_version for chain 
     |            ^^^^^^^^^^^^
     | - perversion
     |
     |   Possible spelling mistake found.

error: spellcheck(Hunspell)
    --> /home/svyatonik/dev/parity-bridges-common/relays/bin-substrate/src/cli/mod.rs:413
     |
 413 | The custom transaction_version for chain 
     |            ^^^^^^^^^^^^^^^^^^^
     | - transubstantiation
     |
     |   Possible spelling mistake found.

[2021-12-15T07:20:45Z INFO  cargo_spellcheck::action] ❌ /home/svyatonik/dev/parity-bridges-common/relays/bin-substrate/src/cli/mod.rs : 4
error: spellcheck(Hunspell)
   --> /home/svyatonik/dev/parity-bridges-common/relays/client-substrate/src/client.rs:69
    |
 69 |  the first is spec_version
    |               ^^^^^^^^^^^^
    | - perversion or interspersion
    |
    |   Possible spelling mistake found.

error: spellcheck(Hunspell)
   --> /home/svyatonik/dev/parity-bridges-common/relays/client-substrate/src/client.rs:70
    |
 70 |  the second is transaction_version
    |                ^^^^^^^^^^^^^^^^^^^
    | - transubstantiation
    |
    |   Possible spelling mistake found.

The idea is that (apart of sepc_verstion typo) all variable/function names should be enclosed in backquoutes.

We'll definitely need to do something with spellcheck logs at CI - I'll create an issue for that.

Copy link
Contributor

@svyatonik svyatonik left a comment

Choose a reason for hiding this comment

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

Looks good. Left couple of suggestions + spellckech fix is required

relays/client-substrate/src/client.rs Outdated Show resolved Hide resolved
@@ -500,11 +531,32 @@ macro_rules! declare_chain_options {
/// Convert connection params into Substrate client.
pub async fn to_client<Chain: CliChain>(
&self,
bundle_spec_version: u32,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we replace these two parameters with Option<RuntimeVersion> here? Option because for some chains (where we won't submit any transaction) the version may be unknown (so it shall be treated as ChainRuntimeVersion::Auto). And using RuntimeVersion would allow us replace four consts with two, where to_client() is called. We'll probably move VERSION constants to Chain trait later => remove these consts at all.

Copy link
Contributor

Choose a reason for hiding this comment

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

Last q - is there any specific reason you have decided to use two Option<u32>arguments instead of single Option<RuntimeVersion> as I've suggested here? If not, we'll change this in near future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I missing here. Let me think about it. Your suggestions are better. I can change it. Please wait.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fewensa
Copy link
Contributor Author

fewensa commented Dec 16, 2021

Done

@fewensa
Copy link
Contributor Author

fewensa commented Dec 16, 2021

I'm not sure what happened in CI

  --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rsix-0.23.9/src/imp/linux_raw/arch/inline/x86_64.rs:73:5
   |
73 |     asm!(
   |     ^^^
   |
   = note: consider importing one of these items:
           std::arch::asm
           core::arch::asm
error: cannot find macro `asm` in this scope

It's ok for my local computer

@svyatonik
Copy link
Contributor

svyatonik commented Dec 16, 2021

I'm not sure what happened in CI

  --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/rsix-0.23.9/src/imp/linux_raw/arch/inline/x86_64.rs:73:5
   |
73 |     asm!(
   |     ^^^
   |
   = note: consider importing one of these items:
           std::arch::asm
           core::arch::asm
error: cannot find macro `asm` in this scope

It's ok for my local computer

Should be something with todays nightly. Will look today

UPD: #1255

@svyatonik
Copy link
Contributor

CI issue should be fixed now. Could you, please, push some dummy commit (e.g. some change + immediate git revert) to restart CI (i have no rights for that :) ). There's also question from my side && it could be merged then

@fewensa fewensa marked this pull request as draft December 16, 2021 11:11
@fewensa fewensa marked this pull request as ready for review December 16, 2021 12:36
Copy link
Contributor

@svyatonik svyatonik left a comment

Choose a reason for hiding this comment

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

Perfect, thank you!

@svyatonik svyatonik enabled auto-merge (squash) December 16, 2021 12:49
@svyatonik svyatonik merged commit edfcb74 into paritytech:master Dec 16, 2021
@fewensa fewensa deleted the realtime-version branch December 16, 2021 13:00
acatangiu added a commit that referenced this pull request Dec 23, 2021
* Add `AtLeast32BitUnsigned` for MessageLance::SourceChainBalance (#1207)

* Fix UI deployment. (#1211)

* Remove unused PoA<>Substrate bridge (#1210)

* Decouple the PoA bridge code from Rialto
* Remove Rialto PoA bridge code
* Remove relays/bin-ethereum code
* Remove relays/client-ethereum code
* Remove modules/ethereum code
* Remove modules/ethereum-contract-builtin code
* Remove PoA bridge documentation
* Remove primitives/ethereum-poa code
* Decouple Rialto from currency-exchange
* Fix building with runtime-benchmarks
* Fix should_encode_bridge_send_message_call test
    Because we removed some runtime modules/pallets, the
    substrate2substrate bridge pallet has a different index within
    the runtime so its calls have a different encoding.
    Update the test to use the new encoding.
* Update readme - no more PoA bridge
* Remove deployments/bridges/poa-rialto
    Also removes:
    - deployments/networks/eth-poa.yml
    - deployments/networks/OpenEthereum.Dockerfile
* Remove deployments/dev/poa-config
* Update deployments readme - no more PoA bridge
* Remove eth-related scripts
    Deletes:
    - deployments/networks/eth-poa.yml
    - scripts/run-openethereum-node.sh
* Remove poa-relay from gitlab-ci
* Dockerfiles to use substrate-relay as default
* Remove modules/currency-exchange code
* Remove primitives/currency-exchange code

Signed-off-by: acatangiu <adrian@parity.io>

* Remove unused `relays/headers` (#1216)

* Decouple `relays/client-substrate` from `headers_relay`
* Remove `blocks_in_state` from `SyncLoopMetrics`
    This metric was only relevant for PoA <> Substrate bridge.
* Move `sync_loop_metrics.rs` to `relays/finality`
* Remove unused `SyncLoopMetrics::update()`
* Hook up SyncLoopMetrics to finality_loop
* Delete now unused `relays/headers`

Signed-off-by: acatangiu <adrian@parity.io>

* remove abandoned exchange relay (#1217)

* Unify metric names (#1209)

* unify metric names

* refactor standalone metrics

* headers sync metrics

* post-merge fix

* fix compilation

* fmt

* fix dashboards

* fix local dashboards

* update Rococo/Wococo runtime version

* remove commented code

* fixed grumbles

* fmt

* fixed widget names

* Add CODEOWNERS file (#1219)

* fixed set_operational in GRANDPA pallet (#1226)

* Add mut support (#1232)

* update dependencies (#1229)

* Integrate BEEFY with Rialto & Millau runtimes (#1227)

* Add Beefy pallet to Rialto runtime

* Add Beefy gadget to Rialto node

* Add MMR pallet to Rialto runtime

* Add Beefy pallet to Millau runtime

* Add Beefy gadget to Millau node

* Add MMR pallet to Millau runtime

* Add pallet_beefy_mmr to Millau runtime

* Add pallet_beefy_mmr to Rialto runtime

* Implement MMR and BEEFY APIs in Rialto

* fix unit tests

- should_encode_bridge_send_message_call() tests for new
  runtime encoding resulted from newly added pallets.
- runtime size_of::<Call>() slightly increased from newly
  added pallets.

* fix grumbles

* tighten clippy allowances

* fix more grumbles

* Add MMR RPC to Rialto and Millau nodes

Also implement MmrApi in Millau runtime.

* rialto: use upstream polkadot_client::RuntimeApiCollection

* Fix storage parameter name computation (#1238)

* fixed storage_parameter_key

* added test for storage_parameter_key

* Enable Beefy debug logs in test deployment (#1237)

Signed-off-by: Adrian Catangiu <adrian@parity.io>

* Enable offchain indexing for Rialto/Millau nodes (#1239)

* Enable off-chain indexing for Rialto & Millau nodes

* cargo fmt --all

* cargo +nightly fmt --all

* fmt is weird.

* Update Rococo/Wococo version + prepare relay for Rococo<>Wococo bridge (#1241)

* update Rococo version + create relayers fund account

* start finality relay guards when complex relay is started

* Refactor finality relay helpers (#1220)

* refactor finality relay helper definitions

* add missing doc

* removed commented code

* fmt

* disable rustfmt for macro

* move best_finalized method const to relay chain def

* Expose prometheus BEEFY metrics and add them to grafana dashboard (#1242)

* deployments: expose node metrics

Signed-off-by: acatangiu <adrian@parity.io>

* deployments: add beefy grafana dashboard

Signed-off-by: acatangiu <adrian@parity.io>

* deployments: add beefy alarms

Signed-off-by: acatangiu <adrian@parity.io>

* Fix transactions mortality (#1196)

* added lost stall timeout fix

* use best_block.parent() to start mortal tx era

* fmt

* Revert "revert messages transactions mortality"

This reverts commit 7777635.

* post-merge build fix (#1243)

* Refactor message relay helpers (#1234)

* refactor message relay helpers

* single standalone_metrics function

* fixed tests

* clippy + fmt

* removed commented code

* add calls tracing

* fix spelling

* cargo fmt

* -commented code

* fix build again

* post-merge build fix

* clippy + fmt

* Use same endowed accounts set on dev/local chains (#1244)

* use same accounts set on dev/local chains

* run altruistic relayers in local demo scripts

* runtimes: fix call_size() test (#1245)

Signed-off-by: acatangiu <adrian@parity.io>

* Bump relay version to 1.0.0 (#1249)

* Add missing RPC APIs to rialto parachain node (#1250)

* add missing RPC APIs to rialto parachain node

* spellcheck

* decrease startup sleep to 5s for relays and to 120s for generators + remove curl (#1251)

* pin bridges-ci image (#1256)

* Change submit transaction spec_version and transaction_version query from chain (#1248)

* The `spec_version` and `transaction_version` query from chain

* fix compile

* Lint

* Custom spec_version and transaction_version

* runtime version params struct opt

* runtime version cli

* cli params

* Add missing types defined

* fix compile

* debug cli

* clippy

* clippy

* Query spec_version and transaction_version same times

* Fix vars

* Wrap option

* Wrap option

* Try fix ci

* Change follow suggestions

* remporary use pinned bridges-ci image in Dockerfile (#1258)

* move storage keys computation to primitivs (#1254)

* override conversion rate in estimate-message-fee RPC (#1189)

* read latest_generated_nonce directly from storage (#1260)

* bump rococo version (#1263)

Co-authored-by: fewensa <37804932+fewensa@users.noreply.github.com>
Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Adrian Catangiu <31917973+acatangiu@users.noreply.github.com>
Co-authored-by: Sergejs Kostjucenko <85877331+sergejparity@users.noreply.github.com>
Co-authored-by: Antonio Dropulic <antonio@parity.io>
Co-authored-by: Adrian Catangiu <adrian@parity.io>
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Mar 27, 2024
…from chain (paritytech#1248)

* The `spec_version` and `transaction_version` query from chain

* fix compile

* Lint

* Custom spec_version and transaction_version

* runtime version params struct opt

* runtime version cli

* cli params

* Add missing types defined

* fix compile

* debug cli

* clippy

* clippy

* Query spec_version and transaction_version same times

* Fix vars

* Wrap option

* Wrap option

* Try fix ci

* Change follow suggestions
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Apr 8, 2024
…from chain (paritytech#1248)

* The `spec_version` and `transaction_version` query from chain

* fix compile

* Lint

* Custom spec_version and transaction_version

* runtime version params struct opt

* runtime version cli

* cli params

* Add missing types defined

* fix compile

* debug cli

* clippy

* clippy

* Query spec_version and transaction_version same times

* Fix vars

* Wrap option

* Wrap option

* Try fix ci

* Change follow suggestions
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