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

Update depedencies #250

Merged
merged 10 commits into from
Jul 10, 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
1,817 changes: 888 additions & 929 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ rosetta-types = { path = "rosetta-types" }
rosetta-utils = { path = "rosetta-utils", default-features = false }

## Crates we want all members to use the same version
jsonrpsee = { version = "0.22", default-features = false }
jsonrpsee = { version = "0.24", default-features = false }
parity-scale-codec = { version = "3.6" }
tokio = { version = "1.32" }
subxt = { version = "0.34", default-features = false }
tokio = { version = "1.37" }
subxt = { version = "0.37", default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
scale-info = { version = "2.3" }
scale-info = { version = "2.11" }

# Used to sign substrate transactions, must be the same version used by subxt
# https://github.com/paritytech/subxt/blob/v0.34.0/Cargo.toml#L125
sp-keyring = { version = "31.0" }
# https://github.com/paritytech/subxt/blob/v0.37.0/Cargo.toml#L138
sp-keyring = { version = "34.0" }
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repository = "https://github.com/analog-labs/chain-connectors"
description = "Arbitrum unit test."

[dev-dependencies]
alloy-sol-types = { version = "0.6" }
alloy-sol-types = { version = "0.7" }
anyhow = "1.0"
ethers = { version = "2.0", default-features = true, features = ["abigen", "rustls", "ws"] }
ethers-solc = "2.0"
Expand Down
Binary file added chains/astar/config/res/astar-90.scale
Binary file not shown.
Binary file removed chains/astar/config/res/astar-dev.scale
Binary file not shown.
2 changes: 1 addition & 1 deletion chains/astar/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::sync::Arc;
// Generate an interface that we can use from the node's metadata.
#[cfg(feature = "astar-metadata")]
pub mod metadata {
#[subxt::subxt(runtime_metadata_path = "res/astar-dev.scale")]
#[subxt::subxt(runtime_metadata_path = "res/astar-90.scale")]
pub mod dev {}
}

Expand Down
4 changes: 2 additions & 2 deletions chains/astar/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ subxt = { workspace = true, features = ["substrate-compat"] }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }

