From 26503142adbda4c1e53a5bf36c466fdc2a4881f6 Mon Sep 17 00:00:00 2001 From: ZeroEkkusu <94782988+ZeroEkkusu@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:39:26 +0200 Subject: [PATCH 1/6] test: upgrade to foundry --- .gitignore | 8 + .gitmodules | 6 + README.md | 21 +- foundry.toml | 45 ++ lib/forge-std | 1 + lib/murky | 1 + package-lock.json | 397 ++++++++++++++---- package.json | 1 + test/BorValidatorSet.t.sol | 397 ++++++++++++++++++ test/ECVerify.t.sol | 72 ++++ test/IterableMapping.t.sol | 100 +++++ test/Migrations.t.sol | 44 ++ test/StateReceiver.t.sol | 129 ++++++ test/System.t.sol | 17 + test/ValidatorVerifier.t.sol | 39 ++ test/helpers/ECVerifyWrapper.sol | 17 + test/helpers/IBorValidatorSet.sol | 51 +++ test/helpers/IECVerifyWrapper.sol | 8 + test/helpers/IIterableMappingWrapper.sol | 25 ++ test/helpers/IMigrations.sol | 9 + test/helpers/IStateReceiver.sol | 10 + test/helpers/ISystem.sol | 6 + test/helpers/IValidatorVerifier.sol | 9 + test/helpers/IterableMappingWrapper.sol | 50 +++ .../rlpEncodeValidatorsAndProducers.js | 60 +++ 25 files changed, 1434 insertions(+), 89 deletions(-) create mode 100644 foundry.toml create mode 160000 lib/forge-std create mode 160000 lib/murky create mode 100644 test/BorValidatorSet.t.sol create mode 100644 test/ECVerify.t.sol create mode 100644 test/IterableMapping.t.sol create mode 100644 test/Migrations.t.sol create mode 100644 test/StateReceiver.t.sol create mode 100644 test/System.t.sol create mode 100644 test/ValidatorVerifier.t.sol create mode 100644 test/helpers/ECVerifyWrapper.sol create mode 100644 test/helpers/IBorValidatorSet.sol create mode 100644 test/helpers/IECVerifyWrapper.sol create mode 100644 test/helpers/IIterableMappingWrapper.sol create mode 100644 test/helpers/IMigrations.sol create mode 100644 test/helpers/IStateReceiver.sol create mode 100644 test/helpers/ISystem.sol create mode 100644 test/helpers/IValidatorVerifier.sol create mode 100644 test/helpers/IterableMappingWrapper.sol create mode 100644 test/helpers/rlpEncodeValidatorsAndProducers.js diff --git a/.gitignore b/.gitignore index ea3a122..64433ce 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,11 @@ logs genesis.json .idea + +/out +/target +/cache +/coverage +lcov.info +.env +.password \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 54134d2..260b693 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,9 @@ [submodule "matic-contracts"] path = matic-contracts url = https://github.com/maticnetwork/contracts.git +[submodule "lib/forge-std"] + path = lib/forge-std + url = https://github.com/foundry-rs/forge-std +[submodule "lib/murky"] + path = lib/murky + url = https://github.com/dmfxyz/murky diff --git a/README.md b/README.md index d7246d0..b52d0b3 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,25 @@ # genesis-contracts +> NOTE (IMPORTANT!) +> If you modify contracts, run `forge build` before testing/deploying/etc, or Foundry may not recompile them! + #### Setup genesis Setup genesis whenever contracts get changed ### 1. Install dependencies and submodules ```bash -$ npm install -$ git submodule init -$ git submodule update +npm install +git submodule init +git submodule update ``` ### 2. Compile Matic contracts ```bash -$ cd matic-contracts -$ npm install -$ node scripts/process-templates.js --bor-chain-id -$ npm run truffle:compile -$ cd .. +cd matic-contracts +npm install +node scripts/process-templates.js --bor-chain-id +npm run truffle:compile +cd .. ``` ### 3. Generate Bor validator set sol file @@ -44,7 +47,7 @@ Following command will generate `genesis.json` file from `genesis-template.json` ```bash # Generate genesis file -$ node generate-genesis.js --bor-chain-id --heimdall-chain-id +node generate-genesis.js --bor-chain-id --heimdall-chain-id ``` ### 7. Run Tests diff --git a/foundry.toml b/foundry.toml new file mode 100644 index 0000000..c576fce --- /dev/null +++ b/foundry.toml @@ -0,0 +1,45 @@ +[profile.default] +src = "contracts" +out = "out" +libs = ["lib"] +optimizer = true +optimizer_runs = 999999 +via_ir = true +verbosity = 2 +ffi = true +fs_permissions = [{ access = "read", path = "./out/"}] + +remappings = [ + "forge-std=lib/forge-std/src", + "openzeppelin-solidity/=node_modules/openzeppelin-solidity/", + "solidity-rlp/=node_modules/solidity-rlp/" +] + +[profile.intense.fuzz] +runs = 10000 +max_test_rejects = 999999 + +[fmt] +line_length = 160 +number_underscore = "thousands" + +[rpc_endpoints] +anvil = "http://127.0.0.1:8545" +mainnet = "https://mainnet.infura.io/v3/${INFURA_KEY}" +goerli = "https://goerli.infura.io/v3/${INFURA_KEY}" +sepolia = "https://sepolia.infura.io/v3/${INFURA_KEY}" +polygon_pos = "https://polygon-mainnet.infura.io/v3/${INFURA_KEY}" +mumbai = "https://polygon-mumbai.infura.io/v3/${INFURA_KEY}" +polygon_zkevm = "https://zkevm-rpc.com" +polygon_zkevm_testnet = "https://rpc.public.zkevm-test.net" + +[etherscan] +mainnet = { key = "${ETHERSCAN_API_KEY}" } +goerli = { key = "${ETHERSCAN_API_KEY}" } +sepolia = { key = "${ETHERSCAN_API_KEY}" } +polygon_pos = { key = "${POLYGONSCAN_API_KEY}" } +mumbai = { key = "${POLYGONSCAN_API_KEY}" } +polygon_zkevm = { key = "${POLYGONSCAN_ZKEVM_API_KEY}" } +polygon_zkevm_testnet = { key = "${POLYGONSCAN_ZKEVM_API_KEY}" } + +# See more config options https://github.com/foundry-rs/foundry/tree/master/config \ No newline at end of file diff --git a/lib/forge-std b/lib/forge-std new file mode 160000 index 0000000..978ac6f --- /dev/null +++ b/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 978ac6fadb62f5f0b723c996f64be52eddba6801 diff --git a/lib/murky b/lib/murky new file mode 160000 index 0000000..5feccd1 --- /dev/null +++ b/lib/murky @@ -0,0 +1 @@ +Subproject commit 5feccd1253d7da820f7cccccdedf64471025455d diff --git a/package-lock.json b/package-lock.json index 00afb62..63fc8a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "genesis-contracts", "version": "1.0.0", "license": "MIT", "dependencies": { @@ -13,6 +14,7 @@ "chai-as-promised": "^7.1.1", "commander": "^3.0.1", "eth-gas-reporter": "^0.2.25", + "ethers": "^6.13.0", "ganache": "^7.5.0", "ganache-cli": "^6.12.2", "nunjucks": "^3.2.0", @@ -22,6 +24,11 @@ "web3": "1.7.4" } }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", + "integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==" + }, "node_modules/@apollo/protobufjs": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@apollo/protobufjs/-/protobufjs-1.2.6.tgz", @@ -500,6 +507,28 @@ "integrity": "sha512-CtzORUwWTTOTqfVtHaKRJ0I1kNQd1bpn3sUh8I3nJDVY+5/M/Oe1DnEWzPQvqq/xPIIkzzzIP7mfCoAjFRvDhg==", "optional": true }, + "node_modules/@noble/curves": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", + "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "dependencies": { + "@noble/hashes": "1.3.2" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves/node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@noble/hashes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.2.0.tgz", @@ -908,6 +937,48 @@ "web3": "1.7.4" } }, + "node_modules/@truffle/interface-adapter/node_modules/aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==", + "optional": true + }, + "node_modules/@truffle/interface-adapter/node_modules/ethers": { + "version": "4.0.49", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.49.tgz", + "integrity": "sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg==", + "optional": true, + "dependencies": { + "aes-js": "3.0.0", + "bn.js": "^4.11.9", + "elliptic": "6.5.4", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.4", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, + "node_modules/@truffle/interface-adapter/node_modules/ethers/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "optional": true + }, + "node_modules/@truffle/interface-adapter/node_modules/js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==", + "optional": true + }, + "node_modules/@truffle/interface-adapter/node_modules/uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "optional": true + }, "node_modules/@truffle/promise-tracker": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/@truffle/promise-tracker/-/promise-tracker-0.1.5.tgz", @@ -1098,9 +1169,9 @@ "optional": true }, "node_modules/@types/node": { - "version": "18.11.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.8.tgz", - "integrity": "sha512-uGwPWlE0Hj972KkHtCDVwZ8O39GmyjfMane1Z3GUBGGnkZ2USDq7SxLpVIiIHpweY9DS0QTDH0Nw7RNBsAAZ5A==" + "version": "18.15.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", + "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==" }, "node_modules/@types/pbkdf2": { "version": "3.1.0", @@ -1199,9 +1270,9 @@ } }, "node_modules/aes-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", - "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==" + "version": "4.0.0-beta.5", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", + "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==" }, "node_modules/ajv": { "version": "8.11.0", @@ -1817,6 +1888,7 @@ "version": "4.0.7", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz", "integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==", + "hasInstallScript": true, "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -3066,6 +3138,11 @@ } } }, + "node_modules/eth-gas-reporter/node_modules/aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==" + }, "node_modules/eth-gas-reporter/node_modules/ansi-colors": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", @@ -3093,6 +3170,11 @@ "sprintf-js": "~1.0.2" } }, + "node_modules/eth-gas-reporter/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "node_modules/eth-gas-reporter/node_modules/chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -3166,6 +3248,22 @@ "@scure/bip39": "1.1.1" } }, + "node_modules/eth-gas-reporter/node_modules/ethers": { + "version": "4.0.49", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.49.tgz", + "integrity": "sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg==", + "dependencies": { + "aes-js": "3.0.0", + "bn.js": "^4.11.9", + "elliptic": "6.5.4", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.4", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, "node_modules/eth-gas-reporter/node_modules/find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -3212,6 +3310,11 @@ "node": ">=4" } }, + "node_modules/eth-gas-reporter/node_modules/js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==" + }, "node_modules/eth-gas-reporter/node_modules/js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -3382,6 +3485,12 @@ "node": ">=6" } }, + "node_modules/eth-gas-reporter/node_modules/uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details." + }, "node_modules/eth-gas-reporter/node_modules/which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -3513,35 +3622,67 @@ } }, "node_modules/ethers": { - "version": "4.0.49", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.49.tgz", - "integrity": "sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.0.tgz", + "integrity": "sha512-+yyQQQWEntY5UVbCv++guA14RRVFm1rSnO1GoLFdrK7/XRWMoktNgyG9UjwxrQqGBfGyFKknNZ81YpUS2emCgg==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/ethers-io/" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], "dependencies": { - "aes-js": "3.0.0", - "bn.js": "^4.11.9", - "elliptic": "6.5.4", - "hash.js": "1.1.3", - "js-sha3": "0.5.7", - "scrypt-js": "2.0.4", - "setimmediate": "1.0.4", - "uuid": "2.0.1", - "xmlhttprequest": "1.8.0" + "@adraffy/ens-normalize": "1.10.1", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", + "@types/node": "18.15.13", + "aes-js": "4.0.0-beta.5", + "tslib": "2.4.0", + "ws": "8.5.0" + }, + "engines": { + "node": ">=14.0.0" } }, - "node_modules/ethers/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "node_modules/ethers/node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } }, - "node_modules/ethers/node_modules/js-sha3": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", - "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==" + "node_modules/ethers/node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, - "node_modules/ethers/node_modules/uuid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", - "integrity": "sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg==" + "node_modules/ethers/node_modules/ws": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", + "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } }, "node_modules/ethjs-unit": { "version": "0.1.6", @@ -4964,6 +5105,7 @@ "version": "1.1.10", "resolved": "https://registry.npmjs.org/@trufflesuite/bigint-buffer/-/bigint-buffer-1.1.10.tgz", "integrity": "sha512-pYIQC5EcMmID74t26GCC67946mgTJFiLXOT/BYozgrd4UEY2JHEGLhWi9cMiQCt5BSqFEvKkCHNnoj82SRjiEw==", + "hasInstallScript": true, "dependencies": { "node-gyp-build": "4.4.0" }, @@ -4994,11 +5136,6 @@ "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==" }, - "node_modules/ganache/node_modules/@types/node": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", - "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==" - }, "node_modules/ganache/node_modules/@types/seedrandom": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", @@ -5027,6 +5164,7 @@ "version": "4.0.5", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz", "integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==", + "hasInstallScript": true, "optional": true, "dependencies": { "node-gyp-build": "^4.3.0" @@ -5106,6 +5244,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.2.tgz", "integrity": "sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ==", + "hasInstallScript": true, "dependencies": { "node-addon-api": "^2.0.0", "node-gyp-build": "^4.2.0", @@ -5119,6 +5258,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-6.1.0.tgz", "integrity": "sha512-8C7oJDT44JXxh04aSSsfcMI8YiaGRhOFI9/pMEL7nWJLVsWajDPTRxsSHTM2WcTVY5nXM+SuRHzPPi0GbnDX+w==", + "hasInstallScript": true, "dependencies": { "abstract-leveldown": "^7.2.0", "napi-macros": "~2.0.0", @@ -5225,6 +5365,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz", "integrity": "sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==", + "hasInstallScript": true, "dependencies": { "elliptic": "^6.5.4", "node-addon-api": "^2.0.0", @@ -5246,6 +5387,7 @@ "version": "5.0.7", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz", "integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==", + "hasInstallScript": true, "optional": true, "dependencies": { "node-gyp-build": "^4.3.0" @@ -6168,6 +6310,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.2.tgz", "integrity": "sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ==", + "hasInstallScript": true, "dependencies": { "node-addon-api": "^2.0.0", "node-gyp-build": "^4.2.0", @@ -6363,6 +6506,7 @@ "version": "5.6.0", "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-5.6.0.tgz", "integrity": "sha512-iB8O/7Db9lPaITU1aA2txU/cBEXAt4vWwKQRrrWuS6XDgbP4QZGj9BL2aNbwb002atoQ/lIotJkfyzz+ygQnUQ==", + "hasInstallScript": true, "optional": true, "dependencies": { "abstract-leveldown": "~6.2.1", @@ -8415,6 +8559,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz", "integrity": "sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==", + "hasInstallScript": true, "dependencies": { "elliptic": "^6.5.4", "node-addon-api": "^2.0.0", @@ -9244,6 +9389,7 @@ "version": "1.1.10", "resolved": "https://registry.npmjs.org/@trufflesuite/bigint-buffer/-/bigint-buffer-1.1.10.tgz", "integrity": "sha512-pYIQC5EcMmID74t26GCC67946mgTJFiLXOT/BYozgrd4UEY2JHEGLhWi9cMiQCt5BSqFEvKkCHNnoj82SRjiEw==", + "hasInstallScript": true, "dependencies": { "node-gyp-build": "4.4.0" }, @@ -9274,11 +9420,6 @@ "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==" }, - "node_modules/truffle/node_modules/ganache/node_modules/@types/node": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", - "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==" - }, "node_modules/truffle/node_modules/ganache/node_modules/@types/seedrandom": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", @@ -9307,6 +9448,7 @@ "version": "4.0.5", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.5.tgz", "integrity": "sha512-HTm14iMQKK2FjFLRTM5lAVcyaUzOnqbPtesFIvREgXpJHdQm8bWS+GkQgIkfaBYRHuCnea7w8UVNfwiAQhlr9A==", + "hasInstallScript": true, "optional": true, "dependencies": { "node-gyp-build": "^4.3.0" @@ -9386,6 +9528,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.2.tgz", "integrity": "sha512-PyKKjkH53wDMLGrvmRGSNWgmSxZOUqbnXwKL9tmgbFYA1iAYqW21kfR7mZXV0MlESiefxQQE9X9fTa3X+2MPDQ==", + "hasInstallScript": true, "dependencies": { "node-addon-api": "^2.0.0", "node-gyp-build": "^4.2.0", @@ -9399,6 +9542,7 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/leveldown/-/leveldown-6.1.0.tgz", "integrity": "sha512-8C7oJDT44JXxh04aSSsfcMI8YiaGRhOFI9/pMEL7nWJLVsWajDPTRxsSHTM2WcTVY5nXM+SuRHzPPi0GbnDX+w==", + "hasInstallScript": true, "dependencies": { "abstract-leveldown": "^7.2.0", "napi-macros": "~2.0.0", @@ -9505,6 +9649,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz", "integrity": "sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==", + "hasInstallScript": true, "dependencies": { "elliptic": "^6.5.4", "node-addon-api": "^2.0.0", @@ -9526,6 +9671,7 @@ "version": "5.0.7", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.7.tgz", "integrity": "sha512-vLt1O5Pp+flcArHGIyKEQq883nBt8nN8tVBcoL0qUXj2XT1n7p70yGIq2VK98I5FdZ1YHc0wk/koOnHjnXWk1Q==", + "hasInstallScript": true, "optional": true, "dependencies": { "node-gyp-build": "^4.3.0" @@ -9765,6 +9911,7 @@ "version": "5.0.10", "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz", "integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==", + "hasInstallScript": true, "dependencies": { "node-gyp-build": "^4.3.0" }, @@ -10695,6 +10842,11 @@ } }, "dependencies": { + "@adraffy/ens-normalize": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", + "integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==" + }, "@apollo/protobufjs": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@apollo/protobufjs/-/protobufjs-1.2.6.tgz", @@ -11149,6 +11301,21 @@ "integrity": "sha512-CtzORUwWTTOTqfVtHaKRJ0I1kNQd1bpn3sUh8I3nJDVY+5/M/Oe1DnEWzPQvqq/xPIIkzzzIP7mfCoAjFRvDhg==", "optional": true }, + "@noble/curves": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", + "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "requires": { + "@noble/hashes": "1.3.2" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==" + } + } + }, "@noble/hashes": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.2.0.tgz", @@ -11520,6 +11687,51 @@ "bn.js": "^5.1.3", "ethers": "^4.0.32", "web3": "1.7.4" + }, + "dependencies": { + "aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==", + "optional": true + }, + "ethers": { + "version": "4.0.49", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.49.tgz", + "integrity": "sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg==", + "optional": true, + "requires": { + "aes-js": "3.0.0", + "bn.js": "^4.11.9", + "elliptic": "6.5.4", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.4", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "optional": true + } + } + }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==", + "optional": true + }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg==", + "optional": true + } } }, "@truffle/promise-tracker": { @@ -11708,9 +11920,9 @@ "optional": true }, "@types/node": { - "version": "18.11.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.8.tgz", - "integrity": "sha512-uGwPWlE0Hj972KkHtCDVwZ8O39GmyjfMane1Z3GUBGGnkZ2USDq7SxLpVIiIHpweY9DS0QTDH0Nw7RNBsAAZ5A==" + "version": "18.15.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", + "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==" }, "@types/pbkdf2": { "version": "3.1.0", @@ -11800,9 +12012,9 @@ } }, "aes-js": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", - "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==" + "version": "4.0.0-beta.5", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", + "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==" }, "ajv": { "version": "8.11.0", @@ -13387,6 +13599,11 @@ "sync-request": "^6.0.0" }, "dependencies": { + "aes-js": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", + "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==" + }, "ansi-colors": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", @@ -13408,6 +13625,11 @@ "sprintf-js": "~1.0.2" } }, + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -13470,6 +13692,22 @@ "@scure/bip39": "1.1.1" } }, + "ethers": { + "version": "4.0.49", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.49.tgz", + "integrity": "sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg==", + "requires": { + "aes-js": "3.0.0", + "bn.js": "^4.11.9", + "elliptic": "6.5.4", + "hash.js": "1.1.3", + "js-sha3": "0.5.7", + "scrypt-js": "2.0.4", + "setimmediate": "1.0.4", + "uuid": "2.0.1", + "xmlhttprequest": "1.8.0" + } + }, "find-up": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", @@ -13504,6 +13742,11 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==" }, + "js-sha3": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", + "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==" + }, "js-yaml": { "version": "3.13.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", @@ -13627,6 +13870,11 @@ "has-flag": "^3.0.0" } }, + "uuid": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", + "integrity": "sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg==" + }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -13755,35 +14003,34 @@ } }, "ethers": { - "version": "4.0.49", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.49.tgz", - "integrity": "sha512-kPltTvWiyu+OktYy1IStSO16i2e7cS9D9OxZ81q2UUaiNPVrm/RTcbxamCXF9VUSKzJIdJV68EAIhTEVBalRWg==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.0.tgz", + "integrity": "sha512-+yyQQQWEntY5UVbCv++guA14RRVFm1rSnO1GoLFdrK7/XRWMoktNgyG9UjwxrQqGBfGyFKknNZ81YpUS2emCgg==", "requires": { - "aes-js": "3.0.0", - "bn.js": "^4.11.9", - "elliptic": "6.5.4", - "hash.js": "1.1.3", - "js-sha3": "0.5.7", - "scrypt-js": "2.0.4", - "setimmediate": "1.0.4", - "uuid": "2.0.1", - "xmlhttprequest": "1.8.0" + "@adraffy/ens-normalize": "1.10.1", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", + "@types/node": "18.15.13", + "aes-js": "4.0.0-beta.5", + "tslib": "2.4.0", + "ws": "8.5.0" }, "dependencies": { - "bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" + "@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==" }, - "js-sha3": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", - "integrity": "sha512-GII20kjaPX0zJ8wzkTbNDYMY7msuZcTWk8S5UOh6806Jq/wz1J8/bnr8uGU0DAUmYDjj2Mr4X1cW8v/GLYnR+g==" + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" }, - "uuid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", - "integrity": "sha512-nWg9+Oa3qD2CQzHIP4qKUqwNfzKn8P0LtFhotaCTFchsV7ZfDhAybeip/HZVeMIpZi9JgY1E3nUlwaCmZT1sEg==" + "ws": { + "version": "8.5.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.5.0.tgz", + "integrity": "sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==", + "requires": {} } } }, @@ -14131,11 +14378,6 @@ "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==" }, - "@types/node": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", - "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==" - }, "@types/seedrandom": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", @@ -18365,11 +18607,6 @@ "resolved": "https://registry.npmjs.org/@types/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-ssE3Vlrys7sdIzs5LOxCzTVMsU7i9oa/IaW92wF32JFb3CVczqOkru2xspuKczHEbG3nvmPY7IFqVmGGHdNbYw==" }, - "@types/node": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.0.tgz", - "integrity": "sha512-eMhwJXc931Ihh4tkU+Y7GiLzT/y/DBNpNtr4yU9O2w3SYBsr9NaOPhQlLKRmoWtI54uNwuo0IOUFQjVOTZYRvw==" - }, "@types/seedrandom": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@types/seedrandom/-/seedrandom-3.0.1.tgz", diff --git a/package.json b/package.json index 3ad1e9c..f712d69 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "chai-as-promised": "^7.1.1", "commander": "^3.0.1", "eth-gas-reporter": "^0.2.25", + "ethers": "^6.13.0", "ganache": "^7.5.0", "ganache-cli": "^6.12.2", "nunjucks": "^3.2.0", diff --git a/test/BorValidatorSet.t.sol b/test/BorValidatorSet.t.sol new file mode 100644 index 0000000..77972b4 --- /dev/null +++ b/test/BorValidatorSet.t.sol @@ -0,0 +1,397 @@ +pragma solidity >0.5.0; + +import "../lib/forge-std/src/Test.sol"; + +import "./helpers/IBorValidatorSet.sol"; + +contract BorValidatorSetTest is Test { + uint8 constant LIST_SHORT_START = 0xc0; + address public constant SYSTEM_ADDRESS = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE; + bytes32 public constant CHAIN = keccak256("heimdall-P5rXwg"); + bytes32 public constant ROUND_TYPE = keccak256("vote"); + bytes32 public constant BOR_ID = keccak256("15001"); + uint8 public constant VOTE_TYPE = 2; + uint256 public constant FIRST_END_BLOCK = 255; + uint256 public constant SPRINT = 64; + + uint256 private _newSpan; + + IBorValidatorSet internal borValidatorSet; + + function setUp() public { + _newSpan = 1; + borValidatorSet = IBorValidatorSet(deployCode("out/BorValidatorSet.sol/BorValidatorSet.json")); + } + + function testConstants() public { + assertEq(borValidatorSet.CHAIN(), CHAIN); + assertEq(borValidatorSet.ROUND_TYPE(), ROUND_TYPE); + assertEq(borValidatorSet.BOR_ID(), BOR_ID); + assertEq(borValidatorSet.VOTE_TYPE(), VOTE_TYPE); + assertEq(borValidatorSet.FIRST_END_BLOCK(), FIRST_END_BLOCK); + assertEq(borValidatorSet.SPRINT(), SPRINT); + } + + function test_currentSprint() public { + assertEq(borValidatorSet.currentSprint(), 0); + vm.roll(SPRINT); + assertEq(borValidatorSet.currentSprint(), 1); + vm.roll(SPRINT * 2 + 1); + assertEq(borValidatorSet.currentSprint(), 2); + } + + function test_getInitialValidators() public { + (address[] memory addresses, uint256[] memory powers) = borValidatorSet.getInitialValidators(); + assertEq(addresses.length, 1); + assertEq(powers.length, 1); + assertEq(addresses[0], 0x6c468CF8c9879006E22EC4029696E005C2319C9D); + assertEq(powers[0], 40); + } + + function testRevert_commitSpan_OnlySystem() public { + vm.expectRevert("Not System Addess!"); + borValidatorSet.commitSpan(0, 0, 0, "", ""); + } + + function testRevert_commitSpan_InvalidSpanId() public { + vm.expectRevert("Invalid span id"); + vm.prank(SYSTEM_ADDRESS); + borValidatorSet.commitSpan(0, 0, 0, "", ""); + } + + function testRevert_commitSpan_InvalidEndBlock() public { + vm.expectRevert("End block must be greater than start block"); + vm.prank(SYSTEM_ADDRESS); + borValidatorSet.commitSpan(1, 0, 0, "", ""); + } + + function testRevert_commitSpan_IncompleteSprint() public { + vm.expectRevert("Difference between start and end block must be in multiples of sprint"); + vm.prank(SYSTEM_ADDRESS); + borValidatorSet.commitSpan(1, 0, 64 * 2, "", ""); + } + + function test_commitSpan() public { + uint256 newSpan = 1; + uint256 startBlock = 0; + uint256 endBlock = 64 * 2 - 1; + + uint256 numOfValidators = 5; + uint256 numOfProducers = 3; + + uint256[] memory ids; + uint256[] memory powers; + address[] memory signers; + bytes memory validatorBytes; + bytes memory producerBytes; + + string[] memory cmd = new string[](4); + cmd[0] = "node"; + cmd[1] = "test/helpers/rlpEncodeValidatorsAndProducers.js"; + cmd[2] = vm.toString(numOfValidators); + cmd[3] = vm.toString(numOfProducers); + bytes memory result = vm.ffi(cmd); + (ids, powers, signers, validatorBytes, producerBytes) = abi.decode(result, (uint256[], uint256[], address[], bytes, bytes)); + + vm.prank(SYSTEM_ADDRESS); + borValidatorSet.commitSpan(newSpan, startBlock, endBlock, validatorBytes, producerBytes); + + (uint256 number_, uint256 startBlock_, uint256 endBlock_) = borValidatorSet.spans(0); + assertEq(number_, 0); + assertEq(startBlock_, 0); + assertEq(endBlock_, FIRST_END_BLOCK); + assertEq(borValidatorSet.spanNumbers(0), 0); + (uint256 id, uint256 power, address signer) = borValidatorSet.validators(0, 0); + (address[] memory initialAddresses, uint256[] memory initialPowers) = borValidatorSet.getInitialValidators(); + assertEq(id, 0); + assertEq(power, initialPowers[0]); + assertEq(signer, initialAddresses[0]); + vm.expectRevert(); + borValidatorSet.validators(0, 1); + (id, power, signer) = borValidatorSet.producers(0, 0); + assertEq(id, 0); + assertEq(power, initialPowers[0]); + assertEq(signer, initialAddresses[0]); + vm.expectRevert(); + borValidatorSet.producers(0, 1); + (number_, startBlock_, endBlock_) = borValidatorSet.spans(newSpan); + assertEq(number_, newSpan); + assertEq(startBlock_, startBlock); + assertEq(endBlock_, endBlock); + assertEq(borValidatorSet.spanNumbers(1), newSpan); + for (uint256 i = 0; i < numOfValidators; i++) { + (id, power, signer) = borValidatorSet.validators(newSpan, i); + assertEq(id, ids[i]); + assertEq(power, powers[i]); + assertEq(signer, signers[i]); + if (i >= numOfProducers) continue; + (id, power, signer) = borValidatorSet.producers(newSpan, i); + assertEq(id, ids[i]); + assertEq(power, powers[i]); + assertEq(signer, signers[i]); + } + vm.expectRevert(); + borValidatorSet.validators(newSpan, numOfValidators); + vm.expectRevert(); + borValidatorSet.producers(newSpan, numOfProducers); + } + + function testRevert_commitSpan_StartLesserThanCurrentSpanStart() public { + _commitSpan(); + vm.expectRevert("Start block must be greater than current span"); + vm.prank(SYSTEM_ADDRESS); + borValidatorSet.commitSpan(2, 0, 64 * 2 - 1, "", ""); + } + + // @note Redundant check. + /*function testRevert_commitSpan_AlreadyExists() public { + }*/ + + function test_getSpan() public { + _commitSpan(); + (uint256 number, uint256 startBlock, uint256 endBlock) = borValidatorSet.getSpan(0); + assertEq(number, 0); + assertEq(startBlock, 0); + assertEq(endBlock, FIRST_END_BLOCK); + (number, startBlock, endBlock) = borValidatorSet.getSpan(1); + assertEq(number, 1); + assertEq(startBlock, 1); + assertEq(endBlock, 64 * 2); + } + + function test_getSpanByBlock() public { + assertEq(borValidatorSet.getSpanByBlock(1_234_567_890), 0); + _commitSpan(); + _commitSpan(1000); + assertEq(borValidatorSet.getSpanByBlock(0), 0); + assertEq(borValidatorSet.getSpanByBlock(100), 1); + assertEq(borValidatorSet.getSpanByBlock(1001), 2); + assertEq(borValidatorSet.getSpanByBlock(1_234_567_890), 2); + } + + function test_currentSpanNumber() public { + vm.roll(1_234_567_890); + assertEq(borValidatorSet.currentSpanNumber(), 0); + _commitSpan(); + _commitSpan(1000); + vm.roll(0); + assertEq(borValidatorSet.currentSpanNumber(), 0); + vm.roll(100); + assertEq(borValidatorSet.currentSpanNumber(), 1); + vm.roll(1001); + assertEq(borValidatorSet.currentSpanNumber(), 2); + vm.roll(1_234_567_890); + assertEq(borValidatorSet.currentSpanNumber(), 2); + } + + function test_getCurrentSpan() public { + _commitSpan(); + (uint256 number, uint256 startBlock, uint256 endBlock) = borValidatorSet.getCurrentSpan(); + assertEq(number, 1); + assertEq(startBlock, 1); + assertEq(endBlock, 64 * 2); + } + + function test_getNextSpan() public { + _commitSpan(); + vm.roll(0); + (uint256 number, uint256 startBlock, uint256 endBlock) = borValidatorSet.getNextSpan(); + assertEq(number, 1); + assertEq(startBlock, 1); + assertEq(endBlock, 64 * 2); + } + + function test_getValidatorsTotalStakeBySpan() public { + (uint256[] memory ids, uint256[] memory powers, address[] memory signers) = _commitSpan(); + uint256 totalStake; + for (uint256 i = 0; i < 5; i++) { + totalStake += powers[i]; + } + assertEq(borValidatorSet.getValidatorsTotalStakeBySpan(1), totalStake); + } + + function test_getProducersTotalStakeBySpan() public { + (uint256[] memory ids, uint256[] memory powers, address[] memory signers) = _commitSpan(); + uint256 totalStake; + for (uint256 i = 0; i < 3; i++) { + totalStake += powers[i]; + } + assertEq(borValidatorSet.getProducersTotalStakeBySpan(1), totalStake); + } + + function test_getValidatorBySigner() public { + (uint256[] memory ids, uint256[] memory powers, address[] memory signers) = _commitSpan(); + Validator memory validator = borValidatorSet.getValidatorBySigner(1, signers[4]); + assertEq(validator.id, ids[4]); + assertEq(validator.power, powers[4]); + assertEq(validator.signer, signers[4]); + } + + function test_isValidator() public { + (uint256[] memory ids, uint256[] memory powers, address[] memory signers) = _commitSpan(); + assertTrue(borValidatorSet.isValidator(1, signers[4])); + assertFalse(borValidatorSet.isValidator(1, makeAddr("not validator"))); + } + + function test_isProducer() public { + (uint256[] memory ids, uint256[] memory powers, address[] memory signers) = _commitSpan(); + assertFalse(borValidatorSet.isProducer(1, signers[4])); + assertFalse(borValidatorSet.isProducer(1, makeAddr("not producer"))); + assertTrue(borValidatorSet.isProducer(1, signers[1])); + } + + function test_isCurrentValidator() public { + (uint256[] memory ids, uint256[] memory powers, address[] memory signers) = _commitSpan(); + assertTrue(borValidatorSet.isCurrentValidator(signers[4])); + vm.roll(0); + assertFalse(borValidatorSet.isCurrentValidator(signers[4])); + } + + function test_isCurrentProducer() public { + (uint256[] memory ids, uint256[] memory powers, address[] memory signers) = _commitSpan(); + assertTrue(borValidatorSet.isCurrentProducer(signers[1])); + vm.roll(0); + assertFalse(borValidatorSet.isCurrentProducer(signers[1])); + } + + function test_getBorValidators() public { + (address[] memory addresses, uint256[] memory powers) = borValidatorSet.getBorValidators(0); + assertEq(addresses.length, 1); + assertEq(powers.length, 1); + assertEq(addresses[0], 0x6c468CF8c9879006E22EC4029696E005C2319C9D); + assertEq(powers[0], 40); + (uint256[] memory ids_, uint256[] memory powers_, address[] memory signers_) = _commitSpan(); + (addresses, powers) = borValidatorSet.getBorValidators(FIRST_END_BLOCK + 1); + for (uint256 i; i < addresses.length; ++i) { + assertEq(addresses[i], signers_[i]); + assertEq(powers[i], powers_[i]); + } + } + + function test_getValidators() public { + vm.roll(0); + (address[] memory addresses, uint256[] memory powers) = borValidatorSet.getValidators(); + assertEq(addresses.length, 1); + assertEq(powers.length, 1); + assertEq(addresses[0], 0x6c468CF8c9879006E22EC4029696E005C2319C9D); + assertEq(powers[0], 40); + (uint256[] memory ids_, uint256[] memory powers_, address[] memory signers_) = _commitSpan(); + vm.roll(FIRST_END_BLOCK + 1); + (addresses, powers) = borValidatorSet.getValidators(); + for (uint256 i; i < addresses.length; ++i) { + assertEq(addresses[i], signers_[i]); + assertEq(powers[i], powers_[i]); + } + } + + function test_getStakePowerBySigs() public { + Account[] memory signerAccounts = new Account[](5); + address[] memory specificSigners = new address[](5); + + bytes32 digest = bytes32("something"); + bytes memory sigs; + + for (uint256 i; i < signerAccounts.length; ++i) { + signerAccounts[i] = makeAccount(string.concat("signer", vm.toString(i))); + specificSigners[i] = signerAccounts[i].addr; + } + + specificSigners = _sortAddresses(specificSigners); + + for (uint256 i; i < signerAccounts.length; ++i) { + uint256 key; + for (uint256 j; j < signerAccounts.length; ++j) { + if (signerAccounts[j].addr == specificSigners[i]) { + key = signerAccounts[j].key; + break; + } + } + (uint8 v, bytes32 r, bytes32 s) = vm.sign(key, digest); + bytes memory sig = bytes.concat(r, s, bytes1(v)); + sigs = abi.encodePacked(sigs, sig); + } + + (uint256[] memory ids_, uint256[] memory powers_, address[] memory signers_) = _commitSpan(specificSigners); + + uint256 sum; + for (uint256 i; i < powers_.length; ++i) { + sum += powers_[i]; + } + + assertEq(borValidatorSet.getStakePowerBySigs(1, digest, sigs), sum); + } + + function test_leafNode(bytes32 d) public returns (bytes32) { + assertEq(borValidatorSet.leafNode(d), sha256(abi.encodePacked(bytes1(uint8(0)), d))); + } + + function test_innerNode(bytes32 left, bytes32 right) public returns (bytes32) { + assertEq(borValidatorSet.innerNode(left, right), sha256(abi.encodePacked(bytes1(uint8(1)), left, right))); + } + + function _commitSpan() internal returns (uint256[] memory ids, uint256[] memory powers, address[] memory signers) { + return _commitSpan(0, new address[](0)); + } + + function _commitSpan(uint256 startBlockOffset) internal returns (uint256[] memory ids, uint256[] memory powers, address[] memory signers) { + return _commitSpan(startBlockOffset, new address[](0)); + } + + function _commitSpan(address[] memory specificSigners) internal returns (uint256[] memory ids, uint256[] memory powers, address[] memory signers) { + return _commitSpan(0, specificSigners); + } + + function _commitSpan(uint256 startBlockOffset, address[] memory specificSigners) + internal + returns (uint256[] memory ids, uint256[] memory powers, address[] memory signers) + { + uint256 startBlock = 1 + startBlockOffset; + uint256 endBlock = startBlockOffset + 64 * 2; + + uint256 numOfValidators = 5; + uint256 numOfProducers = 3; + + uint256[] memory ids; + uint256[] memory powers; + address[] memory signers; + bytes memory validatorBytes; + bytes memory producerBytes; + + string[] memory cmd = new string[](specificSigners.length == 0 ? 4 : 5); + cmd[0] = "node"; + cmd[1] = "test/helpers/rlpEncodeValidatorsAndProducers.js"; + cmd[2] = vm.toString(numOfValidators); + cmd[3] = vm.toString(numOfProducers); + if (specificSigners.length != 0) cmd[4] = vm.toString(abi.encode(specificSigners)); + bytes memory result = vm.ffi(cmd); + (ids, powers, signers, validatorBytes, producerBytes) = abi.decode(result, (uint256[], uint256[], address[], bytes, bytes)); + + vm.prank(SYSTEM_ADDRESS); + borValidatorSet.commitSpan(_newSpan, startBlock, endBlock, validatorBytes, producerBytes); + + ++_newSpan; + + return (ids, powers, signers); + } + + function _sortAddresses(address[] memory addresses) internal pure returns (address[] memory) { + uint256 length = addresses.length; + bool swapped; + + for (uint256 i = 0; i < length - 1; i++) { + swapped = false; + for (uint256 j = 0; j < length - i - 1; j++) { + if (addresses[j] > addresses[j + 1]) { + address temp = addresses[j]; + addresses[j] = addresses[j + 1]; + addresses[j + 1] = temp; + swapped = true; + } + } + + if (!swapped) break; + } + + return addresses; + } +} diff --git a/test/ECVerify.t.sol b/test/ECVerify.t.sol new file mode 100644 index 0000000..0d61de6 --- /dev/null +++ b/test/ECVerify.t.sol @@ -0,0 +1,72 @@ +pragma solidity >0.5.0; + +import "../lib/forge-std/src/Test.sol"; + +import "./helpers/IECVerifyWrapper.sol"; + +contract ECVerifyTest is Test { + Account internal signer; + IECVerifyWrapper internal ecVerifyWrapper; + + function setUp() public { + ecVerifyWrapper = IECVerifyWrapper(deployCode("out/ECVerifyWrapper.sol/ECVerifyWrapper.json")); + signer = makeAccount("signer"); + } + + function test_ecrecovery_sig_LengthNot65() public { + assertEq(ecVerifyWrapper.ecrecovery(bytes32(0), new bytes(64)), address(0)); + assertEq(ecVerifyWrapper.ecrecovery(bytes32(0), new bytes(66)), address(0)); + } + + function test_ecrecovery_sig_VNot27Or28() public { + bytes memory sig = new bytes(65); + sig[64] = bytes1(uint8(26)); + assertEq(ecVerifyWrapper.ecrecovery(bytes32(0), sig), address(0)); + sig[64] = bytes1(uint8(29)); + assertEq(ecVerifyWrapper.ecrecovery(bytes32(0), sig), address(0)); + } + + function testRevert_ecrecovery_sig_NotRecovered() public { + vm.expectRevert(); + ecVerifyWrapper.ecrecovery(bytes32(0), new bytes(65)); + } + + function test_ecrecovery_sig() public { + bytes32 digest = bytes32(vm.unixTime()); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(signer.key, digest); + bytes memory sig = bytes.concat(r, s, bytes1(v)); + assertEq(ecVerifyWrapper.ecrecovery(digest, sig), signer.addr); + } + + function test_ecrecovery_sig_AdjustsV() public { + bytes32 digest = bytes32(uint256(134_234_234)); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(signer.key, digest); + bytes memory sig = bytes.concat(r, s, bytes1(v - 27)); + assertEq(ecVerifyWrapper.ecrecovery(digest, sig), signer.addr); + } + + function testRevert_ecrecovery_vrs_NotRecovered() public { + vm.expectRevert(); + ecVerifyWrapper.ecrecovery(bytes32(0), 0, 0, 0); + } + + function test_ecrecovery_vrs() public { + bytes32 digest = bytes32(vm.unixTime()); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(signer.key, digest); + assertEq(ecVerifyWrapper.ecrecovery(digest, v, r, s), signer.addr); + } + + function test_ecverify_True() public { + bytes32 digest = bytes32(vm.unixTime()); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(signer.key, digest); + bytes memory sig = bytes.concat(r, s, bytes1(v)); + assertTrue(ecVerifyWrapper.ecverify(digest, sig, signer.addr)); + } + + function test_ecverify_False() public { + bytes32 digest = bytes32(vm.unixTime()); + (uint8 v, bytes32 r, bytes32 s) = vm.sign(signer.key, digest); + bytes memory sig = bytes.concat(r, s, bytes1(v)); + assertFalse(ecVerifyWrapper.ecverify(keccak256("fiuewgfniuw34n"), sig, signer.addr)); + } +} diff --git a/test/IterableMapping.t.sol b/test/IterableMapping.t.sol new file mode 100644 index 0000000..ac78702 --- /dev/null +++ b/test/IterableMapping.t.sol @@ -0,0 +1,100 @@ +pragma solidity >0.5.0; + +import "../lib/forge-std/src/Test.sol"; + +import "./helpers/IIterableMappingWrapper.sol"; + +contract IterableMappingTest is Test { + IIterableMappingWrapper internal iterableMappingWrapper; + + function setUp() public { + iterableMappingWrapper = IIterableMappingWrapper(deployCode("out/IterableMappingWrapper.sol/IterableMappingWrapper.json")); + } + + function test_insert_New() public { + assertFalse(iterableMappingWrapper.insert(10, true)); + assertFalse(iterableMappingWrapper.insert(20, false)); + + assertEq(iterableMappingWrapper.$mapSize(), 2); + + assertEq(iterableMappingWrapper.$mapData(10).keyIndex, 1); + assertEq(iterableMappingWrapper.$mapData(10).value, true); + assertEq(iterableMappingWrapper.$mapKeys(0).key, 10); + assertEq(iterableMappingWrapper.$mapKeys(0).deleted, false); + + assertEq(iterableMappingWrapper.$mapData(20).keyIndex, 2); + assertEq(iterableMappingWrapper.$mapData(20).value, false); + assertEq(iterableMappingWrapper.$mapKeys(1).key, 20); + assertEq(iterableMappingWrapper.$mapKeys(1).deleted, false); + } + + function test_insert_Replaced() public { + iterableMappingWrapper.insert(10, true); + assertTrue(iterableMappingWrapper.insert(10, false)); + + assertEq(iterableMappingWrapper.$mapSize(), 1); + + assertEq(iterableMappingWrapper.$mapData(10).keyIndex, 1); + assertEq(iterableMappingWrapper.$mapData(10).value, false); + assertEq(iterableMappingWrapper.$mapKeys(0).key, 10); + assertEq(iterableMappingWrapper.$mapKeys(0).deleted, false); + } + + function test_remove_NonExistent() public { + assertFalse(iterableMappingWrapper.remove(10)); + } + + function test_remove() public { + iterableMappingWrapper.insert(10, true); + // @note Should return true. + assertFalse(iterableMappingWrapper.remove(10)); + + assertEq(iterableMappingWrapper.$mapSize(), 0); + + assertEq(iterableMappingWrapper.$mapData(10).keyIndex, 0); + assertEq(iterableMappingWrapper.$mapData(10).value, false); + assertEq(iterableMappingWrapper.$mapKeys(0).key, 10); + assertEq(iterableMappingWrapper.$mapKeys(0).deleted, true); + } + + function test_contains() public { + assertFalse(iterableMappingWrapper.contains(10)); + iterableMappingWrapper.insert(10, true); + assertTrue(iterableMappingWrapper.contains(10)); + } + + function test_next() public { + assertEq(iterableMappingWrapper.next(0), 1); + iterableMappingWrapper.insert(10, true); + iterableMappingWrapper.insert(20, true); + iterableMappingWrapper.insert(30, true); + iterableMappingWrapper.remove(20); + iterableMappingWrapper.remove(30); + assertEq(iterableMappingWrapper.next(0), 3); + assertEq(iterableMappingWrapper.next(1), 3); + } + + function test_start() public { + assertEq(iterableMappingWrapper.start(), 0); + iterableMappingWrapper.insert(10, true); + iterableMappingWrapper.insert(20, true); + iterableMappingWrapper.insert(30, true); + assertEq(iterableMappingWrapper.start(), 0); + iterableMappingWrapper.remove(10); + iterableMappingWrapper.remove(20); + assertEq(iterableMappingWrapper.start(), 2); + } + + function test_valid() public { + assertFalse(iterableMappingWrapper.valid(0)); + iterableMappingWrapper.insert(10, true); + assertTrue(iterableMappingWrapper.valid(0)); + } + + function test_get() public { + iterableMappingWrapper.insert(10, true); + (uint256 key, bool value) = iterableMappingWrapper.get(0); + assertEq(key, 10); + assertEq(value, true); + } +} diff --git a/test/Migrations.t.sol b/test/Migrations.t.sol new file mode 100644 index 0000000..c190eb3 --- /dev/null +++ b/test/Migrations.t.sol @@ -0,0 +1,44 @@ +pragma solidity >0.5.0; + +import "../lib/forge-std/src/Test.sol"; + +import "./helpers/IMigrations.sol"; + +contract MigrationsTest is Test { + IMigrations internal migrations; + + function setUp() public { + migrations = IMigrations(deployCode("out/Migrations.sol/Migrations.json")); + } + + function test_constructor() public { + assertEq(migrations.owner(), address(this)); + } + + function test_setCompleted() public { + migrations.setCompleted(123); + assertEq(migrations.last_completed_migration(), 123); + } + + function test_setCompleted_Restricted() public { + vm.prank(makeAddr("alien")); + migrations.setCompleted(123); + assertEq(migrations.last_completed_migration(), 0); + } + + function test_upgrade() public { + vm.prank(address(migrations)); + IMigrations newMigrations = IMigrations(deployCode("out/Migrations.sol/Migrations.json")); + migrations.setCompleted(123); + migrations.upgrade(address(newMigrations)); + assertEq(newMigrations.last_completed_migration(), 123); + } + + function test_upgrade_Restricted() public { + IMigrations newMigrations = IMigrations(deployCode("out/Migrations.sol/Migrations.json")); + migrations.setCompleted(123); + vm.prank(makeAddr("alien")); + migrations.upgrade(address(newMigrations)); + assertEq(newMigrations.last_completed_migration(), 0); + } +} diff --git a/test/StateReceiver.t.sol b/test/StateReceiver.t.sol new file mode 100644 index 0000000..b78d7d2 --- /dev/null +++ b/test/StateReceiver.t.sol @@ -0,0 +1,129 @@ +pragma solidity >0.5.0; + +import "../lib/forge-std/src/Test.sol"; + +import "./helpers/IStateReceiver.sol"; + +contract StateReceiverTest is Test { + address public constant SYSTEM_ADDRESS = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE; + uint8 constant LIST_SHORT_START = 0xc0; + + IStateReceiver internal stateReceiver; + + function setUp() public { + stateReceiver = IStateReceiver(deployCode("out/StateReceiver.sol/StateReceiver.json")); + } + + function testRevert_commitState_OnlySystem() public { + vm.expectRevert("Not System Addess!"); + stateReceiver.commitState(0, ""); + } + + function testRevert_commitState_StateIdsAreNotSequential() public { + bytes memory recordBytes = _encodeRecord(2, address(0), ""); + vm.expectRevert("StateIds are not sequential"); + vm.prank(SYSTEM_ADDRESS); + stateReceiver.commitState(0, recordBytes); + } + + function test_commitState_ReceiverNotContract() public { + uint256 stateId = 1; + address receiver = makeAddr("receiver"); + bytes memory recordBytes = _encodeRecord(stateId, receiver, ""); + + vm.prank(SYSTEM_ADDRESS); + assertFalse(stateReceiver.commitState(0, recordBytes)); + assertEq(stateReceiver.lastStateId(), 1); + } + + function test_commitState_ReceiverReverts() public { + uint256 stateId = 1; + address receiver = makeAddr("receiver"); + vm.etch(receiver, "00"); + vm.mockCallRevert(receiver, "", ""); + bytes memory stateData = "State data"; + bytes memory recordBytes = _encodeRecord(stateId, receiver, stateData); + + vm.expectCallMinGas(receiver, 0, 5_000_000, abi.encodeWithSignature("onStateReceive(uint256,bytes)", stateId, stateData)); + vm.prank(SYSTEM_ADDRESS); + vm.expectEmit(); + emit StateCommitted(stateId, false); + assertFalse(stateReceiver.commitState(0, recordBytes)); + assertEq(stateReceiver.lastStateId(), 1); + } + + function test_commitState_Success() public { + uint256 stateId = 1; + address receiver = makeAddr("receiver"); + vm.etch(receiver, "00"); + bytes memory stateData = "State data"; + bytes memory recordBytes = _encodeRecord(stateId, receiver, stateData); + + vm.expectCallMinGas(receiver, 0, 5_000_000, abi.encodeWithSignature("onStateReceive(uint256,bytes)", stateId, stateData)); + vm.prank(SYSTEM_ADDRESS); + vm.expectEmit(); + emit StateCommitted(stateId, true); + assertTrue(stateReceiver.commitState(0, recordBytes)); + assertEq(stateReceiver.lastStateId(), 1); + } + + function _encodeRecord(uint256 stateId, address receiver, bytes memory stateData) public returns (bytes memory recordBytes) { + return abi.encodePacked(LIST_SHORT_START, _rlpEncodeUint(stateId), _rlpEncodeAddress(receiver), _rlpEncodeBytes(stateData)); + } + + function _rlpEncodeUint(uint256 value) internal pure returns (bytes memory) { + if (value == 0) { + return hex"80"; + } else if (value < 0x80) { + return abi.encodePacked(uint8(value)); + } else { + bytes memory result = new bytes(33); + uint256 length = 0; + while (value != 0) { + length++; + result[33 - length] = bytes1(uint8(value)); + value >>= 8; + } + bytes memory encoded = new bytes(length + 1); + encoded[0] = bytes1(uint8(0x80 + length)); + for (uint256 i = 0; i < length; i++) { + encoded[i + 1] = result[33 - length + i]; + } + return encoded; + } + } + + function _rlpEncodeAddress(address value) internal pure returns (bytes memory) { + bytes memory encoded = new bytes(21); + encoded[0] = bytes1(uint8(0x94)); + for (uint256 i = 0; i < 20; i++) { + encoded[i + 1] = bytes1(uint8(uint256(uint160(value)) >> (8 * (19 - i)))); + } + return encoded; + } + + function _rlpEncodeBytes(bytes memory value) internal pure returns (bytes memory) { + uint256 length = value.length; + if (length == 1 && uint8(value[0]) < 0x80) { + return value; + } else if (length <= 55) { + bytes memory encoded = new bytes(length + 1); + encoded[0] = bytes1(uint8(0x80 + length)); + for (uint256 i = 0; i < length; i++) { + encoded[i + 1] = value[i]; + } + return encoded; + } else { + bytes memory lengthEncoded = _rlpEncodeUint(length); + bytes memory encoded = new bytes(1 + lengthEncoded.length + length); + encoded[0] = bytes1(uint8(0xb7 + lengthEncoded.length)); + for (uint256 i = 0; i < lengthEncoded.length; i++) { + encoded[i + 1] = lengthEncoded[i]; + } + for (uint256 i = 0; i < length; i++) { + encoded[i + 1 + lengthEncoded.length] = value[i]; + } + return encoded; + } + } +} diff --git a/test/System.t.sol b/test/System.t.sol new file mode 100644 index 0000000..1ac00a9 --- /dev/null +++ b/test/System.t.sol @@ -0,0 +1,17 @@ +pragma solidity >0.5.0; + +import "../lib/forge-std/src/Test.sol"; + +import "./helpers/ISystem.sol"; + +contract SystemTest is Test { + ISystem internal system; + + function setUp() public { + system = ISystem(deployCode("out/System.sol/System.json")); + } + + function test_constants() public { + assertEq(system.SYSTEM_ADDRESS(), 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE); + } +} diff --git a/test/ValidatorVerifier.t.sol b/test/ValidatorVerifier.t.sol new file mode 100644 index 0000000..67f2b06 --- /dev/null +++ b/test/ValidatorVerifier.t.sol @@ -0,0 +1,39 @@ +pragma solidity >0.5.0; + +import "../lib/forge-std/src/Test.sol"; + +import "./helpers/IValidatorVerifier.sol"; + +contract ValidatorVerifierTest is Test { + address public constant validatorSet = 0x0000000000000000000000000000000000001000; + + IValidatorVerifier internal validatorVerifier; + + function setUp() public { + validatorVerifier = IValidatorVerifier(deployCode("out/ValidatorVerifier.sol/ValidatorVerifier.json")); + } + + function test_constants() public { + assertEq(validatorVerifier.validatorSet(), validatorSet); + } + + function test_isValidatorSetContract() public { + assertFalse(validatorVerifier.isValidatorSetContract()); + vm.prank(validatorSet); + assertTrue(validatorVerifier.isValidatorSetContract()); + } + + function test_isValidator() public { + vm.mockCall(validatorSet, abi.encodeWithSignature("isCurrentValidator(address)", address(this)), abi.encode(true)); + assertTrue(validatorVerifier.isValidator(address(this))); + vm.mockCall(validatorSet, abi.encodeWithSignature("isCurrentValidator(address)", address(this)), abi.encode(false)); + assertFalse(validatorVerifier.isValidator(address(this))); + } + + function test_isProducer() public { + vm.mockCall(validatorSet, abi.encodeWithSignature("isCurrentProducer(address)", address(this)), abi.encode(true)); + assertTrue(validatorVerifier.isProducer(address(this))); + vm.mockCall(validatorSet, abi.encodeWithSignature("isCurrentProducer(address)", address(this)), abi.encode(false)); + assertFalse(validatorVerifier.isProducer(address(this))); + } +} diff --git a/test/helpers/ECVerifyWrapper.sol b/test/helpers/ECVerifyWrapper.sol new file mode 100644 index 0000000..089a4f7 --- /dev/null +++ b/test/helpers/ECVerifyWrapper.sol @@ -0,0 +1,17 @@ +pragma solidity ^0.5.2; + +import "../../contracts/ECVerify.sol"; + +contract ECVerifyWrapper { + function ecrecovery(bytes32 hash, bytes memory sig) public pure returns (address) { + return ECVerify.ecrecovery(hash, sig); + } + + function ecrecovery(bytes32 hash, uint8 v, bytes32 r, bytes32 s) public pure returns (address) { + return ECVerify.ecrecovery(hash, v, r, s); + } + + function ecverify(bytes32 hash, bytes memory sig, address signer) public pure returns (bool) { + return ECVerify.ecverify(hash, sig, signer); + } +} diff --git a/test/helpers/IBorValidatorSet.sol b/test/helpers/IBorValidatorSet.sol new file mode 100644 index 0000000..d001650 --- /dev/null +++ b/test/helpers/IBorValidatorSet.sol @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >0.5.0; + +struct Validator { + uint256 id; + uint256 power; + address signer; +} + +struct Span { + uint256 number; + uint256 startBlock; + uint256 endBlock; +} + +event NewSpan(uint256 indexed id, uint256 indexed startBlock, uint256 indexed endBlock); + +interface IBorValidatorSet { + function BOR_ID() external view returns (bytes32); + function CHAIN() external view returns (bytes32); + function FIRST_END_BLOCK() external view returns (uint256); + function ROUND_TYPE() external view returns (bytes32); + function SPRINT() external view returns (uint256); + function SYSTEM_ADDRESS() external view returns (address); + function VOTE_TYPE() external view returns (uint8); + function checkMembership(bytes32 rootHash, bytes32 leaf, bytes memory proof) external pure returns (bool); + function commitSpan(uint256 newSpan, uint256 startBlock, uint256 endBlock, bytes memory validatorBytes, bytes memory producerBytes) external; + function currentSpanNumber() external view returns (uint256); + function currentSprint() external view returns (uint256); + function getBorValidators(uint256 number) external view returns (address[] memory, uint256[] memory); + function getCurrentSpan() external view returns (uint256 number, uint256 startBlock, uint256 endBlock); + function getInitialValidators() external view returns (address[] memory, uint256[] memory); + function getNextSpan() external view returns (uint256 number, uint256 startBlock, uint256 endBlock); + function getProducersTotalStakeBySpan(uint256 span) external view returns (uint256); + function getSpan(uint256 span) external view returns (uint256 number, uint256 startBlock, uint256 endBlock); + function getSpanByBlock(uint256 number) external view returns (uint256); + function getStakePowerBySigs(uint256 span, bytes32 dataHash, bytes memory sigs) external view returns (uint256); + function getValidatorBySigner(uint256 span, address signer) external view returns (Validator memory result); + function getValidators() external view returns (address[] memory, uint256[] memory); + function getValidatorsTotalStakeBySpan(uint256 span) external view returns (uint256); + function innerNode(bytes32 left, bytes32 right) external pure returns (bytes32); + function isCurrentProducer(address signer) external view returns (bool); + function isCurrentValidator(address signer) external view returns (bool); + function isProducer(uint256 span, address signer) external view returns (bool); + function isValidator(uint256 span, address signer) external view returns (bool); + function leafNode(bytes32 d) external pure returns (bytes32); + function producers(uint256, uint256) external view returns (uint256 id, uint256 power, address signer); + function spanNumbers(uint256) external view returns (uint256); + function spans(uint256) external view returns (uint256 number, uint256 startBlock, uint256 endBlock); + function validators(uint256, uint256) external view returns (uint256 id, uint256 power, address signer); +} diff --git a/test/helpers/IECVerifyWrapper.sol b/test/helpers/IECVerifyWrapper.sol new file mode 100644 index 0000000..b321a71 --- /dev/null +++ b/test/helpers/IECVerifyWrapper.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >0.5.0; + +interface IECVerifyWrapper { + function ecrecovery(bytes32 hash, bytes calldata sig) external pure returns (address); + function ecrecovery(bytes32 hash, uint8 v, bytes32 r, bytes32 s) external pure returns (address); + function ecverify(bytes32 hash, bytes calldata sig, address signer) external pure returns (bool); +} diff --git a/test/helpers/IIterableMappingWrapper.sol b/test/helpers/IIterableMappingWrapper.sol new file mode 100644 index 0000000..cf07822 --- /dev/null +++ b/test/helpers/IIterableMappingWrapper.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >0.5.0; + +struct IndexValue { + uint256 keyIndex; + bool value; +} + +struct KeyFlag { + uint256 key; + bool deleted; +} + +interface IIterableMappingWrapper { + function $mapData(uint256 a) external returns (IndexValue memory); + function $mapKeys(uint256 a) external returns (KeyFlag memory); + function $mapSize() external returns (uint256); + function contains(uint256 key) external view returns (bool); + function get(uint256 keyIndex) external view returns (uint256 key, bool value); + function insert(uint256 key, bool value) external returns (bool replaced); + function next(uint256 keyIndex) external view returns (uint256 r_keyIndex); + function remove(uint256 key) external returns (bool success); + function start() external view returns (uint256 keyIndex); + function valid(uint256 keyIndex) external view returns (bool); +} diff --git a/test/helpers/IMigrations.sol b/test/helpers/IMigrations.sol new file mode 100644 index 0000000..12ea46b --- /dev/null +++ b/test/helpers/IMigrations.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >0.5.0; + +interface IMigrations { + function last_completed_migration() external view returns (uint256); + function owner() external view returns (address); + function setCompleted(uint256 completed) external; + function upgrade(address new_address) external; +} diff --git a/test/helpers/IStateReceiver.sol b/test/helpers/IStateReceiver.sol new file mode 100644 index 0000000..4756457 --- /dev/null +++ b/test/helpers/IStateReceiver.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >0.5.0; + +event StateCommitted(uint256 indexed stateId, bool success); + +interface IStateReceiver { + function SYSTEM_ADDRESS() external view returns (address); + function commitState(uint256 syncTime, bytes memory recordBytes) external returns (bool success); + function lastStateId() external view returns (uint256); +} diff --git a/test/helpers/ISystem.sol b/test/helpers/ISystem.sol new file mode 100644 index 0000000..2095bf5 --- /dev/null +++ b/test/helpers/ISystem.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >0.5.0; + +interface ISystem { + function SYSTEM_ADDRESS() external view returns (address); +} diff --git a/test/helpers/IValidatorVerifier.sol b/test/helpers/IValidatorVerifier.sol new file mode 100644 index 0000000..155f44e --- /dev/null +++ b/test/helpers/IValidatorVerifier.sol @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >0.5.0; + +interface IValidatorVerifier { + function isProducer(address signer) external view returns (bool); + function isValidator(address signer) external view returns (bool); + function isValidatorSetContract() external view returns (bool); + function validatorSet() external view returns (address); +} diff --git a/test/helpers/IterableMappingWrapper.sol b/test/helpers/IterableMappingWrapper.sol new file mode 100644 index 0000000..489af87 --- /dev/null +++ b/test/helpers/IterableMappingWrapper.sol @@ -0,0 +1,50 @@ +pragma solidity ^0.5.2; + +import "../../contracts/IterableMapping.sol"; + +pragma solidity ^0.5.11; +pragma experimental ABIEncoderV2; + +contract IterableMappingWrapper { + IterableMapping.Map internal map; + + function $mapData(uint256 a) external returns (IterableMapping.IndexValue memory) { + return map.data[a]; + } + + function $mapKeys(uint256 a) external returns (IterableMapping.KeyFlag memory) { + return map.keys[a]; + } + + function $mapSize() external returns (uint256) { + return map.size; + } + + function insert(uint256 key, bool value) public returns (bool replaced) { + return IterableMapping.insert(map, key, value); + } + + function remove(uint256 key) public returns (bool success) { + return IterableMapping.remove(map, key); + } + + function contains(uint256 key) public view returns (bool) { + return IterableMapping.contains(map, key); + } + + function start() public view returns (uint256 keyIndex) { + return IterableMapping.start(map); + } + + function valid(uint256 keyIndex) public view returns (bool) { + return IterableMapping.valid(map, keyIndex); + } + + function next(uint256 keyIndex) public view returns (uint256 r_keyIndex) { + return IterableMapping.next(map, keyIndex); + } + + function get(uint256 keyIndex) public view returns (uint256 key, bool value) { + return IterableMapping.get(map, keyIndex); + } +} diff --git a/test/helpers/rlpEncodeValidatorsAndProducers.js b/test/helpers/rlpEncodeValidatorsAndProducers.js new file mode 100644 index 0000000..2f576fb --- /dev/null +++ b/test/helpers/rlpEncodeValidatorsAndProducers.js @@ -0,0 +1,60 @@ +const ethUtils = require("ethereumjs-util"); +const crypto = require("crypto"); +const ethers = require("ethers"); + +const abi = new ethers.AbiCoder(); + +function getRandomInt() { + return Math.floor(Math.random() * 100); +} + +// INPUT HOW MANY TO GENERATE + +const numOfValidators = process.argv[2]; +const numOfProducers = process.argv[3]; +const specificSigners = + process.argv[4] == undefined + ? undefined + : abi.decode(["address[]"], process.argv[4])[0]; +if (numOfProducers > numOfValidators) process.exit(1); +if (specificSigners != undefined && specificSigners.length != numOfValidators) + process.exit(1); + +// RANDOMLY GENERATED + +function getRandomValidator() { + return [ + getRandomInt(), // id + getRandomInt(), // power + "0x" + crypto.randomBytes(20).toString("hex"), // signer + ]; +} + +let totalStake = 0; + +const ids = new Array(numOfValidators); +const powers = new Array(numOfValidators); +const signers = new Array(numOfValidators); + +const validators = new Array(numOfValidators); +for (let i = 0; i < numOfValidators; i++) { + validators[i] = getRandomValidator(); + totalStake += validators[i].power; + + ids[i] = validators[i][0]; + powers[i] = validators[i][1]; + if (specificSigners != undefined) validators[i][2] = specificSigners[i]; + signers[i] = validators[i][2]; +} +this.producers = validators.slice(0, numOfProducers); +const validatorBytes = ethUtils.bufferToHex(ethUtils.rlp.encode(validators)); +const producerBytes = ethUtils.bufferToHex(ethUtils.rlp.encode(this.producers)); + +// THIS WILL BE RETURNED + +const result = abi.encode( + ["uint256[]", "uint256[]", "address[]", "bytes", "bytes"], + [ids, powers, signers, validatorBytes, producerBytes] +); + +console.log(result); From ff6e6cf6efbf39f02d956ec2dce5cc49c93dec84 Mon Sep 17 00:00:00 2001 From: ZeroEkkusu <94782988+ZeroEkkusu@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:34:07 +0200 Subject: [PATCH 2/6] test: add `checkMembership` tests --- .gitmodules | 3 --- lib/murky | 1 - test/BorValidatorSet.t.sol | 19 +++++++++++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) delete mode 160000 lib/murky diff --git a/.gitmodules b/.gitmodules index 260b693..baf0e2d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,6 +4,3 @@ [submodule "lib/forge-std"] path = lib/forge-std url = https://github.com/foundry-rs/forge-std -[submodule "lib/murky"] - path = lib/murky - url = https://github.com/dmfxyz/murky diff --git a/lib/murky b/lib/murky deleted file mode 160000 index 5feccd1..0000000 --- a/lib/murky +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5feccd1253d7da820f7cccccdedf64471025455d diff --git a/test/BorValidatorSet.t.sol b/test/BorValidatorSet.t.sol index 77972b4..653b443 100644 --- a/test/BorValidatorSet.t.sol +++ b/test/BorValidatorSet.t.sol @@ -321,6 +321,25 @@ contract BorValidatorSetTest is Test { assertEq(borValidatorSet.getStakePowerBySigs(1, digest, sigs), sum); } + function test_checkMembership_SingleLeaf() public { + bytes32 leaf = keccak256("leaf"); + assertTrue(borValidatorSet.checkMembership(leaf, leaf, "")); + assertFalse(borValidatorSet.checkMembership(keccak256("not root"), leaf, "")); + } + + function test_checkMembership() public { + bytes32 leaf = keccak256("leaf"); + bytes32 proof1 = keccak256("proof1"); + bytes32 proof2 = keccak256("proof2"); + bytes32 computedHash = sha256(abi.encodePacked(hex"00", leaf)); + bytes memory proof = abi.encodePacked(hex"01", proof1, hex"00", proof2, "garbage"); + bytes32 root = sha256(abi.encodePacked(hex"01", computedHash, proof1)); + root = sha256(abi.encodePacked(hex"01", proof2, root)); + assertTrue(borValidatorSet.checkMembership(root, leaf, proof)); + bytes memory wrongProof = abi.encodePacked(hex"01", proof1, hex"01", proof2, "garbage"); + assertFalse(borValidatorSet.checkMembership(root, leaf, wrongProof)); + } + function test_leafNode(bytes32 d) public returns (bytes32) { assertEq(borValidatorSet.leafNode(d), sha256(abi.encodePacked(bytes1(uint8(0)), d))); } From ba9f72cdfb3aa36232b948eda668253ea9e742ea Mon Sep 17 00:00:00 2001 From: DhairyaSethi <55102840+DhairyaSethi@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:26:54 +0530 Subject: [PATCH 3/6] chore: fix ci --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 614b763..39bd5d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: - develop - master pull_request: - branches: + branches: - develop - master @@ -14,22 +14,26 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Update Path - run: echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)" >> $GITHUB_PATH # Make it accessible from runner - - name: Install solc - run: | - set -x - wget -c https://github.com/ethereum/solidity/releases/download/v0.5.17/solc-static-linux - mv solc-static-linux solc - chmod +x solc - solc --version - - name: Setup Node.js environment - uses: actions/setup-node@v3 - with: - node-version: '16' - registry-url: 'https://registry.npmjs.org' - - name: Generate genesis file - run: bash generate.sh 15001 heimdall-15001 - - name: Run tests - run: npm run test:ci \ No newline at end of file + - uses: actions/checkout@v3 + - name: Update Path + run: echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)" >> $GITHUB_PATH # Make it accessible from runner + - name: Install solc + run: | + set -x + wget -c https://github.com/ethereum/solidity/releases/download/v0.5.17/solc-static-linux + mv solc-static-linux solc + chmod +x solc + solc --version + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: '16' + registry-url: 'https://registry.npmjs.org' + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + - name: Generate genesis file + run: bash generate.sh 15001 heimdall-15001 + - name: Run tests + run: forge test -vvv From 76a111a76e7100ed71c90d254ea6997b6b9685f6 Mon Sep 17 00:00:00 2001 From: DhairyaSethi <55102840+DhairyaSethi@users.noreply.github.com> Date: Tue, 27 Aug 2024 21:27:25 +0530 Subject: [PATCH 4/6] fix: chain id in test --- test/BorValidatorSet.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/BorValidatorSet.t.sol b/test/BorValidatorSet.t.sol index 653b443..fa6255f 100644 --- a/test/BorValidatorSet.t.sol +++ b/test/BorValidatorSet.t.sol @@ -7,7 +7,7 @@ import "./helpers/IBorValidatorSet.sol"; contract BorValidatorSetTest is Test { uint8 constant LIST_SHORT_START = 0xc0; address public constant SYSTEM_ADDRESS = 0xffffFFFfFFffffffffffffffFfFFFfffFFFfFFfE; - bytes32 public constant CHAIN = keccak256("heimdall-P5rXwg"); + bytes32 public constant CHAIN = keccak256("heimdall-15001"); bytes32 public constant ROUND_TYPE = keccak256("vote"); bytes32 public constant BOR_ID = keccak256("15001"); uint8 public constant VOTE_TYPE = 2; From 058630cee41332caa29da38486d3c3f071e2a07b Mon Sep 17 00:00:00 2001 From: DhairyaSethi <55102840+DhairyaSethi@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:00:12 +0530 Subject: [PATCH 5/6] chore: fix ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39bd5d0..2441f97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,4 +36,4 @@ jobs: - name: Generate genesis file run: bash generate.sh 15001 heimdall-15001 - name: Run tests - run: forge test -vvv + run: forge built && forge test -vvv From 9be29b86a912aedb3a60d941581e046640f76b61 Mon Sep 17 00:00:00 2001 From: DhairyaSethi <55102840+DhairyaSethi@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:05:16 +0530 Subject: [PATCH 6/6] chore: typo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2441f97..9145b53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,4 +36,4 @@ jobs: - name: Generate genesis file run: bash generate.sh 15001 heimdall-15001 - name: Run tests - run: forge built && forge test -vvv + run: forge build && forge test -vvv