Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
78752e5
Only client side compile errors
dastanbeksamatov Aug 3, 2023
1a5189c
Upgrade to v1.0.0
dastanbeksamatov Aug 4, 2023
d16b040
Add grandpa bridge to runtime
dastanbeksamatov Aug 4, 2023
e43fdac
Fix clippy and tests
dastanbeksamatov Aug 4, 2023
3414679
Merge branch 'dev' of github-freeverse:freeverseio/laos-ownership-nod…
dastanbeksamatov Aug 4, 2023
ef4e8ae
Merge branch 'dev' into feat/grandpa-bridge
Aug 4, 2023
00262c9
Fix lints
dastanbeksamatov Aug 4, 2023
ade7089
Merge branch 'feat/grandpa-bridge' of github-freeverse:freeverseio/la…
dastanbeksamatov Aug 4, 2023
e02fff8
Fix tests and clippy
dastanbeksamatov Aug 4, 2023
b0bb716
Remove comment
dastanbeksamatov Aug 4, 2023
cc97592
Add ownership chain relayer part
dastanbeksamatov Aug 4, 2023
72b663d
Merge branch 'dev' of github-freeverse:freeverseio/laos-ownership-nod…
dastanbeksamatov Aug 4, 2023
c73309b
Fix tests
dastanbeksamatov Aug 4, 2023
c154b1e
Remove 0x from hex
dastanbeksamatov Aug 4, 2023
1852460
Add bridge relayer
dastanbeksamatov Aug 15, 2023
436593c
Update branch commits
dastanbeksamatov Aug 17, 2023
b69e233
Working state
dastanbeksamatov Aug 22, 2023
8201b0a
Add laos relay
dastanbeksamatov Aug 22, 2023
147051e
Remove unused deps
dastanbeksamatov Aug 22, 2023
9b9b661
Fix lints and prepare for PR
dastanbeksamatov Aug 22, 2023
9926e23
Fix clippy
dastanbeksamatov Aug 22, 2023
1da04d9
Merge branch 'dev' of github-freeverse:freeverseio/laos-ownership-nod…
dastanbeksamatov Aug 22, 2023
68dd5a1
Generate new lock file
dastanbeksamatov Aug 22, 2023
184d0f4
Evochain different branch
dastanbeksamatov Aug 24, 2023
dead57c
Add documentation
dastanbeksamatov Aug 24, 2023
0775b4b
Remove millau related code
dastanbeksamatov Aug 24, 2023
c28b64a
Improve documentation
dastanbeksamatov Aug 24, 2023
a88adf6
Fix lint
dastanbeksamatov Aug 24, 2023
7bad16d
Remove bridge relayer
dastanbeksamatov Aug 25, 2023
e911754
Merge branch 'dev' of github-freeverse:freeverseio/laos-ownership-nod…
dastanbeksamatov Aug 25, 2023
f22143b
Use workspace deps
dastanbeksamatov Aug 25, 2023
0522701
Change crate authors
dastanbeksamatov Aug 25, 2023
4bb12b3
Revert gitignore
dastanbeksamatov Aug 28, 2023
5f60293
Update parity bridges common branch
dastanbeksamatov Aug 29, 2023
3b11c46
Update crate name
dastanbeksamatov Aug 29, 2023
56a4bd8
removed wrong comment
asiniscalchi Aug 29, 2023
147485e
fmt
asiniscalchi Aug 29, 2023
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
Next Next commit
Only client side compile errors
  • Loading branch information
dastanbeksamatov committed Aug 3, 2023
commit 78752e5eb18efed944444c498bcded080ccf6aff
1,715 changes: 895 additions & 820 deletions Cargo.lock

Large diffs are not rendered by default.

