Commit Graph

31 Commits

Author SHA1 Message Date
Svyatoslav Nikolsky 8e8e89511f Message lane weight formulas (#596)
* weight formulas for message-lane calls

* extracted WeightInfoExt into separate file
2024-04-10 10:28:37 +02:00
Hernando Castano a6c3de51d3 Fixes for Polkadot Integration (#586)
* Add AccountIdConverter impl to Kusama and Polkadot primitives

* Add missing message lane config constants

* Add more consts

* Add another missing const

* Move consts in primitives so that they're consistent across files

* Move types and consts to more intuitive locations

* Downgrade hyper from v0.13.8 to v0.13.6

This conflicts with a requirement on the Polkadot side
which requires that hyper is =v0.13.6

* Update hyper to v0.13.9

* Update async-io to v1.3.1

* Update socket2 from v0.3.15 to v0.3.18

* Update message weight/size constants

* Make BlockWeights/Length parameter types

Allows us to re-use these types from both the runtime and
the message lane config files without creating a new instance
of them.

* Remove uneccesary weight constants

These can be found in the `runtime-common` crate used
by Polkadot/Kusama. The constants there will also be
the most up-to-date versions.
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky e5f6e309a6 Automated weights for message lane module (#590)
* automated weights

* associated WeightInfo type

* update weights using wasmtime

* disable clippy for autogenerated weight.rs

* fix
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 9deea5d251 Benchmark for message delivery confirmation transaction (#570)
* receive_delivery_proof benchmarks

* fix compilation

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 63e2655c8b Add messages count parameter to delivery transaction (#581)
* add messages count parameter to delivery transaction

* fix benchmarks compilation
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 6317a31e25 Benchmarks for message delivery transaction (#567)
* benchmarks for pallet_message_lane::receive_messages_proof

* use CallOrigin::TargetAccount (worst case of CallOrigin)

* fmt

* closures

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update modules/message-lane/src/benchmarking.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* fix compilation

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Hernando Castano ee655b1057 Update Substrate Dependency (#566)
* Update `sp-io` dependency

* Rename Trait to Config

* RustFmt

* Bump `sp-io` again

* Use new frame_system weight types in Rialto and Millau runtimes

* Update test Runtimes to use new weight types

* Bump `sp-io` again

* Update to not-the latest first.

* Update benchmarks.

* Another Trai.

* Move new weight types into runtime primitive crates

This allows us to check limits for extrinsics from other parts
of the codebase without pulling in the entire chain runtime.

* Remove leftover comments

* Move new functions to a better location

* Small formatting fixes

* Add actual documentation to new weight config types

* Decrease maximum block weight of Millau chain

* Decreease maximum block length of Millau chain

Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 8a5b51a944 Limit size of message delivery transaction (#575)
* limit messages size in delivery transaction

* docs
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 2a0f7c7d17 fix send_message_worst_case (#571) 2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky f57b7e9de0 Message lane benchmarks: start (#554)
* message lane benchmarks: start

* finish send_message_worst_case benchmark

* fix compilation

* removed redundant bench param
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 2944f997d1 Limit max number of unconfirmed messages at inbound lane (#545)
* limit maximal number of unconfirmed messages at inbound lane

* unrewarded_relayer_entries API

* change relay to support max unrewarded relayer entries

* Update modules/message-lane/src/inbound_lane.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Update relays/messages-relay/src/message_lane_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* removed pub

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 81a3e7cce3 reject too large (by size) messages (#551) 2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky f1949c6342 Limit max number of messages in delivery transaction (#541)
* limit max number of messages in delivery tx

* support max-messages-in-delivery-tx in relayer

* clippy

* clippy

* Update modules/message-lane/src/lib.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Hernando Castano 951aa36c2b Add Derived Account Origins to Dispatcher (#519)
* Update some docs

* Add derived account origin

* Add tests for derived origin

* Do a little bit of cleanup

* Change Origin type to use AccountIds instead of Public keys

* Update (most) tests to use new Origin types

* Remove redundant test

* Update `runtime-common` tests to use new Origin types

* Remove unused import

* Fix documentation around origin verification

* Update config types to use AccountIds in runtime

* Update Origin type used in message relay

* Use correct type when verifying message origin

* Make CallOrigin docs more consistent

* Use AccountIds instead of Public keys in Runtime types

* Introduce trait for converting AccountIds

* Bring back standalone function for deriving account IDs

* Remove AccountIdConverter configuration trait

* Remove old bridge_account_id derivation function

* Handle target ID decoding errors more gracefully

* Update message-lane to use new AccountId derivation

* Update merged code to use new Origin types

* Use explicit conversion between H256 and AccountIds

* Make relayer fund account a config option in `message-lane` pallet

* Add note about deriving the same account on different chains

* Fix test weight

* Use AccountId instead of Public key when signing Calls

* Semi-hardcode relayer fund address into Message Lane pallet
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky dd7242bc79 Migrate back to Substrate master (#528)
* migrate back to Substrate master

* fmt

* clippy
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 53791a1d4a Chain specific message lane apis (#503)
* replace generic message lane APIs with chain-specific

* moved SubstrateHeadersSyncPipeline to headers_pipeline.rs

* substrate-specific message lane trait

* Update relays/substrate/src/messages_lane.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 6dc267393a Use different chain primitives in Millau (#517) 2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 23f5f3cdd6 Limit messages weight in batch (#496)
* limit messages in the batch by weight/count

* fixed components compilation

* reverted obsolete parts of #469

* implement generated_messages_weights

* actually use computed weight in message proof

* fmt and clippy

* fixed TODO

* clippy

* Update relays/messages-relay/src/message_race_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* add issue reference

* add assert message

* grumbles

* fmt

* reexport weight from bp-message-lane

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Hernando Castano <castano.ha@gmail.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 0e6d2b8913 Removed unused file (#498)
* removed unused file

* another unused file
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 0c38193af7 Relay subcommands to initialize substrate bridge pallet (#483)
* initialize substrate bridge from relay

* is_halted: false

* initialize using su instead of owner

* Fix wording in comments

Co-authored-by: Hernando Castano <castano.ha@gmail.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky d4fc7bebdc Millau -> Rialto messages relay (#399)
* Millau messages -> Rialto relay

* prepare for custom race strategy of delivery race

* custom strategy for delivery race

* update TODOs

* add reference to issue 457

* impl reconnect

* clippy

* fix check in test

* fmt

* removed obsolete TODO

* fixed another TODOs

* fmt

* use MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE const from primitives

* Update relays/messages-relay/src/message_lane_loop.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* added SubstrateMessagesProof typedef

* fix test

* removed comment

* additional_proof_required -> ProofParameters

* typo

* multiline literal

* clippy

* fix typo

* and_then -> await

* update_source_latest_confirmed_nonce

* Update relays/messages-relay/src/message_race_delivery.rs

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky ef9357596f Return cumulative dispatch weight of messages from the messageLane_proveMessages (#469)
* implement OutboundLaneApi and InboundLaneApi for Millau /Rialto runtimes

* fixed typo
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky b99fa90edd SubmitMillauToRialtoMessage subcommand in substrate-relay (#460)
* substrate-relay::SubmitMillauToRialtoMessage

* typo

* Update relays/substrate/src/cli.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Hernando Castano a6048bca59 Support Tracking Forks in Substrate Pallet (#409)
* Support multiple "best headers" from different forks

* Update the name of a test

* Add note about multiple scheduled changes

* Disallow multiple scheduled authority set changes

* Return multiple best headers from Runtime APIs

* Remove invalid test write-up

* Add some sketch-ups of test scenarios

* Clean up test scenarios

* Add module for testing forks

* Write headers to storage

* Add way to check expected outcome for header imports

* Add support for importing finality proofs

* Support importing headers which schedule changes

* Write out test scenario using new framework

* Map authority set changes across forks

Gets all the tests in the `forks` module passing

* Remove basic tests

These were used when working on the initial test helper

* Prevent multiple pending set changes on the same fork

* Remove old test which allowed imports past unfinalized header

* Ignore failing test (for now)

* Rewrite `if` comparison using `match` and `cmp`

Fixes Clippy warning: `comparison_chain`

* Add helper for writing test headers with default characteristics

* Fix test that checked authority set updates

* Make note about importing headers on different unfinalized fork

* Perform some cleanup on the fork module

* Fix Clippy complaints

* Provide list of unfinalized headers to Runtime APIs

* Add proofs to expect() calls

* Make tests the focus of the forks module

* Allow specific errors to be checked in fork tests

* Remove unused method

* Replace unreachable() statement with expect()

* Rename storage `unfinalized_headers() `to make its purpose more clear

* Update Runtime API name in relayer to match pallet

* Commit `unfinalized_headers` changes I forgot to add

* Rename ChainTipHeight to BestHeight

* Make schedule_next_set_change require a mutable reference

* Remove check for key when enacting authority set

We only expect to take the happy-path in the pallet anyways, so this check
to save ourselves the time spent decoding the entry isn't really used.

* Clear justification set when writing headers to storage

* Clarify why we only allow one set change per fork

* Change best_headers() to return HeaderIDs

Prevents us from returning full headers (which are more expensive to
get from storage) since we only care about header IDs (number, hash)
anyways.

* Fix Clippy complaint

* Make note about equivocations

* Use HeaderIds when returning incomplete headers

This change stops returning full headers which are more expensive
to get from storage than header Ids (number, hash) are. Clients likely
don't need the full header anyways which is why this change is fine.

* Introduce HeaderId type to reduce type complexity

* Add signal hash to storage during genesis config

* Return error instead of expect()-ing

* Fix Clippy lint about `ok_or` fn call

* Rename `forks` module to indicate that it's for testing

* Use `const` for `expect()` proofs

* Remove check that key exists before `kill`-ing value

Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky e2d9b6393d Integrate Rialto <-> Millau message lanes into Millau/Rialto runtimes (#386)
* millau -> rialto lanes integration

* extrace common message-lane integration types into bridge-runtime-common

* rialto_messages.rs in Millau runtime

* tests

* Update bin/rialto/runtime/src/millau_messages.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* RELAYER_INTEREST_PERCENT -> RELAYER_FEE_PERCENT

* Update bin/runtime-common/src/messages.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* estimate_message_dispatch_and_delivery_fee returns Result

* Update bin/rialto/runtime/src/millau_messages.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update bin/rialto/runtime/src/millau_messages.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* Update bin/rialto/runtime/src/millau_messages.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* fmt

* mowed weight formula to primitives

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 7a03b709be Millau -> Rialto headers relay (#398)
* working-millau-to-rialto-relay

* fix Millau state root

* properly fix synced+incomplete headers for sub2sub

* removed wrong TODO

* fmt + clippy

* Update relays/headers-relay/src/headers.rs

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>

* moved SubstrateTransactionMaker definition

* removed M from phantomdata

* removed prune_synced_children

* methods names as consts

Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Andreas Doerr ede0ff8656 Add ChainTime associated type (#410)
* add HeaderTimestamp associated type

* use Header Timestamp

* rename HeaderTimestamp to ChainTime

* add unit test

* deal with clippy

* Apply suggestions from code review

Commit review suggestions

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* code review

* cargo fmt

* get rid of additional test runtime

* unit test asserts against concrete import context

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
2024-04-10 10:28:37 +02:00
Hernando Castano f52c839d6e Add GenesisConfig for Millau and Rialto Runtimes (#401)
* Add Rialto as a target for the Millau node

* Rename Rialto module to Rialto-PoA

This will reduce confusion as the Millau runtime has a
Rialto module as well which refers to the Substrate chain.

* Add Millau as a target for the Rialto node

* Be more explicit about Rialto PoA related code

* Missed some name changes in the Ethereum PoA relay

* Re-export Substrate pallet structs used by node

* Remove `first_scheduled_change` of Millau in Rialto node

* Make Millau's genesis config for Rialto bridge more accurate

* Set initial header for Millau config

* Update initial Millau authorities

Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>

* RustFmt Millau authorities

Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
2024-04-10 10:28:37 +02:00
Svyatoslav Nikolsky 9e9ac8df3c Move Chain trait to runtime primitives (#403)
* extract ChainBase to bp-runtime

* post-merge fixes

* cargo fmt --all

* compilation fixes

* reexport BlockNumberOf, HashOf, HeaderOf
2024-04-10 10:28:37 +02:00
Hernando Castano 86834e2fd6 Implement Substrate Pallet Runtime APIs (#389)
* Implement public helpers for querying header info

* Update `best_header` when importing headers

* Add BestHeader to GenesisConfig

* Define extra types for Millau primitives

* Start implementing runtime APIs in Millau runtime

* Add helper for getting headers which require a justification

* Add runtime API for getting headers requiring a justification

* Reword `expect()` proof for valid authority sets

* Fix typo

* Clean up Hasher comment

* Add the Call Dispatch Pallet back to the Millau runtime

* Use types from Rialto in bridge pallet config

* Use the Rialto runtime APIS in the Millau runtime

* Include Millau bridge instance in Rialto runtime

* Add missing doc comment

* Use one storage function for setting and clearing `RequiresJustification`

* Remove TODO comments
2024-04-10 10:28:37 +02:00
Hernando Castano 8b8248f83f Split Rialto and Millau Nodes (#372)
* Split the Rialto Node into a standalone crate

* Split the Millau Node into a standalone crate

* Remove `bridge-node` crate

* Add benchmarking feature to nodes

* Check that benchmarks compile in CI

* Remove nodes from CI matrix

* Update Rialto node to Substrate 2.0

* Get Millau node compiling with Substrate 2.0

* Remove extra license text

* Remove comments in TOML files

* Move nodes and runtimes into Rialto and Millau folders

* Fix dependency paths

* Remove unused script

* Add issue to benchmarking TODO

* Fix benchmark manifest paths
2024-04-10 10:28:37 +02:00