Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

refactor: get config from godwoken rpc instead of env #239

Merged
merged 23 commits into from
May 7, 2022

Conversation

RetricSu
Copy link
Contributor

@RetricSu RetricSu commented Mar 29, 2022

the current env-config consists of two parts:

  • env variables such as database URL, redis URL etc;
  • godwoken configs such as rollup_type_script_hash, eth_account_lock_type_hash etc;

this pr:

depends on:


poly_version Rpc Example
{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "poly_version",
    "params": []
}

result

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "versions": {
            "web3Version": "1.0.0-rc1",
            "web3IndexerVersion": "1.0.0-rc1",
            "godwokenVersion": "1.1.0 02b63ce"
        },
        "nodeInfo": {
            "nodeMode": "fullnode",
            "rollupCell": {
                "typeHash": "0x4ed4a999f0046230d67503c07f1e64f2b2ad1440f758ebfc97282be40f74673c",
                "typeScript": {
                    "code_hash": "0x8bdbffb1a94bbe35fa411ed36899a5d7e50591e30ad7b08211def22eedac27e4",
                    "hash_type": "type",
                    "args": "0xfdac8f898714a6ebfc14a7b883b65f175f9e8e4aa4f465b4ef3d528eb7c53cf8"
                }
            },
            "rollupConfig": {
                "requiredStakingCapacity": "0x2540be400",
                "challengeMaturityBlocks": "0x64",
                "finalityBlocks": "0x3",
                "rewardBurnRate": "0x32",
                "chainId": "0x116e8"
            },
            "gwScripts": {
                "deposit": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0x144214d720d6394cd3310bb728da1b2440cfcceca75655c9dcc9febbe17a8733"
                    },
                    "typeHash": "0xcddb997266a74a5e940a240d63ef8aa89d116999044e421dc337ead16ea870eb"
                },
                "withdraw": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0x74a79f8cac0b5d09302fa1b536dda7f5be072947f553fcad35e961b9e81aaebb"
                    },
                    "typeHash": "0xa069d8ba7175c8e9eca9d9fe2bc176483a41f67255f89ed5633c79470b7710e5"
                },
                "stateValidator": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0x999363d38ac555fcb1008164a4d0a18f3abf03f7edb8e4db0cbe287662926b9d"
                    },
                    "typeHash": "0x8bdbffb1a94bbe35fa411ed36899a5d7e50591e30ad7b08211def22eedac27e4"
                },
                "stakeLock": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0x04d949721408b3102ab677ad3822f0c13b74cc9db5fd0a2a4e99db4284baa232"
                    },
                    "typeHash": "0x825fba7d47ae770681e056183681a81310ab19200d82924d786e2cfe23b79cd3"
                },
                "custodianLock": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0xe4e240a9fc8232f8200168ab7be230c108c04668e01fb15c35cd621a443f2dbe"
                    },
                    "typeHash": "0xdef2218cdcda1c9b77c2a1c54dd6635eedccea507dbe5f377f8a1981d6bb6256"
                },
                "challengeLock": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0x7692146339b938f145f0edc8cdb77453e4e142d08538e92dd1590a7edd62cbe2"
                    },
                    "typeHash": "0xa069d8ba7175c8e9eca9d9fe2bc176483a41f67255f89ed5633c79470b7710e5"
                },
                "l1Sudt": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0x57fdfd0617dcb74d1287bb78a7368a3a4bf9a790cfdcf5c1a105fd7cb406de0d"
                    },
                    "typeHash": "0x6283a479a3cf5d4276cd93594de9f1827ab9b55c7b05b3d28e4c2e0a696cfefd"
                },
                "l2Sudt": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0x693105c2af2a0331fe48065360300f043e492814516914b2d71779215360cb5d"
                    },
                    "typeHash": "0x696447c51fdb84d0e59850b26bc431425a74daaac070f2b14f5602fbb469912a"
                },
                "omniLock": {
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0x98fb3542973e32ba43ea6f1cf44cca71569ef4592e80d70b9c890ce1a005b3c9"
                    },
                    "typeHash": "0x889cca40b2197ef887e3904ae1c415984f797ec823b8ac9182a1487b634a31ad"
                }
            },
            "eoaScripts": {
                "eth": {
                    "typeHash": "0x1272c80507fe5e6cf33cf3e5da6a5f02430de40abb14410ea0459361bf74ebe0",
                    "script": {
                        "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
                        "hash_type": "type",
                        "args": "0xb89f105b435c234d2eda67e260c5fdeda1fea26f463592be726530f81b15b96e"
                    }
                }
            },
            "backends": {
                "sudt": {
                    "validatorCodeHash": "0x4ad65c2ed87b4f505fad38b067bf53ff45940ea9984d3626e658a04b92f11b12",
                    "generatorCodeHash": "0x0861ce251b687940e32bef980fe785a27a79415dfa8ec4de6db3155d1ce3187d",
                    "validatorScriptTypeHash": "0x696447c51fdb84d0e59850b26bc431425a74daaac070f2b14f5602fbb469912a"
                },
                "meta": {
                    "validatorCodeHash": "0xbf1e540c239d9e9c894e76ba6142cee4d7755f590101a23b208e0439f4f09482",
                    "generatorCodeHash": "0x277d0449708812cbaa1639e591fd42b813abec4f048c12788dcb5d382a25579a",
                    "validatorScriptTypeHash": "0x32923ebad8e5417ae072decc89774324ec4a623f57af5cee6e2901d29d8e6691"
                },
                "polyjuice": {
                    "validatorCodeHash": "0x6af4952d926eae8d39b4b490212d6cfc1777fe95fadd3ab066bbb74ad85c1fd3",
                    "generatorCodeHash": "0x80f0b383aa89afd4668136435de90f82e57d8e53f10434bc2b1f9b7c427cab2e",
                    "validatorScriptTypeHash": "0x9b599c7df5d7b813f7f9542a5c8a0c12b65261a081b1dba02c2404802f772a15"
                },
                "ethAddrReg": {
                    "validatorCodeHash": "0x5259a0b93696417a36eb5ba81798f0ee15c533ec25395b44577147afa69913c3",
                    "generatorCodeHash": "0xd975d1f46eaa510d523a5099c9b811251f905a98017fd5b781552975ab660262",
                    "validatorScriptTypeHash": "0x59ecd45fc257a761d992507ef2e1acccf43221567f6cf3b1fc6fb9352a7a0ca3"
                }
            },
            "accounts": {
                "polyjuiceCreator": {
                    "id": "0x0",
                    "scriptHash": "0x7df8df09ec23819836b888f575ca4154a2af1f1d4720bca91a5fc9f5f7d9921d"
                },
                "ethAddrReg": {
                    "id": "0x2",
                    "scriptHash": "0xb5f81e2d10af9600194606989583ae8cc3fcb822a24fdea95f42da5ea18606da"
                },
                "defaultFrom": {
                    "id": "0x3",
                    "scriptHash": "0x6b2e2f4bb2e3e88144b3d71e1575b275cc24a1b8b8363675762aa56379fc6d0c"
                }
            },
            "web3ChainId": "0x116e8"
        }
    }
}