274 changes: 137 additions & 137 deletions Cargo.toml

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ fn testnet_genesis(
code: laos_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!")
.to_vec(),
..Default::default()
},
// Configure additional assets here
// For example, this configures asset "ALT1" & "ALT2" with owners, alice and bob, respectively
Expand Down Expand Up @@ -222,7 +223,7 @@ fn testnet_genesis(
// .filter_map(|(idx, acc)| if idx % 2 == 0 { Some(acc.clone()) } else { None })
// .collect::<Vec<_>>(),
// },
parachain_info: laos_runtime::ParachainInfoConfig { parachain_id: id },
parachain_info: laos_runtime::ParachainInfoConfig { parachain_id: id, ..Default::default() },
collator_selection: laos_runtime::CollatorSelectionConfig {
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
candidacy_bond: EXISTENTIAL_DEPOSIT * 16,
Expand All @@ -245,11 +246,11 @@ fn testnet_genesis(
aura: Default::default(),
aura_ext: Default::default(),
parachain_system: Default::default(),
polkadot_xcm: laos_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) },
polkadot_xcm: laos_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), ..Default::default() },
sudo: laos_runtime::SudoConfig { key: root_key },
transaction_payment: Default::default(),
// EVM compatibility
evm_chain_id: laos_runtime::EVMChainIdConfig { chain_id: 1000 },
evm_chain_id: laos_runtime::EVMChainIdConfig { chain_id: 1000, Default::default() },
evm: laos_runtime::EVMConfig {
accounts: {
let mut map = BTreeMap::new();
Expand Down Expand Up @@ -307,6 +308,7 @@ fn testnet_genesis(
);
map
},
..Default::default()
},
ethereum: Default::default(),
// dynamic_fee: Default::default(),
Expand Down
34 changes: 15 additions & 19 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
use crate::{
chain_spec,
cli::{Cli, RelayChainCli, Subcommand},
service::{/*db_config_dir,*/ new_partial, ParachainNativeExecutor},
service::{self, /*db_config_dir,*/ new_partial, ParachainNativeExecutor},
};

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Expand Down Expand Up @@ -69,10 +69,6 @@ impl SubstrateCli for Cli {
fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
load_spec(id)
}

fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
&laos_runtime::VERSION
}
}

impl SubstrateCli for RelayChainCli {
Expand Down Expand Up @@ -115,10 +111,6 @@ impl SubstrateCli for RelayChainCli {
.load_spec(id),
}
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
polkadot_cli::Cli::native_runtime_version(chain_spec)
}
}

macro_rules! construct_async_run {
Expand Down Expand Up @@ -203,10 +195,11 @@ pub fn run() -> Result<()> {
},
Some(Subcommand::ExportGenesisState(cmd)) => {
let runner = cli.create_runner(cmd)?;
runner.sync_run(|_config| {
let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
let state_version = Cli::native_runtime_version(&spec).state_version();
cmd.run::<Block>(&*spec, state_version)
runner.sync_run(|config| {
// let spec = cli.load_spec(&cmd.shared_params.chain.clone().unwrap_or_default())?;
// let state_version = Cli::native_runtime_version(&spec).state_version();
let partials = service::new_partial(&config, &cli.eth)?;
cmd.run::<Block>(&*config.chain_spec, &partials.client)
})
},
Some(Subcommand::ExportGenesisWasm(cmd)) => {
Expand All @@ -220,35 +213,38 @@ pub fn run() -> Result<()> {
let runner = cli.create_runner(cmd)?;
// Switch on the concrete benchmark sub-command-
match cmd {
BenchmarkCmd::Pallet(cmd) =>
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| cmd.run::<Block, ParachainNativeExecutor>(config))
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
},
}
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config, &eth_cfg)?;
cmd.run(partials.client)
}),
#[cfg(not(feature = "runtime-benchmarks"))]
BenchmarkCmd::Storage(_) =>
BenchmarkCmd::Storage(_) => {
return Err(sc_cli::Error::Input(
"Compile with --features=runtime-benchmarks \
to enable storage benchmarks."
.into(),
)
.into()),
.into())
},
#[cfg(feature = "runtime-benchmarks")]
BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config, &eth_cfg)?;
let db = partials.backend.expose_db();
let storage = partials.backend.expose_storage();
cmd.run(config, partials.client.clone(), db, storage)
}),
BenchmarkCmd::Machine(cmd) =>
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())),
BenchmarkCmd::Machine(cmd) => {
runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone()))
},
// NOTE: this allows the Client to leniently implement
// new benchmark commands without requiring a companion MR.
#[allow(unreachable_patterns)]
Expand Down
2 changes: 1 addition & 1 deletion precompile/living-assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ scale-info = { workspace = true, features = [
] }

