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

Feat/substrate v1.0.0 Fix Tests #836

Merged
merged 40 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ee9d022
Fix AssetsExt tests
JasonTulp Apr 16, 2024
02b1dc3
Fix Crowdsale tests
JasonTulp Apr 16, 2024
e177450
Fix Dex tests
JasonTulp Apr 16, 2024
0912857
Fix Doughnut tests
JasonTulp Apr 16, 2024
e6d3154
Fix Erc20-Peg tests
JasonTulp Apr 16, 2024
2b9e343
Fix Evm Chain Id tests
JasonTulp Apr 16, 2024
be4fe45
Fix FeeControl tests
JasonTulp Apr 16, 2024
6e75fe7
Fix FeeProxy tests
JasonTulp Apr 16, 2024
1bfa0fb
Fix MaintenanceMode tests
JasonTulp Apr 16, 2024
2eeb470
Fix Marketplace tests
JasonTulp Apr 16, 2024
227104a
Fix NFT tests
JasonTulp Apr 16, 2024
81adf73
Fix SFT tests
JasonTulp Apr 16, 2024
f8eea21
Fix VTXDistribution tests
JasonTulp Apr 16, 2024
bd59668
Fix XLS20 tests
JasonTulp Apr 16, 2024
a90d7a5
Fix XRPLBridge tests
JasonTulp Apr 16, 2024
284e17a
Fix Echo tests
JasonTulp Apr 16, 2024
4bf5048
Merge remote-tracking branch 'origin/feat/substrate-v1.0.0' into feat…
JasonTulp Apr 16, 2024
cf0e5f6
Fix Futurepass tests
JasonTulp Apr 16, 2024
e7aa0f8
Fix Ethy tests
JasonTulp Apr 17, 2024
1c92ace
Update cargo.toml files to support benchmarking tests
JasonTulp Apr 22, 2024
32345fe
Merge remote-tracking branch 'origin/feat/substrate-v1.0.0' into feat…
JasonTulp Apr 22, 2024
3dcf42b
Fix benchmark tests
JasonTulp Apr 22, 2024
1080a29
Merge remote-tracking branch 'origin/feat/substrate-v1.0.0' into feat…
JasonTulp Apr 30, 2024
e8e0da1
Merge remote-tracking branch 'origin/feat/substrate-v1.0.0' into feat…
JasonTulp May 2, 2024
7045bc9
Merge remote-tracking branch 'origin/feat/substrate-v1.0.0' into feat…
JasonTulp May 7, 2024
ff1428d
Fix assets Config
JasonTulp May 7, 2024
717f41b
Update Futurepass tests
JasonTulp May 8, 2024
9f6af7b
Merge remote-tracking branch 'origin/feat/substrate-v1.0.0' into feat…
JasonTulp May 8, 2024
2ae7206
Fix further test build errors
JasonTulp May 8, 2024
56f8699
Merge remote-tracking branch 'origin/feat/substrate-v1.0.0' into feat…
JasonTulp May 9, 2024
f72ac87
Fix runtime and client tests
JasonTulp May 9, 2024
d8eb451
Add ignore flags for pallet-xrpl failing tests
JasonTulp May 9, 2024
eee88df
Fix fund_authorities_and_accounts test
JasonTulp May 9, 2024
f9ee1a4
Fix multiplier_can_grow_from_zero test
JasonTulp May 9, 2024
08622cc
Add assetsExt fix
JasonTulp May 9, 2024
7d9b14e
Move AssetsExt fix to EVMCurrencyScaler
JasonTulp May 9, 2024
e34fbdc
try-runtime back again.
surangap May 9, 2024
e37aa71
Fix last test
JasonTulp May 10, 2024
97ecb3b
Fix some warnings
JasonTulp May 10, 2024
c692e3a
Fix some more warnings
JasonTulp May 10, 2024
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ sc-consensus-grandpa = { opt-level = 3 }
# end substrate packages
aes = { opt-level = 3 }
blake2 = { opt-level = 3 }
blake2-rfc = { opt-level = 3 }
blake2b_simd = { opt-level = 3 }
blake2s_simd = { opt-level = 3 }
chacha20poly1305 = { opt-level = 3 }
Expand All @@ -60,7 +59,6 @@ hmac = { opt-level = 3 }
httparse = { opt-level = 3 }
integer-sqrt = { opt-level = 3 }
keccak = { opt-level = 3 }
libm = { opt-level = 3 }
librocksdb-sys = { opt-level = 3 }
libsecp256k1 = { opt-level = 3 }
libz-sys = { opt-level = 3 }
Expand All @@ -79,7 +77,6 @@ smallvec = { opt-level = 3 }
snow = { opt-level = 3 }
twox-hash = { opt-level = 3 }
uint = { opt-level = 3 }
wasmi = { opt-level = 3 }
x25519-dalek = { opt-level = 3 }
yamux = { opt-level = 3 }
zeroize = { opt-level = 3 }
2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ rocksdb = ["fc-db/rocksdb"]
runtime-benchmarks = ["frame-benchmarking", "seed-runtime/runtime-benchmarks", "sc-service/runtime-benchmarks"]
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
# in the near future.
try-runtime = ["seed-runtime/try-runtime", "try-runtime-cli"]
try-runtime = ["seed-runtime/try-runtime", "try-runtime-cli/try-runtime", "frame-try-runtime"]
12 changes: 6 additions & 6 deletions client/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ use seed_runtime::{
XRP_ASSET_ID, XRP_DECIMALS, XRP_MINIMUM_BALANCE, XRP_NAME, XRP_SYMBOL,
},
keys::*,
AccountId, AssetsConfig, BabeConfig, Balance, BalancesConfig, EthBridgeConfig, GenesisConfig,
SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig, SudoConfig, SystemConfig,
XRPLBridgeConfig, BABE_GENESIS_EPOCH_CONFIG, WASM_BINARY,
AccountId, AssetsConfig, BabeConfig, Balance, BalancesConfig, EthBridgeConfig,
RuntimeGenesisConfig, SessionConfig, SessionKeys, Signature, StakerStatus, StakingConfig,
SudoConfig, SystemConfig, XRPLBridgeConfig, BABE_GENESIS_EPOCH_CONFIG, WASM_BINARY,
};
use sp_core::{ecdsa, Pair, Public};
use sp_runtime::{
Expand All @@ -36,7 +36,7 @@ use sp_runtime::{
// const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";

/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
pub type ChainSpec = sc_service::GenericChainSpec<RuntimeGenesisConfig>;

/// Type alias for the stash, controller + session key types tuple used by validators
pub type AuthorityKeys = (AccountId, BabeId, ImOnlineId, GrandpaId, EthBridgeId);
Expand Down Expand Up @@ -145,7 +145,7 @@ fn testnet_genesis(
xrp_relayers: Vec<AccountId>,
xrp_door_signers: Vec<EthBridgeId>,
_enable_println: bool,
) -> GenesisConfig {
) -> RuntimeGenesisConfig {
let metadata = vec![
(
ROOT_ASSET_ID,
Expand All @@ -169,7 +169,7 @@ fn testnet_genesis(
}
const VALIDATOR_BOND: Balance = 100_000 * ONE_ROOT;

GenesisConfig {
RuntimeGenesisConfig {
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
Expand Down
8 changes: 0 additions & 8 deletions client/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// You may obtain a copy of the License at the root of this project source code

use crate::custom_commands::VerifyProofSigSubCommand;
use sc_cli::{Error, Result};

#[allow(missing_docs)]
#[derive(Debug, clap::Parser)]
Expand Down Expand Up @@ -42,13 +41,6 @@ pub struct RunCmd {
pub xrp_http: Option<String>,
}

/// Parse HTTP `uri`
fn parse_uri(uri: &str) -> Result<String> {
let _ = url::Url::parse(uri)
.map_err(|_| Error::Input("Invalid external HTTP URI provided".into()))?;
Ok(uri.into())
}

#[derive(Debug, clap::Parser)]
pub struct Cli {
#[clap(subcommand)]
Expand Down
18 changes: 16 additions & 2 deletions client/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
use frame_benchmarking::frame_support::sp_io;
use sc_cli::SubstrateCli;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use sc_service::PartialComponents;
use seed_runtime::Block;

use crate::service::ExecutorDispatch;
use seed_runtime::constants::SLOT_DURATION;
#[cfg(feature = "try-runtime")]
use try_runtime_cli::block_building_info::substrate_info;

impl SubstrateCli for Cli {
fn impl_name() -> String {
"Seed 🌱".into()
Expand Down Expand Up @@ -204,7 +211,14 @@ pub fn run() -> sc_cli::Result<()> {
let task_manager =
sc_service::TaskManager::new(config.tokio_handle.clone(), registry)
.map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?;
Ok((cmd.run::<Block, service::ExecutorDispatch>(config), task_manager))
let info_provider = substrate_info(SLOT_DURATION);
Ok((
cmd.run::<Block, ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<ExecutorDispatch as NativeExecutionDispatch>::ExtendHostFunctions,
>, _>(Some(info_provider)),
task_manager,
))
})
},
#[cfg(not(feature = "try-runtime"))]
Expand Down
4 changes: 1 addition & 3 deletions client/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ use std::{collections::BTreeMap, sync::Arc};

use jsonrpsee::RpcModule;
// Substrate
use core::time::Duration;
use sc_client_api::{
backend::{AuxStore, Backend, StateBackend, StorageProvider},
client::BlockchainEvents,
};
use sc_consensus_epochs::SharedEpochChanges;
use sc_consensus_grandpa::{
FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState,
};
Expand Down Expand Up @@ -226,7 +224,7 @@ where
network,
filter_pool,
frontier_backend,
backend,
backend: _,
Copy link
Contributor

@surangap surangap May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting here for reference. will be addressed in the main PR
check if backend can be removed

max_past_logs,
fee_history_cache,
fee_history_cache_limit,
Expand Down
31 changes: 11 additions & 20 deletions client/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,34 @@

//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.

use futures::{future, StreamExt};

use fc_consensus::FrontierBlockImport;
use fc_db::Backend as FrontierBackend;
use fc_db::{Backend as FrontierBackend, DatabaseSource};
use fc_mapping_sync::{kv::MappingSyncWorker, SyncStrategy};
use fc_rpc::{EthTask, OverrideHandle};
use fc_rpc_core::types::{FeeHistoryCache, FeeHistoryCacheLimit, FilterPool};
use sc_cli::SubstrateCli;
use futures::{future, StreamExt};
use sc_client_api::{
AuxStore, Backend, BlockBackend, BlockchainEvents, StateBackend, StorageProvider,
};
use sc_consensus_babe::{self, SlotProportion};
use sc_consensus_babe::{self, BabeWorkerHandle, SlotProportion};
use sc_consensus_grandpa::SharedVoterState;
pub use sc_executor::NativeElseWasmExecutor;
use sc_keystore::LocalKeystore;
use sc_service::{
error::Error as ServiceError, BasePath, Configuration, TaskManager, WarpSyncParams,
};
use sc_network_sync::SyncingService;
use sc_service::{error::Error as ServiceError, Configuration, TaskManager, WarpSyncParams};
use sc_telemetry::{Telemetry, TelemetryWorker};
use sc_transaction_pool_api::OffchainTransactionPoolFactory;
use sp_runtime::offchain::OffchainStorage;

use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_runtime::{offchain::OffchainStorage, traits::BlakeTwo256};
use std::{
collections::BTreeMap,
path::PathBuf,
sync::{Arc, Mutex},
time::Duration,
};

use fc_db::{kv::DatabaseSettings, DatabaseSource};
use sc_consensus_babe::BabeWorkerHandle;
use sc_network_sync::SyncingService;
use seed_primitives::{ethy::ETH_HTTP_URI, opaque::Block, XRP_HTTP_URI};
use seed_runtime::{self, RuntimeApi};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_runtime::traits::BlakeTwo256;

use crate::{cli::Cli, consensus_data_providers::BabeConsensusDataProvider};

Expand Down Expand Up @@ -261,6 +252,7 @@ pub fn new_partial(
})
}

#[allow(dead_code)]
fn remote_keystore(_url: &String) -> Result<Arc<LocalKeystore>, &'static str> {
// FIXME: here would the concrete keystore be built,
// must return a concrete type (NOT `LocalKeystore`) that
Expand All @@ -269,13 +261,13 @@ fn remote_keystore(_url: &String) -> Result<Arc<LocalKeystore>, &'static str> {
}

/// Builds a new service for a full client.
pub fn new_full(mut config: Configuration, cli: &Cli) -> Result<TaskManager, ServiceError> {
pub fn new_full(config: Configuration, cli: &Cli) -> Result<TaskManager, ServiceError> {
let sc_service::PartialComponents {
client,
backend,
mut task_manager,
import_queue,
mut keystore_container,
keystore_container,
select_chain,
transaction_pool,
other:
Expand Down Expand Up @@ -407,7 +399,6 @@ pub fn new_full(mut config: Configuration, cli: &Cli) -> Result<TaskManager, Ser
let fee_history_cache = fee_history_cache.clone();
let max_past_logs = cli.run.max_past_logs;
let babe_config = babe_link.config().clone();
let shared_epoch_changes = babe_link.epoch_changes().clone();
let pubsub_notification_sinks = pubsub_notification_sinks.clone();

let justification_stream = grandpa_link.justification_stream();
Expand Down
2 changes: 1 addition & 1 deletion ethy-gadget/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ futures = { version = "0.3.24" }
jsonrpsee = { version = "0.16.3", features = ["server", "macros"] }
libsecp256k1 = { version = "0.6.0" }
log = "0.4"
serde = { version = "1.0.131", features = ["derive"] }
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0.64"
rustc-hex = { version = "2.1.0", default-features = false }

Expand Down
4 changes: 2 additions & 2 deletions ethy-gadget/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ use jsonrpsee::{
use log::warn;
use sc_client_api::backend::AuxStore;
use sc_rpc::SubscriptionTaskExecutor;
use sp_api::{BlockId, ProvideRuntimeApi};
use sp_api::{ProvideRuntimeApi};
use sp_core::{Bytes, H256};
use sp_runtime::traits::{Block, Convert};
use std::{hash::Hash, marker::PhantomData, ops::Deref, sync::Arc};
use std::{marker::PhantomData, ops::Deref, sync::Arc};

use ethy_gadget::{notification::EthyEventProofStream, EthyEcdsaToEthereum};
use seed_primitives::{
Expand Down
6 changes: 3 additions & 3 deletions ethy-gadget/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use futures::StreamExt;
use log::{debug, error, info, trace, warn};
use sc_client_api::{Backend, FinalityNotification};
use sc_network_gossip::GossipEngine;
use sp_api::{BlockId, ProvideRuntimeApi};
use sp_api::{ProvideRuntimeApi};
use sp_blockchain::HeaderBackend;
use sp_consensus::SyncOracle;
use sp_runtime::{
Expand Down Expand Up @@ -505,14 +505,14 @@ pub(crate) mod test {
},
witness_record::test::create_witness,
};
use sc_client_api::{AuxStore, FinalizeSummary, UnpinHandle};
use sc_client_api::{AuxStore, FinalizeSummary};
use sc_network_sync::service::chain_sync::SyncingService;
use sc_network_test::{PeersFullClient, TestNetFactory};
use sc_utils::{mpsc::tracing_unbounded, notification::NotificationStream};
use seed_primitives::ethy::{crypto::AuthorityId, EthyChainId, ValidatorSet};
use sp_api::HeaderT;
use substrate_test_runtime_client::{
runtime::{Block, Digest, DigestItem, Header, H256},
runtime::{Block, Digest, DigestItem, Header},
Backend,
};

Expand Down
12 changes: 12 additions & 0 deletions evm-precompiles/utils/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ impl PrecompileHandle for MockHandle {
}
}

fn record_external_cost(
&mut self,
_ref_time: Option<u64>,
_proof_size: Option<u64>,
) -> Result<(), ExitError> {
todo!()
}

fn refund_external_cost(&mut self, _ref_time: Option<u64>, _proof_size: Option<u64>) {
todo!();
}

fn remaining_gas(&self) -> u64 {
self.gas_limit - self.gas_used
}
Expand Down
3 changes: 2 additions & 1 deletion pallet/assets-ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ std = [
"sp-std/std",
"seed-pallet-common/std",
"seed-primitives/std",
"precompile-utils/std"
"precompile-utils/std",
"frame-benchmarking?/std",
]
runtime-benchmarks = ["frame-benchmarking"]
try-runtime = ["frame-support/try-runtime"]
2 changes: 1 addition & 1 deletion pallet/assets-ext/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use jsonrpsee::{
};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
use sp_runtime::{traits::Block as BlockT};

pub use pallet_assets_ext_rpc_runtime_api::{
self as runtime_api, AssetsExtApi as AssetsExtRuntimeApi,
Expand Down
11 changes: 6 additions & 5 deletions pallet/assets-ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
//! It provides a minimal API for authorising holds on asset amounts e.g locking bidder funds of an
//! NFT auction This is similar to 'reserve' which is not implemented for pallet-assets within
//! substrate at this time

#![cfg_attr(not(feature = "std"), no_std)]

pub use pallet::*;
Expand Down Expand Up @@ -84,7 +83,6 @@ pub mod pallet {
use super::*;

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
pub struct Pallet<T>(_);

#[pallet::genesis_config]
Expand Down Expand Up @@ -216,7 +214,7 @@ pub mod pallet {
/// Note, this does not change the deposit when calling create within the assets pallet
/// However that call is filtered
#[pallet::call_index(0)]
#[pallet::weight(< T as Config >::WeightInfo::set_asset_deposit())]
#[pallet::weight(<T as Config>::WeightInfo::set_asset_deposit())]
pub fn set_asset_deposit(
origin: OriginFor<T>,
asset_deposit: DepositBalanceOf<T>,
Expand All @@ -231,7 +229,7 @@ pub mod pallet {
/// Decimals cannot be higher than 18 due to a restriction in the conversion function
/// scale_wei_to_correct_decimals
#[pallet::call_index(1)]
#[pallet::weight(< T as Config >::WeightInfo::create_asset())]
#[pallet::weight(<T as Config>::WeightInfo::create_asset())]
#[transactional]
pub fn create_asset(
origin: OriginFor<T>,
Expand Down Expand Up @@ -499,6 +497,8 @@ impl<T: Config> Mutate<T::AccountId> for Pallet<T> {
preservation,
)
} else {
// Transfers with 0 amount will fail if the destination account does not exist
// This is because the transfer value is less than the existential deposit
<pallet_assets::Pallet<T> as fungibles::Mutate<T::AccountId>>::transfer(
asset_id,
source,
Expand Down Expand Up @@ -528,7 +528,8 @@ impl<T: Config> TransferExt for Pallet<T> {
Error::<T>::BalanceLow
);

for (payee, amount) in transfers.into_iter() {
// Skip zero transfers, these will error within the transfer function
for (payee, amount) in transfers.into_iter().filter(|(_, b)| !b.is_zero()) {
<Self as Mutate<T::AccountId>>::transfer(
asset_id,
who,
Expand Down
Loading