Skip to content

Commit

Permalink
New token pallet (#134)
Browse files Browse the repository at this point in the history
* Updates

* Updates

* Merge pallet_assets w/ orml_tokens

* Pallets compile, node doesn't

* [wip] comment out frontier for now

* Comment out EVM/Frontier, get node compiling

* remove frontier service file from git

* Newlines

* ups (#133)

* Test updates

* Fix merge account

* Fix no_op test

* Updates, dust test not working

* Fix all tests

Co-authored-by: Shady Khalifa <shekohex@gmail.com>
  • Loading branch information
drewstone and Shady Khalifa committed Apr 19, 2021
1 parent b89233e commit f325656
Show file tree
Hide file tree
Showing 23 changed files with 6,993 additions and 2,445 deletions.
3,611 changes: 2,002 additions & 1,609 deletions Cargo.lock

Large diffs are not rendered by default.

269 changes: 135 additions & 134 deletions Cargo.toml

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ substrate-frame-rpc-system = { version = "3.0.0" }

pallet-contracts-rpc = { version = "3.0.0" }

fc-consensus = { git = "https://github.com/paritytech/frontier" }
fp-consensus = { git = "https://github.com/paritytech/frontier" }
fc-rpc = { git = "https://github.com/paritytech/frontier" }
fp-rpc = { git = "https://github.com/paritytech/frontier" }
fc-rpc-core = { git = "https://github.com/paritytech/frontier" }
fc-db = { git = "https://github.com/paritytech/frontier" }
fc-mapping-sync = { git = "https://github.com/paritytech/frontier" }
# fc-consensus = { git = "https://github.com/paritytech/frontier" }
# fp-consensus = { git = "https://github.com/paritytech/frontier" }
# fc-rpc = { git = "https://github.com/paritytech/frontier" }
# fp-rpc = { git = "https://github.com/paritytech/frontier" }
# fc-rpc-core = { git = "https://github.com/paritytech/frontier" }
# fc-db = { git = "https://github.com/paritytech/frontier" }
# fc-mapping-sync = { git = "https://github.com/paritytech/frontier" }

pallet-evm = { git = "https://github.com/paritytech/frontier" }
pallet-ethereum = { git = "https://github.com/paritytech/frontier" }
# pallet-evm = { git = "https://github.com/paritytech/frontier" }
# pallet-ethereum = { git = "https://github.com/paritytech/frontier" }
merkle = { package = "pallet-merkle", version = "3.0.0", path = "../pallets/merkle" }
merkle-rpc = { package = "pallet-merkle-rpc", version = "3.0.0", path = "../pallets/merkle/rpc" }

Expand Down
45 changes: 23 additions & 22 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use frame_benchmarking::whitelisted_caller;
use node_template_runtime::{
AccountId, AuraConfig, BalancesConfig, EVMConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig,
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig,
// EVMConfig,
SystemConfig, WASM_BINARY,
};
use sc_service::ChainType;
Expand Down Expand Up @@ -134,37 +135,37 @@ fn testnet_genesis(
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
) -> GenesisConfig {
let alice_evm_account_id = H160::from_str("19e7e376e7c213b7e7e7e46cc70a5dd086daff2a").unwrap();
let mut evm_accounts = BTreeMap::new();
evm_accounts.insert(alice_evm_account_id, pallet_evm::GenesisAccount {
nonce: 0.into(),
balance: U256::from(123456_123_000_000_000_000_000u128),
storage: BTreeMap::new(),
code: vec![],
});
// let alice_evm_account_id = H160::from_str("19e7e376e7c213b7e7e7e46cc70a5dd086daff2a").unwrap();
// let mut evm_accounts = BTreeMap::new();
// evm_accounts.insert(alice_evm_account_id, pallet_evm::GenesisAccount {
// nonce: 0.into(),
// balance: U256::from(123456_123_000_000_000_000_000u128),
// storage: BTreeMap::new(),
// code: vec![],
// });

GenesisConfig {
frame_system: Some(SystemConfig {
frame_system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
}),
pallet_balances: Some(BalancesConfig {
},
pallet_balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
}),
pallet_contracts: Some(Default::default()),
pallet_aura: Some(AuraConfig {
},
pallet_contracts: Default::default(),
pallet_aura: AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
}),
pallet_grandpa: Some(GrandpaConfig {
},
pallet_grandpa: GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
}),
pallet_sudo: Some(SudoConfig {
},
pallet_sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
}),
pallet_evm: Some(EVMConfig { accounts: evm_accounts }),
pallet_ethereum: Some(Default::default()),
},
// pallet_evm: Some(EVMConfig { accounts: evm_accounts }),
// pallet_ethereum: Some(Default::default()),
}
}
5 changes: 4 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ pub fn run() -> sc_cli::Result<()> {
runner.run_node_until_exit(|config| async move {
match config.role {
Role::Light => service::new_light(config),
_ => service::new_full(config, cli.run.enable_dev_signer),
_ => service::new_full(
config,
// cli.run.enable_dev_signer
),
}
.map_err(sc_cli::Error::Service)
})
Expand Down
120 changes: 60 additions & 60 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#![warn(missing_docs)]

use fc_rpc::{SchemaV1Override, StorageOverride};
use fc_rpc_core::types::{FilterPool, PendingTransactions};
// use fc_rpc::{SchemaV1Override, StorageOverride};
// use fc_rpc_core::types::{FilterPool, PendingTransactions};
use jsonrpc_pubsub::manager::SubscriptionManager;
use merkle_rpc::{MerkleApi, MerkleClient};
use node_template_runtime::{opaque::Block, AccountId, Balance, BlockNumber, Hash, Index};
use pallet_ethereum::EthereumStorageSchema;
// use pallet_ethereum::EthereumStorageSchema;
use sc_client_api::{
backend::{AuxStore, StorageProvider},
client::BlockchainEvents,
Expand Down Expand Up @@ -63,16 +63,16 @@ pub struct FullDeps<C, P, SC, B> {
pub select_chain: SC,
/// The Node authority flag
pub is_authority: bool,
/// Whether to enable dev signer
pub enable_dev_signer: bool,
// /// Whether to enable dev signer
// pub enable_dev_signer: bool,
/// Network service
pub network: Arc<NetworkService<Block, Hash>>,
/// Ethereum pending transactions.
pub pending_transactions: PendingTransactions,
/// EthFilterApi pool.
pub filter_pool: Option<FilterPool>,
/// Backend.
pub backend: Arc<fc_db::Backend<Block>>,
// /// Ethereum pending transactions.
// pub pending_transactions: PendingTransactions,
// /// EthFilterApi pool.
// pub filter_pool: Option<FilterPool>,
// /// Backend.
// pub backend: Arc<fc_db::Backend<Block>>,
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// GRANDPA specific dependencies.
Expand All @@ -93,18 +93,18 @@ where
C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber>,
C::Api: BlockBuilder<Block>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
// C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
C::Api: BlockBuilder<Block>,
C::Api: merkle::MerkleApi<Block>,
P: TransactionPool<Block = Block> + 'static,
SC: SelectChain<Block> + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
{
use fc_rpc::{
EthApi, EthApiServer, EthDevSigner, EthFilterApi, EthFilterApiServer, EthPubSubApi, EthPubSubApiServer,
EthSigner, HexEncodedIdProvider, NetApi, NetApiServer, Web3Api, Web3ApiServer,
};
// use fc_rpc::{
// EthApi, EthApiServer, EthDevSigner, EthFilterApi, EthFilterApiServer, EthPubSubApi, EthPubSubApiServer,
// EthSigner, HexEncodedIdProvider, NetApi, NetApiServer, Web3Api, Web3ApiServer,
// };
use pallet_contracts_rpc::{Contracts, ContractsApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
use substrate_frame_rpc_system::{FullSystem, SystemApi};
Expand All @@ -114,13 +114,13 @@ where
client,
pool,
select_chain: _,
enable_dev_signer,
// enable_dev_signer,
is_authority,
network,
pending_transactions,
// pending_transactions,
deny_unsafe,
filter_pool,
backend,
// filter_pool,
// backend,
grandpa,
} = deps;
let GrandpaDeps {
Expand All @@ -144,46 +144,46 @@ where
client.clone(),
)));

let mut signers = Vec::new();
if enable_dev_signer {
signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);
}
let mut overrides = BTreeMap::new();
overrides.insert(
EthereumStorageSchema::V1,
Box::new(SchemaV1Override::new(client.clone())) as Box<dyn StorageOverride<_> + Send + Sync>,
);
io.extend_with(EthApiServer::to_delegate(EthApi::new(
client.clone(),
pool.clone(),
node_template_runtime::TransactionConverter,
network.clone(),
pending_transactions.clone(),
signers,
overrides,
backend,
is_authority,
)));

if let Some(filter_pool) = filter_pool {
io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(
client.clone(),
filter_pool.clone(),
500 as usize, // max stored filters
)));
}