@RetricSu RetricSu marked this pull request as draft March 29, 2022 03:03
@RetricSu RetricSu marked this pull request as ready for review April 25, 2022 15:23
@RetricSu RetricSu mentioned this pull request Apr 25, 2022
6 tasks
@RetricSu RetricSu linked an issue Apr 26, 2022 that may be closed by this pull request
6 tasks
.github/workflows/node.js.yml Outdated Show resolved Hide resolved
packages/api-server/src/base/gw-config.ts Outdated Show resolved Hide resolved
packages/api-server/src/base/gw-config.ts Outdated Show resolved Hide resolved
packages/api-server/src/base/gw-config.ts Outdated Show resolved Hide resolved
packages/api-server/src/app/app.ts Outdated Show resolved Hide resolved
packages/api-server/src/base/types/node-info.ts Outdated Show resolved Hide resolved
packages/api-server/src/convert-tx.ts Outdated Show resolved Hide resolved
packages/api-server/src/methods/modules/eth.ts Outdated Show resolved Hide resolved
scripts/generate-indexer-config.js Show resolved Hide resolved
scripts/generate-indexer-config.js Outdated Show resolved Hide resolved
packages/api-server/tests/utils/config.test.ts Outdated Show resolved Hide resolved
packages/api-server/src/base/gw-config.ts Outdated Show resolved Hide resolved
packages/api-server/src/base/gw-config.ts Outdated Show resolved Hide resolved
packages/api-server/src/base/gw-config.ts Outdated Show resolved Hide resolved
packages/api-server/src/base/gw-config.ts Show resolved Hide resolved
packages/api-server/src/base/gw-config.ts Outdated Show resolved Hide resolved
rpc: GodwokenClient;
private nodeInfo: NodeInfo | undefined;

