From ee9ad3d25acd6b327dfbb5214633f3b9e114eca8 Mon Sep 17 00:00:00 2001 From: Violet Parr Date: Fri, 14 Jun 2024 17:24:32 -0400 Subject: [PATCH 1/7] Closes #381: Add 2 more validators, providing 4 nodes in the devnet. --- dev/docker-scripts/four-nodes.yaml | 145 +++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 dev/docker-scripts/four-nodes.yaml diff --git a/dev/docker-scripts/four-nodes.yaml b/dev/docker-scripts/four-nodes.yaml new file mode 100644 index 00000000..6962559c --- /dev/null +++ b/dev/docker-scripts/four-nodes.yaml @@ -0,0 +1,145 @@ +# Docker Compose file for making an Entropy blockchain network. +# Currently, it's intended for LOCAL DEVNET FUNCTIONALITY ONLY. +# Things will get better and more generic, but for the moment +# this iteration is for simplifying the dogfooding and testing +# workflows our engineers use, and trying to cut down on some +# of the more complicated test code that spins up this kind of +# environment for their tests. Eventually, we will converge on +# a more canonical set of environments and configuration files. +--- +name: entropy-devnet-local-4-nodes + +services: + alice-tss-server: + # This pulls from Docker Hub, so you can replace the image tag name + # (the string after the `:` in the `image` key) with whatever tag + # name you'd like to use. Each Docker image is built from a specific + # commit in the `entropy-core` repository. Refer to the wiki page at + # https://github.com/entropyxyz/meta/wiki/Git#conventions for details + # about how Git tags, branches, and commits refer to image tags here. + image: entropyxyz/entropy-tss:${ENTROPY_CORE_VERSION:-latest} + ports: + - "127.0.0.1:3001:3001/tcp" + command: + - "--alice" + - "--threshold-url" + - "0.0.0.0:3001" + - "--chain-endpoint" + - "ws://alice-chain-node:9944" + - '--no-sync' + + alice-chain-node: + image: entropyxyz/entropy:${ENTROPY_CORE_VERSION:-latest} + ports: + - "127.0.0.1:9944:9944/tcp" + command: + - "--chain" + - "devnet-local" + - "--alice" + - "--base-path" + - ".entropy/alice" + - "--rpc-port" + - "9944" + - "--rpc-cors" + - "all" + - "--unsafe-rpc-external" # Intentional, for TSS's access. + - "--node-key=0000000000000000000000000000000000000000000000000000000000000001" + - "--tss-server-endpoint" + - "http://alice-tss-server:3001" + + bob-tss-server: + image: entropyxyz/entropy-tss:${ENTROPY_CORE_VERSION:-latest} + ports: + - "127.0.0.1:3002:3002/tcp" + command: + - "--bob" + - "--threshold-url" + - "0.0.0.0:3002" + - "--chain-endpoint" + - "ws://bob-chain-node:9944" + - '--no-sync' + + # "Bob's chain node." + bob-chain-node: + image: entropyxyz/entropy:${ENTROPY_CORE_VERSION:-latest} + ports: + - "127.0.0.1:9945:9944/tcp" + command: + - "--chain" + - "devnet-local" + - "--bob" + - "--base-path" + - ".entropy/bob" + - "--rpc-port" + - "9944" + - "--rpc-cors" + - "all" + - "--unsafe-rpc-external" # Intentional, for TSS's access. + - "--bootnodes" + - "/dns4/alice-chain-node/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" + - "--tss-server-endpoint" + - "http://bob-tss-server:3002" + + dave-tss-server: + image: entropyxyz/entropy-tss:${ENTROPY_CORE_VERSION:-latest} + ports: + - "127.0.0.1:3003:3003/tcp" + command: + - "--dave" + - "--threshold-url" + - "0.0.0.0:3003" + - "--chain-endpoint" + - "ws://dave-chain-node:9944" + - '--no-sync' + + dave-chain-node: + image: entropyxyz/entropy:${ENTROPY_CORE_VERSION:-latest} + ports: + - "127.0.0.1:9946:9944/tcp" + command: + - "--chain" + - "devnet-local" + - "--dave" + - "--base-path" + - ".entropy/dave" + - "--rpc-port" + - "9944" + - "--rpc-cors" + - "all" + - "--unsafe-rpc-external" # Intentional, for TSS's access. + - "--bootnodes" + - "/dns4/alice-chain-node/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" + - "--tss-server-endpoint" + - "http://dave-tss-server:3003" + + eve-tss-server: + image: entropyxyz/entropy-tss:${ENTROPY_CORE_VERSION:-latest} + ports: + - "127.0.0.1:3004:3004/tcp" + command: + - "--dave" + - "--threshold-url" + - "0.0.0.0:3004" + - "--chain-endpoint" + - "ws://eve-chain-node:9944" + - '--no-sync' + + eve-chain-node: + image: entropyxyz/entropy:${ENTROPY_CORE_VERSION:-latest} + ports: + - "127.0.0.1:9947:9944/tcp" + command: + - "--chain" + - "devnet-local" + - "--eve" + - "--base-path" + - ".entropy/eve" + - "--rpc-port" + - "9944" + - "--rpc-cors" + - "all" + - "--unsafe-rpc-external" # Intentional, for TSS's access. + - "--bootnodes" + - "/dns4/alice-chain-node/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp" + - "--tss-server-endpoint" + - "http://eve-tss-server:3004" From 429823e085ff4fb154e227ee9119b4d128349f68 Mon Sep 17 00:00:00 2001 From: frankie Date: Fri, 14 Jun 2024 12:02:02 -1000 Subject: [PATCH 2/7] update the dev/README --- dev/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/README.md b/dev/README.md index 8b60bff0..307edae3 100644 --- a/dev/README.md +++ b/dev/README.md @@ -7,6 +7,8 @@ For the tests to run you **must** edit your `/etc/hosts` file, adding: ``` 127.0.0.1 alice-tss-server 127.0.0.1 bob-tss-server +127.0.0.1 dave-tss-server +127.0.0.1 eve-tss-server ``` ### Gotcha 1 - dirty docker From 7701721f052160529ac949dfc9d9ece7a344c304 Mon Sep 17 00:00:00 2001 From: frankie Date: Fri, 14 Jun 2024 12:24:08 -1000 Subject: [PATCH 3/7] tests - are failing --- tests/four-nodes.test.ts | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/four-nodes.test.ts diff --git a/tests/four-nodes.test.ts b/tests/four-nodes.test.ts new file mode 100644 index 00000000..518d6092 --- /dev/null +++ b/tests/four-nodes.test.ts @@ -0,0 +1,64 @@ +import test from 'tape' +import { readFileSync } from 'fs' +import Entropy, { wasmGlobalsReady } from '../src' +import Keyring from '../src/keys' +import * as util from '@polkadot/util' + +import { + sleep, + promiseRunner, + spinNetworkUp, + charlieStashSeed, + charlieStashAddress, + spinNetworkDown, +} from './testing-utils' + +const networkType = 'four-nodes' + + +test('test the four-nodes docker script for subgroups', async (t) => { + const run = promiseRunner(t) + // context: all run does is checks that it runs + await run('network up', spinNetworkUp(networkType)) + + await sleep(process.env.GITHUB_WORKSPACE ? 30_000 * 2 : 5_000 * 2) + + // this gets called after all tests are run + t.teardown(async () => { + await entropy.close() + await spinNetworkDown(networkType).catch((error) => + console.error('Error while spinning network down', error.message) + ) + }) + + await run('wasm', wasmGlobalsReady()) + + const keyring = new Keyring({ seed: charlieStashSeed, debug: true }) + let store = keyring.getAccount() + t.equal(store.admin.address, keyring.accounts.registration.pair.address, 'admin account should have an address and for now it should match registrations address') + keyring.accounts.on('account-update', (fullAccount) => { + store = fullAccount + }) + + + const entropy = new Entropy({ + keyring, + endpoint: 'ws://127.0.0.1:9944', + }) + + await run('entropy ready', entropy.ready) + const entries = await run('signingGroups', entropy.substrate.query.stakingExtension.signingGroups.entries()) + + const subGroups = entries.map((group) => { + // aka: subGroup + const keyGroup = group[1] + console.log('') + // omg polkadot type gen is a head ache + // @ts-ignore: next line + return keyGroup.unwrap() + }) + t.equal(subGroups.length, 2, 'expecting 2 subgroups') + t.equal(subGroups[0].length, 2, 'expecting 2 validators per subgroup') + await entropy.close() + t.end() +}) From 33fc49f5683659768c27d8c15d9f0c3974c57e4b Mon Sep 17 00:00:00 2001 From: Violet Parr Date: Fri, 14 Jun 2024 18:44:18 -0400 Subject: [PATCH 4/7] Add hostname addressing for `dave`'s and `eve`'s TSS server, too. --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2b06610f..eff4f8c7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,6 +33,6 @@ jobs: password: ${{ secrets.DOCKER_HUB_CI_TOKEN }} - name: Add TSS server host mappings run: | - echo "127.0.0.1 alice-tss-server bob-tss-server" | sudo tee -a /etc/hosts + echo "127.0.0.1 alice-tss-server bob-tss-server dave-tss-server eve-tss-server" | sudo tee -a /etc/hosts - name: Test run: yarn run test From 4a78ac72bb38b2d4b026015b104012959d1aab9e Mon Sep 17 00:00:00 2001 From: Violet Parr Date: Fri, 14 Jun 2024 18:44:54 -0400 Subject: [PATCH 5/7] Suggest newer Docker CLI habits. Fix typo in stderr output. --- dev/README.md | 2 +- tests/testing-utils/network.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/README.md b/dev/README.md index 307edae3..635aad21 100644 --- a/dev/README.md +++ b/dev/README.md @@ -21,7 +21,7 @@ that program is already deployed boo"). Have a look what's running: ```bash -docker ps +docker container list ``` You can close them down like this: diff --git a/tests/testing-utils/network.ts b/tests/testing-utils/network.ts index 6be2f9e4..1b8d3db0 100644 --- a/tests/testing-utils/network.ts +++ b/tests/testing-utils/network.ts @@ -9,7 +9,7 @@ export async function spinNetworkUp(networkType = 'two-nodes') { { shell: true, cwd: process.cwd(), stdio: 'inherit' } // Use shell's search path. ) } catch (e) { - console.error('Error in spintNetworkUp: ', e.message) + console.error('Error in spinNetworkUp: ', e.message) } } From 0c26d63d415d8aac54b5b70366c5c5018b2f7eaf Mon Sep 17 00:00:00 2001 From: Violet Parr Date: Fri, 14 Jun 2024 19:43:09 -0400 Subject: [PATCH 6/7] Mount the `./dev` directory into the devnet containers. This command makes it possible to use files located in the `./dev` directory from within the Docker containers, enabling the option of loading a custom chain spec file for testing. --- dev/docker-scripts/four-nodes.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dev/docker-scripts/four-nodes.yaml b/dev/docker-scripts/four-nodes.yaml index 6962559c..532a0c30 100644 --- a/dev/docker-scripts/four-nodes.yaml +++ b/dev/docker-scripts/four-nodes.yaml @@ -32,6 +32,8 @@ services: image: entropyxyz/entropy:${ENTROPY_CORE_VERSION:-latest} ports: - "127.0.0.1:9944:9944/tcp" + volumes: + - ${PWD}/dev:/srv/entropy/dev command: - "--chain" - "devnet-local" @@ -64,6 +66,8 @@ services: image: entropyxyz/entropy:${ENTROPY_CORE_VERSION:-latest} ports: - "127.0.0.1:9945:9944/tcp" + volumes: + - ${PWD}/dev:/srv/entropy/dev command: - "--chain" - "devnet-local" @@ -96,6 +100,8 @@ services: image: entropyxyz/entropy:${ENTROPY_CORE_VERSION:-latest} ports: - "127.0.0.1:9946:9944/tcp" + volumes: + - ${PWD}/dev:/srv/entropy/dev command: - "--chain" - "devnet-local" @@ -128,6 +134,8 @@ services: image: entropyxyz/entropy:${ENTROPY_CORE_VERSION:-latest} ports: - "127.0.0.1:9947:9944/tcp" + volumes: + - ${PWD}/dev:/srv/entropy/dev command: - "--chain" - "devnet-local" From 0cd6c170a89620423ea2cdb30d5d761a77c4aa8c Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Mon, 24 Jun 2024 13:46:01 -0400 Subject: [PATCH 7/7] chain to proper chain name --- dev/docker-scripts/four-nodes.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/docker-scripts/four-nodes.yaml b/dev/docker-scripts/four-nodes.yaml index 532a0c30..6e4e350a 100644 --- a/dev/docker-scripts/four-nodes.yaml +++ b/dev/docker-scripts/four-nodes.yaml @@ -7,7 +7,7 @@ # environment for their tests. Eventually, we will converge on # a more canonical set of environments and configuration files. --- -name: entropy-devnet-local-4-nodes +name: entropy-devnet-local-four-nodes-4-nodes services: alice-tss-server: @@ -36,7 +36,7 @@ services: - ${PWD}/dev:/srv/entropy/dev command: - "--chain" - - "devnet-local" + - "devnet-local-four-nodes" - "--alice" - "--base-path" - ".entropy/alice" @@ -70,7 +70,7 @@ services: - ${PWD}/dev:/srv/entropy/dev command: - "--chain" - - "devnet-local" + - "devnet-local-four-nodes" - "--bob" - "--base-path" - ".entropy/bob" @@ -104,7 +104,7 @@ services: - ${PWD}/dev:/srv/entropy/dev command: - "--chain" - - "devnet-local" + - "devnet-local-four-nodes" - "--dave" - "--base-path" - ".entropy/dave" @@ -138,7 +138,7 @@ services: - ${PWD}/dev:/srv/entropy/dev command: - "--chain" - - "devnet-local" + - "devnet-local-four-nodes" - "--eve" - "--base-path" - ".entropy/eve"