mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Initial In Instructions pallet and Serai client lib (#233)
* Initial work on an In Inherents pallet * Add an event for when a batch is executed * Add a dummy provider for InInstructions * Add in-instructions to the node * Add the Serai runtime API to the processor * Move processor tests around * Build a subxt Client around Serai * Successfully get Batch events from Serai Renamed processor/substrate to processor/serai. * Much more robust InInstruction pallet * Implement the workaround from https://github.com/paritytech/subxt/issues/602 * Initial prototype of processor generated InInstructions * Correct PendingCoins data flow for InInstructions * Minor lint to in-instructions * Remove the global Serai connection for a partial re-impl * Correct ID handling of the processor test * Workaround the delay in the subscription * Make an unwrap an if let Some, remove old comments * Lint the processor toml * Rebase and update * Move substrate/in-instructions to substrate/in-instructions/pallet * Start an in-instructions primitives lib * Properly update processor to subxt 0.24 Also corrects failures from the rebase. * in-instructions cargo update * Implement IsFatalError * is_inherent -> true * Rename in-instructions crates and misc cleanup * Update documentation * cargo update * Misc update fixes * Replace height with block_number * Update processor src to latest subxt * Correct pipeline for InInstructions testing * Remove runtime::AccountId for serai_primitives::NativeAddress * Rewrite the in-instructions pallet Complete with respect to the currently written docs. Drops the custom serializer for just using SCALE. Makes slight tweaks as relevant. * Move instructions' InherentDataProvider to a client crate * Correct doc gen * Add serde to in-instructions-primitives * Add in-instructions-primitives to pallet * Heights -> BlockNumbers * Get batch pub test loop working * Update in instructions pallet terminology Removes the ambiguous Coin for Update. Removes pending/artificial latency for furture client work. Also moves to using serai_primitives::Coin. * Add a BlockNumber primitive * Belated cargo fmt * Further document why DifferentBatch isn't fatal * Correct processor sleeps * Remove metadata at compile time, add test framework for Serai nodes * Remove manual RPC client * Simplify update test * Improve re-exporting behavior of serai-runtime It now re-exports all pallets underneath it. * Add a function to get storage values to the Serai RPC * Update substrate/ to latest substrate * Create a dedicated crate for the Serai RPC * Remove unused dependencies in substrate/ * Remove unused dependencies in coins/ Out of scope for this branch, just minor and path of least resistance. * Use substrate/serai/client for the Serai RPC lib It's a bit out of place, since these client folders are intended for the node to access pallets and so on. This is for end-users to access Serai as a whole. In that sense, it made more sense as a top level folder, yet that also felt out of place. * Move InInstructions test to serai-client for now * Final cleanup * Update deny.toml * Cargo.lock update from merging develop * Update nightly Attempt to work around the current CI failure, which is a Rust ICE. We previously didn't upgrade due to clippy 10134, yet that's been reverted. * clippy * clippy * fmt * NativeAddress -> SeraiAddress * Sec fix on non-provided updates and doc fixes * Add Serai as a Coin Necessary in order to swap to Serai. * Add a BlockHash type, used for batch IDs * Remove origin from InInstruction Makes InInstructionTarget. Adds RefundableInInstruction with origin. * Document storage items in in-instructions * Rename serai/client/tests/serai.rs to updates.rs It only tested publishing updates and their successful acceptance.
This commit is contained in:
@@ -3,12 +3,9 @@ use sp_runtime::traits::TrailingZeroInput;
|
||||
|
||||
use sc_service::ChainType;
|
||||
|
||||
use serai_primitives::*;
|
||||
use pallet_tendermint::crypto::Public;
|
||||
|
||||
use serai_runtime::{
|
||||
WASM_BINARY, AccountId, opaque::SessionKeys, GenesisConfig, SystemConfig, BalancesConfig,
|
||||
AssetsConfig, ValidatorSetsConfig, SessionConfig,
|
||||
primitives::*, tendermint::crypto::Public, WASM_BINARY, opaque::SessionKeys, GenesisConfig,
|
||||
SystemConfig, BalancesConfig, AssetsConfig, ValidatorSetsConfig, SessionConfig,
|
||||
};
|
||||
|
||||
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
|
||||
@@ -17,22 +14,22 @@ fn insecure_pair_from_name(name: &'static str) -> Pair {
|
||||
Pair::from_string(&format!("//{name}"), None).unwrap()
|
||||
}
|
||||
|
||||
fn account_id_from_name(name: &'static str) -> AccountId {
|
||||
fn address_from_name(name: &'static str) -> SeraiAddress {
|
||||
insecure_pair_from_name(name).public()
|
||||
}
|
||||
|
||||
fn testnet_genesis(
|
||||
wasm_binary: &[u8],
|
||||
validators: &[&'static str],
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
endowed_accounts: Vec<SeraiAddress>,
|
||||
) -> GenesisConfig {
|
||||
let session_key = |name| {
|
||||
let key = account_id_from_name(name);
|
||||
let key = address_from_name(name);
|
||||
(key, key, SessionKeys { tendermint: Public::from(key) })
|
||||
};
|
||||
|
||||
// TODO: Replace with a call to the pallet to ask for its account
|
||||
let owner = AccountId::decode(&mut TrailingZeroInput::new(b"tokens")).unwrap();
|
||||
let owner = SeraiAddress::decode(&mut TrailingZeroInput::new(b"tokens")).unwrap();
|
||||
|
||||
GenesisConfig {
|
||||
system: SystemConfig { code: wasm_binary.to_vec() },
|
||||
@@ -54,8 +51,8 @@ fn testnet_genesis(
|
||||
|
||||
validator_sets: ValidatorSetsConfig {
|
||||
bond: Amount(1_000_000) * COIN,
|
||||
coins: Coin(4),
|
||||
participants: validators.iter().map(|name| account_id_from_name(name)).collect(),
|
||||
coins: vec![BITCOIN, ETHER, DAI, MONERO],
|
||||
participants: validators.iter().map(|name| address_from_name(name)).collect(),
|
||||
},
|
||||
session: SessionConfig { keys: validators.iter().map(|name| session_key(*name)).collect() },
|
||||
}
|
||||
@@ -75,18 +72,18 @@ pub fn development_config() -> Result<ChainSpec, &'static str> {
|
||||
wasm_binary,
|
||||
&["Alice"],
|
||||
vec![
|
||||
account_id_from_name("Alice"),
|
||||
account_id_from_name("Bob"),
|
||||
account_id_from_name("Charlie"),
|
||||
account_id_from_name("Dave"),
|
||||
account_id_from_name("Eve"),
|
||||
account_id_from_name("Ferdie"),
|
||||
account_id_from_name("Alice//stash"),
|
||||
account_id_from_name("Bob//stash"),
|
||||
account_id_from_name("Charlie//stash"),
|
||||
account_id_from_name("Dave//stash"),
|
||||
account_id_from_name("Eve//stash"),
|
||||
account_id_from_name("Ferdie//stash"),
|
||||
address_from_name("Alice"),
|
||||
address_from_name("Bob"),
|
||||
address_from_name("Charlie"),
|
||||
address_from_name("Dave"),
|
||||
address_from_name("Eve"),
|
||||
address_from_name("Ferdie"),
|
||||
address_from_name("Alice//stash"),
|
||||
address_from_name("Bob//stash"),
|
||||
address_from_name("Charlie//stash"),
|
||||
address_from_name("Dave//stash"),
|
||||
address_from_name("Eve//stash"),
|
||||
address_from_name("Ferdie//stash"),
|
||||
],
|
||||
)
|
||||
},
|
||||
@@ -119,18 +116,18 @@ pub fn testnet_config() -> Result<ChainSpec, &'static str> {
|
||||
wasm_binary,
|
||||
&["Alice", "Bob", "Charlie"],
|
||||
vec![
|
||||
account_id_from_name("Alice"),
|
||||
account_id_from_name("Bob"),
|
||||
account_id_from_name("Charlie"),
|
||||
account_id_from_name("Dave"),
|
||||
account_id_from_name("Eve"),
|
||||
account_id_from_name("Ferdie"),
|
||||
account_id_from_name("Alice//stash"),
|
||||
account_id_from_name("Bob//stash"),
|
||||
account_id_from_name("Charlie//stash"),
|
||||
account_id_from_name("Dave//stash"),
|
||||
account_id_from_name("Eve//stash"),
|
||||
account_id_from_name("Ferdie//stash"),
|
||||
address_from_name("Alice"),
|
||||
address_from_name("Bob"),
|
||||
address_from_name("Charlie"),
|
||||
address_from_name("Dave"),
|
||||
address_from_name("Eve"),
|
||||
address_from_name("Ferdie"),
|
||||
address_from_name("Alice//stash"),
|
||||
address_from_name("Bob//stash"),
|
||||
address_from_name("Charlie//stash"),
|
||||
address_from_name("Dave//stash"),
|
||||
address_from_name("Eve//stash"),
|
||||
address_from_name("Ferdie//stash"),
|
||||
],
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user