1. Aug 02, 2023
    • drskalman's avatar
      Support for multiple signature scheme for BEEFY primitves (#14373) · 3fef703e
      drskalman authored
      
      
      * Merged BEEFY primitives with generic signature and keyset commitment support from old pull to current code
      
      * - Add bls-experimental feature to application-crypto and beefy primitives
      - Fix remaining crypto -> ecdsa_crypto
      - code build but not tests
      
      * Make beefy primitive tests compile
      
      * move bls related beefy primitives code and test behind bls-experimental flag
      
      * Make BEEFY clients complies with BEEFY API depending on AuthorityId
      
      * - Rename `BeefyAuthoritySet.root` → `BeefyAuthoritySet.keyset_commitment`.
      - Remove apk proof keyset_commitment from `BeefyAuthoritySet`.
      - Fix failing signed commitment and signature to witness test.
      - Make client compatible with BeefyAPI generic on AuthorityId.
      - `crypto` → `ecdsa_crypto` in BEEFY client and frame.
      
      * Commit Cargo lock remove ark-serialize from BEEFY primitives
      
      * Use Codec instead of Encode + Decode in primitives/consensus/beefy/src/lib.rs
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * - Make `BeefyApi` generic over Signature type.
      - Make new `BeeyApi` functinos also generic over AuthorityId and Signature
      
      * Unmake BeefyAPI generic over Signature. Recover Signature type from AuthId.
      
      * - dont use hex or hex-literal use array-bytes instead in beefy primitives and bls crypto.
      - CamelCase ECDSA and BLS everywhere.
      
      * Move the definition of BEEFY key type from `primitives/beefy` to `crypto.rs` according to new convention.
      
      * - Add bls377_generate_new to `sp-io` and `application_crypto::bls`.
      - Add `bls-experimental` to `sp-io`
      
      Does not compile because PassByCodec can not derive PassBy using customly implemented PassByIner.
      
      * Implement PassBy for `bls::Public` manually
      
      * fix Beefy `KEY_TYPE` in `frame/beefy` tests to come from `sp-core::key_types` enum
      
      * specify both generic for `hex2array_unchecked` in `sp-core/bls.rs`
      
      * Rename `crypto`→`ecdsa_crypto` in `primitives/consensus/beefy/src/test_utils.rs` docs
      
      * remove commented-out code in `primitives/consensus/beefy/src/commitment.rs`
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * Fix inconsistency in panic message in  `primitives/io/src/lib.rs`
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * Remove redundant feature activation in `primitives/io/Cargo.toml`
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * - make `w3f-bls` a dev-dependancy only for beefy primitives.
      
      - clean up comments.
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * export BEEFY KEY_TYPE from primitives/consensus/beefy
      make `frame/consensus/beefy` in dependent of sp_crypto_app
      use consistent naming in the beefy primitive tests.
      
      * - implement `BeefyAuthorityId` for `bls_crypto::AuthorityId`.
      - implement `bls_verify_works` test for BEEFY `bls_crypto`.
      
      * Remove BEEFY `ecdsa_n_bls_crypto` for now for later re-introduction
      
      * Make commitment and witness BEEFY tests not use Keystore.
      
      * put `bls_beefy_verify_works` test under `bls-experimental` flag.
      
      * bump up Runtime `BeefyAPI` to version 3 due to introducing generic AuthorityId.
      
      * reuse code and encapsulate w3f-bls backend in sp-core as most as possible
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * Make comments in primities BEEFY `commitment.rs` and `witness.rs``tests convention conforming
      
      * Use master dep versions
      
      * Trivial change. Mostly to trigger CI
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarAndré Silva <[email protected]>
      
      * Fix Cargo.toml
      
      * Trigger CI with cumulus companion
      
      * Trigger CI after polkadot companion change
      
      ---------
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      Co-authored-by: default avatarAndré Silva <[email protected]>
      3fef703e
  2. Jul 21, 2023
  3. Jul 06, 2023
  4. Jun 29, 2023
  5. Jun 16, 2023
  6. May 25, 2023
    • Adrian Catangiu's avatar
      sc-consensus-beefy: graceful support for pallet-beefy reset (#14217) · b907f520
      Adrian Catangiu authored
      
      
      BEEFY consensus can be restarted by resetting "genesisBlock" in
      pallet-beefy, but we don't want to also reset authority set IDs so
      that they are uniquely identified across the entire chain history
      regardless of how many times BEEFY consensus has been reset/restarted.
      
      This is why the client now also accepts initial authority_set_id != 0.
      
      BEEFY client now detects pallet-beefy reset/reinit and errors-out and
      asks for a restart.
      BEEFY client persisted state should be discarded on client restarts
      following pallet-beefy reset/reinit.
      
      End result is BEEFY client/voter can now completely reinitialize using
      "new" on-chain info following pallet-beefy reset/reinit, discarding old state.
      
      Fixes #14203
      Fixes #14204
      
      Signed-off-by: default avataracatangiu <[email protected]>
      b907f520
  7. May 24, 2023
  8. May 11, 2023
    • Aaro Altonen's avatar
      Prepare `sc-network` for `ProtocolController`/`NotificationService` (#14080) · f36749b9
      Aaro Altonen authored
      
      
      * Prepare `sc-network` for `ProtocolController`/`NotificationService`
      
      The upcoming notification protocol refactoring requires that protocols
      are able to communicate with `sc-network` over unique and direct links.
      This means that `sc-network` side of the link has to be created before
      `sc-network` is initialized and that it is allowed to consume the object
      as the receiver half of the link may not implement `Clone`.
      
      Remove request-response and notification protocols from `NetworkConfiguration`
      and create a new object that contains the configurations of these protocols
      and which is consumable by `sc-network`. This is needed needed because, e.g.,
      the receiver half of `NotificationService` is not clonable so `sc-network`
      must consume it when it's initializing the protocols in `Notifications`.
      
      Similar principe applies to `PeerStore`/`ProtocolController`: as per current
      design, protocols are created before the network so `Protocol` cannot be
      the one creating the `PeerStore` object. `FullNetworkConfiguration` will be
      used to store the objects that `sc-network` will use to communicate with
      protocols and it will also allow protocols to allocate handles so they
      can directly communicate with `sc-network`.
      
      * Fixes
      
      * Update client/service/src/builder.rs
      
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      
      * Updates
      
      * Doc updates + cargo-fmt
      
      ---------
      
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      f36749b9
  9. May 04, 2023
    • Michal Kucharczyk's avatar
      substrate-test-runtime migrated to "pure" frame runtime (#13737) · 6a295e7c
      Michal Kucharczyk authored
      * substrate-test-runtime migrated to pure-frame based
      
      * test block builder: helpers added
      
      * simple renaming
      
      * basic_authorship test adjusted
      
      * block_building storage_proof test adjusted
      
      * babe: tests: should_panic expected added
      
      * babe: tests adjusted
      
      ConsensusLog::NextEpochData is now added by pallet_babe as
      pallet_babe::SameAuthoritiesForever trigger is used in runtime config.
      
      * beefy: tests adjusted
      
      test-substrate-runtime is now using frame::executive to finalize the
      block. during finalization the digests stored during block execution are
      checked against header digests:
      https://github.com/paritytech/substrate/blob/91bb2d29ca905599098a5b35eaf24867c4fbd60a/frame/executive/src/lib.rs#L585-L591
      
      It makes impossible to directly manipulate header's digets, w/o
      depositing logs into system pallet storage `Digest<T: Config>`.
      
      Instead of this dedicated extrinsic allowing to store logs items
      (MmrRoot / AuthoritiesChange) is used.
      
      * grandpa: tests adjusted
      
      test-substrate-runtime is now using frame::executive to finalize the
      block. during finalization the digest logs stored during block execution are
      checked against header digest logs:
      https://github.com/paritytech/substrate/blob/91bb2d29ca905599098a5b35eaf24867c4fbd60a/frame/executive/src/lib.rs#L585-L591
      
      
      
      It makes impossible to directly manipulate header's digets, w/o
      depositing logs into system pallet storage `Digest<T: Config>`.
      
      Instead of this dedicated extrinsic allowing to store logs items
      (ScheduledChange / ForcedChange and DigestItem::Other) is used.
      
      * network:bitswap: test adjusted
      
      The size of unchecked extrinsic was increased. The pattern used in test will
      be placed at the end of scale-encoded buffer.
      
      * runtime apis versions adjusted
      
      * storage keys used in runtime adjusted
      
      * wasm vs native tests removed
      
      * rpc tests: adjusted
      
      Transfer transaction processing was slightly improved, test was
      adjusted.
      
      * tests: sizes adjusted
      
      Runtime extrinsic size was increased. Size of data read during block
      execution was also increased due to usage of new pallets in runtime.
      
      Sizes were adjusted in tests.
      
      * cargo.lock update
      
      cargo update -p substrate-test-runtime -p substrate-test-runtime-client
      
      * warnings fixed
      
      * builders cleanup: includes / std
      
      * extrinsic validation cleanup
      
      * txpool: benches performance fixed
      
      * fmt
      
      * spelling
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * Apply code review suggestions
      
      * Apply code review suggestions
      
      * get rid of 1063 const
      
      * renaming: UncheckedExtrinsic -> Extrinsic
      
      * test-utils-runtime: further step to pure-frame
      
      * basic-authorship: tests OK
      
      * CheckSubstrateCall added + tests fixes
      
      * test::Transfer call removed
      
      * priority / propagate / no sudo+root-testing
      
      * fixing warnings + format
      
      * cleanup: build2/nonce + format
      
      * final tests fixes
      
      all tests are passing
      
      * logs/comments removal
      
      * should_not_accept_old_signatures test removed
      
      * make txpool benches work again
      
      * Cargo.lock reset
      
      * format
      
      * sudo hack removed
      
      * txpool benches fix+cleanup
      
      * .gitignore reverted
      
      * rebase fixing + unsigned cleanup
      
      * Cargo.toml/Cargo.lock cleanup
      
      * force-debug feature removed
      
      * mmr tests fixed
      
      * make cargo-clippy happy
      
      * network sync test uses unsigned extrinsic
      
      * cleanup
      
      * ".git/.scripts/commands/fmt/fmt.sh"
      
      * push_storage_change signed call remove
      
      * GenesisConfig cleanup
      
      * fix
      
      * fix
      
      * GenesisConfig simplified
      
      * storage_keys_works: reworked
      
      * storage_keys_works: expected keys in vec
      
      * storage keys list moved to substrate-test-runtime
      
      * substrate-test: some sanity tests + GenesisConfigBuilder rework
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      
      * Apply suggestions from code review
      
      * Review suggestions
      
      * fix
      
      * fix
      
      * beefy: generate_blocks_and_sync block_num sync with actaul value
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * Update test-utils/runtime/src/genesismap.rs
      
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      
      * cargo update -p sc-rpc -p sc-transaction-pool
      
      * Review suggestions
      
      * fix
      
      * doc added
      
      * slot_duration adjusted for Babe::slot_duration
      
      * small doc fixes
      
      * array_bytes::hex used instead of hex
      
      * tiny -> medium name fix
      
      * Apply suggestions from code review
      
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      
      * TransferData::try_from_unchecked_extrinsic -> try_from
      
      * Update Cargo.lock
      
      ---------
      
      Co-authored-by: parity-processbot <>
      Co-authored-by: default avatarDavide Galassi <[email protected]>
      Co-authored-by: default avatarBastian Köcher <[email protected]>
      Co-authored-by: default avatarSebastian Kunert <[email protected]>
      6a295e7c
  10. Apr 12, 2023
  11. Mar 30, 2023
    • Adrian Catangiu's avatar
      BEEFY: gossip finality proofs (#13727) · 92c1229e
      Adrian Catangiu authored
      * sc-consensus-beefy: add justifications to gossip protocol
      
      * sc-consensus-beefy: voter gossips finality proofs
      
      * sc-consensus-beefy: add finality proof gossip test
      
      * sc-consensus-beefy: always gossip finality proof
      
      Gossip finality proof in _both_ cases of reaching finality threshold
      through votes:
      1. threshold reached through self vote,
      2. threshold reached through incoming vote.
      
      * address comments
      92c1229e
  12. Mar 20, 2023
    • Davide Galassi's avatar
      Keystore overhaul (iter 2) (#13634) · 480396fe
      Davide Galassi authored
      * Remove bloat about remote keystore
      
      * Update docs and remove unused 'KeystoreRef' trait
      
      * Use wherever possible, MemoryKeystore for testing
      
      * Remove unrequired fully qualified method syntax for Keystore
      480396fe
  13. Mar 17, 2023
    • Davide Galassi's avatar
      Keystore overhaul (#13615) · f110941b
      Davide Galassi authored
      * Remove 'supported_keys' 'sign_with_any' and 'sign_with_all' from keystore trait
      
      * Remove the aync keystore
      
      * Renaming:
      - SyncCryptoStore -> Keystore
      - SyncCryptoStorePtr -> KeystorePtr
      - KeyStore -> MemoryKeystore
      
      * Fix authority discovery worker and tests
      
      * Rename 'insert_unknown' to 'insert'
      
      * Remove leftover
      f110941b
  14. Mar 16, 2023
    • Adrian Catangiu's avatar
      sc-consensus-beefy: improve beefy gossip validator (#13606) · 3708b156
      Adrian Catangiu authored
      
      
      * sc-consensus-beefy: improve beefy gossip validator
      
      Old gossip validator was pretty dumb, being very permissive with
      incoming votes - only condition it had was to be newer than best
      finalized.
      
      New filter conditions:
       - voter rounds are initialized (discarding votes until voter is
         actually active),
       - only votes for current active set id are accepted,
       - only votes for rounds in the current voting session are accepted,
       - only votes for GRANDPA finalized blocks are accepted,
       - when BEEFY voter reaches mandatory round, only votes for said
         mandatory round are accepted.
      
      New validator uses the VoterOracle to easily implement above conditions
      and only allow through votes that are immediately useful to the voter.
      
      After every GRANDPA or BEEFY finality, the gossip validator filter is
      updated.
      
      * sc-consensus-beefy: remove votes enqueueing
      
      Since gossip validator will simply disallow votes for future rounds,
      and only allow votes that the voter can immediately process, there
      is no need for the voter to enqueue votes.
      
      It will see these "future" votes later in rebroadcasts, when voter
      will also be able to process them. Only at that point does gossip
      accept and consume them.
      
      * sc-consensus-beefy: refactor persistent state
      
      Move best-beefy and best-grandpa into VoterOracle instead
      of passing them around as params.
      VoterOracle ultimately needs to know best-beefy and/or best-grandpa
      for most of its functions.
      
      * sc-consensus-beefy: further restrict gossip validator
      
      Assuming mandatory done in current session:
      Instead of allowing votes for any round in the current session, only
      accept votes for rounds equal or better than best BEEFY finalized.
      
      * sc-consensus-beefy: add a couple of comments
      
      * sc-consensus-beefy: fix tests involving multiple tasks
      
      Finalize blocks one a time in tests where we want gossip to happen
      in a certain round. Otherwise, some tasks may be left behind in
      terms of gossip round numbers because once "scheduled" a task will
      greedily process as much as possible.
      
      This change should be in line with the real-world scenario where
      voters run "in parallel" across nodes, the only points of
      synchronization being the finality notifications.
      
      * sc-consensus-beefy: address review comments
      
      ---------
      
      Signed-off-by: default avataracatangiu <[email protected]>
      3708b156
  15. Mar 14, 2023
    • Adrian Catangiu's avatar
      sc-consensus-beefy: fix on-demand async state machine (#13599) · 81a02cb7
      Adrian Catangiu authored
      
      
      `futures_util::pending!()` macro only yields to the event loop once,
      resulting in many calls to the `OnDemandJustificationsEngine::next()`
      made by the tokio reactor even though the on-demand-engine is idle.
      
      Replace it with the correct `futures::future::pending::<()>()` function
      which forever yields to the event loop, which is what we want when
      the engine is idle.
      
      Signed-off-by: default avatarAdrian Catangiu <[email protected]>
      81a02cb7
    • Aaro Altonen's avatar
      Move code from `sc-network-common` back to `sc-network` (#13592) · 9ced14e2
      Aaro Altonen authored
      
      
      * Move service tests to `client/network/tests`
      
      These tests depend on `sc-network` and `sc-network-sync` so they should
      live outside the crate.
      
      * Move some configs from `sc-network-common` to `sc-network`
      
      * Move `NetworkService` traits to `sc-network`
      
      * Move request-responses to `sc-network`
      
      * Remove more stuff
      
      * Remove rest of configs from `sc-network-common` to `sc-network`
      
      * Remove more stuff
      
      * Fix warnings
      
      * Update client/network/src/request_responses.rs
      
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      
      * Fix cargo doc
      
      ---------
      
      Co-authored-by: default avatarDmitry Markin <[email protected]>
      9ced14e2
  16. Mar 07, 2023
  17. Mar 06, 2023
    • Aaro Altonen's avatar
      Extract syncing protocol from `sc-network` (#12828) · 1a7f5be0
      Aaro Altonen authored
      
      
      * Move import queue out of `sc-network`
      
      Add supplementary asynchronous API for the import queue which means
      it can be run as an independent task and communicated with through
      the `ImportQueueService`.
      
      This commit removes removes block and justification imports from
      `sc-network` and provides `ChainSync` with a handle to import queue so
      it can import blocks and justifications. Polling of the import queue is
      moved complete out of `sc-network` and `sc_consensus::Link` is
      implemented for `ChainSyncInterfaceHandled` so the import queue
      can still influence the syncing process.
      
      * Move stuff to SyncingEngine
      
      * Move `ChainSync` instanation to `SyncingEngine`
      
      Some of the tests have to be rewritten
      
      * Move peer hashmap to `SyncingEngine`
      
      * Let `SyncingEngine` to implement `ChainSyncInterface`
      
      * Introduce `SyncStatusProvider`
      
      * Move `sync_peer_(connected|disconnected)` to `SyncingEngine`
      
      * Implement `SyncEventStream`
      
      Remove `SyncConnected`/`SyncDisconnected` events from
      `NetworkEvenStream` and provide those events through
      `ChainSyncInterface` instead.
      
      Modify BEEFY/GRANDPA/transactions protocol and `NetworkGossip` to take
      `SyncEventStream` object which they listen to for incoming sync peer
      events.
      
      * Introduce `ChainSyncInterface`
      
      This interface provides a set of miscellaneous functions that other
      subsystems can use to query, for example, the syncing status.
      
      * Move event stream polling to `SyncingEngine`
      
      Subscribe to `NetworkStreamEvent` and poll the incoming notifications
      and substream events from `SyncingEngine`.
      
      The code needs refactoring.
      
      * Make `SyncingEngine` into an asynchronous runner
      
      This commits removes the last hard dependency of syncing from
      `sc-network` meaning the protocol now lives completely outside of
      `sc-network`, ignoring the hardcoded peerset entry which will be
      addressed in the future.
      
      Code needs a lot of refactoring.
      
      * Fix warnings
      
      * Code refactoring
      
      * Use `SyncingService` for BEEFY
      
      * Use `SyncingService` for GRANDPA
      
      * Remove call delegation from `NetworkService`
      
      * Remove `ChainSyncService`
      
      * Remove `ChainSync` service tests
      
      They were written for the sole purpose of verifying that `NetworWorker`
      continues to function while the calls are being dispatched to
      `ChainSync`.
      
      * Refactor code
      
      * Refactor code
      
      * Update client/finality-grandpa/src/communication/tests.rs
      
      Co-authored-by: default avatarAnton <[email protected]>
      
      * Fix warnings
      
      * Apply review comments
      
      * Fix docs
      
      * Fix test
      
      * cargo-fmt
      
      * Update client/network/sync/src/engine.rs
      
      Co-authored-by: default avatarAnton <[email protected]>
      
      * Update client/network/sync/src/engine.rs
      
      Co-authored-by: default avatarAnton <[email protected]>
      
      * Add missing docs
      
      * Refactor code
      
      ---------
      
      Co-authored-by: default avatarAnton <[email protected]>
      1a7f5be0
  18. Mar 01, 2023
  19. Feb 28, 2023