io.extend_with(NetApiServer::to_delegate(NetApi::new(client.clone(), network.clone())));
io.extend_with(Web3ApiServer::to_delegate(Web3Api::new(client.clone())));
io.extend_with(EthPubSubApiServer::to_delegate(EthPubSubApi::new(
pool.clone(),
client.clone(),
network,
SubscriptionManager::<HexEncodedIdProvider>::with_id_provider(
HexEncodedIdProvider::default(),
Arc::new(subscription_task_executor),
),
)));
// let mut signers = Vec::new();
// if enable_dev_signer {
// signers.push(Box::new(EthDevSigner::new()) as Box<dyn EthSigner>);
// }
// let mut overrides = BTreeMap::new();
// overrides.insert(
// EthereumStorageSchema::V1,
// Box::new(SchemaV1Override::new(client.clone())) as Box<dyn StorageOverride<_> + Send + Sync>,
// );
// io.extend_with(EthApiServer::to_delegate(EthApi::new(
// client.clone(),
// pool.clone(),
// node_template_runtime::TransactionConverter,
// network.clone(),
// pending_transactions.clone(),
// signers,
// overrides,
// backend,
// is_authority,
// )));

// if let Some(filter_pool) = filter_pool {
// io.extend_with(EthFilterApiServer::to_delegate(EthFilterApi::new(
// client.clone(),
// filter_pool.clone(),
// 500 as usize, // max stored filters
// )));
// }

// io.extend_with(NetApiServer::to_delegate(NetApi::new(client.clone(), network.clone())));
// io.extend_with(Web3ApiServer::to_delegate(Web3Api::new(client.clone())));
// io.extend_with(EthPubSubApiServer::to_delegate(EthPubSubApi::new(
// pool.clone(),
// client.clone(),
// network,
// SubscriptionManager::<HexEncodedIdProvider>::with_id_provider(
// HexEncodedIdProvider::default(),
// Arc::new(subscription_task_executor),
// ),
// )));

io.extend_with(MerkleApi::to_delegate(MerkleClient::new(client.clone())));

Expand Down

0 comments on commit f325656

Please sign in to comment.