Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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
562 changes: 282 additions & 280 deletions Cargo.lock

Large diffs are not rendered by default.

914 changes: 457 additions & 457 deletions Cargo.toml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "1.48.0"
version = "1.49.0"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down
1 change: 1 addition & 0 deletions integration-tests/src/stableswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use primitives::{constants::time::SECS_PER_BLOCK, BlockNumber};
use sp_runtime::Permill;
use std::sync::Arc;
use test_utils::assert_eq_approx;

pub const DOT: AssetId = 2221;
pub const VDOT: AssetId = 2222;
pub const ADOT: AssetId = 2223;
Expand Down
5 changes: 2 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydradx"
version = "14.3.0"
version = "14.4.0"
description = "Hydration node"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down Expand Up @@ -50,6 +50,7 @@ ethabi = { workspace = true }
# Substrate dependencies
frame-benchmarking = { workspace = true }
frame-benchmarking-cli = { workspace = true, optional = true }
frame-support = { workspace = true }
pallet-transaction-payment-rpc = { workspace = true }
sc-basic-authorship = { workspace = true }
sc-chain-spec = { workspace = true }
Expand Down Expand Up @@ -100,8 +101,6 @@ polkadot-cli = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-service = { workspace = true }

frame-support = { workspace = true }

# Frontier
fc-consensus = { workspace = true }
fc-db = { workspace = true, features = ["default"] }
Expand Down
4 changes: 4 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ pub struct Cli {
#[clap(flatten)]
pub ethereum_config: crate::service::evm::EthereumConfig,

#[arg(long)]
/// Disable overwrite of TX priorities by the client.
pub no_tx_priority_overwrite: bool,
Comment thread
Roznovjak marked this conversation as resolved.
Outdated

/// Liquidation worker configuration
#[clap(flatten)]
pub liquidation_worker_config: crate::liquidation_worker::LiquidationWorkerConfig,
Expand Down
16 changes: 8 additions & 8 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,28 +139,28 @@ pub fn run() -> sc_cli::Result<()> {
Some(Subcommand::CheckBlock(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let partials = new_partial(&config)?;
let partials = new_partial(&config, cli.no_tx_priority_overwrite)?;
Ok((cmd.run(partials.client, partials.import_queue), partials.task_manager))
})
}
Some(Subcommand::ExportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let partials = new_partial(&config)?;
let partials = new_partial(&config, cli.no_tx_priority_overwrite)?;
Ok((cmd.run(partials.client, config.database), partials.task_manager))
})
}
Some(Subcommand::ExportState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let partials = new_partial(&config)?;
let partials = new_partial(&config, cli.no_tx_priority_overwrite)?;
Ok((cmd.run(partials.client, config.chain_spec), partials.task_manager))
})
}
Some(Subcommand::ImportBlocks(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let partials = new_partial(&config)?;
let partials = new_partial(&config, cli.no_tx_priority_overwrite)?;
Ok((cmd.run(partials.client, partials.import_queue), partials.task_manager))
})
}
Expand All @@ -184,7 +184,7 @@ pub fn run() -> sc_cli::Result<()> {
Some(Subcommand::Revert(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.async_run(|config| {
let partials = new_partial(&config)?;
let partials = new_partial(&config, cli.no_tx_priority_overwrite)?;
Ok((cmd.run(partials.client, partials.backend, None), partials.task_manager))
})
}
Expand All @@ -202,14 +202,14 @@ pub fn run() -> sc_cli::Result<()> {
}
}
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = crate::service::new_partial(&config)?;
let partials = crate::service::new_partial(&config, cli.no_tx_priority_overwrite)?;
cmd.run(partials.client)
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) => Err("Storage benchmarking can be enabled with `--features runtime-benchmarks`.".into()),
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config)?;
let partials = new_partial(&config, cli.no_tx_priority_overwrite)?;
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();

Expand Down Expand Up @@ -313,7 +313,7 @@ pub fn run() -> sc_cli::Result<()> {
if config.role.is_authority() { "yes" } else { "no" }
);

crate::service::start_node(config, polkadot_config, cli.ethereum_config, cli.liquidation_worker_config, collator_options, id)
crate::service::start_node(cli, config, polkadot_config, collator_options, id)
.await
.map(|r| r.0)
.map_err(Into::into)
Expand Down
1 change: 1 addition & 0 deletions node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.

pub mod chain_spec;
pub mod cli;
pub mod liquidation_worker;
pub mod rpc;
pub mod service;
76 changes: 70 additions & 6 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#![allow(clippy::all)]

use codec::{Decode, Encode};
use hydradx_runtime::{
opaque::{Block, Hash},
RuntimeApi,
Expand All @@ -41,19 +42,26 @@ use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};

use fc_db::kv::Backend as FrontierBackend;
use fc_rpc_core::types::{FeeHistoryCache, FilterPool};
use fp_self_contained::SelfContainedCall;
use frame_support::traits::GetCallMetadata;
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
use sc_network::NetworkBlock;
use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager};
use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_blockchain::{
EvmTransactionDetail, TransactionDetail, TransactionDetailProvider, TransactionPriorityModule,
TransactionTypeDetail,
};
use sp_keystore::KeystorePtr;
use sp_runtime::traits::Block as BlockT;
use std::{collections::BTreeMap, sync::Mutex};
use substrate_prometheus_endpoint::Registry;

