Skip to main content
Version: Latest

Deploy a Local Network with Godwoken-Kicker

Godwoken-Kicker provides a quick mode and a manual-build mode for deployment.

The quick mode is fast and simple. It executes the builds of all components from pre-built docker images.

Environment

  • Ubuntu 20.04 LTS

Prerequisites

Steps

  1. Clone the source of Godwoken-Kicker under the branch master.

    $ git clone -b master https://github.com/godwokenrises/godwoken-kicker
  2. Start Godwoken devenet_v1.

    The kicker start command can be used to initialize the Godwoken services. The first-time launch might take a few minutes.

    $ cd godwoken-kicker
    $ ./kicker start
    NOTE: The docker-compose version should be newer than 1.29.0
    NOTE: This might take several minutes on the first run

    :> docker-compose -f docker/docker-compose.yml up -d --build

    docker_ckb_1 is up-to-date
    Starting docker_postgres_1 ...
    docker_ckb-miner_1 is up-to-date
    Starting docker_postgres_1 ... done
    Starting docker_check-ckb-started-successfully_1 ... done
    docker_ckb-indexer_1 is up-to-date
    Creating docker_godwoken_1 ... done
    Creating docker_godwoken-readonly_1 ... done
    Creating docker_web3_1 ... done
    Creating docker_web3-indexer_1 ... done
    [start] Services started successfully
    note

    For developers who have configured Godwoken, in case of reported errors that cause the service to fail to start, execute ./kicker stop to disconnect from the Godwoken network and then run ./kickcer clean to ensure a clean running environment.

    The command above deploys the Godwoken local network. After deployment, the following docker containers begin running:

    • docker_ckb_1
    • docker_ckb-miner_1
    • docker_ckb-indexer_1
    • docker_godwoken_1
    • docker_web3_1
    • docker_web3-indexer_1
    • docker_postgres_1
    • docker_redis_1
  3. More information can be viewed at docker-compose.yml.

  4. Deposit CKB to a layer 2 account for testing.

    The kicker get-balance <eth-address> command can be used to check the layer 2 account balance.

    $ ./kicker get-balance 0xCD1d13450cFA630728D0390C99957C6948BF7d19 # check account balance
    script hash: 0x30e9d7aa4c5e72f7fe2a82af771d48b6324e0038a97d44d0b2950818004c378c
    Creating docker_godwoken_run ... done
    2022-06-28T19:31:32.966645Z INFO gw_tools::get_balance: Balance: 0

    The kicker deposit <eth-address> <amount> command can be used to deposit CKB to the layer 2 account.

    $ ./kicker deposit 0xCD1d13450cFA630728D0390C99957C6948BF7d19 999 # deposit ckb to account
    Output

    Creating docker_godwoken_run ... done
    2022-06-28T19:32:34.218450Z INFO gw_tools::deposit_ckb: eth address: 0xcd1d13450cfa630728d0390c99957c6948bf7d19
    2022-06-28T19:32:34.221802Z INFO gw_tools::deposit_ckb: layer2 script hash: 0x30e9d7aa4c5e72f7fe2a82af771d48b6324e0038a97d44d0b2950818004c378c
    2022-06-28T19:32:34.324741Z INFO gw_tools::deposit_ckb: script hash: 0x30e9d7aa4c5e72f7fe2a82af771d48b6324e0038a97d44d0b2950818004c378c
    2022-06-28T19:32:34.326708Z INFO gw_tools::deposit_ckb: balance before deposit: 0
    2022-06-28T19:32:34.953472Z INFO gw_tools::deposit_ckb: tx_hash: 0xcf5cafaf8dbd02c1603681be437a1c4f6332b3d6ec0347c741c2273878a9a962
    2022-06-28T19:32:34.959452Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Pending
    2022-06-28T19:32:37.961956Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Pending
    2022-06-28T19:32:40.965957Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Pending
    2022-06-28T19:32:43.969789Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Pending
    2022-06-28T19:32:46.973281Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Pending
    2022-06-28T19:32:49.976335Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Pending
    2022-06-28T19:32:52.979368Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Proposed
    2022-06-28T19:32:55.981554Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Proposed
    2022-06-28T19:32:58.983675Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Proposed
    2022-06-28T19:33:01.987721Z INFO gw_rpc_client::ckb_client: waiting for transaction, status: Proposed
    2022-06-28T19:33:04.990121Z INFO gw_rpc_client::ckb_client: transaction committed
    2022-06-28T19:33:06.992947Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 2 secs.
    2022-06-28T19:33:08.995002Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 4 secs.
    2022-06-28T19:33:10.996169Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 6 secs.
    2022-06-28T19:33:12.997481Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 8 secs.
    2022-06-28T19:33:14.998152Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 10 secs.
    2022-06-28T19:33:16.999912Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 12 secs.
    2022-06-28T19:33:19.001432Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 14 secs.
    2022-06-28T19:33:21.003545Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 16 secs.
    2022-06-28T19:33:23.005325Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 18 secs.
    2022-06-28T19:33:25.007006Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 20 secs.
    2022-06-28T19:33:27.008300Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 22 secs.
    2022-06-28T19:33:29.010192Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 24 secs.
    2022-06-28T19:33:31.011169Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 26 secs.
    2022-06-28T19:33:33.012858Z INFO gw_tools::deposit_ckb: current balance: 0, waiting for 28 secs.
    2022-06-28T19:33:35.014758Z INFO gw_tools::deposit_ckb: current balance: 999000000000000000000, waiting for 30 secs.
    2022-06-28T19:33:35.014801Z INFO gw_tools::deposit_ckb: deposit success!
    2022-06-28T19:33:35.015527Z INFO gw_tools::deposit_ckb: Your account id: 5

    Verify that the transfer executed successfully.

    $ ./kicker get-balance 0xCD1d13450cFA630728D0390C99957C6948BF7d19
    script hash: 0x30e9d7aa4c5e72f7fe2a82af771d48b6324e0038a97d44d0b2950818004c378c
    Creating docker_godwoken_run ... done
    2022-06-28T19:35:01.434631Z INFO gw_tools::get_balance: Balance: 999000000000000000000
    note

    The accounts are defined in contract/hardhat.config.js.

  5. Run Godwoken-test cases with Hardhat.

    $ git clone https://github.com/godwokenrises/godwoken-tests
    $ cd godwoken-tests
    $ cd contracts
    $ npm install
    $ npm run test
    Output

    > contracts@1.0.0 test
    > hardhat test --network gw_devnet_v1

    contracts/Token.sol: Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.

    Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
    --> contracts/Calc.sol


    Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
    --> contracts/ErrorHandling.sol


    Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
    --> contracts/Memory.sol


    Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
    --> contracts/RecursionContract.sol


    Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.
    --> contracts/Storage.sol


    Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it "abstract" is sufficient.
    --> contracts/Storage.sol:9:3:
    |
    9 | constructor() public {
    | ^ (Relevant source part starts here and spans across multiple lines).


    Warning: Function state mutability can be restricted to pure
    --> contracts/Calc.sol:24:5:
    |
    24 | function add(uint256 x, uint256 y) public view returns (uint256) {
    | ^ (Relevant source part starts here and spans across multiple lines).


    Warning: Function state mutability can be restricted to pure
    --> contracts/Calc.sol:28:5:
    |
    28 | function sub(uint256 x, uint256 y) public view returns (uint256) {
    | ^ (Relevant source part starts here and spans across multiple lines).


    Warning: Function state mutability can be restricted to pure
    --> contracts/ErrorHandling.sol:5:5:
    |
    5 | function getRevertMsg(uint value) public view returns (uint) {
    | ^ (Relevant source part starts here and spans across multiple lines).


    Compiled 18 Solidity files successfully


    BlockInfo Contract
    chainId 8521215115268
    contractChainId 8521215115268
    ✔ should compare web3 chain id and EVM with same results
    contractMiner 0x0Aa49d060c257758846d8E409421AD128c6d5080
    miner 0x0000000000000000000000000000000000000000
    ✔ should compare web3 coinbase and conibase from EVM with same results (181ms)
    blockNumber 606
    contractBlockNumber BigNumber { value: "607" }
    ✔ should compare web3 block number and block number from EVM with same results
    blockHash 0xd16d5455af88c73301a3fced98d5fe7cf3fe8dc6d82616bde133c21baa11eebc
    ✔ should compare web3 block hash and block hash from EVM with same results
    txBlockNumber 607
    eventBlockNumber 607
    txBlockHash 0xd16d5455af88c73301a3fced98d5fe7cf3fe8dc6d82616bde133c21baa11eebd
    eventBlockHash 0x0000000000000000000000000000000000000000000000000000000000000000
    ✔ should mine correct event with block number and hash with OK results (125ms)

    Calc contract
    ✔ Deployment computing contract (232ms)

    HeadTail
    Setup test
    ✔ deploys contract (4336ms)
    ✔ has valid initial values (202ms)
    Stage 1
    ✔ allows to deposit BET_VALUE (129ms)
    ✔ saves address of user (142ms)
    ✔ allows depositing 777 wei (242ms)
    Stage 2
    ✔ allows to save both users addresses (4247ms)
    Stage 5
    ✔ sends ether to a second user after a correct guess (4317ms)

    Memory Contract
    ✔ Deploy and new some memory (509ms)

    Recursion Contract
    depth: 1
    sum = 1
    depth: 2
    sum = 3
    depth: 3
    sum = 6
    depth: 4
    sum = 10
    depth: 5
    sum = 15
    depth: 6
    sum = 21
    depth: 7
    sum = 28
    depth: 8
    sum = 36
    depth: 9
    sum = 45
    depth: 10
    sum = 55
    depth: 11
    sum = 66
    depth: 12
    sum = 78
    depth: 13
    sum = 91
    depth: 14
    sum = 105
    depth: 15
    sum = 120
    depth: 16
    sum = 136
    depth: 17
    sum = 153
    depth: 18
    sum = 171
    depth: 19
    sum = 190
    depth: 20
    sum = 210
    depth: 21
    sum = 231
    depth: 22
    sum = 253
    depth: 23
    sum = 276
    depth: 24
    sum = 300
    depth: 25
    sum = 325
    depth: 26
    sum = 351
    depth: 27
    sum = 378
    depth: 28
    sum = 406
    depth: 29
    sum = 435
    depth: 30
    sum = 465
    depth: 31
    sum = 496
    depth: 32
    sum = 528
    depth: 33
    sum = 561
    depth: 34
    sum = 595
    depth: 35
    sum = 630
    depth: 36
    sum = 666
    ✔ Deploy and call recursive functions (3167ms)

    SisyphusGamble
    sender's address: 0x966B30e576A4d6731996748B48Dd67C94eF29067
    Deploying contract SisyphusGambleVenues
    Sisyphus gamble venues deployed on address: 0x1f4D5204c51007007fD21cF3e94B2Bb6dE8a2f2C
    Deploying contract testERC20
    TestERC20 on address: 0x5B0AdFF638E2862e4834948e559fd821680dc8DF
    sender's balnace = 10000
    Start a new sisyphus gamble
    Getting Sisyphus Gamble Venues...
    gameList: [
    [
    '0x6421e4Ea26E11C895266ab9EE4d724613276a588',
    1,
    2,
    '0x5B0AdFF638E2862e4834948e559fd821680dc8DF',
    BigNumber { value: "1" },
    '0x0000000000000000000000000000000000000000',
    BigNumber { value: "115792089237316195423570985008687907853269984665640564039457584007913129639935" },
    BigNumber { value: "1" },
    sisyphusGamble: '0x6421e4Ea26E11C895266ab9EE4d724613276a588',
    weight: 1,
    gamblingBlocks: 2,
    token: '0x5B0AdFF638E2862e4834948e559fd821680dc8DF',
    totalPrize: BigNumber { value: "1" },
    lastGambler: '0x0000000000000000000000000000000000000000',
    endBlock: BigNumber { value: "115792089237316195423570985008687907853269984665640564039457584007913129639935" },
    minGamble: BigNumber { value: "1" }
    ]
    ]
    Sisyphus gamble venues deployed on address: 0x6421e4Ea26E11C895266ab9EE4d724613276a588
    SisyphusGambling...
    >> Claim Prize
    sender's balnace = 9996
    ✔ Start a new sisyphus gamble -> gamble -> claimPrize (13045ms)

    Token contract
    Deployment
    ✔ Should set the right owner
    ✔ Should assign the total supply of tokens to the owner (52ms)
    Transactions
    ✔ Should transfer tokens between accounts (117ms)
    ✔ Should update balances after transfers (182ms)


    20 passing (53s)

    User can configurate any network in the hardhat.config.js.

    $ npx hardhat run --network <your-network> scripts/deploy.js
  6. Discontinue Godwoken devnet_v1.

    Under the godwoken-kicker directory, the kicker stop command can be used to stop the Godwoken services.

    $ ./kicker stop
    OUTPUT

    :> docker-compose -f docker/docker-compose.yml down --remove-orphans
    Stopping docker_web3-indexer_1 ... done
    Stopping docker_web3_1 ... done
    Stopping docker_godwoken_1 ... done
    Stopping docker_ckb-indexer_1 ... done
    Stopping docker_ckb_1 ... done
    Stopping docker_postgres_1 ... done
    Stopping docker_ckb-miner_1 ... done
    Stopping docker_redis_1 ... done
    Removing docker_godwoken_run_9a9824b6ed91 ... done
    Removing docker_godwoken_run_48fed4562d8b ... done
    Removing docker_godwoken_run_1c4cbcafa53a ... done
    Removing docker_godwoken_run_73d931a6e2dd ... done
    Removing docker_godwoken_run_c9242edc0541 ... done
    Removing docker_web3-indexer_1 ... done
    Removing docker_web3_1 ... done
    Removing docker_godwoken_1 ... done
    Removing docker_godwoken_run_f22dac2cb072 ... done
    Removing docker_godwoken_run_20ec58f86f45 ... done
    Removing docker_ckb-indexer_1 ... done
    Removing docker_check-ckb-started-successfully_1 ... done
    Removing docker_ckb_1 ... done
    Removing docker_postgres_1 ... done
    Removing docker_ckb-miner_1 ... done
    Removing docker_redis_1 ... done
    Removing network docker_default

    The kicker clean command can be used to remove the volumed data of containers.

    $ sudo ./kicker clean
    OUTPUT

    :> docker-compose -f docker/docker-compose.yml ps --quiet
    rm -rf docker/layer2/data/
    rm -f docker/layer2/config/scripts-deployment.json
    rm -f docker/layer2/config/rollup-genesis-deployment.json
    rm -f docker/layer2/config/godwoken-config.toml
    rm -f docker/layer2/config/polyjuice-root-account-id
    rm -f docker/layer2/config/web3-config.env
    rm -f docker/layer2/config/web3-indexer-config.toml
    rm -rf docker/ckb-indexer/
    rm -rf docker/layer1/ckb/data/
    rm -rf docker/layer1/ckb2/data/
    rm -rf docker/layer1/ckb3/data/
    rm -rf docker/postgres/data
    rm -rf docker/redis/data
    rm -rf docker/manual-artifacts

  7. For more information on the use of the Godwoken-Kicker command line, see Godwoken-Kicker Commands.

To use this local network in MetaMask:

  1. After the Godwoken network has been successfully launched, visit the website http://localhost:6100.
  2. Connect the MetaMask wallet and add the Godwoken network by using the following settings:
    • RPC URL=http://localhost:8024
    • CHAIN ID=1024777