From d4aa56a026980a52c0d5fae6e8299ac5a8a0ef53 Mon Sep 17 00:00:00 2001 From: Qinxuan Chen Date: Tue, 9 Jan 2024 00:16:33 +0800 Subject: [PATCH] feat(template): enable insecure_zero_ed feature of pallet-balances (#1270) - enable insecure_zero_ed feature of pallet-balances by default - enable rpc-binary-search-estimate feature by default - update integration tests --- .github/workflows/rust.yml | 2 +- frame/ethereum/Cargo.toml | 2 +- frame/ethereum/src/mock.rs | 2 +- template/node/Cargo.toml | 1 + template/runtime/Cargo.toml | 2 +- template/runtime/src/lib.rs | 2 +- ts-tests/README.md | 2 +- ts-tests/tests/config.ts | 4 ++-- ts-tests/tests/test-block-tags.ts | 3 +-- ts-tests/tests/test-state-override.ts | 4 ++-- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 333758326c..5ad0ff7eec 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -49,7 +49,7 @@ jobs: - name: Build client run: | cd template/node - cargo build --release --locked --verbose --features rpc-binary-search-estimate + cargo build --release --locked --verbose - name: Use Node.js 18 uses: actions/setup-node@v4 with: diff --git a/frame/ethereum/Cargo.toml b/frame/ethereum/Cargo.toml index 634be1081d..1a9975f011 100644 --- a/frame/ethereum/Cargo.toml +++ b/frame/ethereum/Cargo.toml @@ -35,7 +35,7 @@ hex = { workspace = true } libsecp256k1 = { workspace = true, features = ["static-context", "hmac"] } rlp = { workspace = true } # Substrate -pallet-balances = { workspace = true, features = ["default"] } +pallet-balances = { workspace = true, features = ["default", "insecure_zero_ed"] } pallet-timestamp = { workspace = true, features = ["default"] } sp-core = { workspace = true, features = ["default"] } # Frontier diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index 9eeb8f7e7b..fba26450a0 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -80,10 +80,10 @@ impl frame_system::Config for Test { } parameter_types! { + pub const ExistentialDeposit: u64 = 0; // For weight estimation, we assume that the most locks on an individual account will be 50. // This number may need to be adjusted in the future if this assumption no longer holds true. pub const MaxLocks: u32 = 50; - pub const ExistentialDeposit: u64 = 500; } impl pallet_balances::Config for Test { diff --git a/template/node/Cargo.toml b/template/node/Cargo.toml index 6c3b7036fa..a8fc923a5a 100644 --- a/template/node/Cargo.toml +++ b/template/node/Cargo.toml @@ -90,6 +90,7 @@ default = [ "rocksdb", "sql", "txpool", + "rpc-binary-search-estimate", ] rocksdb = [ "sc-cli/rocksdb", diff --git a/template/runtime/Cargo.toml b/template/runtime/Cargo.toml index 5547dee3b9..d0e6737876 100644 --- a/template/runtime/Cargo.toml +++ b/template/runtime/Cargo.toml @@ -35,7 +35,7 @@ frame-system = { workspace = true } frame-system-benchmarking = { workspace = true, optional = true } frame-system-rpc-runtime-api = { workspace = true } pallet-aura = { workspace = true } -pallet-balances = { workspace = true } +pallet-balances = { workspace = true, features = ["insecure_zero_ed"] } pallet-grandpa = { workspace = true } pallet-sudo = { workspace = true } pallet-timestamp = { workspace = true } diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index 5995ec780a..dcf5bb3069 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -259,7 +259,7 @@ impl pallet_timestamp::Config for Runtime { } parameter_types! { - pub const ExistentialDeposit: u128 = 500; + pub const ExistentialDeposit: u128 = 0; // For weight estimation, we assume that the most locks on an individual account will be 50. // This number may need to be adjusted in the future if this assumption no longer holds true. pub const MaxLocks: u32 = 50; diff --git a/ts-tests/README.md b/ts-tests/README.md index de5ec0e9ce..9652999b80 100644 --- a/ts-tests/README.md +++ b/ts-tests/README.md @@ -12,7 +12,7 @@ Each group will start a `frontier test node` with a given `spec` before executin ## Build the node for tests ```bash -cargo build --release --features rpc-binary-search-estimate +cargo build --release ``` ## Installation diff --git a/ts-tests/tests/config.ts b/ts-tests/tests/config.ts index c881df59e5..1753c849b2 100644 --- a/ts-tests/tests/config.ts +++ b/ts-tests/tests/config.ts @@ -1,6 +1,6 @@ export const GENESIS_ACCOUNT = "0x6be02d1d3665660d22ff9624b7be0551ee1ac91b"; export const GENESIS_ACCOUNT_PRIVATE_KEY = "0x99B3C12287537E38C90A9219D4CB074A89A16E9CDB20BF85728EBD97C343E342"; -export const GENESIS_ACCOUNT_BALANCE = "340282366920938463463374607431768210955"; +export const GENESIS_ACCOUNT_BALANCE = "340282366920938463463374607431768211455"; export const FIRST_CONTRACT_ADDRESS = "0xc2bf5f29a4384b1ab0c063e1c666f02121b6084a"; @@ -13,7 +13,7 @@ export const RUNTIME_IMPL_VERSION = 1; export const CHAIN_ID = 42; export const BLOCK_TIMESTAMP = 6; // 6 seconds per block export const BLOCK_HASH_COUNT = 256; -export const EXISTENTIAL_DEPOSIT = 500; // The minimum amount required to keep an account open +export const EXISTENTIAL_DEPOSIT = 0; // The minimum amount required to keep an account open export const ETH_BLOCK_GAS_LIMIT = 75000000; // The same configuration as runtime export const ETH_BLOCK_POV_LIMIT = 5 * 1024 * 1024; // The same configuration as runtime diff --git a/ts-tests/tests/test-block-tags.ts b/ts-tests/tests/test-block-tags.ts index 125d114946..1509fddb2c 100644 --- a/ts-tests/tests/test-block-tags.ts +++ b/ts-tests/tests/test-block-tags.ts @@ -1,8 +1,7 @@ import { expect } from "chai"; import { step } from "mocha-steps"; -import { GENESIS_ACCOUNT, GENESIS_ACCOUNT_PRIVATE_KEY, GENESIS_ACCOUNT_BALANCE, EXISTENTIAL_DEPOSIT } from "./config"; -import { createAndFinalizeBlock, describeWithFrontier, customRequest } from "./util"; +import { createAndFinalizeBlock, describeWithFrontier } from "./util"; describeWithFrontier("Frontier RPC (BlockNumber tags)", (context) => { before("Send some transactions across blocks", async function () { diff --git a/ts-tests/tests/test-state-override.ts b/ts-tests/tests/test-state-override.ts index 3bc1793673..2c946b5e12 100644 --- a/ts-tests/tests/test-state-override.ts +++ b/ts-tests/tests/test-state-override.ts @@ -68,7 +68,7 @@ describeWithFrontier("Frontier RPC (StateOverride)", (context) => { expect(balance.gten(1000), "balance was not above 1000 tether").to.be.true; }); - it("should have a sender balance of 4500 with state override", async function () { + it("should have a sender balance of 5000 with state override", async function () { const { result } = await customRequest(context.web3, "eth_call", [ { from: GENESIS_ACCOUNT, @@ -82,7 +82,7 @@ describeWithFrontier("Frontier RPC (StateOverride)", (context) => { }, }, ]); - expect(Web3.utils.hexToNumberString(result)).to.equal("4500"); // 500 is consumed as gas + expect(Web3.utils.hexToNumberString(result)).to.equal("5000"); }); it("should have availableFunds of 100 without state override", async function () {