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

prepare v5.2.3 #703

Merged
merged 6 commits into from
Feb 21, 2024
Merged
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
158 changes: 88 additions & 70 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainx"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"
description = "Fully Decentralized Interchain Crypto Asset Management on Polkadot"
Expand All @@ -14,6 +14,7 @@ cli = { package = "chainx-cli", path = "cli", features = ["wasmtime"] }
[workspace]
members = [
"cli",
"client/rpc/finality",
"executor",
"primitives",
"primitives/assets-registrar",
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainx-cli"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
description = "Implementation of protocol https://chainx.org in Rust based on the Substrate framework."
edition = "2021"
Expand Down
5 changes: 2 additions & 3 deletions cli/src/res/chainx_regenesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"id": "chainx",
"chainType": "Live",
"bootNodes": [
"/ip4/18.142.230.171/tcp/23555/ws/p2p/12D3KooWQ6GGfmvmmmsbKRmZqMA3A8rxaHz25HvA7JNBbcZhLXtk",
"/ip4/47.99.179.60/tcp/20222/ws/p2p/12D3KooWGLMfkuzy9WzbV7rTRvHk6AvHg89nT8mipNQoQw36eARc",
"/ip4/47.114.74.52/tcp/36789/ws/p2p/12D3KooWJPMUkGytfAMt3AMqm4AFn4VToXjbWZoC4Z2NxXNXvTwb"
"/ip4/18.222.166.234/tcp/9001/ws/p2p/12D3KooWMdwp2izsvRNRRSJTT2VdRu9VQfGck8jx21wX9vwresT4",
"/ip4/18.188.109.150/tcp/9001/ws/p2p/12D3KooWQdw2mmQPmHJjstKhM7q2J7Xxo86qYxDbXH7Gz3wqMznb"
],
"telemetryEndpoints": [
[
Expand Down
21 changes: 21 additions & 0 deletions client/rpc/finality/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "bevm-finality-rpc"
description = "An experimental RPC to check for block and transaction finality in the bevm chain"
version = "5.2.2"
authors = ["The ChainX Authors"]
edition = "2021"

[dependencies]
futures = { version = "0.3", features = [ "compat" ] }
jsonrpc-core = "18.0.0"
jsonrpc-derive = "18.0.0"
parity-scale-codec = "3.0.0"
tokio = { version = "1.12.0", features = [ "sync", "time" ] }

fc-db = { git = "https://github.com/chainx-org/frontier", branch = "polkadot-v0.9.18-btc-fix2" }
fc-rpc = { git = "https://github.com/chainx-org/frontier", branch = "polkadot-v0.9.18-btc-fix2" }
sp-api = { git = "https://github.com/chainx-org/substrate", branch = "polkadot-v0.9.18-fix2" }
sp-blockchain = { git = "https://github.com/chainx-org/substrate", branch = "polkadot-v0.9.18-fix2" }
sp-core = { git = "https://github.com/chainx-org/substrate", branch = "polkadot-v0.9.18-fix2" }
sp-runtime = { git = "https://github.com/chainx-org/substrate", branch = "polkadot-v0.9.18-fix2" }

16 changes: 16 additions & 0 deletions client/rpc/finality/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# rpc

```json
"bevm": {
"isBlockFinalized": {
"description": "Returns whether an Ethereum block is finalized",
"params": [{ "name": "blockHash", "type": "Hash" }],
"type": "bool"
},
"isTxFinalized": {
"description": "Returns whether an Ethereum transaction is finalized",
"params": [{ "name": "txHash", "type": "Hash" }],
"type": "bool"
}
}
```
105 changes: 105 additions & 0 deletions client/rpc/finality/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright 2019-2023 ChainX Project Authors. Licensed under GPL-3.0.

use fc_rpc::frontier_backend_client::{self, is_canon};
use futures::{future::BoxFuture, FutureExt as _};
use jsonrpc_core::Result as RpcResult;
use jsonrpc_derive::rpc;
use sp_core::H256;
use std::{marker::PhantomData, sync::Arc};
//TODO ideally we wouldn't depend on BlockId here. Can we change frontier
// so it's load_hash helper returns an H256 instead of wrapping it in a BlockId?
use fc_db::Backend as FrontierBackend;
use sp_api::BlockId;
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::Block;

/// An RPC endpoint to check for finality of blocks and transactions in Bevm
#[rpc(server)]
pub trait BevmFinalityApi {
/// Reports whether a Substrate or Ethereum block is finalized.
/// Returns false if the block is not found.
#[rpc(name = "bevm_isBlockFinalized")]
fn is_block_finalized(&self, block_hash: H256) -> BoxFuture<'static, RpcResult<bool>>;

/// Reports whether an Ethereum transaction is finalized.
/// Returns false if the transaction is not found
#[rpc(name = "bevm_isTxFinalized")]
fn is_tx_finalized(&self, tx_hash: H256) -> BoxFuture<'static, RpcResult<bool>>;
}

pub struct BevmFinality<B: Block, C> {
pub backend: Arc<FrontierBackend<B>>,
pub client: Arc<C>,
_phdata: PhantomData<B>,
}

impl<B: Block, C> BevmFinality<B, C> {
pub fn new(client: Arc<C>, backend: Arc<FrontierBackend<B>>) -> Self {
Self {
backend,
client,
_phdata: Default::default(),
}
}
}

impl<B, C> BevmFinalityApi for BevmFinality<B, C>
where
B: Block<Hash = H256>,
C: HeaderBackend<B> + Send + Sync + 'static,
{
fn is_block_finalized(&self, raw_hash: H256) -> BoxFuture<'static, RpcResult<bool>> {
let backend = self.backend.clone();
let client = self.client.clone();
async move { is_block_finalized_inner::<B, C>(&backend, &client, raw_hash) }.boxed()
}

fn is_tx_finalized(&self, tx_hash: H256) -> BoxFuture<'static, RpcResult<bool>> {
let backend = self.backend.clone();
let client = self.client.clone();
async move {
if let Some((ethereum_block_hash, _ethereum_index)) =
frontier_backend_client::load_transactions::<B, C>(
&client,
backend.as_ref(),
tx_hash,
true,
)?
{
is_block_finalized_inner::<B, C>(&backend, &client, ethereum_block_hash)
} else {
Ok(false)
}
}
.boxed()
}
}

fn is_block_finalized_inner<B: Block<Hash = H256>, C: HeaderBackend<B> + 'static>(
backend: &FrontierBackend<B>,
client: &C,
raw_hash: H256,
) -> RpcResult<bool> {
let substrate_hash = match frontier_backend_client::load_hash::<B>(backend, raw_hash)? {
// If we find this hash in the frontier data base, we know it is an eth hash
Some(BlockId::Hash(hash)) => hash,
Some(BlockId::Number(_)) => panic!("is_canon test only works with hashes."),
// Otherwise, we assume this is a Substrate hash.
None => raw_hash,
};

// First check whether the block is in the best chain
if !is_canon(client, substrate_hash) {
return Ok(false);
}

// At this point we know the block in question is in the current best chain.
// It's just a question of whether it is in the finalized prefix or not
let query_height = client
.number(substrate_hash)
.expect("No sp_blockchain::Error should be thrown when looking up hash")
.expect("Block is already known to be canon, so it must be in the chain");
let finalized_height = client.info().finalized_number;

Ok(query_height <= finalized_height)
}
16 changes: 8 additions & 8 deletions contracts/uniswap-contracts/address.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"chainx-testnet": {
"WETH": "0x51abb19F1ebc7B64040aFd0ef3C789d75C8707e0",
"Factory": "0xe922A087CA192ffdaA32eCB6A3ad3320bfFDd83b",
"WETH": "0xFd861b4eeA652d92a679504a8b8341655340eA5d",
"Factory": "0x9480C6Fa8768F18cc0cfe35694Ce8C1660A02B5A",
"Factory Feeto": "0xcAF084133CBdBE27490d3afB0Da220a40C32E307",
"RouterV02": "0x990e95C5CddAf60785ad92caF86Dea6c83F6f867",
"Multicall": "0x784ea1566D3820DaE6aa220eA8C5a0836297fcD3",
"RouterV02": "0x054Fa299e4cFE7cDC87a5998eA4e7cfccB3bc4C2",
"Multicall": "0x5a00E2FBCBa6790b20c338DF1eE9842f584DCfdA",
"ENSRegistry": "0x21b782d2357797D78D48813048033F187AAa2F9C",
"init_code_hash": "0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c"
},
"chainx-mainnet": {
"WETH": "0x09Ff8E49D0EA411A3422ed95E8f5497D4241F532",
"Factory": "0x356FD03E73ce821d5F7dFea51d1cB336EeFd67b1",
"WETH": "0x9D1dFD3a94C218B5dF3A1875157A936f99EcAA76",
"Factory": "0xc3A4f9Bab921FbEB26595659C1511e9F24647902",
"Factory Feeto": "0xe4401b593DCBA4c057fccD1baa3ab9cFacfa64d8",
"RouterV02": "0xC7Dd38D6D161e2a440617508308639B2d701F633",
"Multicall": "0x79eA96a9857b3fcf7B037E5EE98D4da63Ff1934A",
"RouterV02": "0xA932608b834b3711FeECBC0e7403B5B530531E0b",
"Multicall": "0x04C3FAfaf3dBb75537c9e524835107E56130aa0A",
"ENSRegistry": "0x8F8F6B104190a4A24CcFf7B4006Ea7A59baeAf81",
"init_code_hash": "0x01429e880a7972ebfbba904a5bbe32a816e78273e4b38ffa6bdeaebce8adba7c"
}
Expand Down
2 changes: 1 addition & 1 deletion executor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainx-executor"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainx-primitives"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/assets-registrar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-assets-registrar"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/gateway/bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-gateway-bitcoin"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/gateway/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-gateway-common"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/genesis-builder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-genesis-builder"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/io/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-io"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/mining/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-mining-common"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/mining/staking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-mining-staking"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-protocol"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-rpc"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion primitives/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "xp-runtime"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
5 changes: 4 additions & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainx-rpc"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down Expand Up @@ -43,6 +43,9 @@ substrate-frame-rpc-system = { git = "https://github.com/chainx-org/substrate",
chainx-primitives = { path = "../primitives" }
xp-runtime = { path = "../primitives/runtime" }