[dev-dependencies]
alloy-primitives = { version = "0.6" }
alloy-sol-types = { version = "0.6" }
alloy-primitives = { version = "0.7" }
alloy-sol-types = { version = "0.7" }
ethers-solc = "2.0"
rosetta-client.workspace = true
rosetta-docker = { workspace = true, features = ["tests"] }
Expand Down
7 changes: 4 additions & 3 deletions chains/astar/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use serde::{Deserialize, Serialize};
use std::sync::Arc;
use subxt::{
backend::{
legacy::{rpc_methods::BlockNumber, LegacyBackend, LegacyRpcMethods},
legacy::{rpc_methods::BlockNumber, LegacyBackendBuilder, LegacyRpcMethods},
rpc::RpcClient,
BlockRef,
},
Expand Down Expand Up @@ -75,7 +75,7 @@ impl AstarClient {
let ws_client = default_client(url, None).await?;
let rpc_client = RpcClient::new(ws_client.clone());
let rpc_methods = LegacyRpcMethods::<PolkadotConfig>::new(rpc_client.clone());
let backend = LegacyBackend::new(rpc_client);
let backend = LegacyBackendBuilder::new().build(rpc_client);
let substrate_client =
OnlineClient::<PolkadotConfig>::from_backend(Arc::new(backend)).await?;
let ethereum_client =
Expand Down Expand Up @@ -279,7 +279,8 @@ impl BlockchainClient for AstarClient {
};

// Build the transfer transaction
let balance_transfer_tx = astar_metadata::tx().balances().transfer(dest.into(), value);
let balance_transfer_tx =
astar_metadata::tx().balances().transfer_allow_death(dest.into(), value);
let alice = sp_keyring::AccountKeyring::Alice.pair();
let signer = PairSigner::<PolkadotConfig, _>::new(alice);

Expand Down
2 changes: 1 addition & 1 deletion chains/ethereum/backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "Ethereum RPC method."
async-trait = "0.1"
auto_impl = "1.1"
futures-core = { version = "0.3", default-features = false, features = ["alloc"] }
jsonrpsee-core = { version = "0.22", default-features = false, features = ["client"], optional = true }
jsonrpsee-core = { version = "0.24", default-features = false, features = ["client"], optional = true }
parity-scale-codec = { workspace = true, features = ["derive"], optional = true }
rosetta-ethereum-types = { workspace = true, features = ["with-rlp", "with-crypto"] }
scale-info = { version = "2.9", default-features = false, features = ["derive"], optional = true }
Expand Down
11 changes: 5 additions & 6 deletions chains/ethereum/backend/src/jsonrpsee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ use crate::{
string::ToString,
vec::Vec,
},
BlockRange, MaybeDeserializeOwned,
BlockRange, BoxFuture, MaybeDeserializeOwned,
};
use async_trait::async_trait;
use futures_core::future::BoxFuture;

use crate::{AccessListWithGasUsed, AtBlock, CallRequest, EthereumPubSub, EthereumRpc, ExitReason};
pub use jsonrpsee_core as core;
use jsonrpsee_core::{
client::{ClientT, SubscriptionClientT},
client::{ClientT, Subscription, SubscriptionClientT},
rpc_params, ClientError as Error,
};
use rosetta_ethereum_types::{
Expand Down Expand Up @@ -396,9 +395,9 @@ impl<T> EthereumPubSub for Adapter<T>
where
T: SubscriptionClientT + Send + Sync,
{
type SubscriptionError = <Self as EthereumRpc>::Error;
type NewHeadsStream<'a> = jsonrpsee_core::client::Subscription<RpcBlock<H256>> where Self: 'a;
type LogsStream<'a> = jsonrpsee_core::client::Subscription<Log> where Self: 'a;
type SubscriptionError = serde_json::Error;
type NewHeadsStream<'a> = Subscription<RpcBlock<H256>> where Self: 'a;
type LogsStream<'a> = Subscription<Log> where Self: 'a;

/// Fires a notification each time a new header is appended to the chain, including chain
/// reorganizations.
Expand Down
6 changes: 3 additions & 3 deletions chains/ethereum/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Ethereum rosetta server."
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
fork-tree = { version = "12.0" }
fork-tree = { version = "13.0" }
futures-timer = "3.0"
futures-util = "0.3"
hashbrown = "0.14"
Expand All @@ -29,8 +29,8 @@ tracing = "0.1"
url = "2.4"

[dev-dependencies]
alloy-primitives = { version = "0.6" }
alloy-sol-types = { version = "0.6" }
alloy-primitives = { version = "0.7" }
alloy-sol-types = { version = "0.7" }
ethers-solc = "2.0"
rosetta-client.workspace = true
rosetta-docker = { workspace = true, features = ["tests"] }
Expand Down
Binary file removed chains/polkadot/config/res/polkadot-v1000001.scale
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion chains/polkadot/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod metadata {
#[cfg(feature = "polkadot-metadata")]
pub mod polkadot {
#[subxt::subxt(
runtime_metadata_path = "res/polkadot-v1000001.scale",
runtime_metadata_path = "res/polkadot-v1002006.scale",
derive_for_all_types = "Clone, Eq, PartialEq"
)]
pub mod dev {}
Expand Down
4 changes: 2 additions & 2 deletions chains/polkadot/server/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use scale_info::{
use serde_json::{Map, Value, Value as SerdeValue};
use subxt::{
dynamic::Value as SubxtValue,
ext::scale_value::{self, scale::TypeId, BitSequence, ValueDef},
ext::scale_value::{self, BitSequence, ValueDef},
metadata::types::StorageEntryType,
OnlineClient,
};
Expand Down Expand Up @@ -321,7 +321,7 @@ fn make_bit_sequence(
Ok(SubxtValue::bit_sequence(bits_array))
}

fn scale_to_serde_json(data: ValueDef<TypeId>) -> Result<SerdeValue> {
fn scale_to_serde_json(data: ValueDef<u32>) -> Result<SerdeValue> {
match data {
scale_value::ValueDef::Composite(val) => match val {
scale_value::Composite::Named(named_composite) => {
Expand Down
19 changes: 8 additions & 11 deletions chains/polkadot/server/src/chains/polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ use rosetta_config_polkadot::metadata::polkadot::dev;
use std::borrow::Borrow;
use subxt::{
config::polkadot,
storage::address,
utils::{AccountId32, MultiAddress},
ext::subxt_core::{
storage::address::{StaticAddress, StaticStorageKey},
tx::payload::StaticPayload,
utils::{AccountId32, MultiAddress, Yes},
},
};

pub type Config = SubxtConfigAdapter<PolkadotConfig>;
pub type ExtrinsicParams = polkadot::PolkadotExtrinsicParams<Config>;
pub type OtherParams = <ExtrinsicParams as subxt::config::ExtrinsicParams<Config>>::OtherParams;
pub type OtherParams = <ExtrinsicParams as subxt::config::ExtrinsicParams<Config>>::Params;
pub type PairSigner = subxt::tx::PairSigner<Config, sp_keyring::sr25519::sr25519::Pair>;

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -37,20 +40,14 @@ impl ClientConfig for PolkadotConfig {

fn account_info(
account: impl Borrow<AccountId32>,
) -> address::Address<
address::StaticStorageMapKey,
Self::AccountInfo,
address::Yes,
address::Yes,
(),
> {
) -> StaticAddress<StaticStorageKey<Self::AccountId>, Self::AccountInfo, Yes, Yes, ()> {
dev::storage().system().account(account)
}

fn transfer_keep_alive(
dest: MultiAddress<AccountId32, ()>,
value: u128,
) -> ::subxt::tx::Payload<Self::TransferKeepAlive> {
) -> StaticPayload<Self::TransferKeepAlive> {
dev::tx().balances().transfer_keep_alive(dest, value)
}

Expand Down
19 changes: 8 additions & 11 deletions chains/polkadot/server/src/chains/westend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ use rosetta_config_polkadot::metadata::westend::dev;
use std::borrow::Borrow;
use subxt::{
config::{polkadot::PolkadotExtrinsicParams, PolkadotConfig},
storage::address,
utils::{AccountId32, MultiAddress},
ext::subxt_core::{
storage::address::{StaticAddress, StaticStorageKey},
tx::payload::StaticPayload,
utils::{AccountId32, MultiAddress, Yes},
},
};

pub type Config = SubxtConfigAdapter<WestendDevConfig>;
pub type ExtrinsicParams = PolkadotExtrinsicParams<Config>;
pub type OtherParams = <ExtrinsicParams as subxt::config::ExtrinsicParams<Config>>::OtherParams;
pub type OtherParams = <ExtrinsicParams as subxt::config::ExtrinsicParams<Config>>::Params;
pub type PairSigner = subxt::tx::PairSigner<Config, sp_keyring::sr25519::sr25519::Pair>;

#[derive(Debug, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -37,20 +40,14 @@ impl ClientConfig for WestendDevConfig {

fn account_info(
account: impl Borrow<AccountId32>,
) -> address::Address<
address::StaticStorageMapKey,
Self::AccountInfo,
address::Yes,
address::Yes,
(),
> {
) -> StaticAddress<StaticStorageKey<Self::AccountId>, Self::AccountInfo, Yes, Yes, ()> {
dev::storage().system().account(account)
}

fn transfer_keep_alive(
dest: MultiAddress<AccountId32, ()>,
value: u128,
) -> ::subxt::tx::Payload<Self::TransferKeepAlive> {
) -> StaticPayload<Self::TransferKeepAlive> {
dev::tx().balances().transfer_keep_alive(dest, value)
}

Expand Down
13 changes: 4 additions & 9 deletions chains/polkadot/server/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@ use crate::types::{BlockIdentifier, ClientConfig, SubxtConfigAdapter};
use anyhow::Context;
use std::{borrow::Borrow, future::Future, sync::Arc};
use subxt::{
backend::{
rpc::{RpcClient, RpcClientT},
RuntimeVersion,
},
backend::rpc::{RpcClient, RpcClientT},
blocks::BlockRef,
client::RuntimeVersion,
metadata::Metadata,
utils::AccountId32,
};

type Config<T> = SubxtConfigAdapter<T>;
type OnlineClient<T> = subxt::OnlineClient<Config<T>>;
type LegacyRpcMethods<T> = subxt::backend::legacy::LegacyRpcMethods<Config<T>>;
type LegacyBackend<T> = subxt::backend::legacy::LegacyBackend<Config<T>>;
// type PairSigner<T> = subxt::tx::PairSigner<Config<T>, <T as ClientConfig>::Pair>;
// type Block<T> = subxt::blocks::Block<Config<T>, OnlineClient<T>>;
type BlockDetails<T> = subxt::backend::legacy::rpc_methods::BlockDetails<Config<T>>;

pub struct SubstrateClient<T: ClientConfig> {
Expand All @@ -32,7 +27,7 @@ impl<T: ClientConfig> SubstrateClient<T> {
pub async fn from_client<C: RpcClientT>(client: C) -> anyhow::Result<Self> {
let rpc_client = RpcClient::new(client);
let rpc_methods = LegacyRpcMethods::<T>::new(rpc_client.clone());
let backend = LegacyBackend::<T>::new(rpc_client);
let backend = subxt::backend::legacy::LegacyBackendBuilder::new().build(rpc_client);
let client = OnlineClient::<T>::from_backend(Arc::new(backend)).await?;
Ok(Self { client, rpc_methods })
}
Expand Down Expand Up @@ -117,7 +112,7 @@ impl<T: ClientConfig> SubstrateClient<T> {
pub async fn faucet(
&self,
signer: T::Pair,
dest: subxt::utils::MultiAddress<AccountId32, ()>,
dest: subxt::ext::subxt_core::utils::MultiAddress<AccountId32, ()>,
value: u128,
) -> anyhow::Result<T::Hash> {
let tx = T::transfer_keep_alive(dest, value);
Expand Down
40 changes: 21 additions & 19 deletions chains/polkadot/server/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
use rosetta_core::{traits::Member, types::PartialBlockIdentifier};
use std::{borrow::Borrow, fmt::Debug, marker::PhantomData};
use subxt::{
blocks::StaticExtrinsic,
config::{ExtrinsicParams, Hasher, Header},
ext::{codec::Encode, scale_decode::DecodeAsType, scale_encode::EncodeAsType},
utils::{AccountId32, MultiAddress},
ext::{
codec::Encode,
scale_decode::DecodeAsType,
scale_encode::{EncodeAsFields, EncodeAsType},
subxt_core::{
config::BlockHash,
metadata::DecodeWithMetadata,
storage::address::{StaticAddress, StaticStorageKey},
tx::{payload::StaticPayload, signer::Signer},
utils::{AccountId32, MultiAddress, Yes},
},
},
Config as SubxtConfig,
};

pub trait ClientConfig: Debug + Clone + PartialEq + Eq + Sized + Send + Sync + 'static {
/// The output of the `Hasher` function.
type Hash: subxt::config::BlockHash;
type Hash: BlockHash;

/// The account ID type.
type AccountId: Member + Encode;
Expand All @@ -32,36 +43,27 @@ pub trait ClientConfig: Debug + Clone + PartialEq + Eq + Sized + Send + Sync + '
type OtherParams: Default + Send + Sync + 'static;

/// This type defines the extrinsic extra and additional parameters.
type ExtrinsicParams: ExtrinsicParams<SubxtConfigAdapter<Self>, OtherParams = Self::OtherParams>;
type ExtrinsicParams: ExtrinsicParams<SubxtConfigAdapter<Self>, Params = Self::OtherParams>;

/// This is used to identify an asset in the `ChargeAssetTxPayment` signed extension.
type AssetId: Debug + Clone + Encode + DecodeAsType + EncodeAsType;

type AccountInfo: Member + subxt::metadata::DecodeWithMetadata;
type AccountInfo: Member + DecodeWithMetadata;

type TransferKeepAlive: Member
+ subxt::blocks::StaticExtrinsic
+ subxt::ext::scale_encode::EncodeAsFields;
type TransferKeepAlive: Member + StaticExtrinsic + EncodeAsFields;

type Pair: subxt::tx::Signer<SubxtConfigAdapter<Self>> + Send + Sync + 'static;
type Pair: Signer<SubxtConfigAdapter<Self>> + Send + Sync + 'static;

fn account_info(
account: impl Borrow<AccountId32>,
) -> ::subxt::storage::address::Address<
::subxt::storage::address::StaticStorageMapKey,
Self::AccountInfo,
::subxt::storage::address::Yes,
::subxt::storage::address::Yes,
(),
>;
) -> StaticAddress<StaticStorageKey<Self::AccountId>, Self::AccountInfo, Yes, Yes, ()>;

fn transfer_keep_alive(
dest: MultiAddress<AccountId32, ()>,
value: u128,
) -> ::subxt::tx::Payload<Self::TransferKeepAlive>;
) -> StaticPayload<Self::TransferKeepAlive>;

fn other_params(
) -> <Self::ExtrinsicParams as ExtrinsicParams<SubxtConfigAdapter<Self>>>::OtherParams;
fn other_params() -> Self::OtherParams;
}

pub struct SubxtConfigAdapter<T>(PhantomData<T>);
Expand Down
4 changes: 1 addition & 3 deletions chains/polygon/rosetta-testing-polygon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ license = "MIT"
repository = "https://github.com/analog-labs/chain-connectors"
description = "Polygon rosetta test."

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
alloy-sol-types = { version = "0.6" }
alloy-sol-types = { version = "0.7" }
anyhow = "1.0"
ethers = { version = "2.0", default-features = true, features = ["abigen", "rustls", "ws"] }
ethers-solc = "2.0"
Expand Down
Loading
Loading