# Frontier
fp-evm = { workspace = true }
fp-evm = { workspace = true, features = ["serde"] }
pallet-evm = { workspace = true }

# Substrate
Expand Down
5 changes: 3 additions & 2 deletions precompile/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
# There's a problem with --all-features when this is moved under dev-deps
evm = { workspace = true, features = ["std"], optional = true }
evm = { workspace = true, optional = true }
impl-trait-for-tuples = { workspace = true }
num_enum = { workspace = true }
sha3 = { workspace = true }
Expand Down Expand Up @@ -38,12 +38,13 @@ hex-literal = { workspace = true }
[features]
default = ["std"]
std = [
"evm/std",
"evm",
"parity-scale-codec/std",
"fp-evm/std",
"frame-support/std",
"frame-system/std",
"pallet-evm/std",
"evm/with-serde",
"sp-core/std",
"sp-io/std",
"sp-std/std",
Expand Down
142 changes: 71 additions & 71 deletions precompile/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,75 +147,75 @@ impl LogExt for Log {
}
}

/// Helper functions requiring a Runtime.
/// This runtime must of course implement `pallet_evm::Config`.
#[derive(Clone, Copy, Debug)]
pub struct RuntimeHelper<Runtime>(PhantomData<Runtime>);

impl<Runtime> RuntimeHelper<Runtime>
where
Runtime: pallet_evm::Config,
Runtime::RuntimeCall: Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo,
{
/// Try to dispatch a Substrate call.
/// Return an error if there are not enough gas, or if the call fails.
/// If successful returns the used gas using the Runtime GasWeightMapping.
pub fn try_dispatch<Call>(
handle: &mut impl PrecompileHandleExt,
origin: <Runtime::RuntimeCall as Dispatchable>::RuntimeOrigin,
call: Call,
) -> EvmResult<()>
where
Runtime::RuntimeCall: From<Call>,
{
let call = Runtime::RuntimeCall::from(call);
let dispatch_info = call.get_dispatch_info();

// Make sure there is enough gas.
let remaining_gas = handle.remaining_gas();
let required_gas = Runtime::GasWeightMapping::weight_to_gas(dispatch_info.weight);
if required_gas > remaining_gas {
return Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas })
}

// Dispatch call.
// It may be possible to not record gas cost if the call returns Pays::No.
// However while Substrate handle checking weight while not making the sender pay for it,
// the EVM doesn't. It seems this safer to always record the costs to avoid unmetered
// computations.
let result = call
.dispatch(origin)
.map_err(|e| revert(alloc::format!("Dispatched call failed with error: {:?}", e)))?;

let used_weight = result.actual_weight;

let used_gas =
Runtime::GasWeightMapping::weight_to_gas(used_weight.unwrap_or(dispatch_info.weight));

handle.record_cost(used_gas)?;

Ok(())
}
}

