diff --git a/.github/workflows/pr-workflow.yml b/.github/workflows/pr-workflow.yml index 4b6b546dc93..b33a674637d 100644 --- a/.github/workflows/pr-workflow.yml +++ b/.github/workflows/pr-workflow.yml @@ -158,6 +158,41 @@ jobs: - id: ok run: echo "ok=true" >> "$GITHUB_OUTPUT" + + # build-all-outputs-packages-arm: + # outputs: + # ok: ${{ steps.ok.outputs.ok }} + # name: build-all-outputs-packages-arm + # needs: + # - privilege-check + # runs-on: + # - aarch64-linux-80C-128GB-2048GB + # concurrency: + # group: ${{ inputs.github_workflow }}-build-all-outputs-packages-arm-${{ github.event.pull_request.number || github.ref }} + # cancel-in-progress: true + # steps: + # - name: Set up Cachix + # if: ${{ inputs.flow == 'push' }} + # uses: cachix/cachix-action@586bf280495080c5a6d4868237ad28a860e4b309 + # with: + # authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + # name: composable + # installCommand: "true" + # - uses: actions/checkout@v3 + # if: ${{ inputs.flow == 'push' }} + # with: + # lfs: true + # ref: ${{ inputs.github_event_pull_request_head_sha || github.sha }} + # persist-credentials: false + # - name: Build all packages + # if: ${{ inputs.flow == 'push' }} + # uses: "./.github/templates/watch-exec" + # with: + # command: nix -- build .#all-outputs + # - id: ok + # run: echo "ok=true" >> "$GITHUB_OUTPUT" + + build-all-outputs-packages: outputs: ok: ${{ steps.ok.outputs.ok }} diff --git a/code/Cargo.toml b/code/Cargo.toml index 340635a61bf..16846148924 100644 --- a/code/Cargo.toml +++ b/code/Cargo.toml @@ -20,10 +20,10 @@ color-eyre = { version = "0.5.11", default-features = false } composable-node = { path = "parachain/node" } [features] -builtin-wasm = [ "composable-node/builtin-wasm" ] +builtin-wasm = ["composable-node/builtin-wasm"] picasso = [] -runtime-benchmarks = [ "composable-node/runtime-benchmarks" ] -std = [ "composable-node/std" ] +runtime-benchmarks = ["composable-node/runtime-benchmarks"] +std = ["composable-node/std"] [workspace.lints.rust] unsafe = "deny" diff --git a/code/cvm/lib/core/Cargo.toml b/code/cvm/lib/core/Cargo.toml index f916fef6f9a..be9decbdfe1 100644 --- a/code/cvm/lib/core/Cargo.toml +++ b/code/cvm/lib/core/Cargo.toml @@ -39,23 +39,23 @@ eth-primitive-types = { package = "primitive-types", git = "https://github.com/d prost-build = { workspace = true } [features] -default = [ "std" ] -xcm = [ "dep:xcm" ] -cosmwasm = [ "cw-storage-plus", "cw20" ] -substrate = [ "xcm" ] +default = ["std"] +xcm = ["dep:xcm"] +cosmwasm = ["cw-storage-plus", "cw20"] +substrate = ["xcm"] std = [ - "cosmwasm-std/std", - "cw-storage-plus/std", - "cw20/std", - "dep:cosmwasm-schema", - "dep:schemars", - "eth-primitive-types/json-schema", - "eth-primitive-types/std", - "ibc-proto/std", - "ibc-rs-scale/schema", - "ibc-rs-scale/std", - "num/std", - "serde-cw-value/schema", - "serde-cw-value/std", - "serde-json-wasm/std", + "cosmwasm-std/std", + "cw-storage-plus/std", + "cw20/std", + "dep:cosmwasm-schema", + "dep:schemars", + "eth-primitive-types/json-schema", + "eth-primitive-types/std", + "ibc-proto/std", + "ibc-rs-scale/schema", + "ibc-rs-scale/std", + "num/std", + "serde-cw-value/schema", + "serde-cw-value/std", + "serde-json-wasm/std", ] diff --git a/code/parachain/frame/assets-registry/Cargo.toml b/code/parachain/frame/assets-registry/Cargo.toml index f202be26f36..e82b12b3f36 100644 --- a/code/parachain/frame/assets-registry/Cargo.toml +++ b/code/parachain/frame/assets-registry/Cargo.toml @@ -42,27 +42,27 @@ frame-benchmarking = { default-features = false, workspace = true } pallet-balances = { workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "log/std", - "pallet-balances/std", - "primitives/std", - "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "xcm/std", + "codec/std", + "composable-support/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "log/std", + "pallet-balances/std", + "primitives/std", + "scale-info/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "xcm/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] diff --git a/code/parachain/frame/assets/Cargo.toml b/code/parachain/frame/assets/Cargo.toml index 6806703d3c8..ce539cb0201 100644 --- a/code/parachain/frame/assets/Cargo.toml +++ b/code/parachain/frame/assets/Cargo.toml @@ -40,31 +40,31 @@ proptest = "1.0" primitives = { path = "../../runtime/primitives", default-features = false } [features] -default = [ "std" ] +default = ["std"] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] std = [ - "codec/std", - "composable-support/std", - "composable-tests-helpers/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "num-traits/std", - "orml-tokens/std", - "orml-traits/std", - "pallet-balances/std", - "primitives/std", - "proptest/std", - "scale-info/std", - "sp-api/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "composable-support/std", + "composable-tests-helpers/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "num-traits/std", + "orml-tokens/std", + "orml-traits/std", + "pallet-balances/std", + "primitives/std", + "proptest/std", + "scale-info/std", + "sp-api/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] diff --git a/code/parachain/frame/assets/rpc/Cargo.toml b/code/parachain/frame/assets/rpc/Cargo.toml index deee3bfcc6d..8935f76943f 100644 --- a/code/parachain/frame/assets/rpc/Cargo.toml +++ b/code/parachain/frame/assets/rpc/Cargo.toml @@ -33,9 +33,9 @@ scale-info = { version = "2.1.1", default-features = false, features = [ jsonrpsee = { version = "0.16.2", features = ["server", "macros"] } [features] -default = [ "std" ] +default = ["std"] std = [ - "assets-runtime-api/std", - "composable-support/std", - "composable-traits/std", + "assets-runtime-api/std", + "composable-support/std", + "composable-traits/std", ] diff --git a/code/parachain/frame/assets/runtime-api/Cargo.toml b/code/parachain/frame/assets/runtime-api/Cargo.toml index 75357a5d6cc..80fcd107eab 100644 --- a/code/parachain/frame/assets/runtime-api/Cargo.toml +++ b/code/parachain/frame/assets/runtime-api/Cargo.toml @@ -19,11 +19,11 @@ sp-api = { default-features = false, workspace = true } sp-std = { default-features = false, workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-traits/std", - "sp-api/std", - "sp-std/std", + "codec/std", + "composable-support/std", + "composable-traits/std", + "sp-api/std", + "sp-std/std", ] diff --git a/code/parachain/frame/call-filter/Cargo.toml b/code/parachain/frame/call-filter/Cargo.toml index c9f66bfa432..148ed00fc66 100644 --- a/code/parachain/frame/call-filter/Cargo.toml +++ b/code/parachain/frame/call-filter/Cargo.toml @@ -26,15 +26,15 @@ sp-core = { workspace = true } sp-io = { workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "frame-support/std", - "frame-system/std", - "scale-info/std", - "serde", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "frame-support/std", + "frame-system/std", + "scale-info/std", + "serde", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] diff --git a/code/parachain/frame/composable-maths/Cargo.toml b/code/parachain/frame/composable-maths/Cargo.toml index fe2082048e5..2269f5e4c18 100644 --- a/code/parachain/frame/composable-maths/Cargo.toml +++ b/code/parachain/frame/composable-maths/Cargo.toml @@ -34,12 +34,12 @@ rust_decimal = { version = "1.2", default-features = false, features = [ ] } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-tests-helpers/std", - "frame-support/std", - "scale-info/std", - "sp-std/std", + "codec/std", + "composable-support/std", + "composable-tests-helpers/std", + "frame-support/std", + "scale-info/std", + "sp-std/std", ] diff --git a/code/parachain/frame/composable-support/Cargo.toml b/code/parachain/frame/composable-support/Cargo.toml index 30a1b6151da..99944a94a52 100644 --- a/code/parachain/frame/composable-support/Cargo.toml +++ b/code/parachain/frame/composable-support/Cargo.toml @@ -49,6 +49,6 @@ serde_json = "1.0.45" sp-io = { workspace = true } [features] -default = [ "std" ] -schema = [ "schemars", "std" ] -std = [ "codec/std", "frame-support/std", "scale-info/std", "sp-std/std" ] +default = ["std"] +schema = ["schemars", "std"] +std = ["codec/std", "frame-support/std", "scale-info/std", "sp-std/std"] diff --git a/code/parachain/frame/composable-tests-helpers/Cargo.toml b/code/parachain/frame/composable-tests-helpers/Cargo.toml index 9834609c7b2..cc8f7b356d3 100644 --- a/code/parachain/frame/composable-tests-helpers/Cargo.toml +++ b/code/parachain/frame/composable-tests-helpers/Cargo.toml @@ -28,21 +28,21 @@ package = "parity-scale-codec" version = "3.0.0" [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "frame-support/std", - "frame-system/std", - "pallet-timestamp/std", - "scale-info/std", - "serde", - "sp-runtime/std", + "codec/std", + "composable-support/std", + "frame-support/std", + "frame-system/std", + "pallet-timestamp/std", + "scale-info/std", + "serde", + "sp-runtime/std", ] runtime-benchmarks = [ - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", ] diff --git a/code/parachain/frame/composable-traits/Cargo.toml b/code/parachain/frame/composable-traits/Cargo.toml index 40d6c35cd0b..e3ecf0ad11d 100644 --- a/code/parachain/frame/composable-traits/Cargo.toml +++ b/code/parachain/frame/composable-traits/Cargo.toml @@ -61,27 +61,27 @@ version = "3.0.0" proptest = { version = "1.0.0" } [features] -default = [ "centauri", "std" ] +default = ["centauri", "std"] std = [ - "codec/std", - "composable-support/std", - "cosmwasm-schema", - "cosmwasm-std/std", - "frame-support/std", - "frame-system/std", - "pallet-ibc/std", - "polkadot-parachain/std", - "proxy/std", - "scale-info/std", - "schemars", - "sp-core/std", - "sp-runtime/std", - "sp-std/std", - "xc-core/std", - "xcm/std", + "codec/std", + "composable-support/std", + "cosmwasm-schema", + "cosmwasm-std/std", + "frame-support/std", + "frame-system/std", + "pallet-ibc/std", + "polkadot-parachain/std", + "proxy/std", + "scale-info/std", + "schemars", + "sp-core/std", + "sp-runtime/std", + "sp-std/std", + "xc-core/std", + "xcm/std", ] test-utils = [] -visualization = [ "plotters" ] +visualization = ["plotters"] centauri = [] [package.metadata.cargo-udeps.ignore] diff --git a/code/parachain/frame/cosmwasm/Cargo.toml b/code/parachain/frame/cosmwasm/Cargo.toml index 71b5a3b8834..95a668d31e9 100644 --- a/code/parachain/frame/cosmwasm/Cargo.toml +++ b/code/parachain/frame/cosmwasm/Cargo.toml @@ -108,66 +108,66 @@ rand = { version = "0.8.5", default-features = false, features = [ [features] -default = [ "std" ] +default = ["std"] runtime-benchmarks = [ - "common/runtime-benchmarks", - "composable-tests-helpers/runtime-benchmarks", - "frame-benchmarking", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "ibc-primitives/runtime-benchmarks", - "orml-tokens/runtime-benchmarks", - "pallet-assets-registry/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-ibc/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "rand", - "sp-runtime/runtime-benchmarks", + "common/runtime-benchmarks", + "composable-tests-helpers/runtime-benchmarks", + "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "ibc-primitives/runtime-benchmarks", + "orml-tokens/runtime-benchmarks", + "pallet-assets-registry/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-ibc/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "rand", + "sp-runtime/runtime-benchmarks", ] std = [ - "codec/std", - "common/std", - "composable-support/std", - "composable-tests-helpers/std", - "composable-traits/std", - "cosmwasm-std/std", - "cosmwasm-vm-wasmi/std", - "cosmwasm-vm/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "hex/std", - "ibc-primitives/std", - "ibc/std", - "libsecp256k1/std", - "log/std", - "num-traits/std", - "orml-tokens/std", - "orml-traits/std", - "pallet-assets-registry/std", - "pallet-assets/std", - "pallet-balances/std", - "pallet-ibc/std", - "pallet-timestamp/std", - "parity-wasm/std", - "primitives/std", - "rand/std", - "scale-info/std", - "serde/std", - "serde_json/std", - "sha2/std", - "sha3/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "vec1/std", - "wasm-instrument/std", - "wasmi-validation/std", - "wasmi/std", + "codec/std", + "common/std", + "composable-support/std", + "composable-tests-helpers/std", + "composable-traits/std", + "cosmwasm-std/std", + "cosmwasm-vm-wasmi/std", + "cosmwasm-vm/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "hex/std", + "ibc-primitives/std", + "ibc/std", + "libsecp256k1/std", + "log/std", + "num-traits/std", + "orml-tokens/std", + "orml-traits/std", + "pallet-assets-registry/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-ibc/std", + "pallet-timestamp/std", + "parity-wasm/std", + "primitives/std", + "rand/std", + "scale-info/std", + "serde/std", + "serde_json/std", + "sha2/std", + "sha3/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "vec1/std", + "wasm-instrument/std", + "wasmi-validation/std", + "wasmi/std", ] [[bin]] diff --git a/code/parachain/frame/cosmwasm/runtime-api/Cargo.toml b/code/parachain/frame/cosmwasm/runtime-api/Cargo.toml index b6509ebe809..20ce1b871f4 100644 --- a/code/parachain/frame/cosmwasm/runtime-api/Cargo.toml +++ b/code/parachain/frame/cosmwasm/runtime-api/Cargo.toml @@ -17,5 +17,5 @@ sp-api = { default-features = false, workspace = true } sp-std = { default-features = false, workspace = true } [features] -default = [ "std" ] -std = [ "sp-api/std" ] +default = ["std"] +std = ["sp-api/std"] diff --git a/code/parachain/frame/crowdloan-rewards/Cargo.toml b/code/parachain/frame/crowdloan-rewards/Cargo.toml index 9b7c312f8a2..f6645a36e10 100644 --- a/code/parachain/frame/crowdloan-rewards/Cargo.toml +++ b/code/parachain/frame/crowdloan-rewards/Cargo.toml @@ -59,43 +59,43 @@ serde = { version = '1.0.136', optional = true } composable-support = { path = "../composable-support", default-features = false } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-tests-helpers/std", - "ed25519-dalek/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "hex/std", - "libsecp256k1/std", - "pallet-balances/std", - "pallet-timestamp/std", - "rustc-hex/std", - "scale-info/std", - "serde/std", - "sp-application-crypto/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-keystore/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "composable-support/std", + "composable-tests-helpers/std", + "ed25519-dalek/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "hex/std", + "libsecp256k1/std", + "pallet-balances/std", + "pallet-timestamp/std", + "rustc-hex/std", + "scale-info/std", + "serde/std", + "sp-application-crypto/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-keystore/std", + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ - "composable-tests-helpers/runtime-benchmarks", - "ed25519-dalek", - "frame-benchmarking", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "libsecp256k1", - "pallet-balances/runtime-benchmarks", - "pallet-timestamp", - "pallet-timestamp/runtime-benchmarks", - "sp-application-crypto", - "sp-runtime/runtime-benchmarks", + "composable-tests-helpers/runtime-benchmarks", + "ed25519-dalek", + "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "libsecp256k1", + "pallet-balances/runtime-benchmarks", + "pallet-timestamp", + "pallet-timestamp/runtime-benchmarks", + "sp-application-crypto", + "sp-runtime/runtime-benchmarks", ] diff --git a/code/parachain/frame/crowdloan-rewards/runtime-api/Cargo.toml b/code/parachain/frame/crowdloan-rewards/runtime-api/Cargo.toml index 4270edb46de..84d2758f1a0 100644 --- a/code/parachain/frame/crowdloan-rewards/runtime-api/Cargo.toml +++ b/code/parachain/frame/crowdloan-rewards/runtime-api/Cargo.toml @@ -18,5 +18,5 @@ sp-api = { default-features = false, workspace = true } [features] -default = [ "std" ] -std = [ "composable-support/std", "sp-api/std" ] +default = ["std"] +std = ["composable-support/std", "sp-api/std"] diff --git a/code/parachain/frame/dex-router/Cargo.toml b/code/parachain/frame/dex-router/Cargo.toml index b139993784d..8f9da7540a6 100644 --- a/code/parachain/frame/dex-router/Cargo.toml +++ b/code/parachain/frame/dex-router/Cargo.toml @@ -46,27 +46,27 @@ pallet-timestamp = { default-features = false, workspace = true } primitives = { path = "../../runtime/primitives", default-features = false } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-tests-helpers/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "orml-tokens/std", - "orml-traits/std", - "pallet-assets-registry/std", - "pallet-pablo/std", - "primitives/std", - "scale-info/std", - "serde/std", - "sp-runtime/std", + "codec/std", + "composable-support/std", + "composable-tests-helpers/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "orml-tokens/std", + "orml-traits/std", + "pallet-assets-registry/std", + "pallet-pablo/std", + "primitives/std", + "scale-info/std", + "serde/std", + "sp-runtime/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] diff --git a/code/parachain/frame/farming/Cargo.toml b/code/parachain/frame/farming/Cargo.toml index 16953ed708b..5404c96ae1a 100644 --- a/code/parachain/frame/farming/Cargo.toml +++ b/code/parachain/frame/farming/Cargo.toml @@ -48,28 +48,28 @@ composable-support = { path = "../composable-support", default-features = false primitives = { path = "../../runtime/primitives", default-features = false } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "log/std", - "pallet-assets/std", - "primitives/std", - "reward/std", - "serde", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "composable-support/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "log/std", + "pallet-assets/std", + "primitives/std", + "reward/std", + "serde", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] diff --git a/code/parachain/frame/liquid-staking/Cargo.toml b/code/parachain/frame/liquid-staking/Cargo.toml index e23e36a34a1..9cfed1bbd3a 100644 --- a/code/parachain/frame/liquid-staking/Cargo.toml +++ b/code/parachain/frame/liquid-staking/Cargo.toml @@ -71,24 +71,24 @@ pallet-message-queue = { git = "https://github.com/paritytech/substrate", defaul composable-traits = { path = "../composable-traits", default-features = false } [features] -default = [ "std" ] +default = ["std"] std = [ - 'cumulus-primitives-core/std', - 'frame-support/std', - 'frame-system/std', - 'pallet-utility/std', - 'pallet-xcm-helper/std', - 'pallet-xcm/std', - 'parity-scale-codec/std', - 'polkadot-parachain/std', - 'polkadot-primitives/std', - 'primitives/std', - 'scale-info/std', - 'sp-runtime/std', - 'sp-std/std', - 'sp-trie/std', - 'xcm/std', - "composable-support/std", - "composable-traits/std" + 'cumulus-primitives-core/std', + 'frame-support/std', + 'frame-system/std', + 'pallet-utility/std', + 'pallet-xcm-helper/std', + 'pallet-xcm/std', + 'parity-scale-codec/std', + 'polkadot-parachain/std', + 'polkadot-primitives/std', + 'primitives/std', + 'scale-info/std', + 'sp-runtime/std', + 'sp-std/std', + 'sp-trie/std', + 'xcm/std', + "composable-support/std", + "composable-traits/std", ] runtime-benchmarks = [] diff --git a/code/parachain/frame/oracle/Cargo.toml b/code/parachain/frame/oracle/Cargo.toml index 7bb6847a902..c94b1c9087a 100644 --- a/code/parachain/frame/oracle/Cargo.toml +++ b/code/parachain/frame/oracle/Cargo.toml @@ -53,27 +53,27 @@ serde = { version = '1.0.136' } sp-keystore = { workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-tests-helpers/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "lite-json/std", - "log/std", - "pallet-balances/std", - "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "composable-support/std", + "composable-tests-helpers/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "lite-json/std", + "log/std", + "pallet-balances/std", + "scale-info/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] diff --git a/code/parachain/frame/origins/Cargo.toml b/code/parachain/frame/origins/Cargo.toml index 72fafd18b3d..c9cf8e17e3d 100644 --- a/code/parachain/frame/origins/Cargo.toml +++ b/code/parachain/frame/origins/Cargo.toml @@ -30,14 +30,14 @@ sp-std = { default-features = false, workspace = true } strum_macros = "0.24" strum = { version = "0.24", default-features = false, features = ["derive"] } [features] -default = [ "std" ] +default = ["std"] std = [ - "frame-support/std", - "frame-system/std", - "scale-info/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "frame-support/std", + "frame-system/std", + "scale-info/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] diff --git a/code/parachain/frame/pablo/Cargo.toml b/code/parachain/frame/pablo/Cargo.toml index 1b2f5b71a70..4742a21df45 100644 --- a/code/parachain/frame/pablo/Cargo.toml +++ b/code/parachain/frame/pablo/Cargo.toml @@ -48,34 +48,34 @@ primitives = { path = "../../runtime/primitives", default-features = false } proptest = { version = "1.0" } [features] -default = [ "std" ] +default = ["std"] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] std = [ - "codec/std", - "composable-maths/std", - "composable-support/std", - "composable-tests-helpers/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "orml-tokens/std", - "orml-traits/std", - "pallet-assets-registry/std", - "pallet-assets/std", - "pallet-balances/std", - "pallet-ibc/std", - "pallet-timestamp/std", - "primitives/std", - "rust_decimal/std", - "scale-info/std", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "composable-maths/std", + "composable-support/std", + "composable-tests-helpers/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "orml-tokens/std", + "orml-traits/std", + "pallet-assets-registry/std", + "pallet-assets/std", + "pallet-balances/std", + "pallet-ibc/std", + "pallet-timestamp/std", + "primitives/std", + "rust_decimal/std", + "scale-info/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] diff --git a/code/parachain/frame/pablo/runtime-api/Cargo.toml b/code/parachain/frame/pablo/runtime-api/Cargo.toml index 2d5490a0668..489ee610e83 100644 --- a/code/parachain/frame/pablo/runtime-api/Cargo.toml +++ b/code/parachain/frame/pablo/runtime-api/Cargo.toml @@ -21,5 +21,5 @@ sp-std = { default-features = false, workspace = true } # REVIEW: Does the runtime API need features? [features] -default = [ "std" ] -std = [ "composable-support/std", "composable-traits/std", "sp-api/std" ] +default = ["std"] +std = ["composable-support/std", "composable-traits/std", "sp-api/std"] diff --git a/code/parachain/frame/pallet-multihop-xcm-ibc/Cargo.toml b/code/parachain/frame/pallet-multihop-xcm-ibc/Cargo.toml index 79ca98d9cad..67aa7597e22 100644 --- a/code/parachain/frame/pallet-multihop-xcm-ibc/Cargo.toml +++ b/code/parachain/frame/pallet-multihop-xcm-ibc/Cargo.toml @@ -60,40 +60,40 @@ frame-benchmarking = { default-features = false, workspace = true } pallet-balances = { workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "bech32-no_std/std", - "codec/std", - "composable-support/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "hex/std", - "ibc-primitives/std", - "ibc-rs-scale/std", - "log/std", - "orml-xtokens/std", - "pallet-balances/std", - "pallet-ibc/std", - "primitives/std", - "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "xc-core/std", - "xcm/std", + "bech32-no_std/std", + "codec/std", + "composable-support/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "hex/std", + "ibc-primitives/std", + "ibc-rs-scale/std", + "log/std", + "orml-xtokens/std", + "pallet-balances/std", + "pallet-ibc/std", + "primitives/std", + "scale-info/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "xc-core/std", + "xcm/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "ibc-primitives/runtime-benchmarks", - "orml-xtokens/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-ibc/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "ibc-primitives/runtime-benchmarks", + "orml-xtokens/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-ibc/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", ] diff --git a/code/parachain/frame/pallet-xcm-helper/Cargo.toml b/code/parachain/frame/pallet-xcm-helper/Cargo.toml index b8883190e08..c549364e693 100644 --- a/code/parachain/frame/pallet-xcm-helper/Cargo.toml +++ b/code/parachain/frame/pallet-xcm-helper/Cargo.toml @@ -53,23 +53,23 @@ xcm-executor = { workspace = true, features = ['std'] } pallet-assets = { git = 'https://github.com/paritytech/substrate.git', branch = 'polkadot-v0.9.43', default-features = false } [features] -default = [ 'std' ] +default = ['std'] # runtime-benchmarks = ['frame-benchmarking'] std = [ - 'cumulus-primitives-core/std', - 'frame-benchmarking/std', - 'frame-support/std', - 'frame-system/std', - 'parity-scale-codec/std', - 'polkadot-parachain/std', - 'polkadot-primitives/std', - 'primitives/std', - 'scale-info/std', - 'sp-core/std', - 'sp-runtime/std', - 'sp-std/std', - 'xcm-executor/std', - 'xcm/std', - "pallet-assets/std" + 'cumulus-primitives-core/std', + 'frame-benchmarking/std', + 'frame-support/std', + 'frame-system/std', + 'parity-scale-codec/std', + 'polkadot-parachain/std', + 'polkadot-primitives/std', + 'primitives/std', + 'scale-info/std', + 'sp-core/std', + 'sp-runtime/std', + 'sp-std/std', + 'xcm-executor/std', + 'xcm/std', + "pallet-assets/std", ] runtime-benchmarks = [] diff --git a/code/parachain/frame/revenue-ibc/Cargo.toml b/code/parachain/frame/revenue-ibc/Cargo.toml index f5cafa84108..7558cc59787 100644 --- a/code/parachain/frame/revenue-ibc/Cargo.toml +++ b/code/parachain/frame/revenue-ibc/Cargo.toml @@ -47,26 +47,26 @@ ibc-rs-scale = { workspace = true, default-features = false, features = [ "serde", ] } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "common/std", - "composable-support/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "pallet-ibc/std", - "primitives/std", - "scale-info/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "common/std", + "composable-support/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "pallet-ibc/std", + "primitives/std", + "scale-info/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] diff --git a/code/parachain/frame/reward/Cargo.toml b/code/parachain/frame/reward/Cargo.toml index 3c00f42a240..5eb31388559 100644 --- a/code/parachain/frame/reward/Cargo.toml +++ b/code/parachain/frame/reward/Cargo.toml @@ -39,24 +39,24 @@ rand = "0.8.3" frame-benchmarking = { default-features = false, workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "log/std", - "serde", - "sp-arithmetic/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "composable-support/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "log/std", + "serde", + "sp-arithmetic/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] diff --git a/code/parachain/frame/reward/rpc/Cargo.toml b/code/parachain/frame/reward/rpc/Cargo.toml index 4eb1e7928e1..8b7d6a4d620 100644 --- a/code/parachain/frame/reward/rpc/Cargo.toml +++ b/code/parachain/frame/reward/rpc/Cargo.toml @@ -14,4 +14,4 @@ reward-rpc-runtime-api = { path = "runtime-api" } composable-support = { path = "../../composable-support" } [features] -std = [ "composable-support/std" ] +std = ["composable-support/std"] diff --git a/code/parachain/frame/reward/rpc/runtime-api/Cargo.toml b/code/parachain/frame/reward/rpc/runtime-api/Cargo.toml index 1b18d497d6c..71d6ec9d8bc 100644 --- a/code/parachain/frame/reward/rpc/runtime-api/Cargo.toml +++ b/code/parachain/frame/reward/rpc/runtime-api/Cargo.toml @@ -19,11 +19,11 @@ scale-info = { version = "2.1.1", default-features = false, features = [ [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "frame-support/std", - "serde", - "sp-api/std", + "codec/std", + "composable-support/std", + "frame-support/std", + "serde", + "sp-api/std", ] diff --git a/code/parachain/frame/transaction-payment/Cargo.toml b/code/parachain/frame/transaction-payment/Cargo.toml index e27e43c99ec..115b7d8386f 100644 --- a/code/parachain/frame/transaction-payment/Cargo.toml +++ b/code/parachain/frame/transaction-payment/Cargo.toml @@ -32,22 +32,22 @@ serde_json = "1.0.85" pallet-balances = { workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "frame-support/std", - "frame-system/std", - "pallet-balances/std", - "scale-info/std", - "serde", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "frame-support/std", + "frame-system/std", + "pallet-balances/std", + "scale-info/std", + "serde", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] -try-runtime = [ "frame-support/try-runtime" ] +try-runtime = ["frame-support/try-runtime"] runtime-benchmarks = [ - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", ] diff --git a/code/parachain/frame/transaction-payment/asset-tx-payment/Cargo.toml b/code/parachain/frame/transaction-payment/asset-tx-payment/Cargo.toml index 0126d61c9de..91ec80737e2 100644 --- a/code/parachain/frame/transaction-payment/asset-tx-payment/Cargo.toml +++ b/code/parachain/frame/transaction-payment/asset-tx-payment/Cargo.toml @@ -45,28 +45,28 @@ pallet-balances = { workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "orml-tokens/std", - "orml-traits/std", - "pallet-authorship/std", - "pallet-balances/std", - "pallet-transaction-payment/std", - "serde", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "orml-tokens/std", + "orml-traits/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-transaction-payment/std", + "serde", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] -try-runtime = [ "frame-support/try-runtime" ] +try-runtime = ["frame-support/try-runtime"] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "pallet-transaction-payment/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-transaction-payment/runtime-benchmarks", ] diff --git a/code/parachain/frame/transaction-payment/rpc/runtime-api/Cargo.toml b/code/parachain/frame/transaction-payment/rpc/runtime-api/Cargo.toml index 9cb4e41140b..83028de346a 100644 --- a/code/parachain/frame/transaction-payment/rpc/runtime-api/Cargo.toml +++ b/code/parachain/frame/transaction-payment/rpc/runtime-api/Cargo.toml @@ -21,10 +21,10 @@ sp-api = { default-features = false, workspace = true } sp-runtime = { default-features = false, workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "pallet-transaction-payment/std", - "sp-api/std", - "sp-runtime/std", + "codec/std", + "pallet-transaction-payment/std", + "sp-api/std", + "sp-runtime/std", ] diff --git a/code/parachain/frame/vesting/Cargo.toml b/code/parachain/frame/vesting/Cargo.toml index edb2b340350..b4fda371063 100644 --- a/code/parachain/frame/vesting/Cargo.toml +++ b/code/parachain/frame/vesting/Cargo.toml @@ -33,29 +33,29 @@ pallet-timestamp = { workspace = true } sp-core = { workspace = true } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-traits/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system/std", - "orml-tokens/std", - "orml-traits/std", - "pallet-timestamp/std", - "scale-info/std", - "serde/std", - "sp-core/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "codec/std", + "composable-support/std", + "composable-traits/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "orml-tokens/std", + "orml-traits/std", + "pallet-timestamp/std", + "scale-info/std", + "serde/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", ] runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", ] -try-runtime = [ "frame-support/try-runtime" ] +try-runtime = ["frame-support/try-runtime"] diff --git a/code/parachain/node/Cargo.toml b/code/parachain/node/Cargo.toml index 87fe00615ad..f8bca66ffac 100644 --- a/code/parachain/node/Cargo.toml +++ b/code/parachain/node/Cargo.toml @@ -110,27 +110,27 @@ hex = "0.4.3" [features] builtin-wasm = [ - "composable-runtime/builtin-wasm", - "picasso-runtime/builtin-wasm", + "composable-runtime/builtin-wasm", + "picasso-runtime/builtin-wasm", ] default = [] runtime-benchmarks = [ - "composable-runtime/runtime-benchmarks", - "picasso-runtime/runtime-benchmarks", - "polkadot-cli/runtime-benchmarks", - "polkadot-service/runtime-benchmarks", + "composable-runtime/runtime-benchmarks", + "picasso-runtime/runtime-benchmarks", + "polkadot-cli/runtime-benchmarks", + "polkadot-service/runtime-benchmarks", ] std = [ - "assets-rpc/std", - "assets-runtime-api/std", - "common/std", - "composable-runtime/std", - "cosmwasm-runtime-api/std", - "crowdloan-rewards-runtime-api/std", - "pablo-runtime-api/std", - "pallet-assets/std", - "pallet-crowdloan-rewards/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "picasso-runtime/std", - "primitives/std", + "assets-rpc/std", + "assets-runtime-api/std", + "common/std", + "composable-runtime/std", + "cosmwasm-runtime-api/std", + "crowdloan-rewards-runtime-api/std", + "pablo-runtime-api/std", + "pallet-assets/std", + "pallet-crowdloan-rewards/std", + "pallet-transaction-payment-rpc-runtime-api/std", + "picasso-runtime/std", + "primitives/std", ] diff --git a/code/parachain/runtime/common/Cargo.toml b/code/parachain/runtime/common/Cargo.toml index bf30338b9fa..ba8fd0b3988 100644 --- a/code/parachain/runtime/common/Cargo.toml +++ b/code/parachain/runtime/common/Cargo.toml @@ -73,36 +73,36 @@ orml-tokens = { workspace = true, default-features = false } sudo = { default-features = false, workspace = true } [features] -default = [ "std" ] +default = ["std"] runtime-benchmarks = [] std = [ - "balances/std", - "codec/std", - "collator-selection/std", - "collective/std", - "composable-support/std", - "composable-traits/std", - "cosmwasm-std/std", - "cumulus-pallet-xcm/std", - "cumulus-primitives-core/std", - "frame-support/std", - "frame-system/std", - "ibc-rs-scale/std", - "orml-tokens/std", - "orml-traits/std", - "pallet-ibc/std", - "polkadot-primitives/std", - "primitives/std", - "scale-info/std", - "serde-json-wasm/std", - "sp-consensus-aura/std", - "sp-io/std", - "sp-runtime/std", - "sp-std/std", - "sudo/std", - "treasury/std", - "xcm-builder/std", - "xcm-executor/std", - "xcm/std", - "pallet-custom-origins/std" + "balances/std", + "codec/std", + "collator-selection/std", + "collective/std", + "composable-support/std", + "composable-traits/std", + "cosmwasm-std/std", + "cumulus-pallet-xcm/std", + "cumulus-primitives-core/std", + "frame-support/std", + "frame-system/std", + "ibc-rs-scale/std", + "orml-tokens/std", + "orml-traits/std", + "pallet-ibc/std", + "polkadot-primitives/std", + "primitives/std", + "scale-info/std", + "serde-json-wasm/std", + "sp-consensus-aura/std", + "sp-io/std", + "sp-runtime/std", + "sp-std/std", + "sudo/std", + "treasury/std", + "xcm-builder/std", + "xcm-executor/std", + "xcm/std", + "pallet-custom-origins/std", ] diff --git a/code/parachain/runtime/common/src/xcmp.rs b/code/parachain/runtime/common/src/xcmp.rs index 4f52d5f8e77..6e79e341693 100644 --- a/code/parachain/runtime/common/src/xcmp.rs +++ b/code/parachain/runtime/common/src/xcmp.rs @@ -311,9 +311,8 @@ pub trait DescribeLocation { impl DescribeLocation for Tuple { fn describe_location(l: &MultiLocation) -> Option> { for_tuples!( #( - match Tuple::describe_location(l) { - Some(result) => return Some(result), - None => {}, + if let Some(result) = Tuple::describe_location(l) { + return Some(result) } )* ); None @@ -325,7 +324,7 @@ impl DescribeLocation for DescribeTerminus { fn describe_location(l: &MultiLocation) -> Option> { match (l.parents, &l.interior) { (0, Here) => Some(Vec::new()), - _ => return None, + _ => None, } } } @@ -336,7 +335,7 @@ impl DescribeLocation for DescribePalletTerminal { match (l.parents, &l.interior) { (0, X1(PalletInstance(i))) => Some((b"Pallet", Compact::::from(*i as u32)).encode()), - _ => return None, + _ => None, } } } @@ -346,7 +345,7 @@ impl DescribeLocation for DescribeAccountId32Terminal { fn describe_location(l: &MultiLocation) -> Option> { match (l.parents, &l.interior) { (0, X1(AccountId32 { id, .. })) => Some((b"AccountId32", id).encode()), - _ => return None, + _ => None, } } } @@ -356,7 +355,7 @@ impl DescribeLocation for DescribeAccountKey20Terminal { fn describe_location(l: &MultiLocation) -> Option> { match (l.parents, &l.interior) { (0, X1(AccountKey20 { key, .. })) => Some((b"AccountKey20", key).encode()), - _ => return None, + _ => None, } } } @@ -368,7 +367,7 @@ impl DescribeLocation for DescribeBodyTerminal { fn describe_location(l: &MultiLocation) -> Option> { match (l.parents, &l.interior) { (0, X1(Plurality { id, part })) => Some((b"Body", id, part).encode()), - _ => return None, + _ => None, } } } @@ -400,7 +399,7 @@ impl DescribeLocation for DescribeFamily { let interior = Suffix::describe_location(&tail)?; Some((b"ParentChain", interior).encode()) }, - _ => return None, + _ => None, } } } diff --git a/code/parachain/runtime/composable-wasm/Cargo.toml b/code/parachain/runtime/composable-wasm/Cargo.toml index b74a27aa20a..23d20faf076 100644 --- a/code/parachain/runtime/composable-wasm/Cargo.toml +++ b/code/parachain/runtime/composable-wasm/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["cdylib"] name = "composable_runtime" [features] -runtime-benchmarks = [ "composable-runtime/runtime-benchmarks" ] -fastnet = [ "composable-runtime/fastnet" ] -testnet = [ "composable-runtime/testnet" ] -std = [ "composable-runtime/std" ] +runtime-benchmarks = ["composable-runtime/runtime-benchmarks"] +fastnet = ["composable-runtime/fastnet"] +testnet = ["composable-runtime/testnet"] +std = ["composable-runtime/std"] diff --git a/code/parachain/runtime/composable/Cargo.toml b/code/parachain/runtime/composable/Cargo.toml index 0b924eac29d..46cb2665a11 100644 --- a/code/parachain/runtime/composable/Cargo.toml +++ b/code/parachain/runtime/composable/Cargo.toml @@ -120,119 +120,119 @@ pallet-proxy = { default-features = false, workspace = true } [features] builtin-wasm = [] -default = [ "std" ] +default = ["std"] testnet = [] fastnet = [] runtime-benchmarks = [ - "asset-tx-payment/runtime-benchmarks", - "assets-registry/runtime-benchmarks", - "balances/runtime-benchmarks", - "collator-selection/runtime-benchmarks", - "collective/runtime-benchmarks", - "common/runtime-benchmarks", - "democracy/runtime-benchmarks", - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system-benchmarking/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "indices/runtime-benchmarks", - "membership/runtime-benchmarks", - "multisig/runtime-benchmarks", - "oracle/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", - "pallet-multihop-xcm-ibc/runtime-benchmarks", - "pallet-proxy/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "scheduler/runtime-benchmarks", - "session-benchmarking/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "timestamp/runtime-benchmarks", - "treasury/runtime-benchmarks", - "utility/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", - "crowdloan-rewards/runtime-benchmarks", - "transaction-payment/runtime-benchmarks" + "asset-tx-payment/runtime-benchmarks", + "assets-registry/runtime-benchmarks", + "balances/runtime-benchmarks", + "collator-selection/runtime-benchmarks", + "collective/runtime-benchmarks", + "common/runtime-benchmarks", + "democracy/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "indices/runtime-benchmarks", + "membership/runtime-benchmarks", + "multisig/runtime-benchmarks", + "oracle/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-multihop-xcm-ibc/runtime-benchmarks", + "pallet-proxy/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "scheduler/runtime-benchmarks", + "session-benchmarking/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "timestamp/runtime-benchmarks", + "treasury/runtime-benchmarks", + "utility/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "crowdloan-rewards/runtime-benchmarks", + "transaction-payment/runtime-benchmarks", ] std = [ - "asset-tx-payment/std", - "assets-registry/std", - "assets-runtime-api/std", - "aura/std", - "authorship/std", - "balances/std", - "call-filter/std", - "codec/std", - "collator-selection/std", - "collective/std", - "common/std", - "composable-support/std", - "composable-traits/std", - "crowdloan-rewards-runtime-api/std", - "crowdloan-rewards/std", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-dmp-queue/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "cumulus-primitives-core/std", - "cumulus-primitives-timestamp/std", - "cumulus-primitives-utility/std", - "democracy/std", - "executive/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system-benchmarking/std", - "frame-system/std", - "ibc-primitives/std", - "ibc-runtime-api/std", - "ibc/std", - "indices/std", - "membership/std", - "multisig/std", - "oracle/std", - "orml-tokens/std", - "orml-traits/std", - "orml-unknown-tokens/std", - "orml-xcm-support/std", - "orml-xtokens/std", - "pallet-assets/std", - "pallet-conviction-voting/std", - "pallet-ibc/std", - "pallet-liquid-staking/std", - "pallet-multihop-xcm-ibc/std", - "pallet-proxy/std", - "pallet-referenda/std", - "pallet-whitelist/std", - "pallet-xcm-helper/std", - "pallet-xcm/std", - "parachain-info/std", - "polkadot-parachain/std", - "preimage/std", - "primitives/std", - "scale-info/std", - "scheduler/std", - "session-benchmarking/std", - "session/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-core/std", - "sp-inherents/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-version/std", - "sudo/std", - "system-rpc-runtime-api/std", - "timestamp/std", - "transaction-payment-rpc-runtime-api/std", - "transaction-payment/std", - "treasury/std", - "utility/std", - "xcm-builder/std", - "xcm-executor/std", - "xcm/std", - "pallet-custom-origins/std" + "asset-tx-payment/std", + "assets-registry/std", + "assets-runtime-api/std", + "aura/std", + "authorship/std", + "balances/std", + "call-filter/std", + "codec/std", + "collator-selection/std", + "collective/std", + "common/std", + "composable-support/std", + "composable-traits/std", + "crowdloan-rewards-runtime-api/std", + "crowdloan-rewards/std", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-dmp-queue/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-core/std", + "cumulus-primitives-timestamp/std", + "cumulus-primitives-utility/std", + "democracy/std", + "executive/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system-benchmarking/std", + "frame-system/std", + "ibc-primitives/std", + "ibc-runtime-api/std", + "ibc/std", + "indices/std", + "membership/std", + "multisig/std", + "oracle/std", + "orml-tokens/std", + "orml-traits/std", + "orml-unknown-tokens/std", + "orml-xcm-support/std", + "orml-xtokens/std", + "pallet-assets/std", + "pallet-conviction-voting/std", + "pallet-ibc/std", + "pallet-liquid-staking/std", + "pallet-multihop-xcm-ibc/std", + "pallet-proxy/std", + "pallet-referenda/std", + "pallet-whitelist/std", + "pallet-xcm-helper/std", + "pallet-xcm/std", + "parachain-info/std", + "polkadot-parachain/std", + "preimage/std", + "primitives/std", + "scale-info/std", + "scheduler/std", + "session-benchmarking/std", + "session/std", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/std", + "sudo/std", + "system-rpc-runtime-api/std", + "timestamp/std", + "transaction-payment-rpc-runtime-api/std", + "transaction-payment/std", + "treasury/std", + "utility/std", + "xcm-builder/std", + "xcm-executor/std", + "xcm/std", + "pallet-custom-origins/std", ] diff --git a/code/parachain/runtime/picasso-wasm/Cargo.toml b/code/parachain/runtime/picasso-wasm/Cargo.toml index 288114f3374..3778ed06b8c 100644 --- a/code/parachain/runtime/picasso-wasm/Cargo.toml +++ b/code/parachain/runtime/picasso-wasm/Cargo.toml @@ -14,7 +14,7 @@ crate-type = ["cdylib"] name = "picasso_runtime" [features] -std = [ "picasso-runtime/std" ] -runtime-benchmarks = [ "picasso-runtime/runtime-benchmarks" ] -fastnet = [ "picasso-runtime/fastnet" ] -testnet = [ "picasso-runtime/testnet" ] +std = ["picasso-runtime/std"] +runtime-benchmarks = ["picasso-runtime/runtime-benchmarks"] +fastnet = ["picasso-runtime/fastnet"] +testnet = ["picasso-runtime/testnet"] diff --git a/code/parachain/runtime/picasso/Cargo.toml b/code/parachain/runtime/picasso/Cargo.toml index ea5ed547306..b358186b8b2 100644 --- a/code/parachain/runtime/picasso/Cargo.toml +++ b/code/parachain/runtime/picasso/Cargo.toml @@ -150,142 +150,142 @@ cosmwasm-vm-wasmi = { workspace = true, default-features = false, features = [ builtin-wasm = [] testnet = [] fastnet = [] -default = [ "std" ] +default = ["std"] runtime-benchmarks = [ - "asset-tx-payment/runtime-benchmarks", - "assets-registry/runtime-benchmarks", - "balances/runtime-benchmarks", - "collator-selection/runtime-benchmarks", - "collective/runtime-benchmarks", - "common/runtime-benchmarks", - "cosmwasm/runtime-benchmarks", - "crowdloan-rewards/runtime-benchmarks", - "democracy/runtime-benchmarks", - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system-benchmarking/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "identity/runtime-benchmarks", - "indices/runtime-benchmarks", - "membership/runtime-benchmarks", - "multisig/runtime-benchmarks", - "oracle/runtime-benchmarks", - "pablo/runtime-benchmarks", - "pallet-assets/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "proxy/runtime-benchmarks", - "scheduler/runtime-benchmarks", - "session-benchmarking/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "timestamp/runtime-benchmarks", - "treasury/runtime-benchmarks", - "utility/runtime-benchmarks", - "vesting/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", - "farming/runtime-benchmarks", - "pallet-multihop-xcm-ibc/runtime-benchmarks", - "revenue-ibc/runtime-benchmarks", - "transaction-payment/runtime-benchmarks", - "reward/runtime-benchmarks" + "asset-tx-payment/runtime-benchmarks", + "assets-registry/runtime-benchmarks", + "balances/runtime-benchmarks", + "collator-selection/runtime-benchmarks", + "collective/runtime-benchmarks", + "common/runtime-benchmarks", + "cosmwasm/runtime-benchmarks", + "crowdloan-rewards/runtime-benchmarks", + "democracy/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "identity/runtime-benchmarks", + "indices/runtime-benchmarks", + "membership/runtime-benchmarks", + "multisig/runtime-benchmarks", + "oracle/runtime-benchmarks", + "pablo/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "proxy/runtime-benchmarks", + "scheduler/runtime-benchmarks", + "session-benchmarking/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "timestamp/runtime-benchmarks", + "treasury/runtime-benchmarks", + "utility/runtime-benchmarks", + "vesting/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "farming/runtime-benchmarks", + "pallet-multihop-xcm-ibc/runtime-benchmarks", + "revenue-ibc/runtime-benchmarks", + "transaction-payment/runtime-benchmarks", + "reward/runtime-benchmarks", ] std = [ - "asset-tx-payment/std", - "assets-registry/std", - "assets-runtime-api/std", - "aura/std", - "authorship/std", - "balances/std", - "call-filter/std", - "codec/std", - "collator-selection/std", - "collective/std", - "common/std", - "composable-support/std", - "composable-traits/std", - "cosmwasm-runtime-api/std", - "cosmwasm-std/std", - "cosmwasm-vm-wasmi/std", - "cosmwasm-vm/std", - "cosmwasm/std", - "crowdloan-rewards-runtime-api/std", - "crowdloan-rewards/std", - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-dmp-queue/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "cumulus-primitives-core/std", - "cumulus-primitives-timestamp/std", - "cumulus-primitives-utility/std", - "democracy/std", - "executive/std", - "farming/std", - "frame-benchmarking/std", - "frame-support/std", - "frame-system-benchmarking/std", - "frame-system/std", - "ibc-primitives/std", - "ibc-runtime-api/std", - "ibc/std", - "identity/std", - "indices/std", - "log/std", - "membership/std", - "multisig/std", - "oracle/std", - "orml-tokens/std", - "orml-traits/std", - "orml-unknown-tokens/std", - "orml-xcm-support/std", - "orml-xtokens/std", - "pablo-runtime-api/std", - "pablo/std", - "pallet-assets/std", - "pallet-conviction-voting/std", - "pallet-ibc/std", - "pallet-liquid-staking/std", - "pallet-multihop-xcm-ibc/std", - "pallet-referenda/std", - "pallet-whitelist/std", - "pallet-xcm-helper/std", - "pallet-xcm/std", - "parachain-info/std", - "polkadot-parachain/std", - "preimage/std", - "primitives/std", - "proxy/std", - "revenue-ibc/std", - "reward-rpc-runtime-api/std", - "reward/std", - "scale-info/std", - "scheduler/std", - "serde-json-wasm/std", - "session-benchmarking/std", - "session/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-core/std", - "sp-inherents/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-version/std", - "sudo/std", - "system-rpc-runtime-api/std", - "timestamp/std", - "transaction-payment-rpc-runtime-api/std", - "transaction-payment/std", - "treasury/std", - "utility/std", - "vesting/std", - "xc-core/std", - "xcm-builder/std", - "xcm-executor/std", - "xcm/std", - "pallet-custom-origins/std" + "asset-tx-payment/std", + "assets-registry/std", + "assets-runtime-api/std", + "aura/std", + "authorship/std", + "balances/std", + "call-filter/std", + "codec/std", + "collator-selection/std", + "collective/std", + "common/std", + "composable-support/std", + "composable-traits/std", + "cosmwasm-runtime-api/std", + "cosmwasm-std/std", + "cosmwasm-vm-wasmi/std", + "cosmwasm-vm/std", + "cosmwasm/std", + "crowdloan-rewards-runtime-api/std", + "crowdloan-rewards/std", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-dmp-queue/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-core/std", + "cumulus-primitives-timestamp/std", + "cumulus-primitives-utility/std", + "democracy/std", + "executive/std", + "farming/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system-benchmarking/std", + "frame-system/std", + "ibc-primitives/std", + "ibc-runtime-api/std", + "ibc/std", + "identity/std", + "indices/std", + "log/std", + "membership/std", + "multisig/std", + "oracle/std", + "orml-tokens/std", + "orml-traits/std", + "orml-unknown-tokens/std", + "orml-xcm-support/std", + "orml-xtokens/std", + "pablo-runtime-api/std", + "pablo/std", + "pallet-assets/std", + "pallet-conviction-voting/std", + "pallet-ibc/std", + "pallet-liquid-staking/std", + "pallet-multihop-xcm-ibc/std", + "pallet-referenda/std", + "pallet-whitelist/std", + "pallet-xcm-helper/std", + "pallet-xcm/std", + "parachain-info/std", + "polkadot-parachain/std", + "preimage/std", + "primitives/std", + "proxy/std", + "revenue-ibc/std", + "reward-rpc-runtime-api/std", + "reward/std", + "scale-info/std", + "scheduler/std", + "serde-json-wasm/std", + "session-benchmarking/std", + "session/std", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/std", + "sudo/std", + "system-rpc-runtime-api/std", + "timestamp/std", + "transaction-payment-rpc-runtime-api/std", + "transaction-payment/std", + "treasury/std", + "utility/std", + "vesting/std", + "xc-core/std", + "xcm-builder/std", + "xcm-executor/std", + "xcm/std", + "pallet-custom-origins/std", ] diff --git a/code/parachain/runtime/primitives/Cargo.toml b/code/parachain/runtime/primitives/Cargo.toml index 995705aa777..b5ca557ad15 100644 --- a/code/parachain/runtime/primitives/Cargo.toml +++ b/code/parachain/runtime/primitives/Cargo.toml @@ -38,17 +38,17 @@ cosmwasm-std = { workspace = true, default-features = false, features = [ serde-json-wasm = { workspace = true, default-features = false } [features] -default = [ "std" ] +default = ["std"] std = [ - "codec/std", - "composable-support/std", - "composable-traits/std", - "cosmwasm-std/std", - "frame-support/std", - "ibc-rs-scale/std", - "scale-info/std", - "serde-json-wasm/std", - "sp-runtime/std", - "sp-std/std", - "xcm/std", + "codec/std", + "composable-support/std", + "composable-traits/std", + "cosmwasm-std/std", + "frame-support/std", + "ibc-rs-scale/std", + "scale-info/std", + "serde-json-wasm/std", + "sp-runtime/std", + "sp-std/std", + "xcm/std", ] diff --git a/docs/README.md b/docs/README.md index 55c01800220..c84c77fb8c1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -35,3 +35,27 @@ $ GIT_USER= yarn deploy ``` If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. + + +## Via Nix + +## Serving a hot-reloading version of these docs + +To serve a hot-reloading version of these docs, simply run: + +```bash +nix run ".#docs-dev" +``` + +And open [http://localhost:3000](http://localhost:3000/) in your browser. + +Then, edit the sources in `docs/`, and see them update live in your browser! + +## Building a static copy + +If you want to build a static copy of these docs, run: + +```bash +nix build ".#docs-static" +``` + diff --git a/docs/docs/nix.md b/docs/docs/nix.md index 4ef7242ef41..13cb79bfc23 100644 --- a/docs/docs/nix.md +++ b/docs/docs/nix.md @@ -1,11 +1,46 @@ -# Nix + +# TLDR; + +Assuming you followed official guidance to install Nix with Flakes enabled. + +Reference in your flake: + +```nix +inputs = { + composable = { + url = "github:ComposableFi/composable"; + inputs.nixpkgs.follows = "nixpkgs"; + }; +}; +``` + + +Shell into dev env: + +```bash +nix develop --impure +``` + +Format all: + +```bash +nix run ".#fmt" +``` + +Check/lint all: + +```bash +nix run ".#check" +``` + +Ask GPT or search internet (or just Github) for any issues and debugging. + +# Long Nix is a requirement to set up and start a local development environment with Composable's code. We recommend using the Zero-to-Nix installer. Refer to our docs for how to [install and configure Nix](nix/install.md). After configuration, familiarize yourself with the following commands: -`nix develop --impure` in to enter dev shell (command line, variables, tools, compilers). - `nix run "composable#devnet-picasso"` to run local devnet for Polkadot CosmWasm development. `nix run "composable#fmt"` format all files. @@ -38,3 +73,121 @@ nix run "github:ComposableFi/composable/#devnet-xc-fresh" --allow-import nix build "github:ComposableFi/composable/#devnet-xc-image" --allow-import-from-derivation --extra-experimental-features "flakes nix-command" --no-sandbox --accept-flake-config --option sandbox relaxed \ && docker load --input result && docker run -it --entrypoint bash devnet-xc:latest -c /bin/devnet-xc-fresh ``` + +# Install Nix + +## Installing Nix + +Once you have determined which one you want to use, [follow the official Nix +installation instructions](https://zero-to-nix.com/start/install). + + +## Configuring your Nix install + +### On NixOS + +In your Nix system config (`/etc/nixos/configuration.nix` by default), configure `nix` like this: + +```nix +{ + nix = { + useSandbox = "relaxed"; + extraOptions = '' + experimental-features = nix-command flakes + allow-import-from-derivation = true + ''; + sandbox = "relaxed"; + }; +} +``` + +### On non-NixOS + +Set the contents of `~/.config/nix/nix.conf` to this: + +```nix +experimental-features = nix-command flakes +sandbox = relaxed +allow-import-from-derivation = true +``` + +Append to `/etc/nix/nix.conf`: +```ini +trusted-users = +``` + +### Using flags + +If you cannot edit these config files, then you can pass the following flags to `nix`. + +```shell +--allow-import-from-derivation --extra-experimental-features "flakes nix-command" --no-sandbox --accept-flake-config --option sandbox relaxed +``` + +--- + +You are now ready to start [running packages](./run-packages)! + + +# Running Nix packages + +*Locations and packages* + +Before trying to run Nix packages, make sure you have git installed. +You can use `which git` to check for a git installation or run `sudo apt install git` to install it. + +Now you can run Nix packages! In order to run one, you need both a **location** and a **package**. + +## Locations + +Locations are the source of a `git` repository containing a Nix flake (such as [ours](https://github.com/ComposableFi/composable)). For example, a **location** can be: + +- `.` for your current directory. +- `github:ComposableFi/composable` for the latest commit on branch main. +- `github:ComposableFi/composable/67b4df903bf8dc2ab0634f9adf9988203a93af27` for commit `67b4df903bf8dc2ab0634f9adf9988203a93af27`. + +Note that for the `github:` locations, you do not need to clone the repository. For `.` you need to clone the repository and `cd` into it. + +## Packages + +Packages are defined in a repository's `flake.nix`. For example, a **package** can be: + +- `composable-book` which builds this book (so meta!). + +If you want to see all packages defined by a repository's flake, run `nix flake show "LOCATION"`, for example: `nix flake show "github:ComposableFi/composable"`. + +Once you know which **location** and **package** you want, simply run: + +```bash +nix run "location#package" +``` + +```bash +nix run "github:ComposableFi/composable#devnet-picasso" +``` + +In case of error, append `--print-build-logs --show-trace --debug --keep-derivations --keep-outputs` to command. + +## Running in Docker + +If you do not have access to `nix`, but you do have access to `docker`, then you can run nix packages within docker as follows: + + +### Creating a `nix` cache volume +In order to save time on subsequent builds, we create a volume that caches `nix` artifacts: + +```bash +docker volume create nix +``` + +### Running your `location#package` + +Make sure you replace `location#package` with your desired **location** and **package**. + +```bash +docker run -v /var/run/docker.sock:/var/run/docker.sock -v nix:/nix -p 9988:9988 -it nixos/nix bash -c "nix-env -iA nixpkgs.cachix && cachix use composable && nix run location#package --print-build-logs --extra-experimental-features nix-command --extra-experimental-features flakes" --no-sandbox" +``` + +--- + +Now that you are able to run all packages, let's [set up your declarative development environment](./development-environments)! diff --git a/docs/docs/nix/defining-your-own-packages.md b/docs/docs/nix/defining-your-own-packages.md deleted file mode 100644 index 68a951914bd..00000000000 --- a/docs/docs/nix/defining-your-own-packages.md +++ /dev/null @@ -1,12 +0,0 @@ -# Defining your own packages - -Your package can reference packages that are defined here, you should add this repository as one of your flake's inputs like this: - -```nix -inputs = { - composable = { - url = "github:ComposableFi/composable"; - inputs.nixpkgs.follows = "nixpkgs"; - }; -}; -``` \ No newline at end of file diff --git a/docs/docs/nix/development-environments.md b/docs/docs/nix/development-environments.md deleted file mode 100644 index 19b9315f90d..00000000000 --- a/docs/docs/nix/development-environments.md +++ /dev/null @@ -1,29 +0,0 @@ -# Development Environments - -*Declarative tooling* - -We want to ensure that all developers use identical tools within their shells. We also want to ensure that these tools are identical to those used in our CI pipelines and that we can declaratively upgrade developer environments. Nix allows us to do this with the [flakes](https://nixos.wiki/wiki/Flakes)' `devShell` system. - -In order to use our declarative development environment, go to your checked out repository and simply run: - -```bash -nix develop -``` - -This will download all required tools you need and put you into our declarative development environment. From there you can type `hx` in order to load [Helix](https://helix-editor.com/), a very fast editor written in Rust that is preconfigured to use the correct language server. You can also launch any other editor from here that you normally use, such as `code`, `vim`, or `emacs`. - -## Alternative `devShell`s - -We provide not only the `default` devShell but also other ones optimized for specific purposes. So, for example, you can use: - -```bash -nix develop ".#docs" -``` - -To launch a shell that only includes the required tools for writing docs. - -You can view all available devShells by typing `nix flake show`. - ---- - -Once you're done developing a new feature or fixing a bug, you should ensure that CI will pass. So let's use Nix to [reproducibly run all checks locally](./running-checks)! diff --git a/docs/docs/nix/editing-docs.md b/docs/docs/nix/editing-docs.md deleted file mode 100644 index 451e168a6e7..00000000000 --- a/docs/docs/nix/editing-docs.md +++ /dev/null @@ -1,22 +0,0 @@ -# Editing Docs - -## Serving a hot-reloading version of these docs - -To serve a hot-reloading version of these docs, simply run: - -```bash -nix run ".#docs-dev" -``` - -And open [http://localhost:3000](http://localhost:3000/) in your browser. - -Then, edit the sources in `docs/`, and see them update live in your browser! - -## Building a static copy - -If you want to build a static copy of these docs, run: - -```bash -nix build ".#docs-static" -``` - diff --git a/docs/docs/nix/install.md b/docs/docs/nix/install.md deleted file mode 100644 index 39e59828ef7..00000000000 --- a/docs/docs/nix/install.md +++ /dev/null @@ -1,53 +0,0 @@ -# Install Nix - -## Installing Nix - -Once you have determined which one you want to use, [follow the official Nix -installation instructions](https://zero-to-nix.com/start/install). - - -## Configuring your Nix install - -### On NixOS - -In your Nix system config (`/etc/nixos/configuration.nix` by default), configure `nix` like this: - -```nix -{ - nix = { - useSandbox = "relaxed"; - extraOptions = '' - experimental-features = nix-command flakes - allow-import-from-derivation = true - ''; - sandbox = "relaxed"; - }; -} -``` - -### On non-NixOS - -Set the contents of `~/.config/nix/nix.conf` to this: - -```nix -experimental-features = nix-command flakes -sandbox = relaxed -allow-import-from-derivation = true -``` - -Append to `/etc/nix/nix.conf`: -```ini -trusted-users = -``` - -### Using flags - -If you cannot edit these config files, then you can pass the following flags to `nix`. - -```shell ---allow-import-from-derivation --extra-experimental-features "flakes nix-command" --no-sandbox --accept-flake-config --option sandbox relaxed -``` - ---- - -You are now ready to start [running packages](./run-packages)! diff --git a/docs/docs/nix/reading-logs.md b/docs/docs/nix/reading-logs.md deleted file mode 100644 index 68bf7e16dc5..00000000000 --- a/docs/docs/nix/reading-logs.md +++ /dev/null @@ -1,94 +0,0 @@ -# Reading logs - -Reading CI logs can be confusing if you are unfamiliar with how Nix builds packages. Don't worry though, it is very simple once you know the basics of how Nix works. - -One of Nix' goals is to **never build the same thing twice**, in order to save us a ton of time and resources. - -It works like this for each package: - -1. Create the **derivation**, which is a pure function from inputs (source code + dependencies) to an output (example: the `composable-node` binary). -2. Get the **hash** of this derivation. -3. Look at our **cache servers**. Have we already built a **derivation** with this **hash**? - - If we have already built this, we **copy the result from the cache server**. - - If we have not built this yet, we **do the actual building**. - -This is why most of our log lines are `copying path` statments like these: - -``` -copying path '/nix/store/qrqwd1ji31vmas9gax819j11w5ickgz1-gnugrep-3.7' from 'https://cache.nixos.org'... -copying path '/nix/store/xcs3ns14mddbjsr96cg7mzkqp7ml21qi-centauri' from 'https://composable.cachix.org'... -``` - -The first one is copying `gnugrep-3.7` with hash `qrqwd1ji31vmas9gax819j11w5ickgz1` from the cache server `cache.nixos.org`. This is a system dependency, so it is in the global `cache.nixos.org` cache server. -The second one is copying `centauri` with the hash `xcs3ns14mddbjsr96cg7mzkqp7ml21qi` from the cache server `composable.cachix.org`. This is one of our own pacakges, so it is cached in our own `composable.cachix.org` cache server. - -## The "Build all packages" job - -Most of our building happens in the "Build all packages" job, which builts all of our packages. This happens on two machines, `x64-monster` and `arm-monster`. These are beefy machines with a ton of cores, capable of compiling all of our packages in parallel for both CPU architectures. - -Most of the log lines will be `copying path` (as mentioned above). For the derivations that are not found in the **cache servers** (the things that have been altered by your PR) you will see log lines like the following: - -``` -zombienet> patching sources -zombienet> updateAutotoolsGnuConfigScriptsPhase -zombienet> configuring -zombienet> no configure script, doing nothing -zombienet> building -``` - -Where `zombienet>` is the package being built, succeeded by the unaltered log lines emitted by the build process of this package. - -When all packages have been downloaded/built, you will see the following log lines at the end: - -``` -Waiting to finish: 1 pushing, 3 in queue -``` - -This is the process of Nix uploading our built derivations to our **cache server**, so that they do not need to be rebuilt next time. - -## The "List built results" step - -Once the "Build all packages" step is completed, we list all of the things that we have built, such as this: - -``` -acala -bifrost -cmc-api -composable -composable-2.10005.0 -composable-build-2.10005.0 -composable-clippy-2.10005.0 -composable-fmt-2.10005.0 -... -etc -``` - -## Which packages will be built? - -All of the packages that are in the monorepo's `/flake/all.nix` list. - -## The "Build all packages" step is failing! Why? - -Read through the logs and look for packages that are being built. You will see - -``` -a-package-you-worked-on> Some error emitted by the pacakge you have altered in your PR -``` - -If you want to easily reproduce this error locally you can then run - -``` -nix build .\#a-package-you-worked-on -L -``` - -in your local copy of the monorepo. - -## I want to build everything that CI is building locally, how do I do this? - -Just run the following: - -``` -nix build .\#all -L -``` - -on your machine, inside of the monorepo directory. If you have [installed Nix correctly and configred your machine to use our **cache server**](./install), then this should be quick as most derivations will be on our cache server. \ No newline at end of file diff --git a/docs/docs/nix/run-packages.md b/docs/docs/nix/run-packages.md deleted file mode 100644 index ceacecdad4b..00000000000 --- a/docs/docs/nix/run-packages.md +++ /dev/null @@ -1,62 +0,0 @@ -# Running Nix packages - -*Locations and packages* - -Before trying to run Nix packages, make sure you have git installed. -You can use `which git` to check for a git installation or run `sudo apt install git` to install it. - -Now you can run Nix packages! In order to run one, you need both a **location** and a **package**. - -## Locations - -Locations are the source of a `git` repository containing a Nix flake (such as [ours](https://github.com/ComposableFi/composable)). For example, a **location** can be: - -- `.` for your current directory. -- `github:ComposableFi/composable` for the latest commit on branch main. -- `github:ComposableFi/composable/67b4df903bf8dc2ab0634f9adf9988203a93af27` for commit `67b4df903bf8dc2ab0634f9adf9988203a93af27`. - -Note that for the `github:` locations, you do not need to clone the repository. For `.` you need to clone the repository and `cd` into it. - -## Packages - -Packages are defined in a repository's `flake.nix`. For example, a **package** can be: - -- `composable-book` which builds this book (so meta!). - -If you want to see all packages defined by a repository's flake, run `nix flake show "LOCATION"`, for example: `nix flake show "github:ComposableFi/composable"`. - -Once you know which **location** and **package** you want, simply run: - -```bash -nix run "location#package" -``` - -```bash -nix run "github:ComposableFi/composable#devnet-picasso" -``` - -In case of error, append `--print-build-logs --show-trace --debug --keep-derivations --keep-outputs` to command. - -## Running in Docker - -If you do not have access to `nix`, but you do have access to `docker`, then you can run nix packages within docker as follows: - - -### Creating a `nix` cache volume -In order to save time on subsequent builds, we create a volume that caches `nix` artifacts: - -```bash -docker volume create nix -``` - -### Running your `location#package` - -Make sure you replace `location#package` with your desired **location** and **package**. - -```bash -docker run -v /var/run/docker.sock:/var/run/docker.sock -v nix:/nix -p 9988:9988 -it nixos/nix bash -c "nix-env -iA nixpkgs.cachix && cachix use composable && nix run location#package --print-build-logs --extra-experimental-features nix-command --extra-experimental-features flakes" --no-sandbox" -``` - ---- - -Now that you are able to run all packages, let's [set up your declarative development environment](./development-environments)! diff --git a/docs/docs/nix/running-checks.md b/docs/docs/nix/running-checks.md deleted file mode 100644 index df4c07ea133..00000000000 --- a/docs/docs/nix/running-checks.md +++ /dev/null @@ -1,45 +0,0 @@ -# Running Checks - -*Cut your check-fix feedback-loop by not waiting on CI runners.* - -We've all been there. You're working on a PR, submit it for review, ping your colleagues to review it on Slack, only to notice that checks are suddenly failing in CI. - -The failing checks happened because it was difficult to reliably run the same checks that CI is running on your local machine. However, Nix fixes this and allows you to **run the same checks locally**. - -Since checks are just packages defined by our repositories' flakes, you can efficiently run them locally. - -Nix also allows you to easily format the entire repository per our formatting spec. - -## Formatting the repository - -We have many different formatting checks, but instead of checking what is unformatted, you can simply run one command to format the entire repository: - -```bash -nix run ".#fmt" -``` - -## Running all checks - -This check runs most of the checks that CI runs. Note that running these checks for the first time will take very long as nothing is cached yet. After that, checks should be faster. - -```bash -nix run ".#check" -``` - -## Running individual checks - -It is also possible to run individual checks, here are some examples: - -### Clippy errors - -```bash -nix build ".#cargo-clippy-check" -``` - -### All others - -There are many more checks we can run. If you want to reproduce one from CI locally, you can check `nix flake show` and the workflows defined under `.github/` to see which `nix` command they are invoking. - ---- - -You now know all you need to know to work on existing packages. However, if you need to introduce a new package, here's how to use Nix to [define your own packages](./defining-your-own-packages)! diff --git a/docs/docs/nix/troubleshooting.md b/docs/docs/nix/troubleshooting.md deleted file mode 100644 index 7e18807df6b..00000000000 --- a/docs/docs/nix/troubleshooting.md +++ /dev/null @@ -1,95 +0,0 @@ -# Troubleshooting - -This document intends to record frequently occurring issues running our Nix setup and how to fix -them. Please note that this list is not exhaustive and only suggests some known fixes that may not -apply to your issue. - -## No space left on device - -``` -LLVM ERROR: IO failure on output stream: No space left on device -``` - -If you encounter a `No space left on device` error even though enough disk space is available, -we need to increase the maximum size of your `/tmp` directory. - -You can achieve this one of two ways: - -### 1. Temporary fix - -To fix the issue temporarily, use the following command as `root` user. - -```shell -$ mount -o remount,size=16G /tmp/ -``` - -This command will remount the `/tmp` directory with an increased size of up to 16Gb. - -### 2. Permanent fix - -To fix this issue permanently, we need to edit the `/etc/fstab` file using a text editor of your -choice. - -Look for a line starting with `tmpfs` and update it like the following, or append it to the bottom -if it doesn't exist yet. - -```shell -$ tmpfs /tmp tmpfs rw,nodev,nosuid,size=16G 0 0 -``` - -This change will permanently mount the `/tmp` directory with a fixed size of 16Gb. - -## Too many open files - -If you encounter a `Too many open files` error, this limit needs to be increased. - -The easiest way is to modify the `run` command with the `ulimit` command. Like the following: - -```shell -$ bash -c 'ulimit -n 10000; nix run github:composablefi/composable#devnet-dali` -``` - -## Nix run command does not respect `nix.conf` configuration. - -If you're running Nix on a non-NixOS Linux distribution, even if your config file(s) are set up correctly, -you may encounter some or all of the following issues: - -``` -experimental Nix feature is disabled. -``` - -``` -error: derivation '/nix/store/some-derivation.drv' has '__noChroot' set, but that's not allowed when 'sandbox' is 'true' -``` - -This is due to Nix not reading the config file. Following are some possible solutions: - -### Restart Nix Daemon - -Restarting the nix-daemon may resolve this: - -```shell -$ systemctl restart nix-daemon -``` - -### Move nix.conf - -The Nix configuration directory may need to be changed to `/etc/nix/nix.conf`, instead of -`~/.config/nix/nix.conf`. See the [installation process](./install.md) for more details. - -## Can't re-install Nix after macOS update - -To successfully re-install Nix after a macOS update, you need to remove the existing `/nix` -directory, and start the installer again. - -The following command removes the `/nix` directory. - -```shell -$ sudo rm -rf /nix -``` - -## flake 'github:ComposableFi/composable' does not provide attribute 'packages.x86_64-linux.PACKAGE-NAME', 'legacyPackages.x86_64-linux.PACKAGE-NAME' or 'runtime-tests-persistent' - -You are probably referencing a package that we do not support, or you are trying to run a package that is not supported by the system that you are currently using. - -Use `nix flake show` in order to see an exhaustive list of all packages we provide. In this tree, you can see which packages are available for each systems. diff --git a/docs/docs/pallets/currency-factory/extrinsics.md b/docs/docs/pallets/currency-factory/extrinsics.md deleted file mode 100644 index b090fc1703f..00000000000 --- a/docs/docs/pallets/currency-factory/extrinsics.md +++ /dev/null @@ -1,16 +0,0 @@ - - - -# Currency Factory Pallet Extrinsics - -## Add Range - -[`add_range`](https://dali.devnets.composablefinance.ninja/doc/pallet_currency_factory/pallet/enum.Call.html#variant.add_range) - -No documentation available at this time. - -## Set Metadata - -[`set_metadata`](https://dali.devnets.composablefinance.ninja/doc/pallet_currency_factory/pallet/enum.Call.html#variant.set_metadata) - -Sets metadata diff --git a/docs/docs/pallets/currency-factory/integration-guide.md b/docs/docs/pallets/currency-factory/integration-guide.md deleted file mode 100644 index d654dc7e92a..00000000000 --- a/docs/docs/pallets/currency-factory/integration-guide.md +++ /dev/null @@ -1 +0,0 @@ -# Integration Guide diff --git a/docs/docs/pallets/dutch-auction/extrinsics.md b/docs/docs/pallets/dutch-auction/extrinsics.md deleted file mode 100644 index 30419502ae9..00000000000 --- a/docs/docs/pallets/dutch-auction/extrinsics.md +++ /dev/null @@ -1,36 +0,0 @@ - - - -# Dutch Auction Pallet Extrinsics - -## Add Configuration - -[`add_configuration`](https://dali.devnets.composablefinance.ninja/doc/pallet_dutch_auction/pallet/enum.Call.html#variant.add_configuration) - -Inserts or replaces auction configuration. -Already running auctions are not updated. - -## Ask - -[`ask`](https://dali.devnets.composablefinance.ninja/doc/pallet_dutch_auction/pallet/enum.Call.html#variant.ask) - -sell `order` in auction with `configuration` -some deposit is taken for storing sell order - -## Take - -[`take`](https://dali.devnets.composablefinance.ninja/doc/pallet_dutch_auction/pallet/enum.Call.html#variant.take) - -adds take to list, does not execute take immediately - -## Liquidate - -[`liquidate`](https://dali.devnets.composablefinance.ninja/doc/pallet_dutch_auction/pallet/enum.Call.html#variant.liquidate) - -allows to remove `order_id` from storage - -## Xcm Sell - -[`xcm_sell`](https://dali.devnets.composablefinance.ninja/doc/pallet_dutch_auction/pallet/enum.Call.html#variant.xcm_sell) - -No documentation available at this time. diff --git a/docs/docs/pallets/dutch-auction/integration-guide.md b/docs/docs/pallets/dutch-auction/integration-guide.md deleted file mode 100644 index d654dc7e92a..00000000000 --- a/docs/docs/pallets/dutch-auction/integration-guide.md +++ /dev/null @@ -1 +0,0 @@ -# Integration Guide diff --git a/docs/docs/pallets/lending/extrinsics.md b/docs/docs/pallets/lending/extrinsics.md deleted file mode 100644 index 671b8537f1e..00000000000 --- a/docs/docs/pallets/lending/extrinsics.md +++ /dev/null @@ -1,78 +0,0 @@ - - - -# Lending Pallet Extrinsics - -## Create Market - -[`create_market`](https://dali.devnets.composablefinance.ninja/doc/pallet_lending/pallet/enum.Call.html#variant.create_market) - -Create a new lending market. - -* `origin` : Sender of this extrinsic. Manager for new market to be created. Can pause - borrow operations. -* `input` : Borrow & deposits of assets, percentages. - -`origin` irreversibly pays `T::OracleMarketCreationStake`. - -## Update Market - -[`update_market`](https://dali.devnets.composablefinance.ninja/doc/pallet_lending/pallet/enum.Call.html#variant.update_market) - -owner must be very careful calling this - -## Deposit Collateral - -[`deposit_collateral`](https://dali.devnets.composablefinance.ninja/doc/pallet_lending/pallet/enum.Call.html#variant.deposit_collateral) - -Deposit collateral to market. - -* `origin` : Sender of this extrinsic. -* `market` : Market index to which collateral will be deposited. -* `amount` : Amount of collateral to be deposited. - -## Withdraw Collateral - -[`withdraw_collateral`](https://dali.devnets.composablefinance.ninja/doc/pallet_lending/pallet/enum.Call.html#variant.withdraw_collateral) - -Withdraw collateral from market. - -* `origin` : Sender of this extrinsic. -* `market_id` : Market index from which collateral will be withdraw. -* `amount` : Amount of collateral to be withdrawn. - -## Borrow - -[`borrow`](https://dali.devnets.composablefinance.ninja/doc/pallet_lending/pallet/enum.Call.html#variant.borrow) - -Borrow asset against deposited collateral. - -* `origin` : Sender of this extrinsic. (Also the user who wants to borrow from market.) -* `market_id` : Market index from which user wants to borrow. -* `amount_to_borrow` : Amount which user wants to borrow. - -## Repay Borrow - -[`repay_borrow`](https://dali.devnets.composablefinance.ninja/doc/pallet_lending/pallet/enum.Call.html#variant.repay_borrow) - -Repay part or all of the borrow in the given market. - -### Parameters - -* `origin` : Sender of this extrinsic. (Also the user who repays beneficiary's borrow.) -* `market_id` : \[`MarketIndex`\] of the market being repaid. -* `beneficiary` : \[`AccountId`\] of the account who is in debt to (has borrowed assets - from) the market. This can be same or different from the `origin`, allowing one - account to pay off another's debts. -* `amount`: The amount to repay. See \[`RepayStrategy`\] for more information. - -## Liquidate - -[`liquidate`](https://dali.devnets.composablefinance.ninja/doc/pallet_lending/pallet/enum.Call.html#variant.liquidate) - -Check if borrows for the `borrowers` accounts are required to be liquidated, initiate -liquidation. - -* `origin` : Sender of this extrinsic. -* `market_id` : Market index from which `borrower` has taken borrow. -* `borrowers` : Vector of borrowers accounts' ids. diff --git a/docs/docs/pallets/lending/integration-guide.md b/docs/docs/pallets/lending/integration-guide.md deleted file mode 100644 index d654dc7e92a..00000000000 --- a/docs/docs/pallets/lending/integration-guide.md +++ /dev/null @@ -1 +0,0 @@ -# Integration Guide diff --git a/docs/docs/technology/cvm.md b/docs/docs/technology/cvm.md index df4232c1499..6e4bde2fb6c 100644 --- a/docs/docs/technology/cvm.md +++ b/docs/docs/technology/cvm.md @@ -22,9 +22,9 @@ User transactions and intents need a language for execution across different env For example, the CVM enables the ability to move Polkadot’s DOT token to Osmosis, swap to DOT to ETH, move ETH to Ethereum, swap to ETH to USDC, and move funds to Composable’s Cosmos chain. This all occurs in one user-signed transaction, which is expressed in plain English. -## [Specification](./cvm/specification.md) +## [Specification](https://github.com/ComposableFi/composable-vm/blob/main/docs/cvm/specification.md) -## [Virtual Wallet](./cvm/virtual-wallet.md) +## [Account Abstractions(aka Virtual Wallet)](https://github.com/ComposableFi/composable-vm/blob/main/docs/cvm/account-abstraction.md) ## [Tutorial](./cvm/tutorial.md) diff --git a/docs/docs/technology/cvm/lowering-routing.md b/docs/docs/technology/cvm/lowering-routing.md deleted file mode 100644 index f0ae9b254c1..00000000000 --- a/docs/docs/technology/cvm/lowering-routing.md +++ /dev/null @@ -1,267 +0,0 @@ -# Problem overview - -We have [CVM language](https://docs.composable.finance/technology/cvm/specification) to describe cross chain execution and on chain routing registry over heterogenous networks. - -**Programs** - -CVM language is basically Abstract Syntax and Routing Tree which declares desire to move funds from chain to chain and execute some operations. - - -Simplified CVM: -```typescript -type Instruction = Deposit | Exchange | Spawn -interface Spawn { - assets : Asset[] - network_id : NetworkId - instructions: Instruction[] -} -type NetworkId = number -type AssetId = number -interface Asset { - asset_id : AssetId - amount : Amount -} - -type Amount = Percentage | Absolute -``` - -More complicated is [asset prefix elimination](https://api-docs.skip.money/docs/ibc-routing-algorithm), swap on some chain and moving assets to final destination. - -**Registry** - -Each chain and hop has its capabilities. One chain can have full set of transport features with contracts, other chain just can receive limited set of final assets and do not allow hosting programs. -Limited chains usually provide some mechanics to execute very specific set of scenarios provided by on chain modules. -Description of chains capabilities and assets they have is on chain registry. - -On chain registry contains information on a lot on directly connected chains, and partial info on some 1+ hop connected, so as far chain is (and higher costs of on chain operation), -the smaller registry is. Actually preventing global knowledge of all possible routes which can carry execution of CVM program. - -Simplified registry: -```typescript -type TracePrefix = String -type NetworkFeatures = object -type ConnectionFeatures = object -interface Registry{ - asset_to_network(asset_id: AssetId) : NetworkId - asset_id_after_transfer(asset_id: AssetId, to: NetworkId) : AssetId? - asset_id_to_prefix(asset_id: AssetId): TracePrefix - network(network_id: NetworkId): NetworkFeatures - network_to_network(from: NetworkId, to: NetworkId): ConnectionFeatures? -} -``` - -**Next steps** - -Next I will describe set of CVM programs, chain capabilities and registry information which should be solved in order express exact packets to send for execution. - -After example I will summarize zoo of things into some categories and describe desired properties of algorithm and solutions to be found to handle user intents. - -## Examples - -Examples follows pattern: -* what expected user intent -* what is ideal execution -* what are CVM and registry subtleties - -### Registry information - -Please use table to refer to features available for chains and transport. - -When `From/To` is same - -| From/To | Centauri | Neutron | Osmosis | Stride | Cosmos Hub | Picasso | Composable | Polkadot | Statemine | -|------------|-----------|-------------------------|-------------------------|----------------------------|------------|---------|------------|-----------------------|-----------------------| -| Centauri | Contracts | IBC | IBC | IBC | IBC | IBC | | | | -| Neutron | IBC | Contracts, WH, Exchange | IBC | IBC | IBC | | | | | -| Osmosis | IBC | IBC | Contracts, WH, Exchange | IBC | IBC | | | | | -| Stride | IBC | IBC | IBC | ICA Callbacks, IBC Staking | IBC | | | | | -| Cosmos Hub | IBC | IBC | IBC | IBC | PFM | | | | | -| Picasso | IBC | | | | IBC | PFM | IBC | | | -| Composable | | | | | | IBC | PFM | | | -| Polkadot | | | | | | | XCM | XCM Multihop Transfer | XCM | -| Statemine | | | | | | | | XCM | XCM Multihop Transfer | - -WH - Wasm Hook. -PFM - Packet Forwarding Middleware, can terminate with WH if final chain has it - - -### A - -User wants `Transfer NTRN from Centauri to Osmosis and Exchange to OSMO`. - -CVM programs describes: -1. Transfer NTRN to Neutron via IBC and call Contract -2. Neutron send NTRN to Osmosis -3. Call Contract to Exchange Contract to get OSMO - -That is super happy path. We have Contracts and Wasm Hooks to do full CVM program. -CVM executed as is. - -### B - -User wants `Transfer ATOM from Centauri to Osmosis and Exchange to PICA` - -What CVM prescribes: -1. Transfer ATOM to Cosmos Hub -2. Transfer ATOM to Osmosis. -3. Exchange to PICA - -Cosmos Hub cannot execute Contracts. -So CVM should generate PFM packet which transfer 100% of assets to Cosmos Hub, -and Cosmos Hub sends it to Osmosis. -On Osmosis PFM ends with Wasm Hook call, where it actually end with CVM program. - -Algorithm should detect, using registry, that intermediate chain does not have Contracts, -and replace intermediate part PFM. - -PFM can transfer only 100% assets, so CVM program transferring part of assets from Cosmos Hub or doing some Exchange must be rejected. - -### C - -CVM program tells: -1. Transfer DOT from Osmosis to Centauri -2. From Centauri to Picasso -3. From Picasso to Composable -4. From Composable to Polkadot - -So in this case full CVM program can transfer from Osmosis to Centauri. -But on chain it is possible to find out that program is transfer of 100% assets only. - -In this case 1-3 can be PFM transfer, and 3-4 can be XCM Multihop transfer. - - -### D - -User intents to `Transfer PICA from Centauri to Polkadot`. - -Whatever CVM program tells that, it must be rejected. -Polkadot can have only DOT. - -### E - -CVM program tells - -1. Transfer PICA to Stride -2. Stake on Stride - -Also CVM describes second operation as if it is happened on Stride, really ICA Callback must be formed by CVM program to send IBC packet to Stake. -Really CVM never reaches as some general AST tree to Stride. - - -### F - -More general case. - -Transfer from A to B to C and exchange on D. - -A and D have Contracts. D has Wasm hook. B and C just PFM. - -So routing algorithm for such CVM program must form sandwich like: `CVM(PFM(PFM(CVM)))` - -### H - -As above `F`, but D and C has Contracts. - -Also D and C can do full CVM hops, why not just do cheaper PFM?s - - -### G - -A chain knows what is on B chain, and B chain knows what is on C. -But chain A does not knows how B is connected to C - -In case B has Contracts, we send it. -In case B has no Contracts, but CVM is just transfer, we send PFM. - -Other cases rejected. - - -## Solution constraints and questions - -Given CVM program(tree) and Registry data(graph) on chain, solution to provide annotated CVM program with hints on transports and payloads to use on each hop. - -**On chain** - -Solution to be executed on chain, cheap one, but still constrained in computation. - -So it can be proven that on chain one is impossible, which is good solution too. - -**Limited information** - -Each chain may have limited information about other chains, and yet we have to trust sender if he knows what he asks for. - -So some CVM program to be rejected - -**Multiple spawns** - -On chain A, program can split to move some assets to B and some to C. -So that both proper transport possibles to be found. - - -**Optimization(Optional)** - -Price optimization, if can do Wasm Hooks/ICA Callbacks instead of full CVM when possible. -Do Transfer if CVM asks only for transfers, even if full CVM possible.s - -**Hints(Optional)** - -CVM program may have routing hints, telling what to do in case of limited information or price option. - -Hints may be replaced by trustless CVM bots force Registry propagation. - -## Possible ideas of implementation - -CVM is tree. - -Registry is graph. - -```python -A - -1 Start breadth first CVM traversing. - -2 If connectivity options found, create traversal branch for each option. - -3 Each child node gets path info which was done up to - - 3.1 Check that given path info, can do operation outlined locally. - -4 In good case, traversed path found - - 4.1 Evaluate price and retain cheapest (CVM>PFM>IBC Transfer) - -5 In case of not found path - - 5.1 Use latest CVM step possible - - 5.2 If no CVM before path not found, reject execution. - -6 Output is send CVM output for generate detailed packets packets - -6.1 CVM uses whole path metadata to generate proper transport payload - -6.2 Including verify receiver on final chain (by checking hash of hash of path + original sender) -``` - - -Also can vary like -```python -B - -1. If CVM is found next step - just do it - -1.2 Assumed that next hop knows more about next hops - -2 If CVM is not immediate steps, but found on some substeps - -2.1 Check that parent path allows CVM sending - -2.2 Do 1 - -3. Do algorithm B -``` - - -### Lowering - -Ethereum too high price to execute above algorithm, so any chain sending to ethereum, but lower CVM program into exact Ethereum ABI. \ No newline at end of file diff --git a/docs/docs/technology/cvm/specification.md b/docs/docs/technology/cvm/specification.md deleted file mode 100644 index e2132e95880..00000000000 --- a/docs/docs/technology/cvm/specification.md +++ /dev/null @@ -1,943 +0,0 @@ -# Specification - -The CVM is made of opaque contracts for execution of non-atomic, asynchronous, trustless, transparent, non-custodial, bridge-agnostic, generalized and [Turing decidable language](https://www.educative.io/answers/what-are-recursive-languages) cross-chain programs and intents. - -## Why CVM? - -To enable users to perform cross-chain intent settlement such as `transferring DOT to Osmosis, swapping to ETH, transferring ETH to Ethereum, swapping to USDC, and moving funds to Composable Cosmos or any desired destination chain, in one user signed transaction`. Users should be able to express in simple english their desired actions. - -Here is what should happen semantically: - -```mermaid -sequenceDiagram - actor User - User ->> Polkadot : Initiate DOT transfer - Polkadot ->> Composable : Transfer DOT - Composable ->> Osmosis : Transfer DOT - Osmosis ->> Osmosis : DOT to ETH - Osmosis ->> Ethereum : Transfer ETH - Ethereum ->> Ethereum: ETH to USDC - Ethereum ->> Composable Cosmos : Transfer USDC -``` - -This sounds simple, but you need to know several encodings, transports protocols, and SDKs to do this. Also, without the CVM, one may not easily start on Polkadot and proceed to the end using a single transaction. - -CVM solves it this way (displayed in a simplified manner): -```mermaid -sequenceDiagram - actor User - User ->> Composable : Initiate CVM program - Composable ->> Composable : Progress CVM via Parity XCM - Composable ->> Polkadot : XCM DOT to Composable - Polkadot ->> Composable : DOT transfer - Composable ->> Composable : Act on next step in CVM program - Composable ->> Osmosis : Send funds over IBC - Osmosis ->> Osmosis: Interpret CVM program, do the swap - Osmosis ->> Osmosis: Continue interpretation - Osmosis ->> Ethereum: Transfer assets and CVM over IBC - Ethereum ->> Ethereum : Interpret Swap - Ethereum ->> Composable Cosmos : Transfer asses and remaining CVM program - Composable Cosmos ->> Composable Cosmos : No more instructions, stop here -``` - -More detail on this architecture can be found in the rest of this documentation. Carrying out cross-chain swaps is just one of the many possible operations - -## Definitions - -- Assets, tokens, coins, funds, amounts: used interchangeably -- Chain, blockchain, consensus, domain: also used interchangeably to refer to `execution systems using different instances of proofs systems` -- Address, account, wallet: also used interchangeably; each can do something on-chain from its own identity, and hold some funds -- Bridge, relayer: Something which can act on one chain on behalf of another, for example mint tokens (transfer) - -### Definition deconstruction - -`Opaque contracts` - In the CVM, these may be module or contract, executing on one or many chains - -`Non-atomic` - the whole program is not executed in single block; it is not an all-or-nothing transaction - -`Asynchronous` - two Spawns in single program, but are sent to bridges at same time, execute concurrently on on several chains; other instruction are sequential - -`Trustless` - internally, the CVM uses the most secured, trustless bridges, to execute CVM programs; CVM contracts are subject to cross-chain governance - -`Non-custodial` - each user owns all assets on each chain; they delegate the ability to move these funds cross-chain from their cross-chain account (executor) - -`Turing decidable language` - that there are no procedural loops or recursion, meaning that CVM programs are predictable, deterministic, and will stop - -`Transparent` - reading and auditing CVM program much easier than set of cross chain contracts, code of propagated along with data, you do not need to deploy programs, you just send programs; as subprograms move from chain to chain, they move assets along - -`Bridge-agnostic, generalized` - CVM abstracts away several underlying transports,encodings, assets systems, and messaging protocols, you do not need to know assets systems, how to talk to bridges, or how to encode common operation on each chain you want to act on; you learn the CVM, and it helps you to handle these details - -`Cross-chain programs` - the same program input works consistently on all supported chains; you can write it once to run anywhere - -`Accessing de facto native liquidity markets` - the CVM uses native assets contracts on each chain and each bridge it uses, so programs can leverage existing liquidity on chains; as new bridges and chains are added, the CVM incorporates these without any modification from the user - - -## Additional References - -Cross-chain DeFi gets complicated. To understand this documentation at the deepest level, it is helpful to have existing knowledge about the application side of messaging protocols, like [Parity’s XCM](https://github.com/paritytech/xcm-format), [Cosmos’s IBC-ICS-20/27](https://github.com/cosmos/ibc), or [NEAR’s multi block execution](https://docs.near.org/concepts/basics/transactions/overview). Also has some resemblance to [Fluence Aqua](https://fluence.dev/docs/aqua-book/language/) and [Anom Juvix](https://docs.juvix.org/) - - -## What is CVM, and what are its functions? - -The following aims to answer this question. You can being reading any of these sections first, perhaps switching back and forth between sections several times as needed; the contents of these categories partially overlap - -### Building blocks - -The CVM is a set of opaque contracts on chains. Each `opaque contract` may be one contract on a specific chain or several, or it can be a module. We will refer to this simply as a contract from this point onwards. - -A CVM `program` is a tree of instructions with attached assets. Each opaque contract has a program as input. The program format is an executable language to describe what the user wants to do across chains. - -Instructions inside programs are interpreted by the `Executor`. It owns all of the user's funds. The executor delegates bridges to manage funds operations cross-chain. The `executor` is the user's cross-chain account. - -Instructions include, but are not limited to: -- Transfer: transfer funds from account to account on a single chain -- Spawn: transfer leaf of tree (subprogram) to other chain with assets, for further execution -- Call: arbitrary ABI builder call per chain allowing invoke arbitrary opaque contracts -- Exchange: the most used operation, allowing the provision of some tokens in order to receive other tokens in return - -A detailed description of each instruction is described later, but the most important aspects are described in this section. - -Spawn uses a path-dependant reserve transfer escrow/mint protocol to move funds. - -Call is a way to represent a native call in encoding that is executable on each chain, and yet able to fill in (bind) some context details like the amount of assets and some addresses in a cross-chain (CVM) way. - -Exchange requires configuration of the pool in CVM contract storage. So do mapping of native assets and chains’ routing capabilities available for CVM programs. Routing information describes the type of bridge and what capabilities and limitations connecting chains it has. There is no requirement for CVM contracts to be deployed on chains as long as chains are reachable by some form of execution. - -Exchange/Transfer/Spawn are shortcuts for specific Calls. From here onwards, we will use `Call` to refer to any of these types of on-chain execution. - -During program interpretation, while the instruction is executing, the result of call execution and bridging state (internal of Spawn) are recorded in executor state. In case of a CVM program error, funds are retained on the sending or receiving executor. Users can observe the state of the executor and send a program to handle the current state. For example, they can move funds to another account or chain. - -### Simplified CVM Design - -```typescript -/// CVM may be physically implemented differently on different chains -type OpaqueContract = SmartContract | Module -type OpaqueUser = OpaqueContract | Wallet - -type Network = number - -interface Program { - instructions: Instruction[] -} - -/// random number to easy invocation tracing -type Tag = Uint8Array - - -/// allows one user to have several Executors to isolate funds and allowances -type Salt = Uint8Array - -type Instruction = Transfer | Call | Spawn | Query | Exchange | Stake | Order | Abort | If | Unstake | Prove | Delegate | Undelegate - -// Venue can convert one AssetId into other using internal rules. -// There can be more than one venue for same input or output asset. -// Different venues can map to same on chain contract, so with differnt default coniguraition. -type VenueId = ExchangeId | StakingId | VerifierId - -interface Venue { - // not whole amount can be taken in some cases - in: (AssetAmount | BindedAmount)[] - // give to account abstrctions immediately - min_out: AssetAmount[] -} - -/// Is atomic without position recorded for user -/// Exchange - can be deposit into pool for LP token, Stake to get liquid stake token, borrow or lend. -/// So it is super set of what usually called swap over CFMM(AMMs). -/// Set `ExchangeError` to result register in case of fail. -interface Exchange { - venu: Venue - condition : ExchangeCondition? -} - -/// in CFMM and OB, there are always fluctuations, -/// allows to decide if steel want to exchange if difference from -/// window on average is too far /// in CFMM and OB, there are always fluctuations, -/// allows to decide if steel want to exchange if difference from -/// window on average is too far -interface ExchangeCondition { - /// minimum number of blocks to consider averaging - window : number? - type : AggregationType - -} -type AggregationType = TimeWeightedAverage - -// Time locks(bond) tokens, potentially getting some tokens out. -// Can be Stake or liquidity provision. -interface Stake { - staking_id: Id - venue: Venue - /// maximum time for bonding, so as close as possible to it - time: Duration -} - -// when executed, consequences may be Slashing or Reward. -// usually called by off chain bots like AVS or relayers -interface Prove { - verifier_id: Id - // optional proof, opaque data - // simplest prove is just empty crank - proof: bytes[]? -} - -interface Unstake { - staking_id: Id - // if user does not expects imeddite untake, `min_amount` can be set to zero - venue : Venue -} - -/// intention for exchange which may happen in future -/// puts into ResultRegister either cross chain error error or OrderPositionId -interface Order { - venue : Venue - timeout : Duration - partial: Ratio[] -} - -type OrderPositionId = Uint128 - -/// cross chain transaction/tracing identifier -interface ProgramInvocation { - /// for tracing - tag : Tag - /// network on which to execute program - network : Network -} - -interface Spawn { - invocation: ProgramInvocation - program : Program - salt : Salt - assets : Assets -} - -interface Delegate { - subject: UserOrigin - premissions: Permissions -} - -/// is target chain dependant -type Payload = Uint8Array - -/// copies RegisterValue into program stack which drained into first Spawn -type Query = RegisterValue | Id - -type RegisterValue = RegisterValue[] - -type RegisterValue = ResultRegister | IPRegister | TipRegister | SelfRegister | VersionRegister | Carry - -/// id sorted coints which was transferred into this `Spawn` (may be less then sent from original chain because if fee) -type Carry = AssetId[] - -type IPRegister = Uint8 - -type TipRegister = Account - -interface Call { - /// most chains have one default executor - /// tells how to interpret `payload` - executor : NativeExecutor? - payload : Payload - bindings : Bindings? -} - -type NativeExecutor = PolkadotPallet | CosmosModule | Evm | CosmWasm | SVM - -interface Binding { - index : Uint8 - value : BindingValue -} - -/// sorted keys by `index` -type Bindings = Binding[] - -interface AssetAmount { - asset_id: AssetId - balance : Balance -} - -/// amount from Carry register or part of it -type BindedAmount = {Carry , Ratio? } - -type Account = Uint8Array - -/// Self is account of Executor -type Self = Account - -/// Pop - pops value from program stack into binding placeholder -type BindingValue = Self | Tip | Result | AssetAmount | GlobalId | Pop | Home - -/// binds to chain id which originated message on this chain -/// can be used just to spawn back -type Home = NetworkId - -/// Aborts transaction on execution chain if BindingValue contains Error. -/// In comparison with ResultRegister just set to error and stop executing (with funds retained on CVM Executor), -/// this instruction rollbacks changed made by this transaction (including results and funds) up to sender network if possible. -interface Abort { - abort_of_error: BindingValue -} - -/// transfer from Executor account to -interface Transfer { - assets : Assets, - to: Tip | Account -} - -/// sorted with unique ids -type Assets = [AssetId, Balance][] - -type AssetId = GlobalId | LocalId -type GlobalId = Uint128 -type LocalId = Uint8Array - -// Source of amount, either account abstraction or carry register (examples, amount received with `Spawn` or after `Exchange`) -type BalanceSource = Carry | Account - -type Balance = { AbsoluteAmount, Ratio, -Source} - -type AbsoluteAmount = Uint128 - -type Unit = Uint128 Ratio -/// parts of whole -type Ratio = { numerator : Uint64, denominator: Uint64} - -/// deterministic encoding of user wallet on each chain (part of [account abstractio](composable-account-abstraction.md) ) -interface UserOrigin = { - account : Account - network: Network -} - -type ExecutorOrigin = Account - -/// data send to other chain -interface SpawnPackage = { - Executor_origin : ExecutorOrigin - user_origin: UserOrigin - /// used by the while instantiating the Executor - /// so user can have several Executors on same chain or reuse existing (same salt) - salt: Salt - program : Program - assets: Assets - stack: ResultRegister[] -} - - -type ResultRegister = Error | ExecutionResult - -type Error = CallError | TransferError | SpawnError | QueryError | OrderError | StakeError | ExchangeError - -/// open set of well know exchange errors -type ExchangeError = Uint8 - -type ExecutionResult = Ok | bytes -type Ok = '0' - -/// One or more ordered set of unique cross chain accounts. -/// Owners have full control over funds in CVM Executor -type Owners = Identity[] - -/// Network prefixed cross chain native chain Account -type Identity = [Network, Account] - -/// this happens in Executor -function execute_program(caller: Account, program: Program) { - ensureOneOf(caller, this.owners, this.outpost) - - // reset from the last execution - this.InstructionPointer = 0; - this.TIP = tip; - - - for (var instruction in program.instructions) { - this.InstructionPointer += 1; - this.result = this.execute_instruction(instruction); - if (is_error(this.result)) { - break; - } - } -} -``` - -The model above does not map exactly what chains receive as bytes that are being input and then outputted to the bridge, rather it outlines the correct semantic model of execution. - -## Detailed CVM Design - -Here are more details for instructions, roles, and the security model of the CVM. - -### Architecture and Flow - -Here is the logical state of the CVM: - -```mermaid -erDiagram - CVM-ACCOUNT { - coin[] some_funds - address xc - } - OFFCHAIN_WALLET { - string private_key - } - CVM { - program[] programs - address[][] wallets - address[] xc_accounts - coin[] all_funds - } - BRIDGE }|..|| CVM : callback_or_call - CVM ||--o{ CVM-ACCOUNT : delegate - CVM-ACCOUNT ||--o{ DEX: swap - OFFCHAIN_WALLET }|..|| CVM-ACCOUNT : manage - OFFCHAIN_WALLET }|..|| CVM : execute -``` - -So, the user (wallet) has an executor (CVM account) on each chain (instantiated on demand). - -The CVM account delegates a CVM contract to bridge assets and execute on behalf of the user across chains. - -The CVM is bridge agnostic, with full capabilities when the target chain allows permissionless contracts and general message passing, as well as limited shortcuts when no custom code is allowed and only a subset of target cross-chain operations are possible. - -Let’s look into one hop from one chain to another chain in detail (additional hops will just repeat part of the picture): - - -```mermaid -sequenceDiagram - actor User - User ->>CVMOnCentauri : Execute program with funds - CVMOnCentauri ->> CVMOnCentauri: Instantiate Executor for user - CVMOnCentauri ->> ExecutorOnCentauri : Transfer funds - ExecutorOnCentauri ->> Program : Interpret - loop Program - ExecutorOnCentauri-->ExecutorOnCentauri: Interact with contracts. - end - Program ->> CVMOnCentauri : Execute Subprogram on Osmosis - CVMOnCentauri ->> CVMOnCentauri: Bridge SubProgram - CVMOnCentauri ->> IBCOnCentauri: Send packet - IBCRelayer ->> IBCOnCentauri: Take packet - IBCRelayer ->> IBCOnOsmosis: Put packet - IBCOnOsmosis ->> CVMOnOsmosis: Invoke contract with SubProgram - CVMOnOsmosis ->> ExecutorOnOsmosis: Instantiate, transfer funds, execute SubProgram - loop SubProgram - ExecutorOnOsmosis-->ExecutorOnOsmosis: Interact with contracts. - end - ExecutorOnOsmosis ->> ExecutorOnOsmosis: Map CVM assets to CW/Bank assets - ExecutorOnOsmosis ->> PoolManager : Swap - ExecutorOnOsmosis ->> IBCOnOsmosis : Send transfer to Ethereum without CVM program - IBCRelayer ->> IBCOnOsmosis: Take packet - IBCRelayer ->> IBCOnEthereum: Put transfer - IBCOnEthereum ->> ERC20: Mint -``` - -The diagram starts with a fully CVM-enabled flow. - -In the end, it shortcuts VM execution to a standard protocol without doing SubProgram execution. This happens if there is an incentive to do a shortcut (for example, gas costs or limited CVM support on the target) and the subprogram is simple, like transfer (or another build in a cross-chain protocol). - -All the CVM receives is CVM programs. It then uses routing configuration (of assets and bridges, and their features) to dispatch programs over underlying protocols. - - -### Instructions - -Spawn instructions are executed concurrently. All other instructions are executed sequentially in a subprogram. - -### Call - -This executes a payload which is an ABI call to an opaque contract within the execution context of the chain. - -The call instruction supports bindings values on the executing side of the program by specifying the `Bindings`. This allows us to construct a program that uses data only available on the executing side. Binding values are lazy filled in on the target chain. - -The binding value `Self` injects the account in the Executor into a call. - -Besides accessing the `Self` register, `BindingValue` allows for lazy lookups of `AssetId` conversions. This is done by using `BindingValue::AssetId(GlobalId)`, or lazily converting `Ratio` to `AbsoluteAmount` type. - -Bindings support byte aligned encodings (all that are prominent in crypto). - - -**Example** - -For example, the swap call of the following contract snippet expects a `to` address to receive the funds after a trade. - -```typescript -function swap(in_amount: number, in_asset: String, min_out: number, out_asset: String, to: AccountId) { - // ... -} -``` - -If the caller wants to swap funds from the Executor account and receive the funds into the Executor account, they need to specify the BindingValue `Self`, using the index of the `to` field for the payload being passed to the contract. - -The sender chain spawns with `swap(100, "dot", "eth", 1, BindingValue::Self)` call, and on target chain Self replaced with address on execution Executor. - - -### Spawn - -Sends a `Program` to another chain to be executed asynchronously. It is only guaranteed to execute on the specified `Network` if its `Program` contains an instruction to execute on the `Network` of the `Spawn` context. - -If `Spawn` fails, it may fail on the sender chain or on the receiver chain, but not both. - -Funds are retained in the Executor. - -`ResultRegister` is written. - - -`AssetId` in `Assets` are converted from the sender to receiver identifiers by the Executor. - -#### How Spawn fails - -Failure on the sender chain is asynchronous too. - -There are two types of failures. - -1. When `SpawnPackage` fails fully without even calling the `executor`, in this case all funds are rolled back to the executor. Target chain will not have an on-chain trace of execution. - -2. When `SpawnPackage` reaches the target chain, starts execution in the Executor and fails. In this case `ResultRegister` is filled on the target chain and funds remain there. The sender chain considers Spawn to be a success. - -There no in-between scenario when the failure is spread onto both chains. - -### Query - -Queries register values of a `CVM` instance across chains. It sets the current `Result Register` to `QueryResult` on the semantics of registers and `RegisterValues`. - - -### Balances - -The amount of assets can be specified using the `Balance` type. This allows foreign programs to specify sending a part of the total amount of funds using `Ratio`. Or, if the caller knows amount of the assets on the destination side using `AbsoluteAmount`. - -### Registers - -Each executor keeps track of persistent states during and across executions, which are stored in different registers. Register values are always updated during execution and can be observed by other contracts. - -#### Result Register - -The result register contains the result of the last executed instruction. - - -If `ResultRegister` was set to `Error` and there is `Restoration` register containing a CVM program, it will be executed. - -#### IP Register - -The instruction pointer register contains the instruction pointer of the last executed program and is updated during program execution. Querying for the `IP` and `Result` can be used to compute the state of the Executor on another chain. - - -#### Tip Register - -The `Tip`` register contains the `Account` of the account which incentives relayers pay gas fees for program propagation from chain to chain and execution. -This can be the IBC relayer or incentive protocol. - - -#### Self Register - -The self register contains the `Account` of the `Executor`. -Most implementations will not need to use storage, but have access to special keywords, such as `this` in Solidity. - -#### Version Register - -The version register contains the semantic version of the contract code, which can be used to verify the subset of CVM functionality supported by the contract. Implementations that support upgradable contracts MUST update the version register. Functionality advertised through the version register MUST be supported by the contract. - -### Program Execution Semantics - -Execution of a program is a two-stage process. - -1. First, the virtual machine MUST verify that the caller is allowed to execute programs for that specific instance, by verifying that the caller is one of the owners. -2. Second, the instructions are iterated over and executed. - -Implementers MUST execute each instruction in the provided order and MUST update the IP register after each instruction is executed. After each instruction is executed, the result register MUST be set to the return value of the instruction. The executor SHOULD NOT alter the return values but store them as returned. Because the return values are chain-specific, the actual structure is left undefined. - -If an error is encountered by executing an instruction, the defined transactional behavior for that instruction should be abided by. All instructions defined in this documentation require the transaction to be aborted on failure. However, subsequent addendums may define new instructions with different behavior. - -After the final instruction has been executed and registers are set, the execution stops and the transaction ends. - -See Appendix A for the algorithm. - -## CVM Execution Semantics - -Each chain within the `CVM` contains a singleton entity consisting of the Router, and the Outpost. Implementors MAY choose to create a monolithic smart contract or a set of modular contracts. - -### Outpost - -Each chain contains a singleton bridge aggregator, the `Outpost`, which abstracts over transports. - -### Router - -Each program arriving through the `Outpost` is passed to the `Router`, which becomes the initial beneficiary of the provided `Assets` before finding or instantiating an `Executor` instance. The router then transfers funds to the `Executor` instance. - -Subsequent calls by the same `Origin` will not result in an instantiation, but instead in a re-use of the `Executor` instance. This allows foreign `Origins` to maintain state across different protocols, such as managing LP positions. - -If no Executor instance has been created for a given caller, the call to the `Router` must either come from the `IBC`, `XCM`, or a local origin. After the instance has been created, it can be configured to accept other origins by the caller. - -**Example** - -For a given CVM program, its Executor instance is derived from `Network Account Salt`. This allows users to create different Executor instances to execute programs against. Note that the `Salt` is not additive and only the composite `Network Account` is forwarded to remote chains as the user origin: -```kdl -spawn network=A salt=0x01 { // the origin for the instructions is (A, AccountOnA, 0x1) - call 0x1337 // Call instruction executed on A - spawn network="B" salt=0x02 {} // Sub-program spawned on B, with 0x02 as salt, the origin for the instructions is (A, AccountOnA, 0x2) -} -``` -A possible usage is to allow one program execution to act on the state of another program execution to restore funds. - - -In the CVM program above, the parent program salt `0x01` is not a prefix of the sub-program salt `0x02`. The user is able to make its Executor origin using a fine grained mode. The following program is an example on how we can spread a salt: -```kdl -spawn A 0x01 { // Parent program spawned on A, with 0x01 as salt, the origin for the instructions is (A, AccountOnA, 0x01) - call 0x1337 // Call instruction executed on A - spawn B 0x0102 {}, // Sub-program spawned on B, with 0x0102 as salt, the origin for the instructions is (A, AccountOnA, 0x0102) -} -``` - -In next program, all spawned instances on all chains share state (including assets): -```kdl -spawn A 0x01 { - call 0x1337 - spawn B 0x01 {}, // Sub-program spawned on B, with 0x01 as salt, the origin for the instructions is (A, AccountOnA, 0x01) allows to share -} -``` - -### Ownership - -Executor instances maintain a set of owners. - -Programs are only executed by the Executor if the caller is in the set of owners. - -On initial instantiation of the `CVM` Executor, the calling `Identity` is the owner. This can be a local or foreign account, depending on the origin. The owning `Identity` has total control of the Executor instance and the funds held can make delegate calls from the instance's account. - -Oftentimes, multiple `Identities` represent a single real-world entity, such as a cross-chain protocol or a user. To accommodate for shared/global ownership of resources, each Executor keeps track of a set of `Identities`, which share ownership of the Executor. Each owning `Identity` has full permissions on the Executor instance. - -Owners may be added by having the Executor call the appropriate setters. We will consider adding specialized instructions later. Owners may be removed by other owners. An CVM instance MUST always have at least one owner. - - -# Fees - -Execution fees are opt-in and paid by the user by using the `Tip` registry value. - -The following example program performs an operation, and rewards the tip address: - -```kdl -{ - call 0x13371337 - transfer tip 15000000000000cvm/42 -} -``` - -## Configuration and routing registry - -Registry stores information about the mapping of native identifiers to CVM such as an asset and inter chain connectivity on chain. - -### Routing - -The `Spawn` instruction uses the registry to lookup CVM cross chain capability with connection. -Per chain registry stores its immediate neiborhood info, and may store more hops. - -Propagating updates across registries is handled by the `CVM` too. - -### Assets and other CVM identifiers - -Each asset identifier `AssetId` is 128 bit number in which the 32 initial bits represent the network identifier `NetworkId`. -It is impossible for a scenario where the same asset id is different on another chain. To put it simply, it will not be possible that on one chain 123213 means PEPA and on other chains 123213 means SHIB. -The Prefix allows you to find which network to look at for asset information as each chain introduces new assets independently. - -**Local** - -Each chain contains data which maps assets to their local representations, such as ERC20 address. -The `Transfer` instruction uses the registry to look up the correct identifiers. - -## Security Considerations - -Ensuring that the caller is an owner is an incredibly important check, as the owner can delegate calls through the Executor, directly owning all state, funds, and possible (financial) positions associated with the Executor account. Since each Executor has their own `Identity`, they might own other accounts as well. Thus the owners control more accounts than just the contract storing the owners. - -The `Call` instruction has the same security risks as calling any arbitrary smart contract, such as setting unlimited allowances. - -Adding an owner to the set of owners grants them the ability to evict other owners. - -Failure to execute an instruction will lead to a transaction being reverted, however, the funds will still be in the Executor account's control. Ensure that changing ownership is always done atomically (add and remove in the same transaction) to ensure funds are not lost forever. - -Using bridges is equivalent to adding them as owners on your Executor instance. - -In general different security can be applied to different programs. - -### Anonymous programs - -These programs operate only on funds inside a program and a limited set of instructions can be executed without sender authentication. - -A specific case of this occurence can be in a program that consists of `Transfer`, `Spawn`, `Exchange` only on assets transferred. - - -### Cross protocol verification - -**Example** - -When a program needs to transfer assets in the IBC, it will use the ICS20 protocol. In order to execute remote transactions on behalf of an account, it can use ICS27. In both packets, the same program can be sent as part of the batch and verified on the other end to be exactly the same when assembled for execution. For this, if one protocol is compromised we are still able to validate via the second one. - - -### Trusted topology - -A program can be executed if these are sent only from some subset of trusted channels. - -### Cross chain multisignatures - -In this case, a program can be executed if it was sent by several chains. - -### Signatures - -For operations of high importance, the EDSCA signature of the program can be propagated from the sending chain and verified on the target chain. - -## Cross chain Transfer - -Transfer is most common operation in blockchain, that why it deserver to be more detailed. - -CVM on CW Cosmos to Cosmos uses ICS20 for value transfers. Each ICS20 channel must be upserted into CVM config. - -CVM uses ICS-20 assets transfers on Cosmos chains. On Polkadot and Ethereum it uses escrow/mint, path dependant semantics compatible with ICS-20. - -## Data encoding - -There is no single encoding used across all CVM hosts. - -But encoding is always deterministic(like SCALE) or using deterministic subset of well known encoding(for example protobuf). - -Specific encoding usage is subject to price, performance and usability constraints decided per chain to chain connection. -Please look into code and/or indexers. - -## Deployments - -CVM is deployed in different hosts which are different in their capabilities. - -CVM handles differences without chaining program semantics and reaches chains without contracts too. - -Security of such multi deploy is described in other section. - -### Deployments (Feature lowering) - -Can be considered as 3 layers, - -1. Full deployment of contract with all capabilities. Can do anything. -2. Partial fulfillment of CVM spec using on chain features in case not deployment is possible (usually can multi hop transfer, swap). -3. Edges which may start or terminate CVM programs, but do not execute anything except simple sings (like one hop final transfer). Csapable doing only limited subset of operation on top of existing cross chain protocol. - - -For each chain and protocol it makes pragmatics solution to use existing liquidity and execution primitives. - -### High price of compute (Route lowering) - -Like Ethereum, in this case sender chain (or wallet) transforms CVM (using registry) into native ABI stucture. In this case Executor does minimal overhead and no need for [routing](lowering-routing.md) to be executed on that chain. - -### No support for arbitrary contracts - -Some chains do not support arbitrary contracts, but support a limited subset of instructions. In this case, only programs which use a limited subset of instruction will be executed on the target chain via virtual spawns. - -**Example** - -The Cosmos Hub complies with the IBC ICS Atomic swap spec, but does not host a contract runtime. - -In this case, programs trying to reach the Cosmos Hub from other chains will not spawn full programs on it. However, it will send only swaps and handle the invocation return on the sender chain. - - -### No support for contract postconditions - -Some chains cannot abort transaction based on arbitrary check after ABI invocation. -In this case for specific subset of instructions to specific whitelisted contracts list will be allowed. - -**Example** - -On Near, you cannot abort a Swap transaction if the amount is less than the expected limit. In this case, only trusted Swap contracts will be callable. - -## Examples - -This documents shows some usages example of CVM. - -### Unwrap token - -Shorten path of wrapped token. - -Just spawn on unwrapping chain and spawn to target chain for execution. - -### Stake (bond, lock) - -Call `Stake` instruction or do raw Call for Staking. - -**Example** - -Program to `Stake` on Stride and transfer staked token to Osmosis -is detected as pattern expressed in CVM. - -That part of program is translated to IBC calls to Stride without contracts deployed. - -So this program is possible -```kdl -execute amount=100atom { // on osmosis - spawn Osmosis amount=100atom { - spawn CosmosHub amount=All { - spawn Stride amount=All { - stake amount=All - spawn Osmosis amount=100%stAtom { - spawn Composable Cosmos amount=All { - - } - } - } - } - } -} -``` - -### Restake (reward/slash) - -Al state tracking in CVM is on per chain and behind composable account abstraction (virtual wallet), -uncluding positions(NFTS) and delegation of users. -Rules of operations are hidden behind venue idenfifiers used. -Dynamic targets of operations are encoded as user origins or other parameters in specific operations (for examle validator ids). - -```kdl -// stake - -``` - -```kdl -// prove to Reward - -``` - -```kdl -// unstake - -``` - - -### Borrow - -A concrete example of using the CVM protocol is to transfer funds to a different chain, use them as collateral in a loan, transmit funds back to the source chain, and use them there. For this example, we'll omit querying for current account `health` and repayments. - -Concretely, we want to execute the following operations: - -- Transfer funds to chain XYZ. -- Call a smart contract to take out a loan. -- Reward the relayer, to incentivize execution. -- Send funds back. - -Since we might not know the current interest rates, we'll use relative values for fund transfers, instead of absolute ones. - -For this example, we have the source initiator be a regular user, however, a smart contract is capable of executing the same operations. - -```mermaid -sequenceDiagram - User->>Executor ABC: Submit Program - Executor ABC->>Router ABC: Spawn Program - Router ABC->>Outpost ABC: Submit Program - Outpost ABC->>Outpost XYZ: Relay Program - Outpost XYZ->>Router XYZ: Instantiate VM - Router XYZ->>Executor XYZ: Execute Spawn - Executor XYZ->>Lender: Call 0x1337 (Borrow USDC for DOT) - Lender->>Executor XYZ: Transfer USDC - Executor XYZ->>Tip: Transfer USDC fee to Relayer - Executor XYZ->>Router XYZ: Spawn Program - Router XYZ->>Outpost XYZ: Submit Program - Outpost XYZ->>Outpost ABC: Relay Program - Outpost ABC->>Router ABC: Instantiate VM - Router ABC->>Executor ABC: Execute Spawn - Executor ABC->>Tip: Transfer USDC fee to Relayer - Executor ABC->>User: Transfer USDC -``` - -Although these operations are quite complicated to code by hand, using the CVM protocol, we can very succinctly express them: - -```kdl -spawn "XYZ" 0 { - call "0x1337" // chain-specific encoding to make a smart contract call - transfer tip=50usdc // 50 bucks for the fee. The relayer earns this if the inner spawn is dispatched - spawn HOME 0 amount=ALL { // We send over 100 DOT from ABC to XYZ. - transfer tip=50usdc // Another 50 bucks fee for the operation, but now reverse direction. - transfer to=Alice amount=All // On ABC, we transfer all USDC to the user. - } -} -``` - -### Cross-Chain Exchange (swap) - -Traditionally, users and applications were trading tokens that were only -available on their native chain. If you were operating on a chain **X**, you -would only be able to **swap** tokens that were registered on **X** (be it -native, ERC20 virtualized or even virtualized and wrapped like WETH). - -Manipulating tokens is very complex already. Users willing to move assets -between chains are facing incredible difficulties. Not only bridging is hard, -but also insecure. In most cases, the bridges are centralized and hackable by -design. We, at Composable, try to push the blockchain vision forward, trustless -from the start to the end. - -In this example, we will execute a cross-chain swap through CVM and understand -how programs are relayed, instructions executed and funds transferred. Be aware -that this use case can be generalized to any DeFi protocol and it is the reason -why **CVM makes protocols cross-chain native**. - -Under CVM, tokens are **free to fly** between any chain connected to its -network. Not only they can be traded regardless of their origin, but they are -completely abstracted thanks to a globally unique CVM **asset identifier**. - -**Alice** could submit the following **CVM program**, along **250 PICA** to execute a cross-chain swap: - -```kdl -spawn network=Osmosis amount=250PICA { // Move to Osmosis with 250 PICA - transfer to=Tip amount=25PICA // optional tip to the relayer for the journey - // Execute a swap, effectively trading 200 PICA for OSMO with 1% slippage tolerance. - // This might be replaced by an arbitrary `call 0x042502` representing the swap, - // but for some well-known protocols, we decided to include a custom, strongly typed instruction. - exchange give=200PICA want=99%OSMO - // At this point, we don't know how many OSMO/PICA we have. - // But we can ask CVM to move 100% of both! - spawn network=Picasso amount=100%OSMO,100%PICA { - // optional tip the relayer for the cosy home with the remaining PICA. - transfer to=Tip amount=100%PICA - // 1.3.2. Funds are safu. - transfer to=Alice amount=100%OSMO - } -} -``` - -1. Alice submits the CVM program and the instruction **1.** is executed, - resulting in: - 1. the **child CVM program**, consisting of the instructions **[1.1., 1.2., - 1.3.]** is being submitted within an IBC packet to **Osmosis**. - 2. the funds attached to the child program, **250 PICA**, are being -transferred to **Osmosis** using an [**ICS20 -transfer**](https://github.com/cosmos/ibc/blob/f6371ffd5de3787eb4b85f9fe77f81be4a5993a0/spec/app/ics-020-fungible-token-transfer/README.md). -2. An IBC relayer, listening to on-chain events, determine that relaying the IBC - packet containing the CVM program is profitable. It proceeds and relays both - the funds and the packet to **Osmosis**. -3. The packet is being submitted by the relayer and subsequently processed on - **Osmosis**, resulting in the **child CVM program** being executed: - 1. the instruction **1.1.** is executed: **25 PICA** are transferred to the - relayer. - 2. the instruction **1.2.** is executed: **200 PICA** are traded against an - unknown amount **X** of **OSMO**. - 3. the instruction **1.3.** is executed, resulting in: - 1. the **second child CVM program**, consisting of the instructions - **[1.3.1., 1.3.2.]** is being submitted within an IBC packet to - **Picasso**. - 2. the funds attached to the second child program, **100% of the OSMO and - 100% of the remaining PICA** are being transferred to **Picasso** using - an **ICS20 transfer**. -4. Finally, an IBC relayer determines that relaying the program is again - profitable, the packet and the funds are relayed to **Picasso**. -5. The packet is being submitted by the relayer and subsequently processed on - **Picasso**, resulting in the **second child CVM program** being executed: - 1. the instruction **1.3.1.** is executed: **100% of the remaining PICA** - (25 + dust from the swap) is transferred to the relayer. - 2. the instruction **1.3.2.** is executed: **100% of the OSMO** is - transferred back to **Alice**. - - -### Prove/Verify - -```kdl -execute chain=Namada { - verify verifier_id=42 payload= # off chain data with solution info - push Register.Result # puts result of verify onto stack - spawn chain=Osmosis { # capture stack with result and jump to Restaking chain - spawn chain=ComposableCosmos { - verify verifier_id=123 payload=Register.Pop - # verifier here checks if he sent that solution to Namada chain - # in case of solution was sent and did not settled as promised, Solver slashed, of Fisherman is slahed if lied - } - } -} -``` diff --git a/docs/docs/technology/cvm/virtual-wallet.md b/docs/docs/technology/cvm/virtual-wallet.md deleted file mode 100644 index ac2a2659c4c..00000000000 --- a/docs/docs/technology/cvm/virtual-wallet.md +++ /dev/null @@ -1,108 +0,0 @@ -# Virtual wallet - -The Virtual Wallet allows users to manage funds across multiple networks using a single native account on one designated chain, known as the "wallet" chain. - -It's important to note that the virtual wallet is not a standalone contract; rather, it leverages the [CVM](../cvm.md) and [MANTIS](../mantis.md) to facilitate the seamless handling of user intentions across different blockchain domains while requiring just one signature from the user. - -## Inventing the Virtual Wallet - -### Problem - -`Alice` only has an `Ethereum` wallet and is able to pay gas fees on ETH mainnet. - -`Bob` only has a `Cosmos` wallet and is able to pay gas fees on the Cosmos Hub. - -Alice wants to swap some `ATOM` for `ETH`. - -Bob wants to swap some `ETH` for `ATOM`. - -Bob and ALice are both satisfied with the price, and they are willing to exchange ATOM and ETH. However, the amount of `ATOM` Alice needs is more than what Bob has to offer. - -**How can we make this exchange happen?** - -### General solution - -To enable a secure and atomic exchange, ensuring that both Alice's and Bob's assets are available simultaneously on the same domain, we can employ a 3rd chain, referred to as the "Composable" domain. Here's how it can be achieved: - -1. Escrow Tokens: Alice and Bob escrow their respective tokens on their source chains (Ethereum and Cosmos Hub). This process involves locking their assets in a smart contract or escrow mechanism on their respective chains. - -2. Bridge Information: The next step is to bridge information about the escrow and its ownership from both Ethereum and Cosmos Hub to Composable. This information should include details about the locked assets, ownership, and any conditions required for the exchange. - -**Atomic Exchange**: Once the information is successfully bridged to the Composable domain, an atomic exchange can be initiated. This exchange process should ensure that both Alice's and Bob's assets are released simultaneously on the Composable chain, enabling a secure and coordinated transfer. - -**This mechanism resembles an IBC ICS-20 or Polkadot XCM reserve transfer.** - -Upon the arrival of information about the escrowed tokens on Composable, users can engage in atomic token exchanges with each other. - -After the swap, users have various options: - -- **Retaining Assets on Composable:** Users can choose to keep their assets on Composable, allowing them to settle their next intentions within the Composable ecosystem. - -- **Moving to the Originating Chain:** Users can move their assets back to the originating chain where they have their primary wallet. - -- **Moving to the Source Chain of Assets:** Users may decide to transfer their assets back to the source chain where the tokens were initially minted. - -- **Moving to Any Other Chain:** Users also have the flexibility to move their assets to any other network of their choice. - -In all these scenarios, users want to maintain control over their assets. To facilitate this, the concept of a CVM Executor is introduced, which acts as a cross-chain account. The CVM Executor plays a crucial role in enabling users to retain control over their assets while seamlessly managing them across different blockchain networks and domains. - - -### Account creation - -When a user sends a message from their domain to another domain, the CVM creates an executor for each originating `signature + chain` pair. For example, if a user moves funds from Ethereum to the Composable domain via CVM, the system creates an executor to represent this particular `signature + chain` pair. - -This architecture allows the user to send messages at the same time or in the next message, to execute various actions such as placing orders or initiating exchanges on behalf of the user. These actions are executed through any CVM executor owned by the user on any chain. - -It's essential to note that CVM enforces strict security measures, ensuring that only the specific signature on the designated chain can issue funds management transactions. This mechanism maintains the sovereignty and control of the user's assets while allowing them to seamlessly manage their funds across different chains and domains. - -**If a user has a native wallet on Composable or desires to authorise external accounts to oversee the management of their assets across the various chains where these assets have been sent, the following applies:** - -*Configuring Proxy (Delegation) Accounts in the CVM Executor* - -Users have the ability to initiate a CVM program to integrate a proxy or delegation account with their CVM Executor account. This enables a native account in Composable to (1) oversee and manage the user's funds, subject to predefined constraints, and (2) execute operations on behalf of the user's CVM Executor. - -*Universal Compatibility* - -This functionality is universally applicable across all networks where the CVM is operational, provided that standardized protocols for proxy or delegation exist. Users can leverage this feature to manage their assets consistently across compatible chains. - -*Delegation to Multiple Origins* - -Users retain the flexibility to delegate these responsibilities to multiple origins of CVM Executors. - -**Why is the user's funds not showing up on their native wallet?** - -Until native wallets on individual chains provide support for the CVM, users will need to make use of a CVM-specific wallet and accompanying dashboard. These specialized tools are designed to consolidate and display the user's assets across all chains where the CVM is operational. - -**Does this mean the Virtual wallet is custodial?** - -No, the Virtual Wallet is non-custodial. The instance of the CVM executor is created per user signature. Therfore, the funds are always in the CVM executor which is owned by the user or in flight over IBC. - -CVM contracts are managed by cross chain DAO. - -## Benefits of the Virtual Wallet - -The Virtual Wallet streamlines operations, reduces risks, enhances gas efficiency, and promotes increased liquidity usage. Additional benefits include: - -1. **Opt for Local Atomic Exchange:** Instead of relying on multi-block swaps that may fail, it executes local atomic exchanges followed by cross-chain transfers, which have a lower likelihood of failure. - -2. **Simplify Multi-hop Operations:** Replaces multi-hop transfers and multi-hop swaps with location-based operations on assets already accessible in wallets with delegated liquidity, such as through CoW orders. - -3. **Flexible Fund Management:** Allows cross-chain asset management to adjust path prefixes, either expanding or reducing them when beneficial. - -4. **Consolidate Cross-Chain Operations:** Bundles multiple small cross-chain operations into a single transaction for improved efficiency. - - -**The role of Solvers in MANTIS in an example use case for the virtual wallet** - -Alice seeks to exchange her ETH for ATOM on Neutron. - -Bob aims to exchange his ATOM for ETH on the Ethereum network. - -Both parties escrow their input tokens to facilitate the exchange on Composable. - -Solvers have identified that: - -- Bob can receive ETH directly on Composable. -- Alice can obtain ATOM directly on Composable. - -This approach offers a more secure and cost-effective exchange compared to permitting intermediaries to transfer and swap tokens on other chains. \ No newline at end of file diff --git a/docs/docs/technology/mantis/degen-math.md b/docs/docs/technology/mantis/degen-math.md deleted file mode 100644 index ca1c1b69584..00000000000 --- a/docs/docs/technology/mantis/degen-math.md +++ /dev/null @@ -1,97 +0,0 @@ -# Why solvers will not rug you? - -## Let us have 4 orders - -1. 100pica=10atom -2. 100pica=10atom -3. 20atom=100pica -4. 20atom=100pica - -Read it 100 pica for minumum for 10 atom and other direction. - -### "Fair" solution is - -1. 20atom -2. 20atom -3. 100pica -4. 100pica - -So read it `order number 1 got 20atom as he wanted` - -Let look different cases of "unfair". - - -### Limits - -1. 9atom -... - -So nobody will get less than limited, liked in FIFO Order Book. - -### Not maximal volume - -1. 10atom -2. 10atom -3. 100pica -4. 100pica - -So as you can see solver favored 3 and 4 solutions, but underfilled 1 and 2. - -Solution will be rejected. Why? - -Volume of `fair` solution is `40*200`. -Volume of this solution is `20*200`. - -Solution with larger volume accepted. - -### Not fair price - -1. 10atom -2. 30atom -3. 100pica -4. 100pica - -In this case volume is good, but settling price for order 2 was better than order 3. - -This solution will be rejected, because all orders will be compare to same single accepted price. -1 and 2 violate one accepted price rule, so solution will be rejected. - -**CoWs ensure that users get fair prices against each other** - -### Price is too far from oracle - -Also we do not use Oracle to define optimal price, -but in case two solution are same in volume and fair price, -solution which is closer to oracle is picked. - -### Cross chain execution - -After users got fair price against each other in CoW, remaining part of batch can be solved cross chain. - -Cross chain execution uses MANTIS commitment protocol to ensure safe execution. - -### Why batch CoW first and only equilibrium after? - -#### Market mechanics in equilibrium - -Like with FIFO Order Book like we all know, when Batch auctions has many solvers and many orders, limit difference narrows down and more solvers compete for being accepted, so larger volume. - -That leads to optimal spot price. - -We assume that fair price in batch auction eventually will be optimal, as safes gas costs of cross chain execution and generally more safe against MEV. - -So instead of these orders: -``` -1. 100pica=10atom -2. 100pica=10atom -3. 20atom=100pica -4. 20atom=100pica -``` - -we get these orders: -``` -1. 100pica=17atom -2. 101pica=18atom -3. 20atom=99pica -4. 21atom=100pica -``` diff --git a/docs/docs/technology/mantis/orderflow-searchers-builders.puml b/docs/docs/technology/mantis/orderflow-searchers-builders.puml deleted file mode 100644 index e9eacbeadc2..00000000000 --- a/docs/docs/technology/mantis/orderflow-searchers-builders.puml +++ /dev/null @@ -1,65 +0,0 @@ -@startuml - -title Maximizes IBC transfer privacy and exeuction speed - -node Solver { - -} - -node PrivateMevRelayer { - collections UserTransactions - collections IBCPacketsFromFromTransactions - collections RoutesOfTransfersAndSwapsFromIBCPackets -} - -node Centauri { - file CosmosBeginOfBlock - file CosmosMiddleOfBlock - file CosmosEndOfBlock -} - -node IBCRelayer { - -} - -node EthereumBlockSpaceAuction { - -} - -node IBCRelayer { - -} - -node Etherum { - file EthereumBeginOfBlock - file EthereumMiddleOfBlock - file EthereumEndOfBlock -} - -node SolanaBlockSpaceAuction { - -} - -node Solana { - file SolanaBeginOfBlock - file SolanaMiddleOfBlock - file SolanaEndOfBlock -} - -Solver -.-> PrivateMevRelayer : find suitable order - -PrivateMevRelayer -> CosmosEndOfBlock : put ordered transactions generating IBC packets into the end of block - -PrivateMevRelayer -.-> EthereumBlockSpaceAuction : book start of in future - -PrivateMevRelayer -.-> SolanaBlockSpaceAuction : book start of in future - -IBCRelayer -.-> EthereumBeginOfBlock : tx - -IBCRelayer -.-> SolanaBeginOfBlock : tx - -IBCRelayer -.-> Centauri : listen finalization from gossip - -IBCRelayer -.-> Centauri : grab reward for ordered delivery - -@enduml \ No newline at end of file diff --git a/docs/docs/technology/mantis/problem-solver-flow.md b/docs/docs/technology/mantis/problem-solver-flow.md deleted file mode 100644 index b1731d2603a..00000000000 --- a/docs/docs/technology/mantis/problem-solver-flow.md +++ /dev/null @@ -1,143 +0,0 @@ -An end to end flow description of getting data for solvers, posting the solution, and executing them on chain. - - -## Overview - -These are steps which, detailed below, happen in this syste: -1. User post problems. -2. Solvers collect data needed to solve problems -3. Solvers run optimization algorithm -4. Solvers post solutions on chain into contract -5. Contract chooses solution with largest volume -6. Contract executes CoW in same transaction if there are COWs -7. Contract sends message to convert route to CVM if there are no COWs -8. CVM program executed - -**Note: CVM information can be found here, essentially a DSL for intents: https://docs.composable.finance/technology/cvm - - -### 1. User posts problem - -User sends TX to Cosmos CosmWasm contract via RPC. - -Order ends up in storage. - -It is the user's responsiblity to consult an oracle to set limits he wants. - -**References** - -Problem format is here: - -https://github.com/ComposableFi/composable/blob/f65076f5fcf2f0903b3d21e62ba22d7ba91c0c9f/code/xcvm/cosmwasm/contracts/order/src/lib.rs#L65 - - -In JSON format: - -In https://www.npmjs.com/package/cvm-cw-types?activeTab=code open -`/cvm-cw-types/dist/cw-mantis-order/response_to_get_all_orders.json` - - -### 2. Solvers collect data needed to solve problems - -AMM amounts/fees, tokens denoms, routes are needed. - -These are collected offchain and onchain. - -Coding in progress to satisfy what Solver algorithm wants. - - -**References** - -AMM Neutron: -https://app.astroport.fi/api/trpc/pools.getAll?input=%7B%22json%22%3A%7B%22chainId%22%3A%22phoenix-1%22%7D%7D - -AMM Osmosis: -https://app.osmosis.zone/api/pools?page=1&limit=300&min_liquidity=500000 - -Routes: -https://github.com/ComposableFi/composable/blob/main/code/cvm/cvm.json - -Fees and rate limits are added if needed. - -### 3. Solvers run optimizaton algorithm - -Solving for: -1. Maximal volume via CoWs, CoWs matched up to limit -2. Remaining proposed to go via CFMM routes - -Python coding is in progress. - -**References** - -Python -https://github.com/BrunoMazorra/2-assets-matching - -Rust port: -https://github.com/ComposableFi/composable/blob/main/mantis/solver/src/solver.rs - - -#### Optimization - -In general, when all routes take proportion fees from token operations (transfer/exchanges). -This happens because solution may pick up any real value amid to points of doing operation with all input tokens or not doing at all. -Actually can find what part of tokens should go into - -With cross transfers, there are constant fees regardless of transfer amount. -That makes need to decide to go to other chain or not. -That decision is binary and makes problem non convex (cannot take arbitrary point of like partially go to chain). -That means that some tricks and heuristics to be used convert mixed integer problem (integer whole values) to convex(real values), -and iterate picking route vs not route decisions semi randomly. - - -### 4. Solvers post solution on chain into contract - -Python solver output in progress. - -Final matrix output to be converted into call to standard Cosmos CosmWasm RPC. - -**References** - -Solution message to RPC format is in -https://www.npmjs.com/package/cvm-cw-types?activeTab=code - -in `/cvm-cw-types/dist/cw-mantis-order/response_to_get_all_solutions.json` file. - - -### 5. Contract chooses solution with largest volume from several. - -Currently any solution of several is picked each block for testing. -Final config will be 2 blocks of solutions. - -Checks that solution respects user's limits. - -**References** - -https://github.com/ComposableFi/composable/blob/f65076f5fcf2f0903b3d21e62ba22d7ba91c0c9f/code/xcvm/cosmwasm/contracts/order/src/lib.rs#L343 - - -### 6. Contract executes CoW in same transaction - -CoWs happen on same chain. - -Coded as a simple CosmWasm transfers back and forth accounts. - -### 7. Contract sends message to convert route to CVM - -Each solution has a simplified version of routes which is 1 to 1 mapped to a more detailed lower level CVM program. - -Coding is in progress. - -**References** - -This is solution route tree -https://github.com/ComposableFi/composable/blob/f65076f5fcf2f0903b3d21e62ba22d7ba91c0c9f/code/xcvm/cosmwasm/contracts/order/src/lib.rs#L153 - -Here is equivalent root of tree in CVM -https://github.com/ComposableFi/composable/blob/ee480d0062b8cde89e5cfb848881d88bb56f2625/docs/docs/technology/cvm/specification.md?plain=1#L120 - -### 8. CVM executed - -That is mostly converting CVM instruction to IBC packets. - - - diff --git a/docs/docs/technology/mantis/solvers-solutions.md b/docs/docs/technology/mantis/solvers-solutions.md index cadfb26c1df..29bf1faf9fd 100644 --- a/docs/docs/technology/mantis/solvers-solutions.md +++ b/docs/docs/technology/mantis/solvers-solutions.md @@ -100,11 +100,11 @@ Overall, this would work as follows: 3. If protocols are successfully chosen as a component of the solution for the solver (and this solver has presented the best solution out of all solvers), then the order flow is routed through the protocol This requires a problem smart contract within MANTIS, which would be able to receive pre-loaded tokens. -- Our "problem" contract would have `xc-account` like any users -- All solution will be routed by MANTIS from the problem origin contract so it will have access to xc account on each chain +- Our "problem" contract would have `cvm-account` like any users +- All solution will be routed by MANTIS from the problem origin contract so it will have access to `cvm-account`` on each chain - So, the problem contract will have access to any tokens on that account - Reasonably, these accounts to have at least native tokens for gas fees and bridge fees -- Or, protocol can have `xc-account` and do extended allowance to MANTIS sent from problem origin so the solution can peek into allowance and pay fees +- Or, protocol can have `cvm-account` and do extended allowance to MANTIS sent from problem origin so the solution can peek into allowance and pay fees This would also require the UI for protocols to initiate and submit tokens for their campaigns, and then to subsequently monitor these campaigns. diff --git a/docs/sidebars.js b/docs/sidebars.js index b99d9cb850e..5ab7397fa4e 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -218,13 +218,11 @@ label: "CVM", link: { type: "doc", - id: "technology/cvm", + id: "technology/cvm", }, collapsible: false, collapsed: false, items: [ - "technology/cvm/specification", - "technology/cvm/virtual-wallet", "technology/cvm/tutorial", ], }, @@ -287,24 +285,9 @@ mantis: [ items: ["develop/cosmwasm/walkthrough"], }, { - type: "category", label: "Nix", - link: { - type: "doc", - id: "nix" - }, - collapsible: true, - collapsed: true, - items: [ - "nix/install", - "nix/run-packages", - "nix/development-environments", - "nix/running-checks", - "nix/reading-logs", - "nix/defining-your-own-packages", - "nix/editing-docs", - "nix/troubleshooting", - ], + type: "doc", + id: "nix" }, { type: "doc", diff --git a/flake/fmt.nix b/flake/fmt.nix index 3391ee8e717..2217135e65c 100644 --- a/flake/fmt.nix +++ b/flake/fmt.nix @@ -20,8 +20,25 @@ allTomlFiles = filesWithExtension "toml"; in { packages = { + fix = pkgs.writeShellApplication { + name = "fix"; + + runtimeInputs = with pkgs; [ + self'.packages.rust-nightly + pkgs.zlib.dev + pkgs.stdenv.cc.cc.lib + pkgs.llvmPackages.libclang.lib + pkgs.zlib.dev + ]; + + text = '' + export ZLIB_VERSION="1.3" + export LIBZ_SYS_STATIC=1 + cargo clippy --fix --allow-dirty --package common + ''; + }; fmt = pkgs.writeShellApplication { - name = "fmt-composable"; + name = "fmt"; runtimeInputs = with pkgs; [ nixfmt coreutils taplo nodePackages.prettier ]