diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a548053b..948d43449 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,8 +14,9 @@ At the moment this project **does not** adhere to There are a few breaking changes in this release, mostly related to the APIs around Programs (formerly Constraints). -Some notables changes introduced in [#428](https://github.com/entropyxyz/entropy-core/pull/428) and -[#433](https://github.com/entropyxyz/entropy-core/pull/433) are: +Some notables changes introduced in [#428](https://github.com/entropyxyz/entropy-core/pull/428), +[#433](https://github.com/entropyxyz/entropy-core/pull/433), and +[#451](https://github.com/entropyxyz/entropy-core/pull/451) are: - The Constraint pallet's `update_v2_constraints` extrinsic has been renamed to `update_program`. The extrinsic arguments remain unchanged @@ -24,6 +25,7 @@ Some notables changes introduced in [#428](https://github.com/entropyxyz/entropy - The Constraint pallet's `V2ConstraintLengthExceeded` error has been renamed to `ProgramLengthExceeded` - The Relayer pallet's `register` extrinsic now takes a `Vec` as a program instead of an `Option` +- The Constraints pallet has been renamed to the Programs pallet ### Added - Proactive refresh ([#413](https://github.com/entropyxyz/entropy-core/pull/413)) @@ -36,6 +38,7 @@ Some notables changes introduced in [#428](https://github.com/entropyxyz/entropy - Replace outdated `--ws-external` with `--rpc-external` ([#424](https://github.com/entropyxyz/entropy-core/pull/424)) - Place `demo_offence` dispatchable behind root origin check ([#426](https://github.com/entropyxyz/entropy-core/pull/426)) - Update `pallet-relayer` to use Contraints V2 ([#433](https://github.com/entropyxyz/entropy-core/pull/433)) +- Rename `pallet-constraints` to `pallet-programs` ([#451](https://github.com/entropyxyz/entropy-core/pull/451)) ### Removed - Remove `is_swapping` from registration details ([#437](https://github.com/entropyxyz/entropy-core/pull/437)) diff --git a/Cargo.lock b/Cargo.lock index 942c4cc67..c52d8232d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -602,18 +602,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "auto_impl" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" -dependencies = [ - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "autocfg" version = "0.1.8" @@ -2624,20 +2612,6 @@ dependencies = [ "try-runtime-cli", ] -[[package]] -name = "entropy-constraints" -version = "0.1.0" -dependencies = [ - "entropy-shared", - "ethers-core", - "hex", - "primitive-types 0.11.1", - "rlp", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "entropy-protocol" version = "0.0.1" @@ -2688,7 +2662,6 @@ dependencies = [ "pallet-balances", "pallet-bounties", "pallet-collective", - "pallet-constraints", "pallet-conviction-voting", "pallet-democracy", "pallet-election-provider-multi-phase", @@ -2709,6 +2682,7 @@ dependencies = [ "pallet-offences", "pallet-offences-benchmarking", "pallet-preimage", + "pallet-programs", "pallet-propagation", "pallet-proxy", "pallet-recovery", @@ -2858,81 +2832,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ethabi" -version = "18.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" -dependencies = [ - "ethereum-types", - "hex", - "once_cell 1.18.0", - "regex", - "serde", - "serde_json", - "sha3", - "thiserror", - "uint", -] - -[[package]] -name = "ethbloom" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c22d4b5885b6aa2fe5e8b9329fb8d232bf739e434e6b87347c63bdd00c120f60" -dependencies = [ - "crunchy", - "fixed-hash 0.8.0", - "impl-codec", - "impl-rlp", - "impl-serde 0.4.0", - "scale-info", - "tiny-keccak", -] - -[[package]] -name = "ethereum-types" -version = "0.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02d215cbf040552efcbe99a38372fe80ab9d00268e20012b79fcd0f073edd8ee" -dependencies = [ - "ethbloom", - "fixed-hash 0.8.0", - "impl-codec", - "impl-rlp", - "impl-serde 0.4.0", - "primitive-types 0.12.1", - "scale-info", - "uint", -] - -[[package]] -name = "ethers-core" -version = "2.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6da5fa198af0d3be20c19192df2bd9590b92ce09a8421e793bec8851270f1b05" -dependencies = [ - "arrayvec 0.7.4", - "bytes", - "chrono", - "elliptic-curve 0.13.5", - "ethabi", - "generic-array 0.14.7", - "hex", - "k256", - "num_enum", - "open-fastrlp", - "rand 0.8.5", - "rlp", - "serde", - "serde_json", - "strum", - "tempfile", - "thiserror", - "tiny-keccak", - "unicode-xid", -] - [[package]] name = "event-listener" version = "2.5.3" @@ -3115,18 +3014,6 @@ dependencies = [ "scale-info", ] -[[package]] -name = "fixed-hash" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" -dependencies = [ - "byteorder", - "rand 0.8.5", - "rustc-hex", - "static_assertions", -] - [[package]] name = "fixed-hash" version = "0.8.0" @@ -4264,24 +4151,6 @@ dependencies = [ "uint", ] -[[package]] -name = "impl-rlp" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28220f89297a075ddc7245cd538076ee98b01f2a9c23a53a4f1105d5a322808" -dependencies = [ - "rlp", -] - -[[package]] -name = "impl-serde" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4551f042f3438e64dbd6226b20527fc84a6e1fe65688b58746a2f53623f25f5c" -dependencies = [ - "serde", -] - [[package]] name = "impl-serde" version = "0.4.0" @@ -4852,7 +4721,7 @@ dependencies = [ "pallet-vesting", "pallet-whitelist", "parity-scale-codec", - "primitive-types 0.12.1", + "primitive-types", "scale-info", "sp-api", "sp-authority-discovery", @@ -6324,27 +6193,6 @@ dependencies = [ "libc", ] -[[package]] -name = "num_enum" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.32", -] - [[package]] name = "number_prefix" version = "0.4.0" @@ -6420,31 +6268,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "open-fastrlp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" -dependencies = [ - "arrayvec 0.7.4", - "auto_impl", - "bytes", - "ethereum-types", - "open-fastrlp-derive", -] - -[[package]] -name = "open-fastrlp-derive" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" -dependencies = [ - "bytes", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "openssl" version = "0.10.55" @@ -6776,25 +6599,6 @@ dependencies = [ "sp-std 8.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", ] -[[package]] -name = "pallet-constraints" -version = "3.0.0-monthly-2021-10" -dependencies = [ - "entropy-shared", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "parity-scale-codec", - "scale-info", - "sp-core 21.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", - "sp-io 23.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", - "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", - "sp-staking", - "sp-std 8.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", -] - [[package]] name = "pallet-contracts" version = "4.0.0-dev" @@ -7362,6 +7166,25 @@ dependencies = [ "sp-std 8.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", ] +[[package]] +name = "pallet-programs" +version = "3.0.0-monthly-2021-10" +dependencies = [ + "entropy-shared", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-core 21.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-io 23.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-runtime 24.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", + "sp-staking", + "sp-std 8.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", +] + [[package]] name = "pallet-propagation" version = "3.0.0-monthly-2021-10" @@ -7377,7 +7200,7 @@ dependencies = [ "pallet-babe", "pallet-bags-list", "pallet-balances", - "pallet-constraints", + "pallet-programs", "pallet-relayer", "pallet-session", "pallet-staking", @@ -7476,7 +7299,7 @@ dependencies = [ "pallet-authorship", "pallet-bags-list", "pallet-balances", - "pallet-constraints", + "pallet-programs", "pallet-session", "pallet-staking", "pallet-staking-extension", @@ -7805,7 +7628,7 @@ dependencies = [ "frame-support", "frame-system", "pallet-balances", - "pallet-constraints", + "pallet-programs", "parity-scale-codec", "scale-info", "smallvec 1.11.0", @@ -8464,30 +8287,16 @@ dependencies = [ "syn 2.0.32", ] -[[package]] -name = "primitive-types" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a" -dependencies = [ - "fixed-hash 0.7.0", - "impl-codec", - "impl-serde 0.3.2", - "scale-info", - "uint", -] - [[package]] name = "primitive-types" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f3486ccba82358b11a77516035647c34ba167dfa53312630de83b12bd4f3d66" dependencies = [ - "fixed-hash 0.8.0", + "fixed-hash", "impl-codec", "impl-num-traits", - "impl-rlp", - "impl-serde 0.4.0", + "impl-serde", "scale-info", "uint", ] @@ -9228,28 +9037,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rlp" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb919243f34364b6bd2fc10ef797edbfa75f33c252e7998527479c6d6b47e1ec" -dependencies = [ - "bytes", - "rlp-derive", - "rustc-hex", -] - -[[package]] -name = "rlp-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "rmp" version = "0.8.11" @@ -10703,7 +10490,7 @@ checksum = "7789f5728e4e954aaa20cadcc370b99096fb8645fca3c9333ace44bb18f30095" dependencies = [ "derive_more", "parity-scale-codec", - "primitive-types 0.12.1", + "primitive-types", "scale-bits", "scale-decode-derive", "scale-info", @@ -10731,7 +10518,7 @@ checksum = "6d70cb4b29360105483fac1ed567ff95d65224a14dd275b6303ed0a654c78de5" dependencies = [ "derive_more", "parity-scale-codec", - "primitive-types 0.12.1", + "primitive-types", "scale-bits", "scale-encode-derive", "scale-info", @@ -11201,7 +10988,6 @@ dependencies = [ "chacha20poly1305 0.10.1", "clap 4.3.11", "ec-runtime", - "entropy-constraints", "entropy-protocol", "entropy-shared", "futures", @@ -11817,7 +11603,7 @@ dependencies = [ "futures", "hash-db", "hash256-std-hasher", - "impl-serde 0.4.0", + "impl-serde", "lazy_static", "libsecp256k1", "log", @@ -11825,7 +11611,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "paste 1.0.13", - "primitive-types 0.12.1", + "primitive-types", "rand 0.8.5", "regex", "scale-info", @@ -11861,7 +11647,7 @@ dependencies = [ "futures", "hash-db", "hash256-std-hasher", - "impl-serde 0.4.0", + "impl-serde", "lazy_static", "libsecp256k1", "log", @@ -11869,7 +11655,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "paste 1.0.13", - "primitive-types 0.12.1", + "primitive-types", "rand 0.8.5", "regex", "scale-info", @@ -12244,7 +12030,7 @@ dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "primitive-types 0.12.1", + "primitive-types", "sp-externalities 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-runtime-interface-proc-macro 11.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "sp-std 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -12262,7 +12048,7 @@ dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "primitive-types 0.12.1", + "primitive-types", "sp-externalities 0.19.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", "sp-runtime-interface-proc-macro 11.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", "sp-std 8.0.0 (git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0)", @@ -12402,7 +12188,7 @@ version = "13.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94294be83f11d4958cfea89ed5798f0b6605f5defc3a996948848458abbcc18e" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -12415,7 +12201,7 @@ name = "sp-storage" version = "13.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "ref-cast", "serde", @@ -12537,7 +12323,7 @@ name = "sp-version" version = "22.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "impl-serde 0.4.0", + "impl-serde", "parity-scale-codec", "parity-wasm", "scale-info", @@ -13033,10 +12819,10 @@ dependencies = [ "frame-metadata 16.0.0", "futures", "hex", - "impl-serde 0.4.0", + "impl-serde", "jsonrpsee 0.20.2", "parity-scale-codec", - "primitive-types 0.12.1", + "primitive-types", "scale-bits", "scale-decode", "scale-encode", diff --git a/README.md b/README.md index e4cdfd615..60fe3ee1e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CircleCI](https://dl.circleci.com/status-badge/img/gh/entropyxyz/entropy-core/tree/master.svg?style=svg&circle-token=bff4726b78a5f7c7771cb9ee8453cde0b8132d6f)](https://dl.circleci.com/status-badge/redirect/gh/entropyxyz/entropy-core/tree/master) -This repo contains the Entropy blockchain node, the validator server (evaluates constraints, stores threshold keyshares, and coordinates threshold-signing), and misc. testing utilities for the network. +This repo contains the Entropy blockchain node, the validator server (evaluates programs, stores threshold keyshares, and coordinates threshold-signing), and misc. testing utilities for the network. Our blockchain node is written with Substrate, and its documentation can be found [here](https://github.com/substrate-developer-hub/substrate-node-template). diff --git a/crypto/README.md b/crypto/README.md index f4440fd93..13b1705c0 100644 --- a/crypto/README.md +++ b/crypto/README.md @@ -44,7 +44,7 @@ Constraints have now moved to [entropyxyz/constraints](https://github.com/entrop 1. User submits a transaction (`pallets::relayer::prep_transaction`) to the chain, containing a message including their substrate address and their (hashed) message. 2. A set of transactions is picked up by the next block proposer (substrate: TODO). The proposed block contains the proposed signing party information (`server/sign_init`). 3. Upon block creation, signers read the block (`pallets::propagation::post`), containing the IP addresses of nodes who must now execute signing protocols. If a node is in a signing party, it advances to the next step. -4. The user submits the full message to be signed to nodes in the signing party by making a POST request to `/user/tx`, so that they can check if it meets the configured constraints. +4. The user submits the full message to be signed to nodes in the signing party by making a POST request to `/user/tx`, so that they can check if it meets the configured programs. diff --git a/crypto/constraints/Cargo.toml b/crypto/constraints/Cargo.toml deleted file mode 100644 index 21ecdae0d..000000000 --- a/crypto/constraints/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name ="entropy-constraints" -version="0.1.0" -edition="2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -thiserror="1.0.48" - -# parsing - -serde ={ version="1.0.147", default-features=false, features=["derive"] } -serde_json ={ version="1.0", default-features=false, features=["alloc"] } -entropy-shared={ path="../shared", default-features=false } - -# EVM -ethers-core={ version="2.0.7", default-features=false } -rlp={ version="0.5.2", default-features=false } -hex="0.4.3" -primitive-types={ version="0.11.1", default-features=false, features=[ - "scale-info", - "serde_no_std", -] } - -[features] -default=["std"] -std =["serde/std", "serde_json/std", "entropy-shared/std", "rlp/std", "primitive-types/std"] diff --git a/crypto/constraints/src/architectures.rs b/crypto/constraints/src/architectures.rs deleted file mode 100644 index 677b83973..000000000 --- a/crypto/constraints/src/architectures.rs +++ /dev/null @@ -1,153 +0,0 @@ -//! This includes the supported architectures and traits for adding new ones. - -use entropy_shared::Arch; -pub use evm::*; -use serde::{Deserialize, Serialize}; - -use crate::Error; - -/// Trait for defining important types associated with an architecture. -pub trait Architecture: Serialize + for<'de> Deserialize<'de> { - /// Account type for that chain(SS58, H160, etc) - type Address: Eq + Serialize + for<'de> Deserialize<'de>; - /// Account type as it is stored in the database - type AddressRaw: Eq + Serialize + for<'de> Deserialize<'de>; - /// Transaction request type for unsigned transactions - type TransactionRequest: GetSender - + GetReceiver - + Serialize - + for<'de> Deserialize<'de> - + Parse; -} - -/// Trait for getting the the sender of a transaction. -pub trait GetSender { - fn sender(&self) -> Option; -} - -/// Trait for getting the the receiver of a transaction. -pub trait GetReceiver { - fn receiver(&self) -> Option; -} - -/// Trait for parsing a raw transaction request into its native transaction request struct. -pub trait Parse { - fn parse(raw_tx: String) -> Result; -} - -/// Trait for getting the Arch of a transaction request. -pub trait GetArch { - fn arch() -> Arch; -} - -/// EVM architecture -pub mod evm { - pub use ethers_core::types::transaction::request::TransactionRequest as EvmTransactionRequest; - use ethers_core::types::{NameOrAddress, H160}; - use rlp::Rlp; - - use super::*; - - #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] - pub struct Evm; - - impl Architecture for Evm { - type Address = H160; - type AddressRaw = [u8; 20]; - type TransactionRequest = EvmTransactionRequest; - } - - impl GetSender for ::TransactionRequest { - fn sender(&self) -> Option<::Address> { self.from } - } - - impl GetReceiver for ::TransactionRequest { - fn receiver(&self) -> Option<::Address> { - match &self.to { - Some(to) => match to { - NameOrAddress::Address(addr) => Some(addr.to_owned()), - // This should never get returned because we Error on ENS names in the `parse` - // function - NameOrAddress::Name(_) => None, - }, - None => None, - } - } - } - - impl GetArch for ::TransactionRequest { - fn arch() -> Arch { Arch::Evm } - } - - impl Parse for ::TransactionRequest { - fn parse( - hex_rlp_raw_tx: String, - ) -> Result<::TransactionRequest, Error> { - let bytes = hex::decode(hex_rlp_raw_tx.replace("0x", "")).map_err(|e| { - Error::InvalidTransactionRequest(format!("Unable to parse to RLP: {e}")) - })?; - let rlp = Rlp::new(&bytes); - match Self::decode_unsigned_rlp(&rlp) { - Ok(tx) => match tx.to { - // Clients shouldn't even be able to serialize tx reqs with ENS names, but it it - // does somehow, err - Some(NameOrAddress::Name(_)) => Err(Error::InvalidTransactionRequest( - "ENS recipients not supported. Resolve to an address first.".to_string(), - )), - _ => Ok(tx), - }, - Err(e) => - Err(Error::InvalidTransactionRequest(format!("Unable to decode string: {e}"))), - } - } - } - - #[cfg(test)] - mod tests { - use std::str::FromStr; - - use ethers_core::types::{Address as EvmAddress, H256}; - - use super::*; - - #[test] - fn can_parse_evm_rlp_transactions() { - // This is `serializedUnsignedTx` from entropy-js threshold-server tests - let raw_unsigned_tx = "0xef01808094772b9a9e8aa1c9db861c6611a82d251db4fac990019243726561746564204f6e20456e74726f7079018080".to_string(); - let unsigned_tx = EvmTransactionRequest::parse(raw_unsigned_tx).unwrap(); - assert_eq!(unsigned_tx.sender(), None); - assert_eq!( - unsigned_tx.receiver(), - Some(EvmAddress::from_str("772b9a9e8aa1c9db861c6611a82d251db4fac990").unwrap()) - ); // manually removed the 0x - } - - /// Tests that the parsed transaction's sighash matches the client's sighash - #[test] - fn evm_parsed_sighash_matches_clients_sighash() { - // These are from from entropy-js threshold-server tests - let raw_unsigned_tx = "0xef01808094772b9a9e8aa1c9db861c6611a82d251db4fac990019243726561746564204f6e20456e74726f7079018080".to_string(); - let known_expected_sighash: H256 = H256::from_slice( - hex::decode( - "0xe62e139a15f27f3d5ba043756aaca2b6fe9597a95973befa36dbe6095ee16da2" - .replace("0x", ""), - ) - .unwrap() - .as_slice(), - ); - - let unsigned_tx = EvmTransactionRequest::parse(raw_unsigned_tx).unwrap(); - assert_eq!(unsigned_tx.sighash(), known_expected_sighash); - } - - #[test] - fn throws_error_parsing_malformed_evm_rlp() { - let random_bytes = - "0x1c9db861c6611a82d251db4fac990019243726561746564204f6e20456e74726f7079018080" - .to_string(); - - let unsigned_tx = EvmTransactionRequest::parse(random_bytes); - assert!(unsigned_tx.is_err()); - } - } -} diff --git a/crypto/constraints/src/constraints.rs b/crypto/constraints/src/constraints.rs deleted file mode 100644 index 8297e04d9..000000000 --- a/crypto/constraints/src/constraints.rs +++ /dev/null @@ -1,41 +0,0 @@ -//! Contains the traits and implementations of each supported constraint. - -use entropy_shared::{Acl, AclKind}; -use ethers_core::types::{NameOrAddress, H160}; - -use crate::{Architecture, Error, Evm}; - -/// Constraints must implement an evaluation trait that parses. -pub trait Evaluate { - fn eval(&self, tx: A::TransactionRequest) -> Result<(), Error>; -} - -// TODO This can likely be made generic over any architecture with GetRecipient and GetSender traits -#[allow(clippy::needless_collect)] -impl Evaluate for Acl<[u8; 20]> { - fn eval(&self, tx: ::TransactionRequest) -> Result<(), Error> { - if tx.to.is_none() { - return match self.allow_null_recipient { - true => Ok(()), - false => Err(Error::Evaluation("Null recipients are not allowed.")), - }; - } - - let converted_addresses: Vec = self - .clone() - .addresses - .into_iter() - .map(|a| NameOrAddress::Address(H160::from(a))) - .collect(); - - match ( - converted_addresses - .contains(&tx.to.ok_or(Error::Evaluation("Error Parsing to address"))?), - self.kind, - ) { - (true, AclKind::Allow) => Ok(()), - (false, AclKind::Deny) => Ok(()), - _ => Err(Error::Evaluation("Transaction not allowed.")), - } - } -} diff --git a/crypto/constraints/src/lib.rs b/crypto/constraints/src/lib.rs deleted file mode 100644 index f0764688c..000000000 --- a/crypto/constraints/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -use thiserror::Error; - -#[cfg(test)] -mod tests; - -pub mod architectures; -pub mod constraints; - -pub use architectures::*; -pub use constraints::*; - -/// Errors related to parsing and evaulating constraints. -#[derive(Error, Debug, PartialEq)] -pub enum Error { - /// Transaction request could not be parsed - #[error("Invalid transaction request: {0}")] - InvalidTransactionRequest(String), - /// Transaction request did not meet constraint requirements. - #[error("Constraint Evaluation error: {0}")] - Evaluation(&'static str), -} diff --git a/crypto/constraints/src/tests.rs b/crypto/constraints/src/tests.rs deleted file mode 100644 index 523adcb6a..000000000 --- a/crypto/constraints/src/tests.rs +++ /dev/null @@ -1,83 +0,0 @@ -#![cfg(test)] - -use entropy_shared::{Acl, AclKind}; -use ethers_core::types::{NameOrAddress, TransactionRequest, H160}; - -use crate::Evaluate; - -#[test] -fn test_acl_functions_properly() { - let evm_address_1: [u8; 20] = [1u8; 20]; - let evm_address_2: [u8; 20] = [2u8; 20]; - let evm_address_3: [u8; 20] = [3u8; 20]; - - let to_address_1_tx = TransactionRequest { - to: Some(NameOrAddress::Address(H160::from(evm_address_1))), - ..Default::default() - }; - let to_address_2_tx = TransactionRequest { - to: Some(NameOrAddress::Address(H160::from(evm_address_2))), - ..Default::default() - }; - let to_address_3_tx = TransactionRequest { - to: Some(NameOrAddress::Address(H160::from(evm_address_3))), - ..Default::default() - }; - let to_null_recipient_tx = TransactionRequest { to: None, ..Default::default() }; - - let allowlisted_acl = Acl::<[u8; 20]> { addresses: vec![evm_address_1], ..Default::default() }; - - // should only let allowlisted_tx through - assert!(allowlisted_acl.eval(to_address_1_tx.clone()).is_ok()); - - assert!(allowlisted_acl.eval(to_address_2_tx.clone()).is_err()); - assert!(allowlisted_acl.eval(to_address_3_tx.clone()).is_err()); - assert!(allowlisted_acl.eval(to_null_recipient_tx.clone()).is_err()); - - let denylisted_acl = Acl::<[u8; 20]> { - addresses: vec![evm_address_1], - kind: AclKind::Deny, - ..Default::default() - }; - - // should only block whitelisted and null recipient txs - assert!(denylisted_acl.eval(to_address_2_tx.clone()).is_ok()); - assert!(denylisted_acl.eval(to_address_3_tx.clone()).is_ok()); - - assert!(denylisted_acl.eval(to_address_1_tx.clone()).is_err()); - assert!(allowlisted_acl.eval(to_null_recipient_tx.clone()).is_err()); - - let allowlisted_acl_with_null_recipient = Acl::<[u8; 20]> { - addresses: vec![evm_address_1], - allow_null_recipient: true, - ..Default::default() - }; - - // should only let allowlisted_tx and null recipient txs through - assert!(allowlisted_acl_with_null_recipient.eval(to_address_1_tx.clone()).is_ok()); - assert!(allowlisted_acl_with_null_recipient.eval(to_null_recipient_tx.clone()).is_ok()); - - assert!(allowlisted_acl_with_null_recipient.eval(to_address_2_tx.clone()).is_err()); - assert!(allowlisted_acl_with_null_recipient.eval(to_address_3_tx.clone()).is_err()); - - let denylisted_acl_with_null_recipient = Acl::<[u8; 20]> { - addresses: vec![evm_address_1], - kind: AclKind::Deny, - allow_null_recipient: true, - }; - - // should only block whitelisted - assert!(denylisted_acl_with_null_recipient.eval(to_address_2_tx.clone()).is_ok()); - assert!(denylisted_acl_with_null_recipient.eval(to_address_3_tx.clone()).is_ok()); - assert!(denylisted_acl_with_null_recipient.eval(to_null_recipient_tx.clone()).is_ok()); - - assert!(denylisted_acl_with_null_recipient.eval(to_address_1_tx.clone()).is_err()); - - let empty_acl = Acl::<[u8; 20]>::default(); - - // should fail all txs - assert!(empty_acl.eval(to_address_1_tx).is_err()); - assert!(empty_acl.eval(to_address_2_tx).is_err()); - assert!(empty_acl.eval(to_address_3_tx).is_err()); - assert!(empty_acl.eval(to_null_recipient_tx).is_err()); -} diff --git a/crypto/server/Cargo.toml b/crypto/server/Cargo.toml index 4570a739e..ba9f57ff8 100644 --- a/crypto/server/Cargo.toml +++ b/crypto/server/Cargo.toml @@ -40,8 +40,7 @@ kvdb ={ path="../kvdb", default-features=false } entropy-protocol={ path="../protocol", features=["server"] } # Constraints -entropy-constraints={ path="../constraints" } -ec-runtime ={ git="ssh://git@github.com/entropyxyz/constraints.git", tag="v0.2.0" } +ec-runtime={ git="ssh://git@github.com/entropyxyz/constraints.git", tag="v0.2.0" } # Logging log ="0.4.17" # todo: remove, overlaps tracing diff --git a/crypto/server/entropy_metadata.scale b/crypto/server/entropy_metadata.scale index e55ec2d8f..e5255948d 100644 Binary files a/crypto/server/entropy_metadata.scale and b/crypto/server/entropy_metadata.scale differ diff --git a/crypto/server/src/chain_api.rs b/crypto/server/src/chain_api.rs index c8ed938f3..925c51fed 100644 --- a/crypto/server/src/chain_api.rs +++ b/crypto/server/src/chain_api.rs @@ -7,10 +7,6 @@ use subxt::{ #[subxt::subxt( runtime_metadata_path = "entropy_metadata.scale", - substitute_type( - path = "entropy_shared::constraints::acl::Acl
", - with = "::subxt::utils::Static<::entropy_shared::Acl
>", - ), substitute_type( path = "entropy_shared::types::KeyVisibility", with = "::subxt::utils::Static<::entropy_shared::KeyVisibility>", diff --git a/crypto/server/src/helpers/substrate.rs b/crypto/server/src/helpers/substrate.rs index d7d656ae9..f6a987f98 100644 --- a/crypto/server/src/helpers/substrate.rs +++ b/crypto/server/src/helpers/substrate.rs @@ -73,7 +73,7 @@ pub async fn get_program( rpc: &LegacyRpcMethods, sig_req_account: &::AccountId, ) -> Result, UserErr> { - let bytecode_address = entropy::storage().constraints().bytecode(sig_req_account); + let bytecode_address = entropy::storage().programs().bytecode(sig_req_account); let block_hash = rpc .chain_get_block_hash(None) .await? @@ -94,7 +94,7 @@ pub async fn make_register( api: &OnlineClient, rpc: &LegacyRpcMethods, sig_req_keyring: sr25519::Pair, - constraint_account: &AccountId32, + program_modification_account: &AccountId32, key_visibility: KeyVisibility, ) { use subxt::utils::Static; @@ -109,7 +109,7 @@ pub async fn make_register( // register the user let empty_program = vec![]; let registering_tx = entropy::tx().relayer().register( - constraint_account.clone(), + program_modification_account.clone(), Static(key_visibility), empty_program, ); diff --git a/crypto/server/src/helpers/tests.rs b/crypto/server/src/helpers/tests.rs index efc0500aa..3d3d4f259 100644 --- a/crypto/server/src/helpers/tests.rs +++ b/crypto/server/src/helpers/tests.rs @@ -148,20 +148,20 @@ pub async fn spawn_testing_validators( pub async fn update_programs( entropy_api: &OnlineClient, sig_req_keyring: &sr25519::Pair, - constraint_modification_account: &sr25519::Pair, + program_modification_account: &sr25519::Pair, initial_program: Vec, ) { - // update/set their constraints + // update/set their programs let update_program_tx = entropy::tx() - .constraints() + .programs() .update_program(SubxtAccountId32::from(sig_req_keyring.public()), initial_program); - let constraint_modification_account = - PairSigner::::new(constraint_modification_account.clone()); + let program_modification_account = + PairSigner::::new(program_modification_account.clone()); entropy_api .tx() - .sign_and_submit_then_watch_default(&update_program_tx, &constraint_modification_account) + .sign_and_submit_then_watch_default(&update_program_tx, &program_modification_account) .await .unwrap() .wait_for_in_block() diff --git a/crypto/server/src/signing_client/errors.rs b/crypto/server/src/signing_client/errors.rs index 3287bc215..58c52afbc 100644 --- a/crypto/server/src/signing_client/errors.rs +++ b/crypto/server/src/signing_client/errors.rs @@ -69,7 +69,7 @@ pub enum ProtocolErr { #[error("Encrypted connection error {0}")] EncryptedConnection(String), #[error("Program error: {0}")] - ProgramError(#[from] entropy_constraints::Error), + ProgramError(#[from] crate::user::errors::ProgramError), #[error("Invalid length for converting address")] AddressConversionError(String), #[error("Ip Address Error: {0}")] diff --git a/crypto/server/src/user/api.rs b/crypto/server/src/user/api.rs index 1ddd7ddea..63665eb33 100644 --- a/crypto/server/src/user/api.rs +++ b/crypto/server/src/user/api.rs @@ -11,14 +11,8 @@ use axum::{ use bip39::{Language, Mnemonic}; use blake2::{Blake2s256, Digest}; use ec_runtime::{InitialState, Runtime}; -use entropy_constraints::{ - Architecture, Error as ConstraintsError, Evaluate, Evm, GetReceiver, GetSender, Parse, -}; use entropy_protocol::ValidatorInfo; -use entropy_shared::{ - types::{Acl, AclKind, Arch, Constraints, KeyVisibility}, - OcwMessage, X25519PublicKey, SIGNING_PARTY_SIZE, -}; +use entropy_shared::{types::KeyVisibility, OcwMessage, X25519PublicKey, SIGNING_PARTY_SIZE}; use futures::{ channel::mpsc, future::{join_all, FutureExt}, @@ -45,7 +39,7 @@ use subxt::{ use tracing::instrument; use zeroize::Zeroize; -use super::{ParsedUserInputPartyInfo, UserErr, UserInputPartyInfo}; +use super::{ParsedUserInputPartyInfo, ProgramError, UserErr, UserInputPartyInfo}; use crate::{ chain_api::{ entropy::{self, runtime_types::pallet_relayer::pallet::RegisteringDetails}, diff --git a/crypto/server/src/user/errors.rs b/crypto/server/src/user/errors.rs index 4e9ba20f2..211b73e49 100644 --- a/crypto/server/src/user/errors.rs +++ b/crypto/server/src/user/errors.rs @@ -8,7 +8,6 @@ use axum::{ response::{IntoResponse, Response}, }; use ec_runtime::RuntimeError as ProgramRuntimeError; -use entropy_constraints::Error as ConstraintsError; use entropy_protocol::errors::ProtocolExecutionErr; use thiserror::Error; use tokio::sync::oneshot::error::RecvError; @@ -18,6 +17,17 @@ use crate::{ signing_client::{ProtocolErr, SubscribeErr}, }; +/// Errors related to parsing and evaulating programs. +#[derive(Error, Debug, PartialEq)] +pub enum ProgramError { + /// Transaction request could not be parsed + #[error("Invalid transaction request: {0}")] + InvalidTransactionRequest(String), + /// Transaction request did not meet programs requirements. + #[error("Program Evaluation error: {0}")] + Evaluation(&'static str), +} + #[derive(Debug, Error)] pub enum UserErr { #[error("Parse error: {0}")] @@ -46,8 +56,8 @@ pub enum UserErr { SubgroupError(&'static str), #[error("Invalid Signature: {0}")] InvalidSignature(&'static str), - #[error("Constraints error: {0}")] - ConstraintsError(#[from] ConstraintsError), + #[error("Program error: {0}")] + ProgramError(#[from] ProgramError), #[error("Signing/DKG protocol error: {0}")] SigningClientError(#[from] ProtocolErr), #[error("Transaction request unable to be deserialized: {0}")] diff --git a/crypto/server/src/user/tests.rs b/crypto/server/src/user/tests.rs index c14f584e9..e7c00d7ed 100644 --- a/crypto/server/src/user/tests.rs +++ b/crypto/server/src/user/tests.rs @@ -9,13 +9,12 @@ use std::{ use axum::http::StatusCode; use bip39::{Language, Mnemonic, MnemonicType}; -use entropy_constraints::{Architecture, Evm, Parse}; use entropy_protocol::{ protocol_transport::{noise::noise_handshake_initiator, SubscribeMessage, WsConnection}, user::{user_participates_in_dkg_protocol, user_participates_in_signing_protocol}, KeyParams, PartyId, ValidatorInfo, }; -use entropy_shared::{Acl, KeyVisibility, OcwMessage}; +use entropy_shared::{KeyVisibility, OcwMessage}; use futures::{ future::{self, join_all}, join, Future, SinkExt, StreamExt, @@ -272,10 +271,10 @@ async fn test_sign_tx_no_chain() { generic_msg.transaction_request = hex::encode(MESSAGE_SHOULD_FAIL); generic_msg.timestamp = SystemTime::now(); - let test_user_failed_constraints_res = + let test_user_failed_programs_res = submit_transaction_requests(validator_ips_and_keys.clone(), generic_msg.clone(), one).await; - for res in test_user_failed_constraints_res { + for res in test_user_failed_programs_res { assert_eq!( res.unwrap().text().await.unwrap(), "Runtime error: Runtime(Error::Evaluation(\"Length of data is too short.\"))" @@ -412,7 +411,7 @@ async fn test_fail_signing_group() { async fn test_store_share() { clean_tests(); let alice = AccountKeyring::Alice; - let alice_constraint = AccountKeyring::Charlie; + let alice_program = AccountKeyring::Charlie; let cxt = test_context_stationary().await; let (_validator_ips, _validator_ids, _) = spawn_testing_validators(None, false).await; @@ -439,7 +438,7 @@ async fn test_store_share() { put_register_request_on_chain( &api, &alice, - alice_constraint.to_account_id().into(), + alice_program.to_account_id().into(), KeyVisibility::Public, ) .await; @@ -508,8 +507,8 @@ async fn test_store_share() { block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number + 1; put_register_request_on_chain( &api, - &alice_constraint, - alice_constraint.to_account_id().into(), + &alice_program, + alice_program.to_account_id().into(), KeyVisibility::Public, ) .await; @@ -662,15 +661,18 @@ async fn test_recover_key() { pub async fn put_register_request_on_chain( api: &OnlineClient, sig_req_keyring: &Sr25519Keyring, - constraint_account: subxtAccountId32, + program_modification_account: subxtAccountId32, key_visibility: KeyVisibility, ) { let sig_req_account = PairSigner::::new(sig_req_keyring.pair()); let empty_program = vec![]; - let registering_tx = - entropy::tx().relayer().register(constraint_account, Static(key_visibility), empty_program); + let registering_tx = entropy::tx().relayer().register( + program_modification_account, + Static(key_visibility), + empty_program, + ); api.tx() .sign_and_submit_then_watch_default(®istering_tx, &sig_req_account) @@ -911,10 +913,10 @@ async fn test_sign_tx_user_participates() { generic_msg.transaction_request = hex::encode(MESSAGE_SHOULD_FAIL); generic_msg.timestamp = SystemTime::now(); - let test_user_failed_constraints_res = + let test_user_failed_programs_res = submit_transaction_requests(validator_ips_and_keys.clone(), generic_msg.clone(), one).await; - for res in test_user_failed_constraints_res { + for res in test_user_failed_programs_res { assert_eq!( res.unwrap().text().await.unwrap(), "Runtime error: Runtime(Error::Evaluation(\"Length of data is too short.\"))" @@ -1001,7 +1003,7 @@ async fn test_register_with_private_key_visibility() { clean_tests(); let one = AccountKeyring::One; - let constraint_account = AccountKeyring::Charlie; + let program_modification_account = AccountKeyring::Charlie; let (validator_ips, _validator_ids, _users_keyshare_option) = spawn_testing_validators(None, false).await; @@ -1016,7 +1018,7 @@ async fn test_register_with_private_key_visibility() { put_register_request_on_chain( &api, &one, - constraint_account.to_account_id().into(), + program_modification_account.to_account_id().into(), KeyVisibility::Private(x25519_public_key), ) .await; diff --git a/crypto/shared/src/constraints.rs b/crypto/shared/src/constraints.rs deleted file mode 100644 index 9e79c7517..000000000 --- a/crypto/shared/src/constraints.rs +++ /dev/null @@ -1,48 +0,0 @@ -pub use acl::*; -use codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; -use serde::{Deserialize, Serialize}; -use sp_std::{fmt::Debug, vec::Vec}; - -/// Supported architectures. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode, Serialize, Deserialize, TypeInfo)] -pub enum Arch { - Evm, - /// Not yet supported on the client, supported in Substrate storage/ACL - Btc, -} - -/// Represents a user's constraints -#[derive(Default, Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)] -pub struct Constraints { - pub evm_acl: Option>, - pub btc_acl: Option>, -} - -/// This includes common types and functions related to using ACL functionality. -mod acl { - use super::*; - - /// An access control list (Allow/Deny lists). - #[derive(Clone, Debug, Encode, Decode, PartialEq, Eq, scale_info::TypeInfo, MaxEncodedLen)] - pub struct Acl
{ - pub addresses: Vec
, - pub kind: AclKind, - pub allow_null_recipient: bool, - } - - /// Represents either an allow or deny list. - #[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode, TypeInfo, MaxEncodedLen)] - pub enum AclKind { - Allow, - Deny, - } - - /// Creates an empty ACL that always evaluates to false. - impl Default for Acl { - fn default() -> Self { - let addresses = Vec::::default(); - Self { addresses, kind: AclKind::Allow, allow_null_recipient: false } - } - } -} diff --git a/crypto/shared/src/lib.rs b/crypto/shared/src/lib.rs index 74aa51740..0bd3895e3 100644 --- a/crypto/shared/src/lib.rs +++ b/crypto/shared/src/lib.rs @@ -3,10 +3,8 @@ //! i.e. messages sent from one to the other and structs contained in those messages //! //! This helps ensures those structs are synced among clients and nodes. -pub use constraints::*; pub use types::*; -pub mod constraints; pub mod types; pub const SIGNING_PARTY_SIZE: usize = 2; diff --git a/crypto/shared/src/types.rs b/crypto/shared/src/types.rs index cd6b17fa0..02052b48d 100644 --- a/crypto/shared/src/types.rs +++ b/crypto/shared/src/types.rs @@ -10,9 +10,6 @@ use scale_info::TypeInfo; #[cfg(feature = "std")] use serde::{Deserialize, Serialize}; -#[cfg(feature = "std")] -/// common structs etc, shared among the substrate-blockchain-code and the crypto-code -pub use crate::constraints::*; /// X25519 public key used by the client in non-interactive ECDH to authenticate/encrypt /// interactions with the threshold server (eg distributing threshold shares). pub type X25519PublicKey = [u8; 32]; diff --git a/crypto/testing-utils/src/chain_api.rs b/crypto/testing-utils/src/chain_api.rs index 5d6ebf30e..57d4e00b6 100644 --- a/crypto/testing-utils/src/chain_api.rs +++ b/crypto/testing-utils/src/chain_api.rs @@ -1,11 +1,5 @@ #![allow(clippy::all)] pub use subxt::config::PolkadotConfig as EntropyConfig; -#[subxt::subxt( - runtime_metadata_path = "../server/entropy_metadata.scale", - substitute_type( - path = "entropy_shared::constraints::acl::Acl
", - with = "::subxt::utils::Static<::entropy_shared::Acl
>", - ) -)] +#[subxt::subxt(runtime_metadata_path = "../server/entropy_metadata.scale")] pub mod entropy {} diff --git a/pallets/constraints/Cargo.toml b/pallets/programs/Cargo.toml similarity index 98% rename from pallets/constraints/Cargo.toml rename to pallets/programs/Cargo.toml index d417d80cf..ff9a3f9a1 100644 --- a/pallets/constraints/Cargo.toml +++ b/pallets/programs/Cargo.toml @@ -4,7 +4,7 @@ description='FRAME pallet template for defining custom runtime logic.' edition ='2021' homepage ='https://substrate.dev' license ='AGPL-3.0-or-later' -name ='pallet-constraints' +name ='pallet-programs' publish =false readme ='README.md' repository ='https://github.com/substrate-developer-hub/substrate-node-template/' diff --git a/pallets/constraints/README.md b/pallets/programs/README.md similarity index 100% rename from pallets/constraints/README.md rename to pallets/programs/README.md diff --git a/pallets/constraints/src/benchmarking.rs b/pallets/programs/src/benchmarking.rs similarity index 91% rename from pallets/constraints/src/benchmarking.rs rename to pallets/programs/src/benchmarking.rs index ed99917a1..7ea0f953f 100644 --- a/pallets/constraints/src/benchmarking.rs +++ b/pallets/programs/src/benchmarking.rs @@ -7,7 +7,7 @@ use sp_runtime::Saturating; use super::*; #[allow(unused)] -use crate::Pallet as ConstraintsPallet; +use crate::Pallet as ProgramsPallet; type CurrencyOf = ::Currency; @@ -41,4 +41,4 @@ benchmarks! { } } -impl_benchmark_test_suite!(ConstraintsPallet, crate::mock::new_test_ext(), crate::mock::Test); +impl_benchmark_test_suite!(ProgramsPallet, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/pallets/constraints/src/lib.rs b/pallets/programs/src/lib.rs similarity index 99% rename from pallets/constraints/src/lib.rs rename to pallets/programs/src/lib.rs index 22c01335d..0375c2464 100644 --- a/pallets/constraints/src/lib.rs +++ b/pallets/programs/src/lib.rs @@ -1,4 +1,4 @@ -//! # Constraints Pallet +//! # Programs Pallet //! //! ## Overview //! diff --git a/pallets/constraints/src/mock.rs b/pallets/programs/src/mock.rs similarity index 95% rename from pallets/constraints/src/mock.rs rename to pallets/programs/src/mock.rs index 80439ccf6..87d3c05eb 100644 --- a/pallets/constraints/src/mock.rs +++ b/pallets/programs/src/mock.rs @@ -6,7 +6,7 @@ use sp_runtime::{ BuildStorage, }; -use crate as pallet_constraints; +use crate as pallet_programs; type Block = frame_system::mocking::MockBlock; @@ -15,7 +15,7 @@ frame_support::construct_runtime!( pub enum Test { System: frame_system, - ConstraintsPallet: pallet_constraints, + ProgramsPallet: pallet_programs, Balances: pallet_balances, } ); @@ -76,7 +76,7 @@ impl pallet_balances::Config for Test { type WeightInfo = (); } -impl pallet_constraints::Config for Test { +impl pallet_programs::Config for Test { type Currency = Balances; type MaxBytecodeLength = MaxBytecodeLength; type ProgramDepositPerByte = ProgramDepositPerByte; diff --git a/pallets/constraints/src/tests.rs b/pallets/programs/src/tests.rs similarity index 84% rename from pallets/constraints/src/tests.rs rename to pallets/programs/src/tests.rs index 98f5c1c36..263e2c824 100644 --- a/pallets/constraints/src/tests.rs +++ b/pallets/programs/src/tests.rs @@ -16,7 +16,7 @@ fn set_programs() { // make sure no one can add a program without explicit permissions assert_noop!( - ConstraintsPallet::update_program( + ProgramsPallet::update_program( RuntimeOrigin::signed(PROGRAM_MODIFICATION_ACCOUNT), SIG_REQ_ACCOUNT, program.clone(), @@ -28,7 +28,7 @@ fn set_programs() { // can't pay deposit assert_noop!( - ConstraintsPallet::update_program( + ProgramsPallet::update_program( RuntimeOrigin::signed(PROGRAM_MODIFICATION_ACCOUNT), SIG_REQ_ACCOUNT, program.clone(), @@ -39,23 +39,23 @@ fn set_programs() { Balances::make_free_balance_be(&PROGRAM_MODIFICATION_ACCOUNT, 100); // It's okay to have an empty program - assert_ok!(ConstraintsPallet::update_program( + assert_ok!(ProgramsPallet::update_program( RuntimeOrigin::signed(PROGRAM_MODIFICATION_ACCOUNT), SIG_REQ_ACCOUNT, empty_program.clone() )); - assert_ok!(ConstraintsPallet::update_program( + assert_ok!(ProgramsPallet::update_program( RuntimeOrigin::signed(PROGRAM_MODIFICATION_ACCOUNT), SIG_REQ_ACCOUNT, program.clone() )); - assert_eq!(ConstraintsPallet::bytecode(SIG_REQ_ACCOUNT).unwrap(), program); + assert_eq!(ProgramsPallet::bytecode(SIG_REQ_ACCOUNT).unwrap(), program); assert_eq!(Balances::free_balance(PROGRAM_MODIFICATION_ACCOUNT), 90); // deposit refunded partial - assert_ok!(ConstraintsPallet::update_program( + assert_ok!(ProgramsPallet::update_program( RuntimeOrigin::signed(PROGRAM_MODIFICATION_ACCOUNT), SIG_REQ_ACCOUNT, vec![10u8] @@ -63,7 +63,7 @@ fn set_programs() { assert_eq!(Balances::free_balance(PROGRAM_MODIFICATION_ACCOUNT), 95); // deposit refunded full - assert_ok!(ConstraintsPallet::update_program( + assert_ok!(ProgramsPallet::update_program( RuntimeOrigin::signed(PROGRAM_MODIFICATION_ACCOUNT), SIG_REQ_ACCOUNT, vec![] @@ -71,7 +71,7 @@ fn set_programs() { assert_eq!(Balances::free_balance(PROGRAM_MODIFICATION_ACCOUNT), 100); assert_noop!( - ConstraintsPallet::update_program( + ProgramsPallet::update_program( RuntimeOrigin::signed(PROGRAM_MODIFICATION_ACCOUNT), SIG_REQ_ACCOUNT, too_long, diff --git a/pallets/constraints/src/weights.rs b/pallets/programs/src/weights.rs similarity index 66% rename from pallets/constraints/src/weights.rs rename to pallets/programs/src/weights.rs index 259f82e83..480e7b0c8 100644 --- a/pallets/constraints/src/weights.rs +++ b/pallets/programs/src/weights.rs @@ -1,5 +1,5 @@ -//! Autogenerated weights for pallet_constraints +//! Autogenerated weights for pallet_programs //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-13, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -16,7 +16,7 @@ // --execution=wasm // --wasm-execution=compiled // --pallet -// pallet_constraints +// pallet_programs // --extrinsic // * // --steps @@ -26,7 +26,7 @@ // --template // frame-weight-template.hbs // --output -// pallets/constraints/src/weights.rs +// pallets/programs/src/weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -36,18 +36,18 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weight functions needed for pallet_constraints. +/// Weight functions needed for pallet_programs. pub trait WeightInfo { fn update_program() -> Weight; } -/// Weights for pallet_constraints using the Substrate node and recommended hardware. +/// Weights for pallet_programs using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Constraints AllowedToModifyConstraints (r:1 w:0) - /// Proof Skipped: Constraints AllowedToModifyConstraints (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints Bytecode (r:1 w:1) - /// Proof Skipped: Constraints Bytecode (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs AllowedToModifyPrograms (r:1 w:0) + /// Proof Skipped: Programs AllowedToModifyPrograms (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs Bytecode (r:1 w:1) + /// Proof Skipped: Programs Bytecode (max_values: None, max_size: None, mode: Measured) fn update_program() -> Weight { // Proof Size summary in bytes: // Measured: `236` @@ -61,10 +61,10 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Constraints AllowedToModifyConstraints (r:1 w:0) - /// Proof Skipped: Constraints AllowedToModifyConstraints (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints Bytecode (r:1 w:1) - /// Proof Skipped: Constraints Bytecode (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs AllowedToModifyPrograms (r:1 w:0) + /// Proof Skipped: Programs AllowedToModifyPrograms (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs Bytecode (r:1 w:1) + /// Proof Skipped: Programs Bytecode (max_values: None, max_size: None, mode: Measured) fn update_program() -> Weight { // Proof Size summary in bytes: // Measured: `236` diff --git a/pallets/propagation/Cargo.toml b/pallets/propagation/Cargo.toml index be6fd95ad..9df0ce831 100644 --- a/pallets/propagation/Cargo.toml +++ b/pallets/propagation/Cargo.toml @@ -41,7 +41,7 @@ version ='4.0.0-dev' [dependencies] pallet-authorship ={ version="4.0.0-dev", default-features=false, git='https://github.com/paritytech/substrate.git', branch="polkadot-v1.0.0" } pallet-relayer ={ version="3.0.0", default-features=false, path="../relayer" } -pallet-constraints ={ default-features=false, path="../constraints" } +pallet-programs ={ default-features=false, path="../programs" } pallet-staking-extension={ version="3.0.0", default-features=false, path="../staking" } scale-info ={ version="2.0.1", default-features=false, features=["derive"] } @@ -80,7 +80,7 @@ std=[ 'frame-benchmarking/std', 'pallet-authorship/std', 'pallet-staking-extension/std', - 'pallet-constraints/std', + 'pallet-programs/std', 'pallet-balances/std', 'pallet-babe/std', 'pallet-relayer/std', diff --git a/pallets/propagation/src/mock.rs b/pallets/propagation/src/mock.rs index d9e4a2822..0b1a52dce 100644 --- a/pallets/propagation/src/mock.rs +++ b/pallets/propagation/src/mock.rs @@ -33,7 +33,7 @@ frame_support::construct_runtime!( Timestamp: pallet_timestamp, Authorship: pallet_authorship, Relayer: pallet_relayer, - Constraints: pallet_constraints, + Programs: pallet_programs, Propagation: pallet_propagation, Staking: pallet_staking_extension, FrameStaking: pallet_staking, @@ -301,7 +301,7 @@ parameter_types! { pub const ProgramDepositPerByte: u32 = 5; } -impl pallet_constraints::Config for Test { +impl pallet_programs::Config for Test { type Currency = (); type MaxBytecodeLength = MaxBytecodeLength; type ProgramDepositPerByte = ProgramDepositPerByte; diff --git a/pallets/relayer/Cargo.toml b/pallets/relayer/Cargo.toml index f408d4b5a..7bccb3c54 100644 --- a/pallets/relayer/Cargo.toml +++ b/pallets/relayer/Cargo.toml @@ -66,10 +66,10 @@ entropy-shared ={ path="../../crypto/shared", default-features=false, f sp-std ={ package="sp-std", git="https://github.com/paritytech/substrate", branch="polkadot-v1.0.0", default-features=false } pallet-authorship ={ version="4.0.0-dev", default-features=false, git='https://github.com/paritytech/substrate.git', branch="polkadot-v1.0.0" } log ={ version="0.4.0", default-features=false } -pallet-staking-extension={ version="3.0.0", default-features=false, path="../staking" } -pallet-constraints ={ path="../constraints", default-features=false } -pallet-staking ={ version="4.0.0-dev", default-features=false, git='https://github.com/paritytech/substrate.git', branch="polkadot-v1.0.0" } +pallet-programs ={ path="../programs", default-features=false } pallet-session ={ version="4.0.0-dev", default-features=false, git='https://github.com/paritytech/substrate.git', branch="polkadot-v1.0.0" } +pallet-staking ={ version="4.0.0-dev", default-features=false, git='https://github.com/paritytech/substrate.git', branch="polkadot-v1.0.0" } +pallet-staking-extension={ version="3.0.0", default-features=false, path="../staking" } [dev-dependencies] pallet-balances ={ version="4.0.0-dev", default-features=false, git='https://github.com/paritytech/substrate.git', branch="polkadot-v1.0.0" } @@ -90,7 +90,7 @@ std=[ 'frame-system/std', 'frame-benchmarking/std', 'pallet-balances/std', - 'pallet-constraints/std', + 'pallet-programs/std', 'pallet-staking-extension/std', "sp-std/std", "sp-runtime/std", @@ -99,7 +99,7 @@ std=[ default=['std'] runtime-benchmarks=[ 'frame-benchmarking', - 'pallet-constraints/runtime-benchmarks', + 'pallet-programs/runtime-benchmarks', 'pallet-staking-extension/runtime-benchmarks', ] try-runtime=['frame-support/try-runtime'] diff --git a/pallets/relayer/src/benchmarking.rs b/pallets/relayer/src/benchmarking.rs index b9d355327..4d022ddf0 100644 --- a/pallets/relayer/src/benchmarking.rs +++ b/pallets/relayer/src/benchmarking.rs @@ -53,12 +53,12 @@ benchmarks! { register { // Since we're usually using `steps >> 1` when running benches this shouldn't take too long to // run - let p in 0..::MaxBytecodeLength::get(); + let p in 0..::MaxBytecodeLength::get(); let program = vec![0u8; p as usize]; - let constraint_account: T::AccountId = whitelisted_caller(); + let program_modification_account: T::AccountId = whitelisted_caller(); let sig_req_account: T::AccountId = whitelisted_caller(); - }: _(RawOrigin::Signed(sig_req_account.clone()), constraint_account, KeyVisibility::Public, program) + }: _(RawOrigin::Signed(sig_req_account.clone()), program_modification_account, KeyVisibility::Public, program) verify { assert_last_event::(Event::SignalRegister(sig_req_account.clone()).into()); assert!(Registering::::contains_key(sig_req_account)); diff --git a/pallets/relayer/src/lib.rs b/pallets/relayer/src/lib.rs index e62ade50e..2df1d6ef1 100644 --- a/pallets/relayer/src/lib.rs +++ b/pallets/relayer/src/lib.rs @@ -45,7 +45,7 @@ pub mod pallet { traits::{ConstU32, IsSubType}, }; use frame_system::pallet_prelude::*; - use pallet_constraints::{AllowedToModifyProgram, Pallet as ConstraintsPallet}; + use pallet_programs::{AllowedToModifyProgram, Pallet as ProgramsPallet}; use pallet_staking_extension::ServerInfo; use scale_info::TypeInfo; use sp_runtime::traits::{DispatchInfoOf, SignedExtension}; @@ -59,7 +59,7 @@ pub mod pallet { + frame_system::Config + pallet_authorship::Config + pallet_staking_extension::Config - + pallet_constraints::Config + + pallet_programs::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -190,7 +190,7 @@ pub mod pallet { ) -> DispatchResult { let sig_req_account = ensure_signed(origin)?; - // Ensure account isn't already registered or has existing constraints + // Ensure account isn't already registered or has existing programs ensure!(!Registered::::contains_key(&sig_req_account), Error::::AlreadySubmitted); ensure!( !Registering::::contains_key(&sig_req_account), @@ -199,13 +199,13 @@ pub mod pallet { ensure!( initial_program.len() as u32 - <= ::MaxBytecodeLength::get(), + <= ::MaxBytecodeLength::get(), Error::::MaxProgramLengthExceeded, ); // We take a storage deposit here based off the program length. This can be returned to - // the user if they clear the program from storage using the Constraints pallet. - ConstraintsPallet::::reserve_program_deposit( + // the user if they clear the program from storage using the Programs pallet. + ProgramsPallet::::reserve_program_deposit( &program_modification_account, initial_program.len(), )?; @@ -292,7 +292,7 @@ pub mod pallet { (), ); - ConstraintsPallet::::set_program_unchecked( + ProgramsPallet::::set_program_unchecked( &sig_req_account, registering_info.program, )?; diff --git a/pallets/relayer/src/mock.rs b/pallets/relayer/src/mock.rs index 82f041d5c..d6942603e 100644 --- a/pallets/relayer/src/mock.rs +++ b/pallets/relayer/src/mock.rs @@ -37,7 +37,7 @@ frame_support::construct_runtime!( Session: pallet_session, Historical: pallet_session_historical, BagsList: pallet_bags_list, - Constraints: pallet_constraints, + Programs: pallet_programs, } ); @@ -299,7 +299,7 @@ parameter_types! { pub const ProgramDepositPerByte: u32 = 5; } -impl pallet_constraints::Config for Test { +impl pallet_programs::Config for Test { type Currency = Balances; type MaxBytecodeLength = MaxBytecodeLength; type ProgramDepositPerByte = ProgramDepositPerByte; diff --git a/pallets/relayer/src/tests.rs b/pallets/relayer/src/tests.rs index 2022409fb..2da533f32 100644 --- a/pallets/relayer/src/tests.rs +++ b/pallets/relayer/src/tests.rs @@ -5,7 +5,7 @@ use frame_support::{ dispatch::{GetDispatchInfo, Pays}, BoundedVec, }; -use pallet_constraints::AllowedToModifyProgram; +use pallet_programs::AllowedToModifyProgram; use pallet_relayer::Call as RelayerCall; use sp_runtime::{ traits::SignedExtension, @@ -87,7 +87,7 @@ fn it_takes_a_program_storage_deposit_during_register() { program.clone(), )); - let expected_reserve = ::ProgramDepositPerByte::get() + let expected_reserve = ::ProgramDepositPerByte::get() * (program.len() as u32); assert_eq!( @@ -172,7 +172,7 @@ fn it_confirms_registers_a_user() { } ); - // make sure constraint and sig req keys are set + // make sure program and sig req keys are set assert!(AllowedToModifyProgram::::contains_key(2, 1)); }); } @@ -189,7 +189,7 @@ fn it_doesnt_allow_double_registering() { empty_program, )); - // error if they try to submit another request, even with a different constraint key + // error if they try to submit another request, even with a different program key assert_noop!( Relayer::register(RuntimeOrigin::signed(1), 2, KeyVisibility::Permissioned, vec![]), Error::::AlreadySubmitted diff --git a/pallets/relayer/src/weights.rs b/pallets/relayer/src/weights.rs index f3b7b875b..8765c2c1e 100644 --- a/pallets/relayer/src/weights.rs +++ b/pallets/relayer/src/weights.rs @@ -88,10 +88,10 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: StakingExtension SigningGroups (max_values: None, max_size: None, mode: Measured) /// Storage: Relayer Registered (r:0 w:1) /// Proof Skipped: Relayer Registered (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints V2Bytecode (r:0 w:1) - /// Proof Skipped: Constraints V2Bytecode (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints AllowedToModifyConstraints (r:0 w:1) - /// Proof Skipped: Constraints AllowedToModifyConstraints (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs V2Bytecode (r:0 w:1) + /// Proof Skipped: Programs V2Bytecode (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs AllowedToModifyPrograms (r:0 w:1) + /// Proof Skipped: Programs AllowedToModifyPrograms (max_values: None, max_size: None, mode: Measured) /// The range of component `c` is `[0, 2]`. fn confirm_register_registered(_c: u32, ) -> Weight { // Proof Size summary in bytes: @@ -148,10 +148,10 @@ impl WeightInfo for () { /// Proof Skipped: StakingExtension SigningGroups (max_values: None, max_size: None, mode: Measured) /// Storage: Relayer Registered (r:0 w:1) /// Proof Skipped: Relayer Registered (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints V2Bytecode (r:0 w:1) - /// Proof Skipped: Constraints V2Bytecode (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints AllowedToModifyConstraints (r:0 w:1) - /// Proof Skipped: Constraints AllowedToModifyConstraints (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs V2Bytecode (r:0 w:1) + /// Proof Skipped: Programs V2Bytecode (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs AllowedToModifyPrograms (r:0 w:1) + /// Proof Skipped: Programs AllowedToModifyPrograms (max_values: None, max_size: None, mode: Measured) /// The range of component `c` is `[0, 2]`. fn confirm_register_registered(_c: u32, ) -> Weight { // Proof Size summary in bytes: diff --git a/pallets/transaction-pause/Cargo.toml b/pallets/transaction-pause/Cargo.toml index 756eb7d68..3378805e2 100644 --- a/pallets/transaction-pause/Cargo.toml +++ b/pallets/transaction-pause/Cargo.toml @@ -13,11 +13,11 @@ frame-system ={ git="https://github.com/paritytech/substrate", branch="polk sp-std ={ git="https://github.com/paritytech/substrate", branch="polkadot-v1.0.0", default-features=false } [dev-dependencies] -sp-core ={ version="21.0.0", git="https://github.com/paritytech/substrate", branch="polkadot-v1.0.0" } -sp-io ={ git="https://github.com/paritytech/substrate", branch="polkadot-v1.0.0" } -pallet-balances ={ git="https://github.com/paritytech/substrate", branch="polkadot-v1.0.0" } -smallvec ="1.4.1" -pallet-constraints={ version="3.0.0-monthly-2021-10", default-features=false, path="../constraints" } +pallet-balances={ git="https://github.com/paritytech/substrate", branch="polkadot-v1.0.0" } +pallet-programs={ version="3.0.0-monthly-2021-10", default-features=false, path="../programs" } +smallvec ="1.4.1" +sp-core ={ version="21.0.0", git="https://github.com/paritytech/substrate", branch="polkadot-v1.0.0" } +sp-io ={ git="https://github.com/paritytech/substrate", branch="polkadot-v1.0.0" } [features] default=["std"] @@ -31,7 +31,7 @@ std=[ "sp-runtime/std", "frame-support/std", "frame-system/std", - "pallet-constraints/std", + "pallet-programs/std", "sp-std/std", ] try-runtime=["frame-support/try-runtime"] diff --git a/pallets/transaction-pause/src/mock.rs b/pallets/transaction-pause/src/mock.rs index 1fdebe2cc..83c00ab77 100644 --- a/pallets/transaction-pause/src/mock.rs +++ b/pallets/transaction-pause/src/mock.rs @@ -85,7 +85,7 @@ parameter_types! { pub const ProgramDepositPerByte: u32 = 5; } -impl pallet_constraints::Config for Runtime { +impl pallet_programs::Config for Runtime { type Currency = (); type MaxBytecodeLength = MaxBytecodeLength; type ProgramDepositPerByte = ProgramDepositPerByte; @@ -110,7 +110,7 @@ construct_runtime!( System: frame_system, TransactionPause: transaction_pause, Balances: pallet_balances, - ConstraintsPallet: pallet_constraints, + ProgramsPallet: pallet_programs, } ); diff --git a/pallets/transaction-pause/src/tests.rs b/pallets/transaction-pause/src/tests.rs index 52da06bb6..2e501f789 100644 --- a/pallets/transaction-pause/src/tests.rs +++ b/pallets/transaction-pause/src/tests.rs @@ -133,7 +133,7 @@ fn unpause_transaction_work() { fn paused_transaction_filter_work() { ExtBuilder::default().build().execute_with(|| { let whitelist_address_call = - &mock::RuntimeCall::ConstraintsPallet(pallet_constraints::Call::update_program { + &mock::RuntimeCall::ProgramsPallet(pallet_programs::Call::update_program { sig_req_account: ALICE, new_program: vec![], }); @@ -146,7 +146,7 @@ fn paused_transaction_filter_work() { )); assert_ok!(TransactionPause::pause_transaction( RuntimeOrigin::signed(1), - b"ConstraintsPallet".to_vec(), + b"ProgramsPallet".to_vec(), b"update_program".to_vec() )); @@ -159,7 +159,7 @@ fn paused_transaction_filter_work() { )); assert_ok!(TransactionPause::unpause_transaction( RuntimeOrigin::signed(1), - b"ConstraintsPallet".to_vec(), + b"ProgramsPallet".to_vec(), b"update_program".to_vec() )); diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 440d22fc9..1bdab92e6 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -102,7 +102,7 @@ pallet-vesting={ version="4.0.0-dev", default-features=false, git='https://githu pallet-relayer ={ version='3.0.0-monthly-2021-10', default-features=false, path='../pallets/relayer' } pallet-slashing ={ version='3.0.0-monthly-2021-10', default-features=false, path='../pallets/slashing' } -pallet-constraints ={ version='3.0.0-monthly-2021-10', default-features=false, path='../pallets/constraints' } +pallet-programs ={ version='3.0.0-monthly-2021-10', default-features=false, path='../pallets/programs' } pallet-staking-extension={ version='3.0.0-monthly-2021-10', default-features=false, path='../pallets/staking' } pallet-transaction-pause={ version='3.0.0-monthly-2021-10', default-features=false, path='../pallets/transaction-pause' } pallet-free-tx ={ version='3.0.0-monthly-2021-10', default-features=false, path='../pallets/free-tx' } @@ -130,7 +130,7 @@ std=[ "codec/std", "scale-info/std", "pallet-collective/std", - "pallet-constraints/std", + "pallet-programs/std", "pallet-conviction-voting/std", "pallet-democracy/std", "pallet-elections-phragmen/std", @@ -206,7 +206,7 @@ runtime-benchmarks=[ "pallet-bags-list/runtime-benchmarks", "pallet-bounties/runtime-benchmarks", "pallet-collective/runtime-benchmarks", - "pallet-constraints/runtime-benchmarks", + "pallet-programs/runtime-benchmarks", "pallet-nomination-pools-benchmarking/runtime-benchmarks", "pallet-conviction-voting/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 129287dcd..9611524fe 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1256,12 +1256,12 @@ parameter_types! { pub const ProgramDepositPerByte: Balance = MILLICENTS; } -impl pallet_constraints::Config for Runtime { +impl pallet_programs::Config for Runtime { type Currency = Balances; type MaxBytecodeLength = MaxBytecodeLength; type ProgramDepositPerByte = ProgramDepositPerByte; type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::pallet_constraints::WeightInfo; + type WeightInfo = weights::pallet_programs::WeightInfo; } impl pallet_transaction_pause::Config for Runtime { @@ -1336,7 +1336,7 @@ construct_runtime!( // custom pallets Relayer: pallet_relayer = 51, Slashing: pallet_slashing = 52, - Constraints: pallet_constraints = 53, + Programs: pallet_programs = 53, TransactionPause: pallet_transaction_pause = 54, FreeTx: pallet_free_tx = 55, Propagation: pallet_propagation = 56, @@ -1404,7 +1404,7 @@ mod benches { [pallet_balances, Balances] [pallet_bounties, Bounties] [pallet_collective, Council] - [pallet_constraints, Constraints] + [pallet_programs, Programs] [pallet_democracy, Democracy] [pallet_election_provider_multi_phase, ElectionProviderMultiPhase] [pallet_election_provider_support_benchmarking, EPSBench::] diff --git a/runtime/src/weights/mod.rs b/runtime/src/weights/mod.rs index a61892831..16f9dabfd 100644 --- a/runtime/src/weights/mod.rs +++ b/runtime/src/weights/mod.rs @@ -1,5 +1,5 @@ -pub mod pallet_constraints; pub mod pallet_free_tx; +pub mod pallet_programs; pub mod pallet_relayer; pub mod pallet_staking_extension; pub mod pallet_transaction_pause; diff --git a/runtime/src/weights/pallet_constraints.rs b/runtime/src/weights/pallet_programs.rs similarity index 69% rename from runtime/src/weights/pallet_constraints.rs rename to runtime/src/weights/pallet_programs.rs index 962b6f532..043b06981 100644 --- a/runtime/src/weights/pallet_constraints.rs +++ b/runtime/src/weights/pallet_programs.rs @@ -1,6 +1,6 @@ #![allow(clippy::all)] -//! Autogenerated weights for `pallet_constraints` +//! Autogenerated weights for `pallet_programs` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-13, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -16,7 +16,7 @@ // dev // --execution=wasm // --wasm-execution=compiled -// --pallet=pallet_constraints +// --pallet=pallet_programs // --extrinsic=* // --steps=50 // --repeat=20 @@ -31,13 +31,13 @@ use frame_support::{traits::Get, weights::Weight}; use core::marker::PhantomData; -/// Weight functions for `pallet_constraints`. +/// Weight functions for `pallet_programs`. pub struct WeightInfo(PhantomData); -impl pallet_constraints::WeightInfo for WeightInfo { - /// Storage: Constraints AllowedToModifyConstraints (r:1 w:0) - /// Proof Skipped: Constraints AllowedToModifyConstraints (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints Bytecode (r:1 w:1) - /// Proof Skipped: Constraints Bytecode (max_values: None, max_size: None, mode: Measured) +impl pallet_programs::WeightInfo for WeightInfo { + /// Storage: Programs AllowedToModifyPrograms (r:1 w:0) + /// Proof Skipped: Programs AllowedToModifyPrograms (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs Bytecode (r:1 w:1) + /// Proof Skipped: Programs Bytecode (max_values: None, max_size: None, mode: Measured) fn update_program() -> Weight { // Proof Size summary in bytes: // Measured: `236` diff --git a/runtime/src/weights/pallet_relayer.rs b/runtime/src/weights/pallet_relayer.rs index 253207fd0..a90b102e9 100644 --- a/runtime/src/weights/pallet_relayer.rs +++ b/runtime/src/weights/pallet_relayer.rs @@ -80,10 +80,10 @@ impl pallet_relayer::WeightInfo for WeightInfo { /// Proof Skipped: StakingExtension SigningGroups (max_values: None, max_size: None, mode: Measured) /// Storage: Relayer Registered (r:0 w:1) /// Proof Skipped: Relayer Registered (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints V2Bytecode (r:0 w:1) - /// Proof Skipped: Constraints V2Bytecode (max_values: None, max_size: None, mode: Measured) - /// Storage: Constraints AllowedToModifyConstraints (r:0 w:1) - /// Proof Skipped: Constraints AllowedToModifyConstraints (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs V2Bytecode (r:0 w:1) + /// Proof Skipped: Programs V2Bytecode (max_values: None, max_size: None, mode: Measured) + /// Storage: Programs AllowedToModifyPrograms (r:0 w:1) + /// Proof Skipped: Programs AllowedToModifyPrograms (max_values: None, max_size: None, mode: Measured) /// The range of component `c` is `[0, 2]`. fn confirm_register_registered(c: u32, ) -> Weight { // Proof Size summary in bytes: diff --git a/scripts/benchmarks.sh b/scripts/benchmarks.sh index 288d51d9b..7f507dfcd 100755 --- a/scripts/benchmarks.sh +++ b/scripts/benchmarks.sh @@ -7,22 +7,21 @@ entropyChain=dev pallets=( pallet_relayer pallet_staking_extension - pallet_constraints + pallet_programs pallet_transaction_pause pallet_free_tx ) for p in ${pallets[@]} do - ./target/release/entropy benchmark pallet \ - --chain $entropyChain \ - --execution=wasm \ - --wasm-execution=compiled \ - --pallet=$p \ - --extrinsic='*' \ - --steps=$steps \ - --repeat=$repeat \ - --header=./file_header.txt \ - --output=$entropyOutput - + ./target/release/entropy benchmark pallet \ + --chain $entropyChain \ + --execution=wasm \ + --wasm-execution=compiled \ + --pallet=$p \ + --extrinsic='*' \ + --steps=$steps \ + --repeat=$repeat \ + --header=./file_header.txt \ + --output=$entropyOutput done