impl<Runtime> RuntimeHelper<Runtime>
where
Runtime: pallet_evm::Config,
{
/// Cost of a Substrate DB write in gas.
pub fn db_write_gas_cost() -> u64 {
<Runtime as pallet_evm::Config>::GasWeightMapping::weight_to_gas(
<Runtime as frame_system::Config>::DbWeight::get().writes(1),
)
}

/// Cost of a Substrate DB read in gas.
pub fn db_read_gas_cost() -> u64 {
<Runtime as pallet_evm::Config>::GasWeightMapping::weight_to_gas(
<Runtime as frame_system::Config>::DbWeight::get().reads(1),
)
}
}
// /// Helper functions requiring a Runtime.
// /// This runtime must of course implement `pallet_evm::Config`.
// #[derive(Clone, Copy, Debug)]
// pub struct RuntimeHelper<Runtime>(PhantomData<Runtime>);

// impl<Runtime> RuntimeHelper<Runtime>
// where
// Runtime: pallet_evm::Config,
// Runtime::RuntimeCall: Dispatchable<PostInfo = PostDispatchInfo> + GetDispatchInfo,
// {
// /// Try to dispatch a Substrate call.
// /// Return an error if there are not enough gas, or if the call fails.
// /// If successful returns the used gas using the Runtime GasWeightMapping.
// pub fn try_dispatch<Call>(
// handle: &mut impl PrecompileHandleExt,
// origin: <Runtime::RuntimeCall as Dispatchable>::RuntimeOrigin,
// call: Call,
// ) -> EvmResult<()>
// where
// Runtime::RuntimeCall: From<Call>,
// {
// let call = Runtime::RuntimeCall::from(call);
// let dispatch_info = call.get_dispatch_info();

// // Make sure there is enough gas.
// let remaining_gas = handle.remaining_gas();
// let required_gas = Runtime::GasWeightMapping::weight_to_gas(dispatch_info.weight);
// if required_gas > remaining_gas {
// return Err(PrecompileFailure::Error { exit_status: ExitError::OutOfGas })
// }

// // Dispatch call.
// // It may be possible to not record gas cost if the call returns Pays::No.
// // However while Substrate handle checking weight while not making the sender pay for it,
// // the EVM doesn't. It seems this safer to always record the costs to avoid unmetered
// // computations.
// let result = call
// .dispatch(origin)
// .map_err(|e| revert(alloc::format!("Dispatched call failed with error: {:?}", e)))?;

// let used_weight = result.actual_weight;

// let used_gas =
// Runtime::GasWeightMapping::weight_to_gas(used_weight.unwrap_or(dispatch_info.weight));

// handle.record_cost(used_gas)?;

// Ok(())
// }
// }

// impl<Runtime> RuntimeHelper<Runtime>
// where
// Runtime: pallet_evm::Config + frame_system::Config,
// {
// /// Cost of a Substrate DB write in gas.
// pub fn db_write_gas_cost() -> u64 {
// <Runtime as pallet_evm::Config>::GasWeightMapping::weight_to_gas(
// <Runtime as frame_system::Config>::DbWeight::get().writes(1),
// )
// }

// /// Cost of a Substrate DB read in gas.
// pub fn db_read_gas_cost() -> u64 {
// <Runtime as pallet_evm::Config>::GasWeightMapping::weight_to_gas(
// <Runtime as frame_system::Config>::DbWeight::get().reads(1),
// )
// }
// }

/// Represents modifiers a Solidity function can be annotated with.
#[derive(Copy, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -343,11 +343,11 @@ fn check_function_modifier(
modifier: FunctionModifier,
) -> EvmResult {
if is_static && modifier != FunctionModifier::View {
return Err(revert("can't call non-static function in static context"))
return Err(revert("can't call non-static function in static context"));
}

if modifier != FunctionModifier::Payable && context.apparent_value > U256::zero() {
return Err(revert("function is not payable"))
return Err(revert("function is not payable"));
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ parachains-common = { workspace = true }

# Frontier
fp-rpc = { workspace = true }
fp-self-contained = { workspace = true }
fp-self-contained = { workspace = true, features = ["serde"] }

# Frontier FRAME
pallet-base-fee = { workspace = true }
Expand Down
Loading