pub(crate) mod evm;
use crate::{chain_spec, liquidation_worker, rpc};
use crate::{chain_spec, cli, liquidation_worker, rpc};

type ParachainClient = TFullClient<
Block,
Expand All @@ -68,12 +76,56 @@ type ParachainBackend = TFullBackend<Block>;

type ParachainBlockImport = TParachainBlockImport<Block, Arc<ParachainClient>, ParachainBackend>;

pub struct TxDetailProvider;
impl TransactionDetailProvider for TxDetailProvider {
type Block = Block;

fn get_transaction_detail(&self, tx: <Self::Block as BlockT>::Extrinsic) -> Option<TransactionDetail> {
let opaque_tx_encoded = tx.encode();
let tx = hydradx_runtime::UncheckedExtrinsic::decode(&mut &*opaque_tx_encoded).ok()?;
let call_metadata = tx.0.function.get_call_metadata();

match tx.0.function {
hydradx_runtime::RuntimeCall::Ethereum(pallet_ethereum::Call::transact { ref transaction }) => {
if let Some(Ok(signer)) = tx.0.function.check_self_contained() {
let action = match transaction.clone() {
pallet_ethereum::Transaction::Legacy(legacy_transaction) => legacy_transaction.action,
pallet_ethereum::Transaction::EIP2930(eip2930_transaction) => eip2930_transaction.action,
pallet_ethereum::Transaction::EIP1559(eip1559_transaction) => eip1559_transaction.action,
};
let maybe_call_address = match action {
pallet_ethereum::TransactionAction::Call(call_address) => Some(call_address),
_ => None,
};

Some(TransactionDetail {
module: call_metadata.pallet_name,
extrinsic: call_metadata.function_name,
transaction_data: Some(TransactionTypeDetail::Evm(EvmTransactionDetail {
call_address: maybe_call_address,
signer: signer,
})),
})
} else {
None
}
}
_ => Some(TransactionDetail {
module: call_metadata.pallet_name,
extrinsic: call_metadata.function_name,
transaction_data: None,
}),
}
}
}

/// Starts a `ServiceBuilder` for a full service.
///
/// Use this macro if you don't actually need the full service, but just the builder in order to
/// be able to perform chain operations.
pub fn new_partial(
config: &Configuration,
no_tx_priority_overwrite: bool,
) -> Result<
PartialComponents<
ParachainClient,
Expand Down Expand Up @@ -118,12 +170,23 @@ pub fn new_partial(
.with_runtime_cache_size(config.executor.runtime_cache_size)
.build();

let tx_priority_json = if no_tx_priority_overwrite {
None
} else {
Some(include_str!("./tx_priority.json"))
};

let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts_record_import::<Block, RuntimeApi, _>(
config,
telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()),
executor,
true,
Some(TransactionPriorityModule::<Block>::new(
// Updating the file is not enough. The client needs to be rebuilt.
tx_priority_json,
Box::new(TxDetailProvider),
)),
)?;

let client = Arc::new(client);
Expand Down Expand Up @@ -200,10 +263,11 @@ async fn start_node_impl(
liquidation_worker_config: liquidation_worker::LiquidationWorkerConfig,
collator_options: CollatorOptions,
para_id: ParaId,
no_tx_priority_overwrite: bool,
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
let parachain_config = prepare_node_config(parachain_config);

let params = new_partial(&parachain_config)?;
let params = new_partial(&parachain_config, no_tx_priority_overwrite)?;
let (block_import, mut telemetry, telemetry_worker_handle, frontier_backend, filter_pool, fee_history_cache) =
params.other;

Expand Down Expand Up @@ -523,20 +587,20 @@ fn start_consensus(

/// Start a parachain node.
pub async fn start_node(
cli: cli::Cli,
parachain_config: Configuration,
polkadot_config: Configuration,
ethereum_config: evm::EthereumConfig,
liquidation_worker_config: liquidation_worker::LiquidationWorkerConfig,
collator_options: CollatorOptions,
para_id: ParaId,
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient>)> {
start_node_impl(
parachain_config,
polkadot_config,
ethereum_config,
liquidation_worker_config,
cli.ethereum_config,
cli.liquidation_worker_config,
collator_options,
para_id,
cli.no_tx_priority_overwrite,
)
.await
}
24 changes: 24 additions & 0 deletions node/src/tx_priority.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[
{
"module": "Ethereum",
"extrinsic": "transact",
"transaction_data": {
"Evm": {
"call_address": "0xdee629af973ebf5bf261ace12ffd1900ac715f5e",
"signer": "0x33a5e905fB83FcFB62B0Dd1595DfBc06792E054e"
}
},
"priority": 100000
},
{
"module": "Ethereum",
"extrinsic": "transact",
"transaction_data": {
"Evm": {
"call_address": "0x48ae7803cd09c48434e3fc5629f15fb76f0b5ce5",
"signer": "0xff0c624016c873d359dde711b42a2f475a5a07d3"
}
},
"priority": 100000
}
]
Loading