Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#244 Fix: Include contracts pallet in RPC Calls #245

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ jobs:
with:
version: "3.x"

- name: Set up cargo cache
uses: actions/cache@v3
continue-on-error: false
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Build optimized binary
uses: actions-rs/cargo@v1
with:
Expand Down
13 changes: 7 additions & 6 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ fc-consensus = { git = "https://github.com/web3labs/frontier", branch = "polkado
fp-consensus = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
fp-storage = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }

fc-rpc = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
fp-rpc = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
fc-rpc-core = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
fc-db = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
fc-mapping-sync = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
fp-evm = { default-features = false, git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
fc-rpc = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.30" }
fp-rpc = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.30"}
fc-rpc-core = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.30" }
fc-db = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.30" }
fc-mapping-sync = { git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.30" }
fp-evm = { default-features = false, git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.30"}


pallet-evm = { default-features = false, git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
pallet-ethereum = { default-features = false, git = "https://github.com/web3labs/frontier", branch = "polkadot-v0.9.36" }
Expand Down
3 changes: 2 additions & 1 deletion node/src/chain_spec/frost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn testnet_genesis(
.collect::<Vec<_>>(),
},
evm: EVMConfig {
accounts: {
accounts: {
let mut map = BTreeMap::new();
map.insert(
// H160 address of Alice dev account
Expand Down Expand Up @@ -208,6 +208,7 @@ fn testnet_genesis(
},
);
map

},
},
ethereum: EthereumConfig {},
Expand Down
4 changes: 4 additions & 0 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ use sp_runtime::traits::BlakeTwo256;
use std::collections::BTreeMap;
use std::sync::Arc;
use substrate_frame_rpc_system::{System, SystemApiServer};
use pallet_contracts_rpc::{Contracts};
use pallet_contracts_rpc::ContractsApiServer;

use crate::primitives::*;

Expand Down Expand Up @@ -134,6 +136,7 @@ where
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ fp_rpc::ConvertTransactionRuntimeApi<Block>
+ fp_rpc::EthereumRuntimeRPCApi<Block>
+ pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>
+ BlockBuilder<Block>,
P: TransactionPool<Block = Block> + Sync + Send + 'static,
BE: Backend<Block> + 'static,
Expand All @@ -159,6 +162,7 @@ where

io.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
io.merge(TransactionPayment::new(client.clone()).into_rpc())?;
io.merge(Contracts::new(client.clone()).into_rpc())?;

io.merge(
Eth::new(
Expand Down
1 change: 1 addition & 0 deletions node/src/service/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ where
+ sp_block_builder::BlockBuilder<Block>
+ substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>
+ fp_rpc::EthereumRuntimeRPCApi<Block>
+ fp_rpc::ConvertTransactionRuntimeApi<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>,
Expand Down
24 changes: 1 addition & 23 deletions ts-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cargo build --release --no-default-features --features manual-seal,rpc_binary_se
npm install
```

## Run automated tests
## Run the tests

```bash
npm run build && npm run test
Expand All @@ -34,25 +34,3 @@ ICE_LOG="warn,rpc=trace" npm run test
```

(The Ice node be listening for RPC on port 19933, mostly to avoid conflict with already running substrate node)

## Run tests for contracts state
Ensure that the deployed contract state is intact.
```bash
npm run test-ctx-state <chain>
```
*where `chain` could be one of the following:*
- *snow*
- *arctic*
- *snow_staging*
- *local*

`The contract should be readily available on SNOW/Arctic/Staging Network.`
*<b>Optionally:</b>* If you save your `private key` in `.env` file, you can deploy the contract to SNOW/Arctic:
```bash
npm run deploy-upgrade-ctx <chain>
```
*where `chain` could be one of the following:*
- *snow*
- *arctic*
- *snow_staging*
- *local*
10 changes: 2 additions & 8 deletions ts-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"fmt-check": "prettier ./tests --check",
"fmt": "prettier ./tests --write",
"build": "truffle compile",
"test": "mocha -r ts-node/register 'tests/test-*.{js,ts}'",
"deploy-upgrade-ctx": "node -r ts-node/register -r dotenv/config tests/networkUpgradeTests/deploy-upgrade-ctx.ts --chain $1",
"test-ctx-state": "mocha -r ts-node/register tests/networkUpgradeTests/test-ctx-state.ts --chain $1"
"test": "mocha -r ts-node/register 'tests/**/test-*.{js,ts}'"
},
"author": "",
"license": "ISC",
Expand All @@ -18,7 +16,6 @@
"@types/mocha": "^8.0.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"dotenv": "^16.0.3",
"ethereum-waffle": "^3.4.4",
"ethers": "^5.4.6",
"mocha": "^8.0.1",
Expand All @@ -27,13 +24,10 @@
"truffle": "^5.1.62",
"ts-node": "^8.10.2",
"typescript": "^3.9.6",
"web3": "^1.8.0-rc.0",
"yargs": "^17.6.2"
"web3": "^1.8.0-rc.0"
},
"devDependencies": {
"@types/chai-as-promised": "^7.1.5",
"@types/node": "^18.13.0",
"@types/yargs": "^17.0.22",
"prettier": "^2.6.2"
}
}
23 changes: 0 additions & 23 deletions ts-tests/tests/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,3 @@ export const BLOCK_TIMESTAMP = 6; // 6 seconds per block
export const BLOCK_HASH_COUNT = 256;
export const EXISTENTIAL_DEPOSIT = 10_000_000_000_000_000; // The minimum amount required to keep an account open
export const BLOCK_GAS_LIMIT = 60000000;

export const CHAINS = {
snow: {
RPC_ENDPOINT: "https://snow-rpc.icenetwork.io:9933",
CHAIN_ID: 552,
UPGRADE_CTX_ADDRESS: "0x3f71f31caf936b5b95fe1f207498fe798bd7723b",
},
arctic: {
RPC_ENDPOINT: "https://arctic-rpc.icenetwork.io:9933",
CHAIN_ID: 553,
UPGRADE_CTX_ADDRESS: "0x41897dad572342942d8e86572dd579cf3da16526",
},
snow_staging: {
RPC_ENDPOINT: "https://snow-staging-rpc.web3labs.com:9933",
CHAIN_ID: 552,
UPGRADE_CTX_ADDRESS: "0x5c1c61cb2d66bb77ae2df436cb5e3f92db065a3c",
},
local: {
RPC_ENDPOINT: "https://localhost:9933",
CHAIN_ID: 554,
UPGRADE_CTX_ADDRESS: "", // Update according to local env
},
}
4 changes: 1 addition & 3 deletions ts-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"compilerOptions": {
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2020"
"resolveJsonModule": true
}
}
Loading