Skip to content

Commit

Permalink
change existential deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
masterdubs committed May 10, 2021
1 parent 94940e1 commit 1d66657
Show file tree
Hide file tree
Showing 8 changed files with 749 additions and 151 deletions.
492 changes: 349 additions & 143 deletions Cargo.lock

Large diffs are not rendered by default.

217 changes: 217 additions & 0 deletions customSpec.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ jsonrpc-core = '15.1.0'
structopt = '0.3.8'

# Substrate dependencies
node-primitives = { version = "2.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking = { version = "3.1.0", git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-contracts = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-contracts-rpc = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master" }
sc-basic-authorship = { version = "0.9.0",git = "https://github.com/paritytech/substrate", branch = "master" }
sc-cli = { version = "0.9.0", git = "https://github.com/paritytech/substrate", branch = "master", features = ['wasmtime'] }
Expand Down
9 changes: 7 additions & 2 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sp_core::{Pair, Public, sr25519};
use galital_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
SudoConfig, SystemConfig, WASM_BINARY, Signature
SudoConfig, SystemConfig, WASM_BINARY, Signature, ContractsConfig
};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_finality_grandpa::AuthorityId as GrandpaId;
Expand Down Expand Up @@ -131,7 +131,7 @@ fn testnet_genesis(
initial_authorities: Vec<(AuraId, GrandpaId)>,
root_key: AccountId,
endowed_accounts: Vec<AccountId>,
_enable_println: bool,
enable_println: bool,
) -> GenesisConfig {
GenesisConfig {
frame_system: SystemConfig {
Expand All @@ -149,6 +149,11 @@ fn testnet_genesis(
pallet_grandpa: GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
},
pallet_contracts: ContractsConfig {
// println should only be enabled on development chains
current_schedule: pallet_contracts::Schedule::default()
.enable_println(enable_println),
},
pallet_sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
Expand Down
2 changes: 1 addition & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use galital_runtime::Block;

impl SubstrateCli for Cli {
fn impl_name() -> String {
"Substrate Node".into()
"Galital".into()
}

fn impl_version() -> String {
Expand Down
9 changes: 8 additions & 1 deletion node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

use std::sync::Arc;

use galital_runtime::{opaque::Block, AccountId, Balance, Index};
use galital_runtime::{opaque::Block, AccountId, Balance, Index, BlockNumber, Hash};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::{Error as BlockChainError, HeaderMetadata, HeaderBackend};
use sp_block_builder::BlockBuilder;
pub use sc_rpc_api::DenyUnsafe;
use sp_transaction_pool::TransactionPool;



/// Full client dependencies.
pub struct FullDeps<C, P> {
/// The client instance to use.
Expand All @@ -33,11 +34,13 @@ pub fn create_full<C, P>(
C: HeaderBackend<Block> + HeaderMetadata<Block, Error=BlockChainError> + 'static,
C: Send + Sync + 'static,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: pallet_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance, BlockNumber, Hash>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
{
use substrate_frame_rpc_system::{FullSystem, SystemApi};
use pallet_contracts_rpc::{Contracts, ContractsApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};

let mut io = jsonrpc_core::IoHandler::default();
Expand All @@ -51,6 +54,10 @@ pub fn create_full<C, P>(
SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe))
);

io.extend_with(
ContractsApi::to_delegate(Contracts::new(client.clone()))
);

io.extend_with(
TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone()))
);
Expand Down
15 changes: 15 additions & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ frame-system-benchmarking = { version = "3.0.0", git = "https://github.com/parit
frame-system-rpc-runtime-api = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-aura = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-balances = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-contracts = { version = "3.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-contracts-primitives = { version = "3.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "master"}
pallet-contracts-rpc-runtime-api = { version = "3.0.0", default-features = false, git = "https://github.com/paritytech/substrate", branch = "master"}
pallet-grandpa = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-randomness-collective-flip = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-sudo = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand All @@ -50,13 +53,19 @@ sp-session = { version = "3.0.0", git = "https://github.com/paritytech/substrate
sp-std = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-transaction-pool = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-version = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-io = { version = "3.0.0", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }


# NFT dependencies
pallet-atomic-swap = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
orml-nft = { git = "https://github.com/starkleytech/open-runtime-module-library", branch = "master", default-features = false }
nft-factory-pallet = { git = 'https://github.com/starkleytech/nft-factory-pallet', branch = 'master', default-features = false }

#Bridge
chainbridge = { git = 'https://github.com/starkleytech/chainbridge-substrate', branch = 'main', default-features = false }
bridge-pallet = { git = 'https://github.com/starkleytech/bridge-pallet', branch = 'main', default-features = false }



[features]
default = ['std']
Expand All @@ -79,6 +88,9 @@ std = [
'frame-system-rpc-runtime-api/std',
'pallet-aura/std',
'pallet-balances/std',
"pallet-contracts/std",
"pallet-contracts-primitives/std",
"pallet-contracts-rpc-runtime-api/std",
'pallet-grandpa/std',
'pallet-randomness-collective-flip/std',
'pallet-sudo/std',
Expand All @@ -96,7 +108,10 @@ std = [
'sp-std/std',
'sp-transaction-pool/std',
'sp-version/std',
"sp-io/std",
"pallet-atomic-swap/std",
"orml-nft/std",
'nft-factory-pallet/std',
'chainbridge/std',
'bridge-pallet/std'
]
153 changes: 149 additions & 4 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ use sp_version::RuntimeVersion;
#[cfg(feature = "std")]
use sp_version::NativeVersion;

use sp_io::hashing::{blake2_128};


// A few exports that help ease life for downstream crates.
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand All @@ -35,6 +38,7 @@ pub use frame_support::{
weights::{
Weight, IdentityFee,
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass,
},
};
use pallet_transaction_payment::CurrencyAdapter;
Expand Down Expand Up @@ -65,6 +69,8 @@ pub type Hash = sp_core::H256;
/// Digest item type.
pub type DigestItem = generic::DigestItem<Hash>;

use pallet_contracts::weights::WeightInfo;

/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
/// the specifics of the runtime. They can then be made to be agnostic over specific formats
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
Expand Down Expand Up @@ -124,8 +130,25 @@ pub fn native_version() -> NativeVersion {
}
}


pub const MILLICENTS: Balance = 1_000_000_000;
pub const CENTS: Balance = 1_000 * MILLICENTS;
pub const DOLLARS: Balance = 100 * CENTS;

const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS
}


/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers.
/// This is used to limit the maximal weight of a single extrinsic.
const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
/// by Operational extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);



parameter_types! {
pub const Version: RuntimeVersion = VERSION;
pub const BlockHashCount: BlockNumber = 2400;
Expand Down Expand Up @@ -224,8 +247,10 @@ impl pallet_timestamp::Config for Runtime {
type WeightInfo = ();
}



parameter_types! {
pub const ExistentialDeposit: u128 = 500;
pub const ExistentialDeposit: u128 = 1;
pub const MaxLocks: u32 = 50;
}

Expand All @@ -252,11 +277,87 @@ impl pallet_transaction_payment::Config for Runtime {
type FeeMultiplierUpdate = ();
}

parameter_types! {
pub TombstoneDeposit: Balance = deposit(
1,
<pallet_contracts::Pallet<Runtime>>::contract_info_size(),
);
pub DepositPerContract: Balance = TombstoneDeposit::get();
pub const DepositPerStorageByte: Balance = deposit(0, 1);
pub const DepositPerStorageItem: Balance = deposit(1, 0);
pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);
pub const SurchargeReward: Balance = 150 * MILLICENTS;
pub const SignedClaimHandicap: u32 = 2;
pub const MaxDepth: u32 = 32;
pub const MaxValueSize: u32 = 16 * 1024;
// The lazy deletion runs inside on_initialize.
pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *
BlockWeights::get().max_block;
// The weight needed for decoding the queue should be less or equal than a fifth
// of the overall weight dedicated to the lazy deletion.
pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (
<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -
<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)
)) / 5) as u32;
pub MaxCodeSize: u32 = 128 * 1024;
}

impl pallet_contracts::Config for Runtime {
type Time = Timestamp;
type Randomness = RandomnessCollectiveFlip;
type Currency = Balances;
type Event = Event;
type RentPayment = ();
type SignedClaimHandicap = SignedClaimHandicap;
type TombstoneDeposit = TombstoneDeposit;
type DepositPerContract = DepositPerContract;
type DepositPerStorageByte = DepositPerStorageByte;
type DepositPerStorageItem = DepositPerStorageItem;
type RentFraction = RentFraction;
type SurchargeReward = SurchargeReward;
type MaxDepth = MaxDepth;
type MaxValueSize = MaxValueSize;
type WeightPrice = pallet_transaction_payment::Module<Self>;
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
type ChainExtension = ();
type DeletionQueueDepth = DeletionQueueDepth;
type DeletionWeightLimit = DeletionWeightLimit;
type MaxCodeSize = MaxCodeSize;
}

impl pallet_sudo::Config for Runtime {
type Event = Event;
type Call = Call;
}

parameter_types! {
pub const ChainId: u8 = 1;
pub const ProposalLifetime: BlockNumber = 1000;
}

impl chainbridge::Config for Runtime {
type Event = Event;
type AdminOrigin = frame_system::EnsureRoot<Self::AccountId>;
type Proposal = Call;
type ChainId = ChainId;
type ProposalLifetime = ProposalLifetime;
}

parameter_types! {
pub HashId: chainbridge::ResourceId = chainbridge::derive_resource_id(1, &blake2_128(b"hash"));
// Note: Chain ID is 0 indicating this is native to another chain
pub NativeTokenId: chainbridge::ResourceId = chainbridge::derive_resource_id(0, &blake2_128(b"BTAL"));

}

impl bridge_pallet::Config for Runtime {
type Event = Event;
type BridgeOrigin = chainbridge::EnsureBridge<Runtime>;
type Currency = pallet_balances::Pallet<Runtime>;
type HashId = HashId;
type NativeTokenId = NativeTokenId;
}

parameter_types! {
pub const ProofLimit: u32 = 10_000;
}
Expand Down Expand Up @@ -292,11 +393,14 @@ construct_runtime!(
Aura: pallet_aura::{Pallet, Config<T>},
Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Contracts: pallet_contracts::{Pallet, Call, Config<T>, Storage, Event<T>},
TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
Sudo: pallet_sudo::{Pallet, Call, Config<T>, Storage, Event<T>},
AtomicSwap: pallet_atomic_swap::{Pallet, Call, Storage, Event<T>},
Nft: orml_nft::{Pallet, Call, Storage},
NftFactory: nft_factory_pallet::{Pallet, Call, Storage, Event<T>},
BridgeOracle: chainbridge::{Pallet, Call, Storage, Event<T>},
Bridge: bridge_pallet::{Pallet, Call, Event<T>},
}
);

Expand Down Expand Up @@ -375,9 +479,7 @@ impl_runtime_apis! {
data.check_extrinsics(&block)
}

fn random_seed() -> <Block as BlockT>::Hash {
RandomnessCollectiveFlip::random_seed().0
}

}

impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
Expand Down Expand Up @@ -443,6 +545,47 @@ impl_runtime_apis! {
}
}

impl pallet_contracts_rpc_runtime_api::ContractsApi<
Block, AccountId, Balance, BlockNumber, Hash,
>
for Runtime
{
fn call(
origin: AccountId,
dest: AccountId,
value: Balance,
gas_limit: u64,
input_data: Vec<u8>,
) -> pallet_contracts_primitives::ContractExecResult {
Contracts::bare_call(origin, dest, value, gas_limit, input_data)
}

fn instantiate(
origin: AccountId,
endowment: Balance,
gas_limit: u64,
code: pallet_contracts_primitives::Code<Hash>,
data: Vec<u8>,
salt: Vec<u8>,
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>
{
Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true)
}

fn get_storage(
address: AccountId,
key: [u8; 32],
) -> pallet_contracts_primitives::GetStorageResult {
Contracts::get_storage(address, key)
}

fn rent_projection(
address: AccountId,
) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {
Contracts::rent_projection(address)
}
}

impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
fn account_nonce(account: AccountId) -> Index {
System::account_nonce(account)
Expand Down Expand Up @@ -499,6 +642,8 @@ impl_runtime_apis! {
add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_timestamp, Timestamp);
add_benchmark!(params, batches, pallet_contracts, Contracts);


if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down

0 comments on commit 1d66657

Please sign in to comment.