diff --git a/Cargo.lock b/Cargo.lock index 3b8dea8..04909c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -117,7 +117,6 @@ name = "aga-node" version = "0.0.0" dependencies = [ "aga-runtime", - "bs58 0.5.1", "clap", "frame-benchmarking-cli", "frame-system", @@ -181,10 +180,8 @@ dependencies = [ "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", - "log", "pallet-asset-conversion", "pallet-asset-conversion-tx-payment", - "pallet-asset-rate", "pallet-assets", "pallet-aura", "pallet-authorship", @@ -192,7 +189,6 @@ dependencies = [ "pallet-contracts", "pallet-grandpa", "pallet-insecure-randomness-collective-flip", - "pallet-node-authorization", "pallet-session", "pallet-sudo", "pallet-template", @@ -213,7 +209,6 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-staking", "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", "sp-storage 19.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", "sp-transaction-pool", @@ -355,7 +350,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d1da02abba9f9063d786eab1509833ebb2fac0f966862ca59439c76b9c566760" dependencies = [ "include_dir", - "itertools 0.10.5", + "itertools", "proc-macro-error", "proc-macro2", "quote", @@ -369,7 +364,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21cc1548309245035eb18aa7f0967da6bc65587005170c56e6ef2788a4cf3f4e" dependencies = [ "include_dir", - "itertools 0.10.5", + "itertools", "proc-macro-error", "proc-macro2", "quote", @@ -382,9 +377,9 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb00293ba84f51ce3bd026bd0de55899c4e68f0a39a5728cebae3a73ffdc0a4f" dependencies = [ - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-std 0.4.0", + "ark-ec", + "ark-ff", + "ark-std", ] [[package]] @@ -394,9 +389,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20c7021f180a0cbea0380eba97c2af3c57074cdaffe0eef7e840e1c9f2841e55" dependencies = [ "ark-bls12-377", - "ark-ec 0.4.2", + "ark-ec", "ark-models-ext", - "ark-std 0.4.0", + "ark-std", ] [[package]] @@ -405,10 +400,10 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" dependencies = [ - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", ] [[package]] @@ -418,11 +413,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1dc4b3d08f19e8ec06e949712f95b8361e43f1391d94f65e4234df03480631c" dependencies = [ "ark-bls12-381", - "ark-ec 0.4.2", - "ark-ff 0.4.2", + "ark-ec", + "ark-ff", "ark-models-ext", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-serialize", + "ark-std", ] [[package]] @@ -432,9 +427,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e0605daf0cc5aa2034b78d008aaf159f56901d92a52ee4f6ecdfdac4f426700" dependencies = [ "ark-bls12-377", - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-std 0.4.0", + "ark-ec", + "ark-ff", + "ark-std", ] [[package]] @@ -444,10 +439,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccee5fba47266f460067588ee1bf070a9c760bf2050c1c509982c5719aadb4f2" dependencies = [ "ark-bw6-761", - "ark-ec 0.4.2", - "ark-ff 0.4.2", + "ark-ec", + "ark-ff", "ark-models-ext", - "ark-std 0.4.0", + "ark-std", ] [[package]] @@ -456,39 +451,18 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ - "ark-ff 0.4.2", - "ark-poly 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", "derivative", "hashbrown 0.13.2", - "itertools 0.10.5", + "itertools", "num-traits", "rayon", "zeroize", ] -[[package]] -name = "ark-ec" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d68f2d516162846c1238e755a7c4d131b892b70cc70c471a8e3ca3ed818fce" -dependencies = [ - "ahash 0.8.7", - "ark-ff 0.5.0", - "ark-poly 0.5.0", - "ark-serialize 0.5.0", - "ark-std 0.5.0", - "educe", - "fnv", - "hashbrown 0.15.2", - "itertools 0.13.0", - "num-bigint", - "num-integer", - "num-traits", - "zeroize", -] - [[package]] name = "ark-ed-on-bls12-377" version = "0.4.0" @@ -496,9 +470,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b10d901b9ac4b38f9c32beacedfadcdd64e46f8d7f8e88c1ae1060022cf6f6c6" dependencies = [ "ark-bls12-377", - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-std 0.4.0", + "ark-ec", + "ark-ff", + "ark-std", ] [[package]] @@ -507,11 +481,11 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524a4fb7540df2e1a8c2e67a83ba1d1e6c3947f4f9342cc2359fc2e789ad731d" dependencies = [ - "ark-ec 0.4.2", + "ark-ec", "ark-ed-on-bls12-377", - "ark-ff 0.4.2", + "ark-ff", "ark-models-ext", - "ark-std 0.4.0", + "ark-std", ] [[package]] @@ -521,9 +495,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9cde0f2aa063a2a5c28d39b47761aa102bda7c13c84fc118a61b87c7b2f785c" dependencies = [ "ark-bls12-381", - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-std 0.4.0", + "ark-ec", + "ark-ff", + "ark-std", ] [[package]] @@ -532,11 +506,11 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d15185f1acb49a07ff8cbe5f11a1adc5a93b19e211e325d826ae98e98e124346" dependencies = [ - "ark-ec 0.4.2", + "ark-ec", "ark-ed-on-bls12-381-bandersnatch", - "ark-ff 0.4.2", + "ark-ff", "ark-models-ext", - "ark-std 0.4.0", + "ark-std", ] [[package]] @@ -545,13 +519,13 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" dependencies = [ - "ark-ff-asm 0.4.2", - "ark-ff-macros 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", "derivative", "digest 0.10.7", - "itertools 0.10.5", + "itertools", "num-bigint", "num-traits", "paste", @@ -559,26 +533,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "ark-ff" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a177aba0ed1e0fbb62aa9f6d0502e9b46dad8c2eab04c14258a1212d2557ea70" -dependencies = [ - "ark-ff-asm 0.5.0", - "ark-ff-macros 0.5.0", - "ark-serialize 0.5.0", - "ark-std 0.5.0", - "arrayvec", - "digest 0.10.7", - "educe", - "itertools 0.13.0", - "num-bigint", - "num-traits", - "paste", - "zeroize", -] - [[package]] name = "ark-ff-asm" version = "0.4.2" @@ -589,16 +543,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ark-ff-asm" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62945a2f7e6de02a31fe400aa489f0e0f5b2502e69f95f853adb82a96c7a6b60" -dependencies = [ - "quote", - "syn 2.0.89", -] - [[package]] name = "ark-ff-macros" version = "0.4.2" @@ -612,29 +556,16 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ark-ff-macros" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3" -dependencies = [ - "num-bigint", - "num-traits", - "proc-macro2", - "quote", - "syn 2.0.89", -] - [[package]] name = "ark-models-ext" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e9eab5d4b5ff2f228b763d38442adc9b084b0a465409b059fac5c2308835ec2" dependencies = [ - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", "derivative", ] @@ -644,38 +575,23 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" dependencies = [ - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-ff", + "ark-serialize", + "ark-std", "derivative", "hashbrown 0.13.2", ] -[[package]] -name = "ark-poly" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579305839da207f02b89cd1679e50e67b4331e2f9294a57693e5051b7703fe27" -dependencies = [ - "ahash 0.8.7", - "ark-ff 0.5.0", - "ark-serialize 0.5.0", - "ark-std 0.5.0", - "educe", - "fnv", - "hashbrown 0.15.2", -] - [[package]] name = "ark-scale" version = "0.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f69c00b3b529be29528a6f2fd5fa7b1790f8bed81b9cdca17e326538545a179" dependencies = [ - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", "parity-scale-codec", "scale-info", ] @@ -685,11 +601,11 @@ name = "ark-secret-scalar" version = "0.0.2" source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" dependencies = [ - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", - "ark-transcript 0.0.2", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-std", + "ark-transcript 0.0.2 (git+https://github.com/w3f/ring-vrf?rev=e9782f9)", "digest 0.10.7", "getrandom_or_panic", "zeroize", @@ -701,21 +617,8 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ - "ark-serialize-derive 0.4.2", - "ark-std 0.4.0", - "digest 0.10.7", - "num-bigint", -] - -[[package]] -name = "ark-serialize" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f4d068aaf107ebcd7dfb52bc748f8030e0fc930ac8e360146ca54c1203088f7" -dependencies = [ - "ark-serialize-derive 0.5.0", - "ark-std 0.5.0", - "arrayvec", + "ark-serialize-derive", + "ark-std", "digest 0.10.7", "num-bigint", ] @@ -731,17 +634,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "ark-serialize-derive" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213888f660fddcca0d257e88e54ac05bca01885f258ccdf695bafd77031bb69d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.89", -] - [[package]] name = "ark-std" version = "0.4.0" @@ -753,24 +645,15 @@ dependencies = [ "rayon", ] -[[package]] -name = "ark-std" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246a225cc6131e9ee4f24619af0f19d67761fff15d7ccc22e42b80846e69449a" -dependencies = [ - "num-traits", - "rand", -] - [[package]] name = "ark-transcript" version = "0.0.2" -source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "563084372d89271122bd743ef0a608179726f5fad0566008ba55bd0f756489b8" dependencies = [ - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-ff", + "ark-serialize", + "ark-std", "digest 0.10.7", "rand_core 0.6.4", "sha3", @@ -778,12 +661,12 @@ dependencies = [ [[package]] name = "ark-transcript" -version = "0.0.3" -source = "git+https://github.com/w3f/ark-transcript#37a169f587f45d67e5afad143bc2a7c9c864884b" +version = "0.0.2" +source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" dependencies = [ - "ark-ff 0.5.0", - "ark-serialize 0.5.0", - "ark-std 0.5.0", + "ark-ff", + "ark-serialize", + "ark-std", "digest 0.10.7", "rand_core 0.6.4", "sha3", @@ -944,11 +827,11 @@ version = "0.0.4" source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" dependencies = [ "ark-bls12-381", - "ark-ec 0.4.2", + "ark-ec", "ark-ed-on-bls12-381-bandersnatch", - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", + "ark-ff", + "ark-serialize", + "ark-std", "dleq_vrf", "fflonk", "merlin", @@ -1164,9 +1047,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bs58" -version = "0.5.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" dependencies = [ "tinyvec", ] @@ -1472,13 +1355,13 @@ dependencies = [ [[package]] name = "common" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof#1eedf08d97effe1921f4aa2e926575088b068e2b" +source = "git+https://github.com/w3f/ring-proof#652286c32f96beb9ce7f5793f5e2c2c923f63b73" dependencies = [ - "ark-ec 0.5.0", - "ark-ff 0.5.0", - "ark-poly 0.5.0", - "ark-serialize 0.5.0", - "ark-std 0.5.0", + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", "fflonk", "getrandom_or_panic", "rand_core 0.6.4", @@ -1690,7 +1573,7 @@ dependencies = [ "cranelift-codegen", "cranelift-entity", "cranelift-frontend", - "itertools 0.10.5", + "itertools", "log", "smallvec", "wasmparser", @@ -2075,13 +1958,13 @@ name = "dleq_vrf" version = "0.0.2" source = "git+https://github.com/w3f/ring-vrf?rev=e9782f9#e9782f938629c90f3adb3fff2358bc8d1386af3e" dependencies = [ - "ark-ec 0.4.2", - "ark-ff 0.4.2", + "ark-ec", + "ark-ff", "ark-scale", "ark-secret-scalar", - "ark-serialize 0.4.2", - "ark-std 0.4.0", - "ark-transcript 0.0.2", + "ark-serialize", + "ark-std", + "ark-transcript 0.0.2 (git+https://github.com/w3f/ring-vrf?rev=e9782f9)", "arrayvec", "zeroize", ] @@ -2212,18 +2095,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "educe" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7bc049e1bd8cdeb31b68bbd586a9464ecf9f3944af3958a7a9d0f8b9799417" -dependencies = [ - "enum-ordinalize", - "proc-macro2", - "quote", - "syn 2.0.89", -] - [[package]] name = "either" version = "1.9.0" @@ -2268,26 +2139,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "enum-ordinalize" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" -dependencies = [ - "enum-ordinalize-derive", -] - -[[package]] -name = "enum-ordinalize-derive" -version = "4.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.89", -] - [[package]] name = "env_logger" version = "0.10.2" @@ -2412,14 +2263,14 @@ dependencies = [ [[package]] name = "fflonk" -version = "0.1.1" -source = "git+https://github.com/w3f/fflonk#eda051ea3b80042e844a3ebd17c2f60536e6ee3f" +version = "0.1.0" +source = "git+https://github.com/w3f/fflonk#1e854f35e9a65d08b11a86291405cdc95baa0a35" dependencies = [ - "ark-ec 0.5.0", - "ark-ff 0.5.0", - "ark-poly 0.5.0", - "ark-serialize 0.5.0", - "ark-std 0.5.0", + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", "merlin", ] @@ -2574,7 +2425,7 @@ dependencies = [ "frame-system", "gethostname", "handlebars", - "itertools 0.10.5", + "itertools", "lazy_static", "linked-hash-map", "log", @@ -2711,7 +2562,7 @@ dependencies = [ "derive-syn-parse", "expander", "frame-support-procedural-tools", - "itertools 0.10.5", + "itertools", "macro_magic", "proc-macro-warning", "proc-macro2", @@ -3155,15 +3006,6 @@ dependencies = [ "allocator-api2", ] -[[package]] -name = "hashbrown" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" -dependencies = [ - "allocator-api2", -] - [[package]] name = "hashlink" version = "0.8.4" @@ -3637,15 +3479,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "1.0.10" @@ -5165,21 +4998,6 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", ] -[[package]] -name = "pallet-asset-rate" -version = "7.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0#3c3d6fceb82372a3019b37117aa453d564b212de" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", -] - [[package]] name = "pallet-assets" version = "29.0.0" @@ -5333,22 +5151,6 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", ] -[[package]] -name = "pallet-node-authorization" -version = "28.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0#3c3d6fceb82372a3019b37117aa453d564b212de" -dependencies = [ - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0)", -] - [[package]] name = "pallet-session" version = "28.0.0" @@ -5865,12 +5667,6 @@ dependencies = [ "log", ] -[[package]] -name = "polkavm-common" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0dbafef4ab6ceecb4982ac3b550df430ef4f9fdbf07c108b7d4f91a0682fce" - [[package]] name = "polkavm-derive" version = "0.5.0" @@ -5887,16 +5683,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae8c4bea6f3e11cd89bb18bcdddac10bd9a24015399bd1c485ad68a985a19606" dependencies = [ - "polkavm-derive-impl-macro 0.9.0", -] - -[[package]] -name = "polkavm-derive" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206caf322dfc02144510ad8360ff2051e5072f0874dcab3b410f78cdd52d0ebb" -dependencies = [ - "polkavm-derive-impl-macro 0.17.0", + "polkavm-derive-impl-macro", ] [[package]] @@ -5923,18 +5710,6 @@ dependencies = [ "syn 2.0.89", ] -[[package]] -name = "polkavm-derive-impl" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42565aed4adbc4034612d0b17dea8db3681fb1bd1aed040d6edc5455a9f478a1" -dependencies = [ - "polkavm-common 0.17.0", - "proc-macro2", - "quote", - "syn 2.0.89", -] - [[package]] name = "polkavm-derive-impl-macro" version = "0.9.0" @@ -5945,16 +5720,6 @@ dependencies = [ "syn 2.0.89", ] -[[package]] -name = "polkavm-derive-impl-macro" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d9838e95241b0bce4fe269cdd4af96464160505840ed5a8ac8536119ba19e2" -dependencies = [ - "polkavm-derive-impl 0.17.0", - "syn 2.0.89", -] - [[package]] name = "polkavm-linker" version = "0.9.2" @@ -6039,7 +5804,7 @@ checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" dependencies = [ "difflib", "float-cmp", - "itertools 0.10.5", + "itertools", "normalize-line-endings", "predicates-core", "regex", @@ -6235,7 +6000,7 @@ checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" dependencies = [ "bytes", "heck 0.4.1", - "itertools 0.10.5", + "itertools", "lazy_static", "log", "multimap", @@ -6256,7 +6021,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools", "proc-macro2", "quote", "syn 1.0.109", @@ -6269,7 +6034,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools", "proc-macro2", "quote", "syn 2.0.89", @@ -6626,14 +6391,15 @@ dependencies = [ [[package]] name = "ring" version = "0.1.0" -source = "git+https://github.com/w3f/ring-proof#1eedf08d97effe1921f4aa2e926575088b068e2b" -dependencies = [ - "ark-ec 0.5.0", - "ark-ff 0.5.0", - "ark-poly 0.5.0", - "ark-serialize 0.5.0", - "ark-std 0.5.0", - "ark-transcript 0.0.3", +source = "git+https://github.com/w3f/ring-proof#652286c32f96beb9ce7f5793f5e2c2c923f63b73" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "ark-transcript 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "arrayvec", "blake2 0.10.6", "common", "fflonk", @@ -7046,7 +6812,7 @@ dependencies = [ "clap", "fdlimit", "futures", - "itertools 0.10.5", + "itertools", "libp2p-identity", "log", "names", @@ -8540,14 +8306,14 @@ dependencies = [ "bitflags 1.3.2", "blake2 0.10.6", "bounded-collections", - "bs58 0.5.1", + "bs58 0.5.0", "dyn-clonable", "ed25519-zebra", "futures", "hash-db", "hash256-std-hasher", "impl-serde 0.4.0", - "itertools 0.10.5", + "itertools", "k256", "libsecp256k1", "log", @@ -8580,7 +8346,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -8588,7 +8354,7 @@ dependencies = [ "ark-bls12-381-ext", "ark-bw6-761", "ark-bw6-761-ext", - "ark-ec 0.4.2", + "ark-ec", "ark-ed-on-bls12-377", "ark-ed-on-bls12-377-ext", "ark-ed-on-bls12-381-bandersnatch", @@ -8642,7 +8408,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" dependencies = [ "proc-macro2", "quote", @@ -8663,7 +8429,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" dependencies = [ "environmental", "parity-scale-codec", @@ -8850,12 +8616,12 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" dependencies = [ "bytes", "impl-trait-for-tuples", "parity-scale-codec", - "polkavm-derive 0.17.1", + "polkavm-derive 0.9.1", "primitive-types 0.13.1", "sp-externalities 0.25.0 (git+https://github.com/paritytech/polkadot-sdk)", "sp-runtime-interface-proc-macro 17.0.0 (git+https://github.com/paritytech/polkadot-sdk)", @@ -8882,7 +8648,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" dependencies = [ "Inflector", "expander", @@ -8975,7 +8741,7 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-v1.9.0 [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" [[package]] name = "sp-storage" @@ -8993,7 +8759,7 @@ dependencies = [ [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" dependencies = [ "impl-serde 0.5.0", "parity-scale-codec", @@ -9030,7 +8796,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" dependencies = [ "parity-scale-codec", "tracing", @@ -9130,7 +8896,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#526a440203d1ff96640c6163291e57e10c8e4f9b" +source = "git+https://github.com/paritytech/polkadot-sdk#2ef2723126584dfcd6d2a9272282ee78375dbcd3" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -9422,7 +9188,7 @@ dependencies = [ [[package]] name = "substrate-validator-set" version = "1.1.0" -source = "git+https://github.com/gautamdhameja/substrate-validator-set?tag=polkadot-v1.9.0#2c5e00ca3fd99380978d653fd79c8635aeb84c0c" +source = "git+https://github.com/AlphaGamingArcade/substrate-validator-set.git?tag=polkadot-v1.9.0-2#7c1ce921f23d2535020fe372bfa5ffa44f12ef34" dependencies = [ "frame-benchmarking", "frame-support", @@ -10269,10 +10035,10 @@ checksum = "7335e4c132c28cc43caef6adb339789e599e39adbe78da0c4d547fad48cbc331" dependencies = [ "ark-bls12-377", "ark-bls12-381", - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-serialize-derive 0.4.2", + "ark-ec", + "ark-ff", + "ark-serialize", + "ark-serialize-derive", "arrayref", "constcat", "digest 0.10.7", diff --git a/node/Cargo.toml b/node/Cargo.toml index 8f4070d..663e4e7 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -18,10 +18,9 @@ workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] -bs58 = { version = "0.5.1" } clap = { version = "4.5.3", features = ["derive"] } futures = { version = "0.3.30", features = ["thread-pool"] } -serde_json = { version = "1.0.114", default-features = true } +serde_json = { version = "1.0.114", default-features = true, features = ["alloc"] } jsonrpsee = { version = "0.22", features = ["server"] } # substrate client diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index b3a0256..bee9e89 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -1,4 +1,4 @@ -use aga_runtime::{AccountId, RuntimeGenesisConfig, Signature, WASM_BINARY, opaque::SessionKeys}; +use aga_runtime::{AccountId, RuntimeGenesisConfig, Signature, WASM_BINARY, Balance, opaque::SessionKeys }; use sc_service::ChainType; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_consensus_grandpa::AuthorityId as GrandpaId; @@ -32,10 +32,11 @@ where AccountPublic::from(get_from_seed::(seed)).into_account() } -/// Generate an Aura authority key. +// /// Generate an Aura authority key. // pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { // (get_from_seed::(s), get_from_seed::(s)) // } + fn session_keys(aura: AuraId, grandpa: GrandpaId) -> SessionKeys { SessionKeys { aura, grandpa } } @@ -106,6 +107,8 @@ pub fn local_testnet_config() -> Result { .build()) } +const INITIAL_BALANCE: Balance = 100_000_000_000_000_000_000_000; + /// Configure initial storage state for FRAME modules. fn testnet_genesis( initial_authorities: Vec<(AccountId, AuraId, GrandpaId)>, @@ -115,16 +118,21 @@ fn testnet_genesis( ) -> serde_json::Value { serde_json::json!({ "balances": { - // Configure endowed accounts with initial balance of 1 << 60. - "balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::>(), + // Configure endowed accounts with initial balance. + "balances": endowed_accounts.iter().cloned().map(|k| (k, INITIAL_BALANCE)).collect::>(), }, "validatorSet": { - "initialValidators": initial_authorities.iter().map(|x| (x.0.clone())).collect::>(), + "initialValidators": initial_authorities.iter().map(|x| x.0.clone()).collect::>(), }, "session": { - "keys": initial_authorities.iter().map(|x| { - (x.0.clone(), x.0.clone(), session_keys(x.1.clone(), x.2.clone())) - }).collect::>(), + "keys": initial_authorities + .iter() + .map(|x| ( + x.0.clone(), + x.0.clone(), + session_keys(x.1.clone(), x.2.clone()) + )) + .collect::>(), }, "aura": { "authorities": [], @@ -133,7 +141,6 @@ fn testnet_genesis( "authorities": [], }, "sudo": { - // Assign network admin rights. "key": Some(root_key), } }) diff --git a/primitives/aga/src/lib.rs b/primitives/aga/src/lib.rs index 472dd74..6bc2f6d 100644 --- a/primitives/aga/src/lib.rs +++ b/primitives/aga/src/lib.rs @@ -29,7 +29,4 @@ pub enum TransferType { pub trait DecimalConverter { fn convert_to(amount: u128, decimal: u8) -> u128; fn convert_from(amount: u128, decimal: u8) -> u128; -} - -/// Simple index type with which we can count sessions. -pub type SessionIndex = u32; +} \ No newline at end of file diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index a34aea6..ae603f3 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -48,13 +48,10 @@ pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk # asset conversion pallet-asset-conversion = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.9.0", default-features = false } pallet-asset-conversion-tx-payment = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.9.0", default-features = false } -pallet-asset-rate = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.9.0", default-features = false } # Validator management -sp-staking = { git = "https://github.com/paritytech/polkadot-sdk", tag = "polkadot-v1.9.0", default-features = false } -pallet-session = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false, features = ['historical'] } -pallet-node-authorization = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false} -pallet-validator-set = { package = "substrate-validator-set", version = "1.1.0", git = "https://github.com/gautamdhameja/substrate-validator-set", tag = "polkadot-v1.9.0", default-features = false } +pallet-validator-set = { version = '1.1.0', git = "https://github.com/AlphaGamingArcade/substrate-validator-set.git", package = "substrate-validator-set", tag = "polkadot-v1.9.0-2", default-features = false } +pallet-session = { default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0" } # primitives hex-literal = { version = "0.4.1", default-features = false } @@ -74,7 +71,7 @@ sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "p sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false, features = [ "serde", ] } -sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false} +sp-session = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } sp-std = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } sp-storage = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } @@ -100,8 +97,6 @@ aga-bridge = { path = "../pallets/bridge", default-features = false} pallet-treasury = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", default-features = false } aga-primitives = { path = "../primitives/aga", default-features = false } -log = "0.4" - [build-dependencies] substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.9.0", optional = true } @@ -130,20 +125,19 @@ std = [ "pallet-transaction-payment/std", "pallet-asset-conversion/std", "pallet-asset-conversion-tx-payment/std", - "pallet-asset-rate/std", "pallet-assets/std", "pallet-authorship/std", "pallet-contracts/std", "pallet-utility/std", - "pallet-session/std", - "pallet-node-authorization/std", - "pallet-validator-set/std", "aga-access-segregator/std", "aga-bridge/std", "aga-primitives/std", + "pallet-validator-set/std", + "pallet-session/std", + "sp-api/std", "sp-block-builder/std", "sp-consensus-aura/std", diff --git a/runtime/src/assets_config.rs b/runtime/src/assets_config.rs deleted file mode 100644 index 2f4181d..0000000 --- a/runtime/src/assets_config.rs +++ /dev/null @@ -1,121 +0,0 @@ -use crate::{AccountId, Balance, Balances, Runtime, RuntimeEvent, PoolAssets, Assets, NativeOrWithIdOf}; -use frame_support::{ - parameter_types, ord_parameter_types, - traits::{ - tokens::{ - fungible::{NativeFromLeft, NativeOrWithId, UnionOf}, - imbalance::ResolveAssetTo, - }, - AsEnsureOriginWithArg, ConstU128, ConstU32, - }, - PalletId -}; -use sp_std::vec; -use frame_system::{EnsureRoot, EnsureSigned, EnsureSignedBy}; -pub const MILLICENTS: Balance = 1_000_000_000; -pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. -pub const DOLLARS: Balance = 100 * CENTS; -use sp_runtime::{ - traits::AccountIdConversion, - Permill -}; - -use pallet_asset_conversion::WithFirstAsset; - -/// We allow root to execute privileged asset operations. -pub type AssetsForceOrigin = EnsureRoot; - -parameter_types! { - pub const AssetDeposit: Balance = 100 * DOLLARS; - pub const ApprovalDeposit: Balance = 1 * DOLLARS; - pub const StringLimit: u32 = 50; - pub const MetadataDepositBase: Balance = 10 * DOLLARS; - pub const MetadataDepositPerByte: Balance = 1 * DOLLARS; -} - -pub type TrustBackedAssetsInstance = pallet_assets::Instance1; -impl pallet_assets::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = u128; - type AssetId = u32; - type AssetIdParameter = codec::Compact; - type CreateOrigin = AsEnsureOriginWithArg>; - type Currency = Balances; - type ForceOrigin = frame_system::EnsureRoot; - type AssetDeposit = AssetDeposit; - type AssetAccountDeposit = ConstU128; - type MetadataDepositBase = MetadataDepositBase; - type MetadataDepositPerByte = MetadataDepositPerByte; - type ApprovalDeposit = ApprovalDeposit; - type StringLimit = StringLimit; - type Freezer = (); - type Extra = (); - type WeightInfo = pallet_assets::weights::SubstrateWeight; - type RemoveItemsLimit = ConstU32<1000>; - type CallbackHandle = (); -} - - -parameter_types! { - pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon"); - pub const Native: NativeOrWithIdOf = NativeOrWithId::Native; - pub storage LiquidityWithdrawalFee: Permill = Permill::from_percent(0); -} - -ord_parameter_types! { - pub const AssetConversionOrigin: sp_runtime::AccountId32 = - AccountIdConversion::::into_account_truncating(&AssetConversionPalletId::get()); -} - -pub type PoolAssetsInstance = pallet_assets::Instance2; -impl pallet_assets::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type RemoveItemsLimit = ConstU32<1000>; - type AssetId = u32; - type AssetIdParameter = u32; - type Currency = Balances; - type CreateOrigin = - AsEnsureOriginWithArg>; - type ForceOrigin = AssetsForceOrigin; - // Deposits are zero because creation/admin is limited to Asset Conversion pallet. - type AssetDeposit = ConstU128<0>; - type AssetAccountDeposit = ConstU128<0>; - type MetadataDepositBase = ConstU128<0>; - type MetadataDepositPerByte = ConstU128<0>; - type ApprovalDeposit = ApprovalDeposit; - type StringLimit = ConstU32<50>; - type Freezer = (); - type Extra = (); - type WeightInfo = pallet_assets::weights::SubstrateWeight; - type CallbackHandle = (); - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); -} - -pub type NativeAndAssets = UnionOf; - -impl pallet_asset_conversion::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type HigherPrecisionBalance = u128; - type AssetKind = NativeOrWithIdOf; - type Assets = NativeAndAssets; - type PoolId = (Self::AssetKind, Self::AssetKind); - type PoolLocator = WithFirstAsset; - type PoolAssetId = u32; - type PoolAssets = PoolAssets; - type PoolSetupFee = ConstU128<100>; // should be more or equal to the existential deposit - type PoolSetupFeeAsset = Native; - type PoolSetupFeeTarget = ResolveAssetTo; - type PalletId = AssetConversionPalletId; - type WeightInfo = pallet_asset_conversion::weights::SubstrateWeight; - type LPFee = ConstU32<3>; // means 0.3% - type LiquidityWithdrawalFee = LiquidityWithdrawalFee; - type MaxSwapPathLength = ConstU32<4>; - type MintMinLiquidity = ConstU128<100>; // 100 is good enough when the main currency has 12 decimals. - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); -} - - diff --git a/runtime/src/benchmarks.rs b/runtime/src/benchmarks.rs new file mode 100644 index 0000000..3a40658 --- /dev/null +++ b/runtime/src/benchmarks.rs @@ -0,0 +1,10 @@ +#[cfg(feature = "runtime-benchmarks")] +mod benches { + frame_benchmarking::define_benchmarks!( + [frame_benchmarking, BaselineBench::] + [frame_system, SystemBench::] + [pallet_balances, Balances] + [pallet_timestamp, Timestamp] + [pallet_sudo, Sudo] + ); +} diff --git a/runtime/src/configs/mod.rs b/runtime/src/configs/mod.rs new file mode 100644 index 0000000..b4b94f2 --- /dev/null +++ b/runtime/src/configs/mod.rs @@ -0,0 +1,436 @@ +use crate::*; +use frame_support::{ + parameter_types, ord_parameter_types, + traits::{ + tokens::{ + fungible::{NativeFromLeft, NativeOrWithId, UnionOf}, + imbalance::ResolveAssetTo, + }, + AsEnsureOriginWithArg, ConstBool, ConstU128, ConstU32, + }, + PalletId +}; +use sp_std::vec; +use frame_system::{EnsureRoot, EnsureSigned, EnsureSignedBy}; +use sp_runtime::{ + traits::AccountIdConversion, + Permill +}; + +use pallet_asset_conversion::WithFirstAsset; + +use super::{EXISTENTIAL_DEPOSIT, DOLLARS}; + +/// The default types are being injected by [`derive_impl`](`frame_support::derive_impl`) from +/// [`SoloChainDefaultConfig`](`struct@frame_system::config_preludes::SolochainDefaultConfig`), +/// but overridden as needed. +#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { + /// The block type for the runtime. + type Block = Block; + /// Block & extrinsics weights: base values and limits. + type BlockWeights = RuntimeBlockWeights; + /// The maximum length of a block (in bytes). + type BlockLength = RuntimeBlockLength; + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The type for storing how many extrinsics an account has signed. + type Nonce = Nonce; + /// The type for hashing blocks and tries. + type Hash = Hash; + /// Maximum number of block number to block hash mappings to keep (oldest pruned first). + type BlockHashCount = BlockHashCount; + /// The weight of database operations that the runtime can invoke. + type DbWeight = RocksDbWeight; + /// Version of the runtime. + type Version = Version; + /// The data to be stored in an account. + type AccountData = pallet_balances::AccountData; + /// This is used as an identifier of the chain. 42 is the generic substrate prefix. + type SS58Prefix = SS58Prefix; + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +/// We allow root to execute privileged asset operations. +pub type AssetsForceOrigin = EnsureRoot; + +parameter_types! { + pub const AssetDeposit: Balance = 100 * DOLLARS; + pub const ApprovalDeposit: Balance = 1 * DOLLARS; + pub const StringLimit: u32 = 50; + pub const MetadataDepositBase: Balance = 10 * DOLLARS; + pub const MetadataDepositPerByte: Balance = 1 * DOLLARS; +} + +pub type TrustBackedAssetsInstance = pallet_assets::Instance1; +impl pallet_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = u128; + type AssetId = u32; + type AssetIdParameter = codec::Compact; + type CreateOrigin = AsEnsureOriginWithArg>; + type Currency = Balances; + type ForceOrigin = frame_system::EnsureRoot; + type AssetDeposit = AssetDeposit; + type AssetAccountDeposit = ConstU128; + type MetadataDepositBase = MetadataDepositBase; + type MetadataDepositPerByte = MetadataDepositPerByte; + type ApprovalDeposit = ApprovalDeposit; + type StringLimit = StringLimit; + type Freezer = (); + type Extra = (); + type WeightInfo = pallet_assets::weights::SubstrateWeight; + type RemoveItemsLimit = ConstU32<1000>; + type CallbackHandle = (); +} + + +parameter_types! { + pub const AssetConversionPalletId: PalletId = PalletId(*b"py/ascon"); + pub const Native: NativeOrWithIdOf = NativeOrWithId::Native; + pub storage LiquidityWithdrawalFee: Permill = Permill::from_percent(0); +} + +ord_parameter_types! { + pub const AssetConversionOrigin: sp_runtime::AccountId32 = + AccountIdConversion::::into_account_truncating(&AssetConversionPalletId::get()); +} + +pub type PoolAssetsInstance = pallet_assets::Instance2; +impl pallet_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type RemoveItemsLimit = ConstU32<1000>; + type AssetId = u32; + type AssetIdParameter = u32; + type Currency = Balances; + type CreateOrigin = + AsEnsureOriginWithArg>; + type ForceOrigin = AssetsForceOrigin; + // Deposits are zero because creation/admin is limited to Asset Conversion pallet. + type AssetDeposit = ConstU128<0>; + type AssetAccountDeposit = ConstU128<0>; + type MetadataDepositBase = ConstU128<0>; + type MetadataDepositPerByte = ConstU128<0>; + type ApprovalDeposit = ApprovalDeposit; + type StringLimit = ConstU32<50>; + type Freezer = (); + type Extra = (); + type WeightInfo = pallet_assets::weights::SubstrateWeight; + type CallbackHandle = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); +} + +pub type NativeAndAssets = UnionOf; + +impl pallet_asset_conversion::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = ::Balance; + type HigherPrecisionBalance = u128; + type AssetKind = NativeOrWithIdOf; + type Assets = NativeAndAssets; + type PoolId = (Self::AssetKind, Self::AssetKind); + type PoolLocator = WithFirstAsset; + type PoolAssetId = u32; + type PoolAssets = PoolAssets; + type PoolSetupFee = ConstU128<100>; // should be more or equal to the existential deposit + type PoolSetupFeeAsset = Native; + type PoolSetupFeeTarget = ResolveAssetTo; + type PalletId = AssetConversionPalletId; + type WeightInfo = (); + type LPFee = ConstU32<3>; // means 0.3% + type LiquidityWithdrawalFee = LiquidityWithdrawalFee; + type MaxSwapPathLength = ConstU32<4>; + type MintMinLiquidity = ConstU128<100>; // 100 is good enough when the main currency has 12 decimals. + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); +} + +pub enum AllowBalancesCall {} + +impl frame_support::traits::Contains for AllowBalancesCall { + fn contains(call: &RuntimeCall) -> bool { + matches!(call, RuntimeCall::Balances(BalancesCall::transfer_allow_death { .. })) + } +} + +const fn deposit(items: u32, bytes: u32) -> Balance { + (items as Balance * CENTS + (bytes as Balance) * (5 * MILLICENTS / 100)) / 10 +} + +fn schedule() -> pallet_contracts::Schedule { + pallet_contracts::Schedule { + limits: pallet_contracts::Limits { + runtime_memory: 1024 * 1024 * 1024, + ..Default::default() + }, + ..Default::default() + } +} + +parameter_types! { + pub const DepositPerItem: Balance = deposit(1, 0); + pub const DepositPerByte: Balance = deposit(0, 1); + pub Schedule: pallet_contracts::Schedule = schedule::(); + pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); + pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0); + pub const MaxDelegateDependencies: u32 = 32; +} + +impl pallet_contracts::Config for Runtime { + type Time = Timestamp; + type Randomness = RandomnessCollectiveFlip; + type Currency = Balances; + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + + /// The safest default is to allow no calls at all. + /// + /// Runtimes should whitelist dispatchables that are allowed to be called from contracts + /// and make sure they are stable. Dispatchables exposed to contracts are not allowed to + /// change because that would break already deployed contracts. The `RuntimeCall` structure + /// itself is not allowed to change the indices of existing pallets, too. + type CallFilter = AllowBalancesCall; + type DepositPerItem = DepositPerItem; + type DepositPerByte = DepositPerByte; + type CallStack = [pallet_contracts::Frame; 23]; + type WeightPrice = pallet_transaction_payment::Pallet; + type WeightInfo = pallet_contracts::weights::SubstrateWeight; + type ChainExtension = (); + type Schedule = Schedule; + type AddressGenerator = pallet_contracts::DefaultAddressGenerator; + // This node is geared towards development and testing of contracts. + // We decided to increase the default allowed contract size for this + // reason (the default is `128 * 1024`). + // + // Our reasoning is that the error code `CodeTooLarge` is thrown + // if a too-large contract is uploaded. We noticed that it poses + // less friction during development when the requirement here is + // just more lax. + type MaxCodeLen = ConstU32<{ 256 * 1024 }>; + type DefaultDepositLimit = DefaultDepositLimit; + type MaxStorageKeyLen = ConstU32<128>; + type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; + type UnsafeUnstableInterface = ConstBool; + type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; + type MaxDelegateDependencies = MaxDelegateDependencies; + type RuntimeHoldReason = RuntimeHoldReason; + + type Environment = (); + type Debug = (); + type ApiVersion = (); + type Migrations = (); + type Xcm = (); + + type UploadOrigin = EnsureSigned; + type InstantiateOrigin = EnsureSigned; +} + + +parameter_types! { + pub const UncleGenerations: u32 = 0; +} + +impl pallet_aura::Config for Runtime { + type AuthorityId = AuraId; + type DisabledValidators = (); + type MaxAuthorities = ConstU32<32>; + type AllowMultipleBlocksPerSlot = ConstBool; + + #[cfg(feature = "experimental")] + type SlotDuration = pallet_aura::MinimumPeriodTimesTwo; +} + +impl pallet_grandpa::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + + type WeightInfo = (); + type MaxAuthorities = ConstU32<32>; + type MaxNominators = ConstU32<0>; + type MaxSetIdSessionEntries = ConstU64<0>; + + type KeyOwnerProof = sp_core::Void; + type EquivocationReportSystem = (); +} + +pub struct AuraAccountAdapter; +impl frame_support::traits::FindAuthor for AuraAccountAdapter { + fn find_author<'a, I>(digests: I) -> Option + where I: 'a + IntoIterator + { + pallet_aura::AuraAuthorId::::find_author(digests).and_then(|k| { + AccountId::try_from(k.as_ref()).ok() + }) + } +} + +impl pallet_authorship::Config for Runtime { + type FindAuthor = AuraAccountAdapter; + type EventHandler = (); +} + +impl pallet_timestamp::Config for Runtime { + /// A timestamp: milliseconds since the unix epoch. + type Moment = u64; + type OnTimestampSet = Aura; + type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; + type WeightInfo = (); +} + +parameter_types! { + pub const MaxLocks: u32 = 50; + pub const MaxReserves: u32 = 50; +} + +impl pallet_balances::Config for Runtime { + type MaxLocks = MaxLocks; + type MaxReserves = MaxReserves; + type ReserveIdentifier = [u8; 8]; + /// The type for recording an account's balance. + type Balance = Balance; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ConstU128; + type AccountStore = System; + type WeightInfo = pallet_balances::weights::SubstrateWeight; + type FreezeIdentifier = (); + type MaxFreezes = (); + type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = RuntimeFreezeReason; +} + +/// Logic for the author to get a portion of fees. +pub type NegativeImbalance = as Currency<::AccountId,>>::NegativeImbalance; +pub struct ToAuthor(sp_std::marker::PhantomData); +impl OnUnbalanced> for ToAuthor +where + R: pallet_balances::Config + pallet_authorship::Config, + ::AccountId: From, + ::AccountId: Into, +{ + fn on_nonzero_unbalanced(amount: NegativeImbalance) { + if let Some(author) = >::author() { + >::resolve_creating(&author, amount); + } + } +} + +parameter_types! { + pub FeeMultiplier: Multiplier = Multiplier::one(); +} + +impl pallet_transaction_payment::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnChargeTransaction = CurrencyAdapter>; + type OperationalFeeMultiplier = ConstU8<5>; + type WeightToFee = IdentityFee; + type LengthToFee = IdentityFee; + type FeeMultiplierUpdate = ConstFeeMultiplier; +} + +impl pallet_sudo::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type WeightInfo = pallet_sudo::weights::SubstrateWeight; +} + +impl pallet_utility::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type PalletsOrigin = OriginCaller; + type WeightInfo = pallet_utility::weights::SubstrateWeight; +} + + +parameter_types! { + // Make sure put same value with `construct_runtime` + pub const AccessSegregatorPalletIndex: u8 = 15; + pub const BridgePalletIndex: u8 = 16; + // pub const BasicFeeHandlerPalletIndex: u8 = 10; + // pub const FeeHandlerRouterPalletIndex: u8 = 12; + // pub const PercentageFeeHandlerRouterPalletIndex: u8 = 13; + // RegisteredExtrinsics here registers all valid (pallet index, extrinsic_name) paris + // make sure to update this when adding new access control extrinsic + pub RegisteredExtrinsics: Vec<(u8, Vec)> = [ + (AccessSegregatorPalletIndex::get(), b"grant_access".to_vec()), + (BridgePalletIndex::get(), b"register_domain".to_vec()), + (BridgePalletIndex::get(), b"unregister_domain".to_vec()), + (BridgePalletIndex::get(), b"transfer".to_vec()), + (BridgePalletIndex::get(), b"set_fee".to_vec()), + (BridgePalletIndex::get(), b"deposit".to_vec()), + (BridgePalletIndex::get(), b"execute_proposals".to_vec()), + (BridgePalletIndex::get(), b"pause_bridge".to_vec()), + (BridgePalletIndex::get(), b"unpause_bridge".to_vec()), + (BridgePalletIndex::get(), b"pause_all_bridges".to_vec()), + (BridgePalletIndex::get(), b"unpause_all_bridges".to_vec()), + // (BridgePalletIndex::get(), b"retry".to_vec()), + // (FeeHandlerRouterPalletIndex::get(), b"set_fee_handler".to_vec()), + // (PercentageFeeHandlerRouterPalletIndex::get(), b"set_fee_rate".to_vec()), + ].to_vec(); +} + + +impl aga_access_segregator::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type BridgeCommitteeOrigin = frame_system::EnsureRoot; + type PalletIndex = AccessSegregatorPalletIndex; + type Extrinsics = RegisteredExtrinsics; + type WeightInfo = aga_access_segregator::weights::SygmaWeightInfo; +} + +parameter_types! { + // TreasuryAccount is an substrate account and currently used for substrate -> EVM bridging fee collection + // TreasuryAccount address: 5ELLU7ibt5ZrNEYRwohtaRBDBa3TzcWwwPELBPSWWd2mbgv3 + pub BridgeAccountNativeFee: AccountId = AccountId::new([100u8; 32]); + // BridgeAccountNative: 5EYCAe5jLbHcAAMKvLFSXgCTbPrLgBJusvPwfKcaKzuf5X5e + pub BridgeAccountNative: AccountId = AgaBridgePalletId::get().into_account_truncating(); + // AgaBridgePalletId is the palletIDl + // this is used as the replacement of handler address in the ProposalExecution event + pub const AgaBridgePalletId: PalletId = PalletId(*b"aga/0001"); + /// Native asset's ResourceId. + pub const AgaResourceId: [u8; 32] = [0u8; 32]; +} + +// This bridge only support AGA Coin +impl aga_bridge::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AssetKind = Balance; + type NativeBalances = Balances; + type TransferReserveAccount = BridgeAccountNative; + type FeeReserveAccount = BridgeAccountNativeFee; + type PalletId = AgaBridgePalletId; + type PalletIndex = BridgePalletIndex; + type ResourceId = AgaResourceId; + type WeightInfo = aga_bridge::weights::SubstrateWeight; +} + +parameter_types! { + pub const MinAuthorities: u32 = 1; +} + +impl pallet_validator_set::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AddRemoveOrigin = EnsureRoot; + type MinAuthorities = MinAuthorities; + type WeightInfo = (); // Benchmark broken +} + + +parameter_types! { + pub const Period: u32 = 2 * MINUTES; + pub const Offset: u32 = 0; +} + +impl pallet_session::Config for Runtime { + type SessionHandler = ::KeyTypeIdProviders; + type ShouldEndSession = pallet_session::PeriodicSessions; + type SessionManager = ValidatorSet; + type RuntimeEvent = RuntimeEvent; + type Keys = opaque::SessionKeys; + type NextSessionRotation = pallet_session::PeriodicSessions; + type ValidatorId = ::AccountId; + type ValidatorIdOf = pallet_validator_set::ValidatorOf; + type WeightInfo = pallet_session::weights::SubstrateWeight; // No benchmark available +} diff --git a/runtime/src/contract_config.rs b/runtime/src/contract_config.rs deleted file mode 100644 index 2dc1f5c..0000000 --- a/runtime/src/contract_config.rs +++ /dev/null @@ -1,93 +0,0 @@ -use crate::{ - Balance, Balances, BalancesCall, Perbill, RandomnessCollectiveFlip, Runtime, RuntimeCall, - RuntimeEvent, RuntimeHoldReason, Timestamp, -}; -use frame_support::{ - parameter_types, - traits::{ConstBool, ConstU32}, -}; -use frame_system::EnsureSigned; - -pub enum AllowBalancesCall {} - -impl frame_support::traits::Contains for AllowBalancesCall { - fn contains(call: &RuntimeCall) -> bool { - matches!(call, RuntimeCall::Balances(BalancesCall::transfer_allow_death { .. })) - } -} - -// Unit = the base number of indivisible units for balances -const UNIT: Balance = 1_000_000_000_000; -const MILLIUNIT: Balance = 1_000_000_000; - -const fn deposit(items: u32, bytes: u32) -> Balance { - (items as Balance * UNIT + (bytes as Balance) * (5 * MILLIUNIT / 100)) / 10 -} - -fn schedule() -> pallet_contracts::Schedule { - pallet_contracts::Schedule { - limits: pallet_contracts::Limits { - runtime_memory: 1024 * 1024 * 1024, - ..Default::default() - }, - ..Default::default() - } -} - -parameter_types! { - pub const DepositPerItem: Balance = deposit(1, 0); - pub const DepositPerByte: Balance = deposit(0, 1); - pub Schedule: pallet_contracts::Schedule = schedule::(); - pub const DefaultDepositLimit: Balance = deposit(1024, 1024 * 1024); - pub const CodeHashLockupDepositPercent: Perbill = Perbill::from_percent(0); - pub const MaxDelegateDependencies: u32 = 32; -} - -impl pallet_contracts::Config for Runtime { - type Time = Timestamp; - type Randomness = RandomnessCollectiveFlip; - type Currency = Balances; - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - - /// The safest default is to allow no calls at all. - /// - /// Runtimes should whitelist dispatchables that are allowed to be called from contracts - /// and make sure they are stable. Dispatchables exposed to contracts are not allowed to - /// change because that would break already deployed contracts. The `RuntimeCall` structure - /// itself is not allowed to change the indices of existing pallets, too. - type CallFilter = AllowBalancesCall; - type DepositPerItem = DepositPerItem; - type DepositPerByte = DepositPerByte; - type CallStack = [pallet_contracts::Frame; 23]; - type WeightPrice = pallet_transaction_payment::Pallet; - type WeightInfo = pallet_contracts::weights::SubstrateWeight; - type ChainExtension = (); - type Schedule = Schedule; - type AddressGenerator = pallet_contracts::DefaultAddressGenerator; - // This node is geared towards development and testing of contracts. - // We decided to increase the default allowed contract size for this - // reason (the default is `128 * 1024`). - // - // Our reasoning is that the error code `CodeTooLarge` is thrown - // if a too-large contract is uploaded. We noticed that it poses - // less friction during development when the requirement here is - // just more lax. - type MaxCodeLen = ConstU32<{ 256 * 1024 }>; - type DefaultDepositLimit = DefaultDepositLimit; - type MaxStorageKeyLen = ConstU32<128>; - type MaxDebugBufferLen = ConstU32<{ 2 * 1024 * 1024 }>; - type UnsafeUnstableInterface = ConstBool; - type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent; - type MaxDelegateDependencies = MaxDelegateDependencies; - type RuntimeHoldReason = RuntimeHoldReason; - - type Environment = (); - type Debug = (); - type ApiVersion = (); - type Migrations = (); - type Xcm = (); - - type UploadOrigin = EnsureSigned; - type InstantiateOrigin = EnsureSigned; -} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index c2a0872..ab25fdd 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -3,8 +3,10 @@ #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); -mod assets_config; -mod contract_config; +// pub mod apis; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarks; +pub mod configs; use aga_primitives::{DepositNonce, DomainID}; use pallet_grandpa::AuthorityId as GrandpaId; @@ -13,38 +15,28 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, One, Verify, OpaqueKeys}, + traits::{OpaqueKeys, BlakeTwo256, Block as BlockT, IdentifyAccount, NumberFor, One, Verify}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, MultiSignature, }; use sp_std::prelude::*; -use sp_runtime::traits::AccountIdConversion; -use frame_support::PalletId; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use frame_support::{ +use frame_system::limits::{BlockLength, BlockWeights}; +pub use frame_support::{ dispatch::DispatchClass, - traits::{ - OnUnbalanced, - Currency, - tokens::fungible::NativeOrWithId - }, genesis_builder_helper::{build_config, create_default_config}, -}; -use frame_system::{ - EnsureRoot, - limits::{BlockLength, BlockWeights} -}; -pub use frame_support::{ construct_runtime, derive_impl, parameter_types, traits::{ + OnUnbalanced, + Currency, + tokens::fungible::NativeOrWithId, ConstBool, ConstU128, ConstU32, ConstU64, ConstU8, KeyOwnerProofSystem, Randomness, StorageInfo, }, weights::{ - ConstantMultiplier, constants::{ BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_REF_TIME_PER_SECOND, }, @@ -60,9 +52,6 @@ use pallet_transaction_payment::{ConstFeeMultiplier, CurrencyAdapter, Multiplier pub use sp_runtime::BuildStorage; pub use sp_runtime::{Perbill, Permill}; -/// Import the template pallet. -pub use pallet_template; - /// An index to a block. pub type BlockNumber = u32; @@ -109,19 +98,25 @@ pub mod opaque { } } +pub const DOLLARS: Balance = 100 * CENTS; +pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. +pub const MILLICENTS: Balance = 1_000_000_000; + +pub const EXISTENTIAL_DEPOSIT: Balance = MILLICENTS; + // To learn more about runtime versioning, see: // https://docs.substrate.io/main-docs/build/upgrade#runtime-versioning #[sp_version::runtime_version] pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("aga"), - impl_name: create_runtime_str!("aga"), + spec_name: create_runtime_str!("aga-testnet"), + impl_name: create_runtime_str!("aga-testnet"), authoring_version: 1, // The version of the runtime specification. A full node will not attempt to use its native // runtime in substitute for the on-chain Wasm runtime unless all of `spec_name`, // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 103, + spec_version: 100, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -161,17 +156,6 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX); -// Prints debug output of the `contracts` pallet to stdout if the node is -// started with `-lruntime::contracts=debug`. -const CONTRACTS_DEBUG_OUTPUT: pallet_contracts::DebugInfo = - pallet_contracts::DebugInfo::UnsafeDebug; -const CONTRACTS_EVENTS: pallet_contracts::CollectEvents = - pallet_contracts::CollectEvents::UnsafeCollect; - -// Unit = the base number of indivisible units for balances -const MILLIUNIT: Balance = 1_000_000_000; -pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT; - impl pallet_insecure_randomness_collective_flip::Config for Runtime {} parameter_types! { @@ -206,301 +190,6 @@ parameter_types! { pub const SS58Prefix: u8 = 42; } -/// The default types are being injected by [`derive_impl`](`frame_support::derive_impl`) from -/// [`SoloChainDefaultConfig`](`struct@frame_system::config_preludes::SolochainDefaultConfig`), -/// but overridden as needed. -#[derive_impl(frame_system::config_preludes::SolochainDefaultConfig as frame_system::DefaultConfig)] -impl frame_system::Config for Runtime { - /// The block type for the runtime. - type Block = Block; - /// Block & extrinsics weights: base values and limits. - type BlockWeights = RuntimeBlockWeights; - /// The maximum length of a block (in bytes). - type BlockLength = RuntimeBlockLength; - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; - /// The type for storing how many extrinsics an account has signed. - type Nonce = Nonce; - /// The type for hashing blocks and tries. - type Hash = Hash; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). - type BlockHashCount = BlockHashCount; - /// The weight of database operations that the runtime can invoke. - type DbWeight = RocksDbWeight; - /// Version of the runtime. - type Version = Version; - /// The data to be stored in an account. - type AccountData = pallet_balances::AccountData; - /// This is used as an identifier of the chain. 42 is the generic substrate prefix. - type SS58Prefix = SS58Prefix; - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const UncleGenerations: u32 = 0; -} - -impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; - type DisabledValidators = (); - type MaxAuthorities = ConstU32<32>; - type AllowMultipleBlocksPerSlot = ConstBool; - - #[cfg(feature = "experimental")] - type SlotDuration = pallet_aura::MinimumPeriodTimesTwo; -} - -impl pallet_grandpa::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - - type WeightInfo = (); - type MaxAuthorities = ConstU32<32>; - type MaxNominators = ConstU32<0>; - type MaxSetIdSessionEntries = ConstU64<0>; - - type KeyOwnerProof = sp_core::Void; - type EquivocationReportSystem = (); -} - -pub struct AuraAccountAdapter; -impl frame_support::traits::FindAuthor for AuraAccountAdapter { - fn find_author<'a, I>(digests: I) -> Option - where I: 'a + IntoIterator - { - // for (id, data) in digests { - // log::info!("Digest: {:?}, Data: {:?}", id, data); - // } - - pallet_aura::AuraAuthorId::::find_author(digests).and_then(|k| { - AccountId::try_from(k.as_ref()).ok() - }) - } -} - -impl pallet_authorship::Config for Runtime { - type FindAuthor = AuraAccountAdapter; - type EventHandler = (); -} - -impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the unix epoch. - type Moment = u64; - type OnTimestampSet = Aura; - type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; - type WeightInfo = (); -} - -parameter_types! { - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 50; -} - -impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; - type MaxReserves = MaxReserves; - type ReserveIdentifier = [u8; 8]; - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ConstU128; - type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; - type FreezeIdentifier = (); - type MaxFreezes = (); - type RuntimeHoldReason = RuntimeHoldReason; - type RuntimeFreezeReason = RuntimeFreezeReason; -} - -/// Logic for the author to get a portion of fees. -pub type NegativeImbalance = as Currency<::AccountId,>>::NegativeImbalance; -pub struct ToAuthor(sp_std::marker::PhantomData); -impl OnUnbalanced> for ToAuthor -where - R: pallet_balances::Config + pallet_authorship::Config, - ::AccountId: From, - ::AccountId: Into, -{ - fn on_nonzero_unbalanced(amount: NegativeImbalance) { - if let Some(author) = >::author() { - log::info!("Fee credited to block author: {:?}", author); - >::resolve_creating(&author, amount); - } else { - log::warn!("No block author found!"); - } - } -} - -parameter_types! { - // pub const TransactionByteFee: Balance = 5 * MILLICENTS; - pub FeeMultiplier: Multiplier = Multiplier::one(); - /// This value increases the priority of `Operational` transactions by adding - /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`. - pub const OperationalFeeMultiplier: u8 = 5; -} - -impl pallet_transaction_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = CurrencyAdapter>; - type OperationalFeeMultiplier = ConstU8<5>; - type WeightToFee = IdentityFee; - type LengthToFee = IdentityFee; - type FeeMultiplierUpdate = ConstFeeMultiplier; -} - -// impl pallet_transaction_payment::Config for Runtime { -// type RuntimeEvent = RuntimeEvent; -// type OnChargeTransaction = CurrencyAdapter>; -// type OperationalFeeMultiplier = OperationalFeeMultiplier; -// type WeightToFee = IdentityFee; -// type LengthToFee = ConstantMultiplier; -// type FeeMultiplierUpdate = ConstFeeMultiplier; -// } - -impl pallet_sudo::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type WeightInfo = pallet_sudo::weights::SubstrateWeight; -} - -/// Configure the pallet-template in pallets/template. -impl pallet_template::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = pallet_template::weights::SubstrateWeight; -} - -impl pallet_utility::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type PalletsOrigin = OriginCaller; - type WeightInfo = pallet_utility::weights::SubstrateWeight; -} - -parameter_types! { - // Make sure put same value with `construct_runtime` - pub const AccessSegregatorPalletIndex: u8 = 15; - pub const BridgePalletIndex: u8 = 16; - // pub const BasicFeeHandlerPalletIndex: u8 = 10; - // pub const FeeHandlerRouterPalletIndex: u8 = 12; - // pub const PercentageFeeHandlerRouterPalletIndex: u8 = 13; - // RegisteredExtrinsics here registers all valid (pallet index, extrinsic_name) paris - // make sure to update this when adding new access control extrinsic - pub RegisteredExtrinsics: Vec<(u8, Vec)> = [ - (AccessSegregatorPalletIndex::get(), b"grant_access".to_vec()), - (BridgePalletIndex::get(), b"register_domain".to_vec()), - (BridgePalletIndex::get(), b"unregister_domain".to_vec()), - (BridgePalletIndex::get(), b"transfer".to_vec()), - (BridgePalletIndex::get(), b"set_fee".to_vec()), - (BridgePalletIndex::get(), b"deposit".to_vec()), - (BridgePalletIndex::get(), b"execute_proposals".to_vec()), - (BridgePalletIndex::get(), b"pause_bridge".to_vec()), - (BridgePalletIndex::get(), b"unpause_bridge".to_vec()), - (BridgePalletIndex::get(), b"pause_all_bridges".to_vec()), - (BridgePalletIndex::get(), b"unpause_all_bridges".to_vec()), - // (BridgePalletIndex::get(), b"retry".to_vec()), - // (FeeHandlerRouterPalletIndex::get(), b"set_fee_handler".to_vec()), - // (PercentageFeeHandlerRouterPalletIndex::get(), b"set_fee_rate".to_vec()), - ].to_vec(); -} - - -impl aga_access_segregator::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type BridgeCommitteeOrigin = frame_system::EnsureRoot; - type PalletIndex = AccessSegregatorPalletIndex; - type Extrinsics = RegisteredExtrinsics; - type WeightInfo = aga_access_segregator::weights::SygmaWeightInfo; -} - -parameter_types! { - // TreasuryAccount is an substrate account and currently used for substrate -> EVM bridging fee collection - // TreasuryAccount address: 5ELLU7ibt5ZrNEYRwohtaRBDBa3TzcWwwPELBPSWWd2mbgv3 - pub BridgeAccountNativeFee: AccountId = AccountId::new([100u8; 32]); - // BridgeAccountNative: 5EYCAe5jLbHcAAMKvLFSXgCTbPrLgBJusvPwfKcaKzuf5X5e - pub BridgeAccountNative: AccountId = AgaBridgePalletId::get().into_account_truncating(); - // AgaBridgePalletId is the palletIDl - // this is used as the replacement of handler address in the ProposalExecution event - pub const AgaBridgePalletId: PalletId = PalletId(*b"aga/0001"); - /// Native asset's ResourceId. - pub const AgaResourceId: [u8; 32] = [0u8; 32]; -} - -// This bridge only support AGA Coin -impl aga_bridge::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type AssetKind = Balance; - type NativeBalances = Balances; - type TransferReserveAccount = BridgeAccountNative; - type FeeReserveAccount = BridgeAccountNativeFee; - type PalletId = AgaBridgePalletId; - type PalletIndex = BridgePalletIndex; - type ResourceId = AgaResourceId; - type WeightInfo = aga_bridge::weights::SubstrateWeight; -} - - -impl pallet_asset_rate::Config for Runtime { - type WeightInfo = pallet_asset_rate::weights::SubstrateWeight; - type RuntimeEvent = RuntimeEvent; - type CreateOrigin = EnsureRoot; - type RemoveOrigin = EnsureRoot; - type UpdateOrigin = EnsureRoot; - type Currency = Balances; - type AssetKind = u32; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = runtime_common::impls::benchmarks::AssetRateArguments; -} - -parameter_types! { - pub const MaxWellKnownNodes: u32 = 8; - pub const MaxPeerIdLength: u32 = 128; -} - -impl pallet_node_authorization::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type MaxWellKnownNodes = MaxWellKnownNodes; - type MaxPeerIdLength = MaxPeerIdLength; - type AddOrigin = EnsureRoot; - type RemoveOrigin = EnsureRoot; - type SwapOrigin = EnsureRoot; - type ResetOrigin = EnsureRoot; - type WeightInfo = (); -} - -parameter_types! { - pub const MinAuthorities: u32 = 2; -} - -impl pallet_validator_set::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type AddRemoveOrigin = EnsureRoot; - type MinAuthorities = MinAuthorities; - type WeightInfo = pallet_validator_set::weights::SubstrateWeight; -} - -parameter_types! { - pub const Period: u32 = 2 * MINUTES; - pub const Offset: u32 = 0; -} - -impl pallet_session::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ValidatorId = ::AccountId; - type ValidatorIdOf = pallet_validator_set::ValidatorOf; - type ShouldEndSession = pallet_session::PeriodicSessions; - type NextSessionRotation = pallet_session::PeriodicSessions; - type SessionManager = ValidatorSet; - type SessionHandler = ::KeyTypeIdProviders; - type Keys = opaque::SessionKeys; - type WeightInfo = pallet_session::weights::SubstrateWeight; -} - -impl pallet_session::historical::Config for Runtime { - type FullIdentification = Self::ValidatorId; - type FullIdentificationOf = Self::ValidatorIdOf; -} - construct_runtime!( pub enum Runtime { System: frame_system = 0, @@ -509,22 +198,18 @@ construct_runtime!( ValidatorSet: pallet_validator_set = 3, Session: pallet_session = 4, Aura: pallet_aura = 5, - Historical: pallet_session::historical = 6, - Grandpa: pallet_grandpa = 7, - TransactionPayment: pallet_transaction_payment = 8, - Sudo: pallet_sudo = 9, - TemplateModule: pallet_template = 10, - Assets: pallet_assets:: = 11, - PoolAssets: pallet_assets:: = 12, - AssetConversion: pallet_asset_conversion = 13, - RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip = 14, - Utility: pallet_utility = 15, - Authorship: pallet_authorship = 16, - Contracts: pallet_contracts = 17, - AgaAccessSegregator: aga_access_segregator = 18, - AgaBridge: aga_bridge = 19, - AssetRate: pallet_asset_rate = 20, - NodeAuthorization: pallet_node_authorization = 21 + Grandpa: pallet_grandpa = 6, + TransactionPayment: pallet_transaction_payment = 7, + Sudo: pallet_sudo = 8, + Assets: pallet_assets:: = 9, + PoolAssets: pallet_assets:: = 10, + AssetConversion: pallet_asset_conversion = 11, + RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip = 12, + Utility: pallet_utility = 13, + Authorship: pallet_authorship = 14, + Contracts: pallet_contracts = 15, + AgaAccessSegregator: aga_access_segregator = 16, + AgaBridge: aga_bridge = 17 } ); @@ -572,17 +257,11 @@ type EventRecord = frame_system::EventRecord< ::Hash, >; -#[cfg(feature = "runtime-benchmarks")] -mod benches { - frame_benchmarking::define_benchmarks!( - [frame_benchmarking, BaselineBench::] - [frame_system, SystemBench::] - [pallet_balances, Balances] - [pallet_timestamp, Timestamp] - [pallet_sudo, Sudo] - [pallet_template, TemplateModule] - ); -} +// Prints debug output of the `contracts` pallet to stdout if the node is +// started with `-lruntime::contracts=debug`. +const CONTRACTS_DEBUG_OUTPUT: pallet_contracts::DebugInfo = pallet_contracts::DebugInfo::UnsafeDebug; +const CONTRACTS_EVENTS: pallet_contracts::CollectEvents = pallet_contracts::CollectEvents::UnsafeCollect; + impl_runtime_apis! { impl sp_api::Core for Runtime {