web3ChainId: HexNumber | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use #?

@RetricSu RetricSu requested a review from Flouse May 5, 2022 02:56
@RetricSu RetricSu merged commit b97b1a5 into compatibility-breaking-changes May 7, 2022
@RetricSu RetricSu deleted the refactor-config branch May 7, 2022 08:24
@Flouse
Copy link
Collaborator

Flouse commented May 25, 2022

This RPC interface poly_version is available on testnet_v1.1.
cc:

echo '{
    "id": 2,
    "jsonrpc": "2.0",
    "method": "poly_version",
    "params": []
}' | tr -d '\n' \
| curl -H 'content-type: application/json' -d @- \
https://godwoken-testnet-v1.ckbapp.dev

Result:

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "versions": {
      "web3Version": "1.0.0-rc1",
      "web3IndexerVersion": "1.0.0-rc1",
      "godwokenVersion": "1.1.3 5ee735b"
    },
    "nodeInfo": {
      "nodeMode": "fullnode",
      "rollupCell": {
        "typeHash": "0x702359ea7f073558921eb50d8c1c77e92f760c8f8656bde4995f26b8963e2dd8",
        "typeScript": {
          "code_hash": "0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854",
          "hash_type": "type",
          "args": "0x86c7429247beba7ddd6e4361bcdfc0510b0b644131e2afb7e486375249a01802"
        }
      },
      "rollupConfig": {
        "requiredStakingCapacity": "0x3691d6afc000",
        "challengeMaturityBlocks": "0x1c2",
        "finalityBlocks": "0x64",
        "rewardBurnRate": "0x32",
        "chainId": "0x116e9"
      },
      "gwScripts": {
        "deposit": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0x86d24e5cb132478005dcf2b59680a9f37011cb54a5947f42f19ba5076bc6594d"
          },
          "typeHash": "0x50704b84ecb4c4b12b43c7acb260ddd69171c21b4c0ba15f3c469b7d143f6f18"
        },
        "withdraw": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0xbfef6580c1f93b98fa7d33bb3faa63255caba9bfbebfbada5eab4ce195052b9f"
          },
          "typeHash": "0x06ae0706bb2d7997d66224741d3ec7c173dbb2854a6d2cf97088796b677269c6"
        },
        "stateValidator": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0x063555cc66a1c270aafbe9324718232289a462f4d9edfc7a57f9c6e0f8257669"
          },
          "typeHash": "0x1e44736436b406f8e48a30dfbddcf044feb0c9eebfe63b0f81cb5bb727d84854"
        },
        "stakeLock": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0x0fc0f22f9a6e000692159c9d5dc633fba7ffcd1f1f2218d23aa2ede96f4b471d"
          },
          "typeHash": "0x7f5a09b8bd0e85bcf2ccad96411ccba2f289748a1c16900b0635c2ed9126f288"
        },
        "custodianLock": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0xc4695745c69c298c89bc701b6cc8614332c6fd8a2ed160e04748fc6fda636e71"
          },
          "typeHash": "0x85ae4db0dd83f428a31deb342e4000af37ce2c9645d9e619df00096e3c50a2bb"
        },
        "challengeLock": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0x7997689a9038a5487535cd8297d37b39840e140c849efd6f07ecc20ee9b9c244"
          },
          "typeHash": "0x06ae0706bb2d7997d66224741d3ec7c173dbb2854a6d2cf97088796b677269c6"
        },
        "l1Sudt": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0x4db75e03349f4f2ec792476035dd1b7376c683130f7e2e74024be2d9ee064511"
          },
          "typeHash": "0xc5e5dcf215925f7ef4dfaf5f4b4f105bc321c02776d6e7d52a1db3fcd9d011a4"
        },
        "l2Sudt": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0xe9374fd920cd4144ce72ab7ef3405d89e5f8530d586ba986e993f1d285060a7a"
          },
          "typeHash": "0xb6176a6170ea33f8468d61f934c45c57d29cdc775bcd3ecaaec183f04b9f33d9"
        },
        "omniLock": {
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0x1b8572b16c07f46a0efed623aea6de05d45985b9a7c1b0b52276da5d9f9615b7"
          },
          "typeHash": "0x79f90bb5e892d80dd213439eeab551120eb417678824f282b4ffb5f21bad2e1e"
        }
      },
      "eoaScripts": {
        "eth": {
          "typeHash": "0x07521d0aa8e66ef441ebc31204d86bb23fc83e9edc58c19dbb1b0ebe64336ec0",
          "script": {
            "code_hash": "0x00000000000000000000000000000000000000000000000000545950455f4944",
            "hash_type": "type",
            "args": "0x66056785e4e989729053508c30d620ead06b377f600eedc0419e6858e459ccfa"
          }
        }
      },
      "backends": {
        "sudt": {
          "validatorCodeHash": "0xb9d9375c0fd4d50ed95019d8307961238316cd18c1fb3faeb15ac0d3c6d76bda",
          "generatorCodeHash": "0xf87824d6723b3c0be51b1213e8b35a6e8587a10f2f27734a344f201bf2ab05ef",
          "validatorScriptTypeHash": "0xb6176a6170ea33f8468d61f934c45c57d29cdc775bcd3ecaaec183f04b9f33d9"
        },
        "meta": {
          "validatorCodeHash": "0x4cf8b2b8b04dab0de276093de71f98592a5d683d42e2aa70110e904b564fc1c3",
          "generatorCodeHash": "0x8c6c44b97d9de23dc0047356fb0b3e258a60e14a1f2bfa8f95ddc7b41985a8e0",
          "validatorScriptTypeHash": "0x37b25df86ca495856af98dff506e49f2380d673b0874e13d29f7197712d735e8"
        },
        "polyjuice": {
          "validatorCodeHash": "0xfeb459ef3e797e3c7b5a4ec3b647d30fd0994f0f2733f3eda018a85e7e310a1b",
          "generatorCodeHash": "0x308f8b2b54df5133ea73508e4879d08ae70d437037e585dcbb800e1d0609c946",
          "validatorScriptTypeHash": "0x1629b04b49ded9e5747481f985b11cba6cdd4ffc167971a585e96729455ca736"
        },
        "ethAddrReg": {
          "validatorCodeHash": "0x9085bd6a550a9921b46d23ba7d9b0f9f5c5d0c9c00999988cd907ce16015e467",
          "generatorCodeHash": "0xe2ba730569850cca7a56c9a96754bd0bfd784c8f001e997e4512edf572190c4a",
          "validatorScriptTypeHash": "0xa30dcbb83ebe571f49122d8d1ce4537679ebf511261c8ffaaa6679bf9fdea3a4"
        }
      },
      "accounts": {
        "polyjuiceCreator": {
          "id": "0x4",
          "scriptHash": "0x829cc5785a4d8ac642ede32cb3cb5cb9dc389d5892f2fc2afc760691445be194"
        },
        "ethAddrReg": {
          "id": "0x2",
          "scriptHash": "0x08c9937e412e135928fd6dec7255965ddd7df4d5a163564b60895100bb3b2f9e"
        },
        "defaultFrom": {
          "id": "0x3",
          "scriptHash": "0x495d9cfb7b6faeaeb0f5a7ed81a830a477f7aeea8d53ef73abdc2ec2f5fed07c"
        }
      },
      "chainId": "0x116e9"
    }
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v1: simplify Web3 configuration
5 participants