# Finality-rpc
bevm-finality-rpc = { path = "../client/rpc/finality" }

# ChainX pallets
xpallet-assets-rpc = { path = "../xpallets/assets/rpc" }
xpallet-assets-rpc-runtime-api = { path = "../xpallets/assets/rpc/runtime-api" }
Expand Down
6 changes: 6 additions & 0 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ where
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
A: ChainApi<Block = Block> + 'static,
{
use bevm_finality_rpc::{BevmFinality, BevmFinalityApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
use substrate_frame_rpc_system::{FullSystem, SystemApi};
use xpallet_assets_rpc::{Assets, XAssetsApi};
Expand Down Expand Up @@ -338,6 +339,11 @@ where
fee_history_cache,
)));

io.extend_with(BevmFinalityApi::to_delegate(BevmFinality::new(
client.clone(),
backend.clone(),
)));

if let Some(filter_pool) = filter_pool {
io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(
client.clone(),
Expand Down
2 changes: 1 addition & 1 deletion runtime/chainx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chainx-runtime"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion runtime/chainx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("chainx"),
impl_name: create_runtime_str!("chainx-net"),
authoring_version: 1,
spec_version: 33,
spec_version: 34,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 7,
Expand Down
2 changes: 1 addition & 1 deletion runtime/dev/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dev-runtime"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion runtime/dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("chainx"),
impl_name: create_runtime_str!("chainx-dev"),
authoring_version: 1,
spec_version: 33,
spec_version: 34,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 7,
Expand Down
2 changes: 1 addition & 1 deletion runtime/malan/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "malan-runtime"
version = "5.2.2"
version = "5.2.3"
authors = ["The ChainX Authors"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion runtime/malan/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("chainx"),
impl_name: create_runtime_str!("chainx-malan"),
authoring_version: 1,
spec_version: 33,
spec_version: 34,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 7,
Expand Down
Loading
Loading