diff --git a/core/src/client/client.rs b/core/src/client/client.rs index 2e3e9c6bb1..11bc8a2657 100644 --- a/core/src/client/client.rs +++ b/core/src/client/client.rs @@ -33,7 +33,6 @@ use crate::transaction::{ LocalizedTransaction, PendingVerifiedTransactions, UnverifiedTransaction, VerifiedTransaction, }; use crate::types::{BlockId, BlockStatus, TransactionId, VerificationQueueInfo as BlockQueueInfo}; -use crate::MemPoolMinFees; use cdb::{new_journaldb, Algorithm, AsHashDB}; use cio::IoChannel; use ckey::{Address, NetworkId, PlatformAddress}; @@ -699,10 +698,6 @@ impl MiningBlockChainClient for Client { fn register_immune_users(&self, immune_user_vec: Vec
) { self.importer.miner.register_immune_users(immune_user_vec) } - - fn mem_pool_min_fees(&self) -> MemPoolMinFees { - self.importer.miner.get_options().mem_pool_min_fees - } } impl FindDoubleVoteHandler for Client { diff --git a/core/src/client/mod.rs b/core/src/client/mod.rs index 6da6d4cd02..ea5e11be34 100644 --- a/core/src/client/mod.rs +++ b/core/src/client/mod.rs @@ -33,7 +33,6 @@ use crate::blockchain_info::BlockChainInfo; use crate::consensus::EngineError; use crate::encoded; use crate::error::{BlockImportError, Error as GenericError}; -use crate::miner::MemPoolMinFees; use crate::transaction::{LocalizedTransaction, PendingVerifiedTransactions, VerifiedTransaction}; use crate::types::{BlockId, BlockStatus, TransactionId, VerificationQueueInfo as BlockQueueInfo}; use cdb::DatabaseError; @@ -262,8 +261,6 @@ pub trait MiningBlockChainClient: BlockChainClient + BlockProducer + FindDoubleV /// Append designated users to the immune user list. fn register_immune_users(&self, immune_user_vec: Vec
); - - fn mem_pool_min_fees(&self) -> MemPoolMinFees; } /// Provides methods to access database. diff --git a/core/src/client/test_client.rs b/core/src/client/test_client.rs index 2cd54dd9f3..d1e123e439 100644 --- a/core/src/client/test_client.rs +++ b/core/src/client/test_client.rs @@ -40,7 +40,7 @@ use crate::consensus::EngineError; use crate::db::{COL_STATE, NUM_COLUMNS}; use crate::encoded; use crate::error::{BlockImportError, Error as GenericError}; -use crate::miner::{MemPoolMinFees, Miner, MinerService, TransactionImportResult}; +use crate::miner::{Miner, MinerService, TransactionImportResult}; use crate::scheme::Scheme; use crate::transaction::{LocalizedTransaction, PendingVerifiedTransactions, VerifiedTransaction}; use crate::types::{BlockId, TransactionId, VerificationQueueInfo as QueueInfo}; @@ -362,10 +362,6 @@ impl MiningBlockChainClient for TestBlockChainClient { fn register_immune_users(&self, immune_user_vec: Vec
) { self.miner.register_immune_users(immune_user_vec) } - - fn mem_pool_min_fees(&self) -> MemPoolMinFees { - self.miner.get_options().mem_pool_min_fees - } } impl AccountData for TestBlockChainClient { diff --git a/core/src/codechain_machine.rs b/core/src/codechain_machine.rs index 8a6bba2209..9b2b740664 100644 --- a/core/src/codechain_machine.rs +++ b/core/src/codechain_machine.rs @@ -21,8 +21,6 @@ use crate::error::Error; use crate::transaction::{UnverifiedTransaction, VerifiedTransaction}; use ckey::Address; use cstate::{StateError, TopState, TopStateView}; -use ctypes::errors::SyntaxError; -use ctypes::transaction::Action; use ctypes::{CommonParams, Header}; use std::convert::TryInto; @@ -42,25 +40,6 @@ impl CodeChainMachine { &self.params } - /// Does basic verification of the transaction. - pub fn verify_transaction_with_params( - &self, - tx: &UnverifiedTransaction, - common_params: &CommonParams, - ) -> Result<(), Error> { - let min_cost = Self::min_cost(common_params, &tx.transaction().action); - if tx.transaction().fee < min_cost { - return Err(SyntaxError::InsufficientFee { - minimal: min_cost, - got: tx.transaction().fee, - } - .into()) - } - tx.verify_with_params(common_params)?; - - Ok(()) - } - /// Verify a particular transaction's seal is valid. pub fn verify_transaction_seal(p: UnverifiedTransaction, _header: &Header) -> Result { Ok(p.try_into()?) @@ -78,32 +57,6 @@ impl CodeChainMachine { Ok(()) } - pub fn min_cost(params: &CommonParams, action: &Action) -> u64 { - match action { - Action::Pay { - .. - } => params.min_pay_transaction_cost(), - Action::CreateShard { - .. - } => params.min_create_shard_transaction_cost(), - Action::SetShardOwners { - .. - } => params.min_set_shard_owners_transaction_cost(), - Action::SetShardUsers { - .. - } => params.min_set_shard_users_transaction_cost(), - Action::Custom { - .. - } => params.min_custom_transaction_cost(), - Action::ShardStore { - .. - } => { - // FIXME - 0 - } - } - } - pub fn balance(&self, live: &ExecutedBlock, address: &Address) -> Result { Ok(live.state().balance(address).map_err(StateError::from)?) } diff --git a/core/src/consensus/mod.rs b/core/src/consensus/mod.rs index 351b18e6a1..a95c84cb3a 100644 --- a/core/src/consensus/mod.rs +++ b/core/src/consensus/mod.rs @@ -341,7 +341,8 @@ pub trait CodeChainEngine: ConsensusEngine { action.verify(common_params)?; } - self.machine().verify_transaction_with_params(tx, common_params) + tx.verify_with_params(common_params)?; + Ok(()) } } diff --git a/core/src/lib.rs b/core/src/lib.rs index 07b39efa95..11a3ae5d88 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -61,7 +61,7 @@ pub use crate::consensus::stake; pub use crate::consensus::{EngineType, TimeGapParams}; pub use crate::db::{COL_STATE, NUM_COLUMNS}; pub use crate::error::{BlockImportError, Error, ImportError}; -pub use crate::miner::{MemPoolMinFees, Miner, MinerOptions, MinerService}; +pub use crate::miner::{Miner, MinerOptions, MinerService}; pub use crate::peer_db::PeerDb; pub use crate::scheme::Scheme; pub use crate::service::ClientService; diff --git a/core/src/miner/mem_pool.rs b/core/src/miner/mem_pool.rs index 55e7f2dc43..07e1e086c5 100644 --- a/core/src/miner/mem_pool.rs +++ b/core/src/miner/mem_pool.rs @@ -16,8 +16,8 @@ use super::backup; use super::mem_pool_types::{ - AccountDetails, CurrentQueue, FutureQueue, MemPoolInput, MemPoolItem, MemPoolMinFees, MemPoolStatus, - PoolingInstant, QueueTag, TransactionOrder, TransactionOrderWithTag, TxOrigin, + AccountDetails, CurrentQueue, FutureQueue, MemPoolInput, MemPoolItem, MemPoolStatus, PoolingInstant, QueueTag, + TransactionOrder, TransactionOrderWithTag, TxOrigin, }; use super::TransactionImportResult; use crate::client::{AccountData, BlockChainTrait}; @@ -72,8 +72,6 @@ impl From for Error { } pub struct MemPool { - /// Fee threshold for transactions that can be imported to this pool - minimum_fees: MemPoolMinFees, /// A value which is used to check whether a new transaciton can replace a transaction in the memory pool with the same signer and seq. /// If the fee of the new transaction is `new_fee` and the fee of the transaction in the memory pool is `old_fee`, /// then `new_fee > old_fee + old_fee >> mem_pool_fee_bump_shift` should be satisfied to replace. @@ -113,15 +111,8 @@ pub struct MemPool { impl MemPool { /// Create new instance of this Queue with specified limits - pub fn with_limits( - limit: usize, - memory_limit: usize, - fee_bump_shift: usize, - db: Arc, - minimum_fees: MemPoolMinFees, - ) -> Self { + pub fn with_limits(limit: usize, memory_limit: usize, fee_bump_shift: usize, db: Arc) -> Self { MemPool { - minimum_fees, fee_bump_shift, max_block_number_period_in_pool: DEFAULT_POOLING_PERIOD, current: CurrentQueue::new(), @@ -700,23 +691,6 @@ impl MemPool { origin: TxOrigin, client_account: &AccountDetails, ) -> Result<(), Error> { - let action_min_fee = self.minimum_fees.min_cost(&tx.transaction().action); - if origin != TxOrigin::Local && tx.transaction().fee < action_min_fee { - ctrace!( - MEM_POOL, - "Dropping transaction below mempool defined minimum fee: {:?} (gp: {} < {})", - tx.hash(), - tx.transaction().fee, - action_min_fee - ); - - return Err(SyntaxError::InsufficientFee { - minimal: action_min_fee, - got: tx.transaction().fee, - } - .into()) - } - let full_pools_lowest = self.effective_minimum_fee(); if origin != TxOrigin::Local && tx.transaction().fee < full_pools_lowest { ctrace!( @@ -1042,7 +1016,7 @@ pub mod test { test_client.set_balance(default_addr, u64::max_value()); let db = Arc::new(kvdb_memorydb::create(crate::db::NUM_COLUMNS.unwrap_or(0))); - let mut mem_pool = MemPool::with_limits(8192, usize::max_value(), 3, db.clone(), Default::default()); + let mut mem_pool = MemPool::with_limits(8192, usize::max_value(), 3, db.clone()); let fetch_account = fetch_account_creator(&test_client); @@ -1076,7 +1050,7 @@ pub mod test { inputs.push(create_mempool_input_with_pay(7u64, &keypair)); mem_pool.add(inputs, inserted_block_number, inserted_timestamp, &fetch_account); - let mut mem_pool_recovered = MemPool::with_limits(8192, usize::max_value(), 3, db, Default::default()); + let mut mem_pool_recovered = MemPool::with_limits(8192, usize::max_value(), 3, db); mem_pool_recovered.recover_from_db(&test_client); assert_eq!(mem_pool_recovered.first_seqs, mem_pool.first_seqs); @@ -1105,131 +1079,18 @@ pub mod test { VerifiedTransaction::new_with_sign(tx, keypair.private()) } - fn create_signed_pay_with_fee(seq: u64, fee: u64, keypair: &KeyPair) -> VerifiedTransaction { - let receiver = 1u64.into(); - let tx = Transaction { - seq, - fee, - network_id: "tc".into(), - action: Action::Pay { - receiver, - quantity: 100_000, - }, - }; - VerifiedTransaction::new_with_sign(tx, keypair.private()) - } - fn create_mempool_input_with_pay(seq: u64, keypair: &KeyPair) -> MemPoolInput { let signed = create_signed_pay(seq, &keypair); MemPoolInput::new(signed, TxOrigin::Local) } - fn abbreviated_mempool_add( - test_client: &TestBlockChainClient, - mem_pool: &mut MemPool, - txs: Vec, - origin: TxOrigin, - ) -> Vec> { - let fetch_account = fetch_account_creator(test_client); - - let inserted_block_number = 1; - let inserted_timestamp = 100; - let inputs: Vec = txs.into_iter().map(|tx| MemPoolInput::new(tx, origin)).collect(); - mem_pool.add(inputs, inserted_block_number, inserted_timestamp, &fetch_account) - } - - #[test] - fn local_transactions_whose_fees_are_under_the_mem_pool_min_fee_should_not_be_rejected() { - let test_client = TestBlockChainClient::new(); - - // Set the pay transaction minimum fee - let fees = MemPoolMinFees::create_from_options(Some(150), None, None, None, None); - - let db = Arc::new(kvdb_memorydb::create(crate::db::NUM_COLUMNS.unwrap_or(0))); - let mut mem_pool = MemPool::with_limits(8192, usize::max_value(), 3, db, fees); - let keypair: KeyPair = Random.generate().unwrap(); - let address = public_to_address(keypair.public()); - - test_client.set_balance(address, 1_000_000_000_000); - - let txs = vec![ - create_signed_pay_with_fee(0, 200, &keypair), - create_signed_pay_with_fee(1, 140, &keypair), - create_signed_pay_with_fee(2, 160, &keypair), - ]; - let result = abbreviated_mempool_add(&test_client, &mut mem_pool, txs, TxOrigin::Local); - assert_eq!( - vec![ - Ok(TransactionImportResult::Current), - Ok(TransactionImportResult::Current), - Ok(TransactionImportResult::Current) - ], - result - ); - - assert_eq!( - vec![ - create_signed_pay_with_fee(0, 200, &keypair), - create_signed_pay_with_fee(1, 140, &keypair), - create_signed_pay_with_fee(2, 160, &keypair) - ], - mem_pool.top_transactions(std::usize::MAX, 0..std::u64::MAX).transactions - ); - - assert_eq!(Vec::::default(), mem_pool.future_transactions()); - } - - #[test] - fn external_transactions_whose_fees_are_under_the_mem_pool_min_fee_are_rejected() { - let test_client = TestBlockChainClient::new(); - // Set the pay transaction minimum fee - let fees = MemPoolMinFees::create_from_options(Some(150), None, None, None, None); - - let db = Arc::new(kvdb_memorydb::create(crate::db::NUM_COLUMNS.unwrap_or(0))); - let mut mem_pool = MemPool::with_limits(8192, usize::max_value(), 3, db, fees); - let keypair: KeyPair = Random.generate().unwrap(); - let address = public_to_address(keypair.public()); - - test_client.set_balance(address, 1_000_000_000_000); - - let txs = vec![ - create_signed_pay_with_fee(0, 200, &keypair), - create_signed_pay_with_fee(1, 140, &keypair), - create_signed_pay_with_fee(1, 160, &keypair), - create_signed_pay_with_fee(2, 149, &keypair), - ]; - let result = abbreviated_mempool_add(&test_client, &mut mem_pool, txs, TxOrigin::External); - assert_eq!( - vec![ - Ok(TransactionImportResult::Current), - Err(Error::Syntax(SyntaxError::InsufficientFee { - minimal: 150, - got: 140, - })), - Ok(TransactionImportResult::Current), - Err(Error::Syntax(SyntaxError::InsufficientFee { - minimal: 150, - got: 149, - })), - ], - result - ); - - assert_eq!( - vec![create_signed_pay_with_fee(0, 200, &keypair), create_signed_pay_with_fee(1, 160, &keypair)], - mem_pool.top_transactions(std::usize::MAX, 0..std::u64::MAX).transactions - ); - - assert_eq!(Vec::::default(), mem_pool.future_transactions()); - } - #[test] fn transactions_are_moved_to_future_queue_if_the_preceding_one_removed() { //setup test_client let test_client = TestBlockChainClient::new(); let db = Arc::new(kvdb_memorydb::create(crate::db::NUM_COLUMNS.unwrap_or(0))); - let mut mem_pool = MemPool::with_limits(8192, usize::max_value(), 3, db, Default::default()); + let mut mem_pool = MemPool::with_limits(8192, usize::max_value(), 3, db); let fetch_account = fetch_account_creator(&test_client); let keypair: KeyPair = Random.generate().unwrap(); diff --git a/core/src/miner/mem_pool_types.rs b/core/src/miner/mem_pool_types.rs index 7fb99770c2..c7a523ccdd 100644 --- a/core/src/miner/mem_pool_types.rs +++ b/core/src/miner/mem_pool_types.rs @@ -391,57 +391,3 @@ pub struct AccountDetails { /// Current account balance pub balance: u64, } - -#[derive(Default, Clone, Copy, Debug, PartialEq)] -/// Minimum fee thresholds defined not by network but by Mempool -pub struct MemPoolMinFees { - pub min_pay_transaction_cost: u64, - pub min_create_shard_transaction_cost: u64, - pub min_set_shard_owners_transaction_cost: u64, - pub min_set_shard_users_transaction_cost: u64, - pub min_custom_transaction_cost: u64, -} - -impl MemPoolMinFees { - #[allow(clippy::too_many_arguments)] - pub fn create_from_options( - min_pay_cost_option: Option, - min_create_shard_cost_option: Option, - min_set_shard_owners_cost_option: Option, - min_set_shard_users_cost_option: Option, - min_custom_cost_option: Option, - ) -> Self { - MemPoolMinFees { - min_pay_transaction_cost: min_pay_cost_option.unwrap_or_default(), - min_create_shard_transaction_cost: min_create_shard_cost_option.unwrap_or_default(), - min_set_shard_owners_transaction_cost: min_set_shard_owners_cost_option.unwrap_or_default(), - min_set_shard_users_transaction_cost: min_set_shard_users_cost_option.unwrap_or_default(), - min_custom_transaction_cost: min_custom_cost_option.unwrap_or_default(), - } - } - pub fn min_cost(&self, action: &Action) -> u64 { - match action { - Action::Pay { - .. - } => self.min_pay_transaction_cost, - Action::CreateShard { - .. - } => self.min_create_shard_transaction_cost, - Action::SetShardOwners { - .. - } => self.min_set_shard_owners_transaction_cost, - Action::SetShardUsers { - .. - } => self.min_set_shard_users_transaction_cost, - Action::Custom { - .. - } => self.min_custom_transaction_cost, - Action::ShardStore { - .. - } => { - // FIXME - 0 - } - } - } -} diff --git a/core/src/miner/miner.rs b/core/src/miner/miner.rs index af9e74389a..fd4d8535f6 100644 --- a/core/src/miner/miner.rs +++ b/core/src/miner/miner.rs @@ -15,7 +15,6 @@ // along with this program. If not, see . use super::mem_pool::{Error as MemPoolError, MemPool}; -pub use super::mem_pool_types::MemPoolMinFees; use super::mem_pool_types::{MemPoolInput, TxOrigin}; use super::{fetch_account_creator, MinerService, MinerStatus, TransactionImportResult}; use crate::account_provider::{AccountProvider, Error as AccountProviderError}; @@ -67,8 +66,6 @@ pub struct MinerOptions { /// Local transactions ignore this option. pub mem_pool_fee_bump_shift: usize, pub allow_create_shard: bool, - /// Minimum fees configured by the machine. - pub mem_pool_min_fees: MemPoolMinFees, } impl Default for MinerOptions { @@ -82,7 +79,6 @@ impl Default for MinerOptions { mem_pool_memory_limit: Some(2 * 1024 * 1024), mem_pool_fee_bump_shift: 3, allow_create_shard: false, - mem_pool_min_fees: Default::default(), } } } @@ -136,7 +132,6 @@ impl Miner { mem_limit, options.mem_pool_fee_bump_shift, db, - options.mem_pool_min_fees, ))); Self { @@ -762,7 +757,7 @@ pub mod test { let scheme = Scheme::new_test(); let miner = Arc::new(Miner::with_scheme(&scheme, db.clone())); - let mut mem_pool = MemPool::with_limits(8192, usize::max_value(), 3, db.clone(), Default::default()); + let mut mem_pool = MemPool::with_limits(8192, usize::max_value(), 3, db.clone()); let client = generate_test_client(db, Arc::clone(&miner), &scheme).unwrap(); let private = Private::random(); diff --git a/core/src/miner/mod.rs b/core/src/miner/mod.rs index 331c62fb5f..ae8bc784a5 100644 --- a/core/src/miner/mod.rs +++ b/core/src/miner/mod.rs @@ -28,7 +28,6 @@ use primitives::Bytes; use std::ops::Range; use self::mem_pool_types::AccountDetails; -pub use self::mem_pool_types::MemPoolMinFees; pub use self::miner::{AuthoringParams, Miner, MinerOptions}; use crate::account_provider::{AccountProvider, Error as AccountProviderError}; use crate::client::{ diff --git a/foundry/config/mod.rs b/foundry/config/mod.rs index ff1d247919..cc5aa7c454 100644 --- a/foundry/config/mod.rs +++ b/foundry/config/mod.rs @@ -16,7 +16,7 @@ mod chain_type; -use ccore::{MemPoolMinFees, MinerOptions, TimeGapParams}; +use ccore::{MinerOptions, TimeGapParams}; use cidr::IpCidr; use cinformer::InformerConfig; use ckey::PlatformAddress; @@ -73,14 +73,6 @@ impl Config { None => unreachable!(), }; - let mem_pool_min_fees = MemPoolMinFees::create_from_options( - self.mining.min_pay_transaction_cost, - self.mining.min_create_shard_transaction_cost, - self.mining.min_set_shard_owners_transaction_cost, - self.mining.min_set_shard_users_transaction_cost, - self.mining.min_custom_transaction_cost, - ); - Ok(MinerOptions { mem_pool_size: self.mining.mem_pool_size.unwrap(), mem_pool_memory_limit: match self.mining.mem_pool_mem_limit.unwrap() { @@ -93,7 +85,6 @@ impl Config { reseal_on_external_transaction, reseal_min_period: Duration::from_millis(self.mining.reseal_min_period.unwrap()), no_reseal_timer: self.mining.no_reseal_timer.unwrap(), - mem_pool_min_fees, }) } @@ -232,11 +223,6 @@ pub struct Mining { pub no_reseal_timer: Option, pub allowed_past_gap: Option, pub allowed_future_gap: Option, - pub min_pay_transaction_cost: Option, - pub min_create_shard_transaction_cost: Option, - pub min_set_shard_owners_transaction_cost: Option, - pub min_set_shard_users_transaction_cost: Option, - pub min_custom_transaction_cost: Option, } #[derive(Deserialize)] @@ -419,21 +405,6 @@ impl Mining { if other.no_reseal_timer.is_some() { self.no_reseal_timer = other.no_reseal_timer; } - if other.min_pay_transaction_cost.is_some() { - self.min_pay_transaction_cost = other.min_pay_transaction_cost; - } - if other.min_create_shard_transaction_cost.is_some() { - self.min_create_shard_transaction_cost = other.min_create_shard_transaction_cost; - } - if other.min_set_shard_owners_transaction_cost.is_some() { - self.min_set_shard_owners_transaction_cost = other.min_set_shard_owners_transaction_cost; - } - if other.min_set_shard_users_transaction_cost.is_some() { - self.min_set_shard_users_transaction_cost = other.min_set_shard_users_transaction_cost; - } - if other.min_custom_transaction_cost.is_some() { - self.min_custom_transaction_cost = other.min_custom_transaction_cost; - } } pub fn overwrite_with(&mut self, matches: &clap::ArgMatches<'_>) -> Result<(), String> { diff --git a/json/src/scheme/params.rs b/json/src/scheme/params.rs index 484243d29f..dbb669389a 100644 --- a/json/src/scheme/params.rs +++ b/json/src/scheme/params.rs @@ -27,13 +27,6 @@ pub struct Params { #[serde(rename = "networkID")] pub network_id: NetworkId, - /// Minimum transaction cost. - pub min_pay_cost: Uint, - pub min_create_shard_cost: Uint, - pub min_set_shard_owners_cost: Uint, - pub min_set_shard_users_cost: Uint, - pub min_custom_cost: Uint, - /// Maximum size of block body. pub max_body_size: Uint, /// Snapshot creation period in unit of block numbers. @@ -64,11 +57,6 @@ mod tests { let s = r#"{ "maxExtraDataSize": "0x20", "networkID" : "tc", - "minPayCost" : 10, - "minCreateShardCost" : 12, - "minSetShardOwnersCost" : 13, - "minSetShardUsersCost" : 14, - "minCustomCost" : 16, "maxBodySize" : 4194304, "snapshotPeriod": 16384, "termSeconds": 3600, @@ -85,11 +73,6 @@ mod tests { let deserialized: Params = serde_json::from_str(s).unwrap(); assert_eq!(deserialized.max_extra_data_size, 0x20.into()); assert_eq!(deserialized.network_id, "tc".into()); - assert_eq!(deserialized.min_pay_cost, 10.into()); - assert_eq!(deserialized.min_create_shard_cost, 12.into()); - assert_eq!(deserialized.min_set_shard_owners_cost, 13.into()); - assert_eq!(deserialized.min_set_shard_users_cost, 14.into()); - assert_eq!(deserialized.min_custom_cost, 16.into()); assert_eq!(deserialized.max_body_size, 4_194_304.into()); assert_eq!(deserialized.snapshot_period, 16_384.into()); assert_eq!(deserialized.term_seconds, 3600.into()); @@ -110,11 +93,6 @@ mod tests { let s = r#"{ "maxExtraDataSize": "0x20", "networkID" : "tc", - "minPayCost" : 10, - "minCreateShardCost" : 12, - "minSetShardOwnersCost" : 13, - "minSetShardUsersCost" : 14, - "minCustomCost" : 16, "maxBodySize" : 4194304, "snapshotPeriod": 16384, "termSeconds": 3600, @@ -132,11 +110,6 @@ mod tests { let deserialized: Params = serde_json::from_str(s).unwrap(); assert_eq!(deserialized.max_extra_data_size, 0x20.into()); assert_eq!(deserialized.network_id, "tc".into()); - assert_eq!(deserialized.min_pay_cost, 10.into()); - assert_eq!(deserialized.min_create_shard_cost, 12.into()); - assert_eq!(deserialized.min_set_shard_owners_cost, 13.into()); - assert_eq!(deserialized.min_set_shard_users_cost, 14.into()); - assert_eq!(deserialized.min_custom_cost, 16.into()); assert_eq!(deserialized.max_body_size, 4_194_304.into()); assert_eq!(deserialized.snapshot_period, 16_384.into()); assert_eq!(deserialized.term_seconds, 3600.into()); diff --git a/json/src/scheme/scheme.rs b/json/src/scheme/scheme.rs index 42b447df56..144db21d5f 100644 --- a/json/src/scheme/scheme.rs +++ b/json/src/scheme/scheme.rs @@ -95,11 +95,6 @@ mod tests { "maxTransferMetadataSize": "0x0100", "maxTextContentSize": "0x0200", "networkID" : "tc", - "minPayCost" : 10, - "minCreateShardCost" : 12, - "minSetShardOwnersCost" : 13, - "minSetShardUsersCost" : 14, - "minCustomCost" : 16, "maxBodySize": 4194304, "snapshotPeriod": 16384, "termSeconds": 3600, diff --git a/rpc/src/v1/impls/chain.rs b/rpc/src/v1/impls/chain.rs index 10778ea5dd..b3836af1ad 100644 --- a/rpc/src/v1/impls/chain.rs +++ b/rpc/src/v1/impls/chain.rs @@ -158,27 +158,6 @@ where Ok(self.client.block(&BlockId::Hash(block_hash)).map(|block| block.transactions_count())) } - fn get_min_transaction_fee(&self, action_type: String, block_number: Option) -> Result> { - if block_number == Some(0) { - return Ok(None) - } - // Unlike other RPCs, use the latest parameters if the block number is `null`. - let block_id = block_number.map(|n| (n - 1).into()).unwrap_or(BlockId::Latest); - if let Some(common_parameters) = self.client.common_params(block_id) { - Ok(match action_type.as_str() { - "pay" => Some(common_parameters.min_pay_transaction_cost()), - "createShard" => Some(common_parameters.min_create_shard_transaction_cost()), - "setShardOwners" => Some(common_parameters.min_set_shard_owners_transaction_cost()), - "setShardUsers" => Some(common_parameters.min_set_shard_users_transaction_cost()), - "custom" => Some(common_parameters.min_custom_transaction_cost()), - - _ => None, - }) - } else { - Ok(None) - } - } - fn get_network_id(&self) -> Result { Ok(self.client.network_id()) } diff --git a/rpc/src/v1/impls/devel.rs b/rpc/src/v1/impls/devel.rs index 7148050a62..70f5ee3778 100644 --- a/rpc/src/v1/impls/devel.rs +++ b/rpc/src/v1/impls/devel.rs @@ -128,7 +128,6 @@ where fn test_tps(&self, setting: TPSTestSetting) -> Result { let common_params = self.client.common_params(BlockId::Latest).unwrap(); - let pay_fee = common_params.min_pay_transaction_cost(); let network_id = common_params.network_id(); // NOTE: Assuming solo network @@ -144,7 +143,7 @@ where ($seq:expr, $address:expr, $quantity: expr) => { Transaction { seq: $seq, - fee: pay_fee, + fee: 0, network_id, action: Action::Pay { receiver: $address, diff --git a/rpc/src/v1/impls/mempool.rs b/rpc/src/v1/impls/mempool.rs index 569cfd7b8c..1440c0e674 100644 --- a/rpc/src/v1/impls/mempool.rs +++ b/rpc/src/v1/impls/mempool.rs @@ -16,7 +16,7 @@ use super::super::errors; use super::super::traits::Mempool; -use super::super::types::{MemPoolMinFees, PendingTransactions}; +use super::super::types::PendingTransactions; use ccore::{BlockChainClient, EngineInfo, MiningBlockChainClient, UnverifiedTransaction, VerifiedTransaction}; use cjson::bytes::Bytes; use ckey::{Address, PlatformAddress}; @@ -124,8 +124,4 @@ where self.client.register_immune_users(immune_user_vec); Ok(()) } - - fn get_machine_minimum_fees(&self) -> Result { - Ok(MemPoolMinFees::from(self.client.mem_pool_min_fees())) - } } diff --git a/rpc/src/v1/traits/chain.rs b/rpc/src/v1/traits/chain.rs index ded4fabc16..1e826e15da 100644 --- a/rpc/src/v1/traits/chain.rs +++ b/rpc/src/v1/traits/chain.rs @@ -95,10 +95,6 @@ pub trait Chain { #[rpc(name = "chain_getBlockTransactionCountByHash")] fn get_block_transaction_count_by_hash(&self, block_hash: BlockHash) -> Result>; - ///Gets the minimum transaction fee of the given name. - #[rpc(name = "chain_getMinTransactionFee")] - fn get_min_transaction_fee(&self, action_type: String, block_number: Option) -> Result>; - /// Return the network id that is used in this chain. #[rpc(name = "chain_getNetworkId")] fn get_network_id(&self) -> Result; diff --git a/rpc/src/v1/traits/mempool.rs b/rpc/src/v1/traits/mempool.rs index b93d009601..252658b59b 100644 --- a/rpc/src/v1/traits/mempool.rs +++ b/rpc/src/v1/traits/mempool.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -use super::super::types::{MemPoolMinFees, PendingTransactions}; +use super::super::types::PendingTransactions; use cjson::bytes::Bytes; use ckey::PlatformAddress; use ctypes::TxHash; @@ -66,7 +66,4 @@ pub trait Mempool { #[rpc(name = "mempool_registerImmuneAccounts")] fn register_immune_accounts(&self, immune_user_list: Vec) -> Result<()>; - - #[rpc(name = "mempool_getMachineMinimumFees")] - fn get_machine_minimum_fees(&self) -> Result; } diff --git a/rpc/src/v1/types/mem_pool.rs b/rpc/src/v1/types/mem_pool.rs deleted file mode 100644 index a9a7d701b2..0000000000 --- a/rpc/src/v1/types/mem_pool.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2020 Kodebox, Inc. -// This file is part of CodeChain. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#[derive(Debug, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct MemPoolMinFees { - min_pay_transaction_cost: u64, - min_create_shard_transaction_cost: u64, - min_set_shard_owners_transaction_cost: u64, - min_set_shard_users_transaction_cost: u64, - min_custom_transaction_cost: u64, -} - -impl From for MemPoolMinFees { - fn from(fees: ccore::MemPoolMinFees) -> Self { - Self { - min_pay_transaction_cost: fees.min_pay_transaction_cost, - min_create_shard_transaction_cost: fees.min_create_shard_transaction_cost, - min_set_shard_owners_transaction_cost: fees.min_set_shard_owners_transaction_cost, - min_set_shard_users_transaction_cost: fees.min_set_shard_users_transaction_cost, - min_custom_transaction_cost: fees.min_custom_transaction_cost, - } - } -} diff --git a/rpc/src/v1/types/mod.rs b/rpc/src/v1/types/mod.rs index ff2b4e0e5d..1214dfac89 100644 --- a/rpc/src/v1/types/mod.rs +++ b/rpc/src/v1/types/mod.rs @@ -16,7 +16,6 @@ mod action; mod block; -mod mem_pool; mod transaction; mod unsigned_transaction; mod work; @@ -24,7 +23,6 @@ mod work; pub use self::action::{Action, ActionWithTracker}; pub use self::block::Block; pub use self::block::BlockNumberAndHash; -pub use self::mem_pool::MemPoolMinFees; pub use self::transaction::{PendingTransactions, Transaction}; pub use self::unsigned_transaction::UnsignedTransaction; pub use self::work::Work; diff --git a/state/src/impls/top_level.rs b/state/src/impls/top_level.rs index daa095e1ad..5bee5b149c 100644 --- a/state/src/impls/top_level.rs +++ b/state/src/impls/top_level.rs @@ -967,7 +967,7 @@ mod tests_state { let mut state = get_temp_state(); let a = Address::default(); state.get_account_mut(&a).unwrap(); - assert_eq!(Ok(H256::from("37db9832f9e2f164789ddf7e399481a0386f61acb49a52d975466058bc1bbbcb")), state.commit()); + assert_eq!(Ok(H256::from("7bde6a7da8ce95df6ace46805285f37ec7943d633c0d57e1631dc424489147fe")), state.commit()); } #[test] diff --git a/test/src/e2e.dynval/1/dv.changeParams.test.ts b/test/src/e2e.dynval/1/dv.changeParams.test.ts index b48cf8f0a8..cca2e17d78 100644 --- a/test/src/e2e.dynval/1/dv.changeParams.test.ts +++ b/test/src/e2e.dynval/1/dv.changeParams.test.ts @@ -176,7 +176,6 @@ describe("Change commonParams that doesn't affects validator set", function() { promiseExpect, overrideParams: { termSeconds: 10, - minPayCost: 10, maxCandidateMetadataSize: 128 }, validators: validators.slice(0, 3).map((signer, index) => ({ @@ -238,43 +237,6 @@ describe("Change commonParams that doesn't affects validator set", function() { }); }); - describe("Change minimum fee", async function() { - it("Change minimum fee of pay transaction", async function() { - const checkingNode = nodes[0]; - - this.slow(4_000); - this.timeout(6_000); - - const changeTxHash = await changeParams(checkingNode, 1, { - ...initialParams, - minPayCost: 11 - }); - - await checkingNode.waitForTx(changeTxHash); - - const tx = checkingNode.testFramework.core - .createPayTransaction({ - recipient: validators[0].address, - quantity: 100 - }) - .sign({ - secret: faucetSecret, - seq: (await checkingNode.rpc.chain.getSeq({ - address: faucetAddress.toString() - }))!, - fee: 10 - }); - try { - await checkingNode.rpc.mempool.sendSignedTransaction({ - tx: tx.rlpBytes().toString("hex") - }); - expect.fail(); - } catch (e) { - expect(e).is.similarTo(ERROR.TOO_LOW_FEE); - } - }); - }); - describe("Change the maximum size of candidate metadata", async function() { function nominationWithMetadata(size: number) { return stake.createSelfNominateTransaction( diff --git a/test/src/e2e.dynval/setup.ts b/test/src/e2e.dynval/setup.ts index 22e7cfce28..d79e115a0d 100644 --- a/test/src/e2e.dynval/setup.ts +++ b/test/src/e2e.dynval/setup.ts @@ -387,11 +387,6 @@ export async function fullyConnect( export const defaultParams = { maxExtraDataSize: 0x20, networkID: "tc", - minPayCost: 10, - minCreateShardCost: 10, - minSetShardOwnersCost: 10, - minSetShardUsersCost: 10, - minCustomCost: 0, maxBodySize: 4194304, snapshotPeriod: 16384, @@ -416,11 +411,6 @@ function encodeParams(params: CommonParams): any[] { const result = [ params.maxExtraDataSize, params.networkID, - params.minPayCost, - params.minCreateShardCost, - params.minSetShardOwnersCost, - params.minSetShardUsersCost, - params.minCustomCost, params.maxBodySize, params.snapshotPeriod, params.termSeconds, diff --git a/test/src/e2e.long/mempoolMinfee.test.ts b/test/src/e2e.long/mempoolMinfee.test.ts deleted file mode 100644 index 045221a2a8..0000000000 --- a/test/src/e2e.long/mempoolMinfee.test.ts +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2019 Kodebox, Inc. -// This file is part of CodeChain. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import { expect } from "chai"; -import "mocha"; -import { - validator0Address, - validator1Address, - validator2Address -} from "../helper/constants"; -import CodeChain from "../helper/spawn"; - -describe("MemPoolMinFees", async function() { - const chain = `${__dirname}/../scheme/tendermint-int.json`; - const config1 = `test/src/config/mem-pool-min-fee1.toml`; - const config2 = `test/src/config/mem-pool-min-fee2.toml`; - let valNode1WithMinPayFee150: CodeChain; - let valNode2WithMinPayFee200: CodeChain; - let valNode3: CodeChain; - const nonValAddress = "tccq9td7gtgjhu08ud9hs7uml0pj4lt36mdwyft72tl"; - let nonValNode: CodeChain; - - beforeEach(async function() { - valNode1WithMinPayFee150 = new CodeChain({ - chain, - argv: [ - "--engine-signer", - validator0Address.toString(), - "--password-path", - "test/tendermint/password.json", - "--force-sealing", - "--config", - config1 - ], - additionalKeysPath: "tendermint/keys" - }); - - valNode2WithMinPayFee200 = new CodeChain({ - chain, - argv: [ - "--engine-signer", - validator1Address.toString(), - "--password-path", - "test/tendermint/password.json", - "--force-sealing", - "--config", - config2 - ], - additionalKeysPath: "tendermint/keys" - }); - - valNode3 = new CodeChain({ - chain, - argv: [ - "--engine-signer", - validator2Address.toString(), - "--password-path", - "test/tendermint/password.json", - "--force-sealing" - ], - additionalKeysPath: "tendermint/keys" - }); - - await valNode1WithMinPayFee150.start(); - await valNode2WithMinPayFee200.start(); - await valNode3.start(); - - await valNode1WithMinPayFee150.connect(valNode2WithMinPayFee200); - await valNode1WithMinPayFee150.connect(valNode3); - await valNode2WithMinPayFee200.connect(valNode3); - - await valNode1WithMinPayFee150.waitPeers(2); - await valNode2WithMinPayFee200.waitPeers(2); - await valNode3.waitPeers(2); - }); - - afterEach(async function() { - await valNode1WithMinPayFee150.clean(); - await valNode2WithMinPayFee200.clean(); - await valNode3.clean(); - }); - - it("A node should accept a transaction with a fee higher than the node's mem pool minimum fee and the block should be propagated", async function() { - const tx = await valNode1WithMinPayFee150.sendPayTx({ - seq: 0, - fee: 175, - quantity: 100_000, - recipient: validator0Address - }); - await valNode1WithMinPayFee150.waitBlockNumber(2); - await valNode2WithMinPayFee200.waitBlockNumber(2); - await valNode3.waitBlockNumber(2); - - expect( - await valNode1WithMinPayFee150.rpc.chain.containsTransaction({ - transactionHash: `0x${tx.hash().toString()}` - }) - ).to.be.true; - expect( - await valNode2WithMinPayFee200.rpc.chain.containsTransaction({ - transactionHash: `0x${tx.hash().toString()}` - }) - ).to.be.true; - expect( - await valNode3.rpc.chain.containsTransaction({ - transactionHash: `0x${tx.hash().toString()}` - }) - ).to.be.true; - }); - - it("Connected validators should reject a transaction with a fee lower than the nodes' mem pool minimum fees", async function() { - nonValNode = new CodeChain({ - chain, - argv: [ - "--engine-signer", - nonValAddress, - "--password-path", - `test/custom.minfee/${nonValAddress}/password.json`, - "--force-sealing" - ], - additionalKeysPath: `custom.minfee/${nonValAddress}/keys` - }); - await nonValNode.start(); - await nonValNode.connect(valNode1WithMinPayFee150); - await nonValNode.connect(valNode2WithMinPayFee200); - - await nonValNode.waitPeers(2); - await valNode1WithMinPayFee150.waitPeers(3); - await valNode2WithMinPayFee200.waitPeers(3); - - const nodeArray = [ - valNode1WithMinPayFee150, - valNode2WithMinPayFee200, - valNode3, - nonValNode - ]; - - const txShouldBeRejected = await nonValNode.sendPayTx({ - fee: 145, - quantity: 100_000, - recipient: validator0Address - }); - - const txShouldBeAccepted = await nonValNode.sendPayTx({ - fee: 210, - quantity: 100_000, - recipient: validator0Address - }); - - await Promise.all(nodeArray.map(node => node.waitBlockNumber(4))); - const expectedTrues = await Promise.all( - nodeArray.map(node => - node.rpc.chain.containsTransaction({ - transactionHash: `0x${txShouldBeAccepted.hash().toString()}` - }) - ) - ); - const expectedFalses = await Promise.all( - nodeArray.map(node => - node.rpc.chain.containsTransaction({ - transactionHash: `0x${txShouldBeRejected.hash().toString()}` - }) - ) - ); - - expectedTrues.map(val => expect(val).to.be.true); - expectedFalses.map(val => expect(val).to.be.false); - - await nonValNode.clean(); - }); -}); diff --git a/test/src/e2e.long/staking.test.ts b/test/src/e2e.long/staking.test.ts index 2810b15afe..51ce86e1f6 100644 --- a/test/src/e2e.long/staking.test.ts +++ b/test/src/e2e.long/staking.test.ts @@ -817,7 +817,6 @@ describe("Staking", function() { // faucet: 20000, alice: 20000, bob: 10000, validator0: 50110, validator1: 110, validator2: 110, validator3: 110 const blockNumber = await nodes[0].getBestBlockNumber(); - const minCustomCost = Scheme.params.minCustomCost; const oldAliceBalance = +(await nodes[0].rpc.chain.getBalance({ address: aliceAddress.toString(), @@ -925,7 +924,6 @@ describe("Staking", function() { // faucet: 20000, alice: 20000, bob: 10000, val0: 110 (delegated 50000 to val1), val1: 110, val2: 110, val3: 110 const blockNumber = await nodes[0].getBestBlockNumber(); - const minCustomCost = Scheme.params.minCustomCost; const oldAliceBalance = +(await nodes[0].rpc.chain.getBalance({ address: aliceAddress.toString(), @@ -1076,7 +1074,6 @@ describe("Staking", function() { // faucet: 10000, alice: 20000, bob: 10000, val0: 110 (delegated 30000 to val1), val1: 30110, val2: 110, val3: 110 const blockNumber = await nodes[0].getBestBlockNumber(); - const minCustomCost = Scheme.params.minCustomCost; const oldAliceBalance = +(await nodes[0].rpc.chain.getBalance({ address: aliceAddress.toString(), diff --git a/test/src/e2e/changeParams.test.ts b/test/src/e2e/changeParams.test.ts index 7d9cd554e7..8d5bba3483 100644 --- a/test/src/e2e/changeParams.test.ts +++ b/test/src/e2e/changeParams.test.ts @@ -69,13 +69,8 @@ describe("ChangeParams", function() { it("change", async function() { const newParams = [ - 0x20, // maxExtraDataSize + 0x30, // maxExtraDataSize "tc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -122,25 +117,14 @@ describe("ChangeParams", function() { }) ).be.true; } - try { - await node.sendPayTx({ fee: 10 }); - expect.fail(); - } catch (e) { - expect(e).is.similarTo(ERROR.TOO_LOW_FEE); - } const params = await node.rpc.chain.getCommonParams({}); - expect(+params!.minPayCost!).to.be.deep.equal(11); + expect(+params!.maxExtraDataSize!).to.be.deep.equal(0x30); }); it("cannot change the network id", async function() { const newParams = [ 0x20, // maxExtraDataSize "cc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -189,18 +173,13 @@ describe("ChangeParams", function() { const params = await node.rpc.chain.getCommonParams({ blockNumber: null }); - expect(+params!.minPayCost!).to.be.deep.equal(10); + expect(+params!.maxExtraDataSize!).to.be.deep.equal(0x20); }); it("the parameter is applied from the next block", async function() { const newParams = [ - 0x20, // maxExtraDataSize + 0x44, // maxExtraDataSize "tc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -261,23 +240,14 @@ describe("ChangeParams", function() { blockNumber + 1 ); } - try { - await node.sendPayTx({ fee: 10 }); - expect.fail(); - } catch (e) { - expect(e).is.similarTo(ERROR.TOO_LOW_FEE); - } + const params = await node.rpc.chain.getCommonParams({}); + expect(+params!.maxExtraDataSize!).to.be.deep.equal(0x44); }); it("the parameter changed twice in the same block", async function() { const newParams1 = [ - 0x20, // maxExtraDataSize + 0x30, // maxExtraDataSize "tc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -292,13 +262,8 @@ describe("ChangeParams", function() { 0 // era ]; const newParams2 = [ - 0x20, // maxExtraDataSize + 0x40, // maxExtraDataSize "tc", // networkID - 5, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -389,23 +354,14 @@ describe("ChangeParams", function() { transactionHash: `0x${pay.hash().toString()}` }) ).be.true; - try { - await node.sendPayTx({ fee: 4 }); - expect.fail(); - } catch (e) { - expect(e).is.similarTo(ERROR.TOO_LOW_FEE); - } + const params = await node.rpc.chain.getCommonParams({}); + expect(+params!.maxExtraDataSize!).to.be.deep.equal(0x40); }); it("cannot reuse the same signature", async function() { const newParams1 = [ - 0x20, // maxExtraDataSize + 0x30, // maxExtraDataSize "tc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -420,13 +376,8 @@ describe("ChangeParams", function() { 0 // era ]; const newParams2 = [ - 0x20, // maxExtraDataSize + 0x40, // maxExtraDataSize "tc", // networkID - 5, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -511,29 +462,14 @@ describe("ChangeParams", function() { ); } - const pay = await node.sendPayTx({ fee: 5 }); - expect( - await node.rpc.chain.containsTransaction({ - transactionHash: "0x".concat(pay.hash().toString()) - }) - ).be.true; - try { - await node.sendPayTx({ fee: 4 }); - expect.fail(); - } catch (e) { - expect(e).is.similarTo(ERROR.TOO_LOW_FEE); - } + const params = await node.rpc.chain.getCommonParams({}); + expect(+params!.maxExtraDataSize!).to.be.deep.equal(0x40); }); it("cannot change params with insufficient stakes", async function() { const newParams = [ - 0x20, // maxExtraDataSize + 0x30, // maxExtraDataSize "tc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -604,13 +540,8 @@ describe("ChangeParams", function() { it("the amount of stakes not the number of stakeholders", async function() { const newParams = [ - 0x20, // maxExtraDataSize + 0x30, // maxExtraDataSize "tc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -654,13 +585,8 @@ describe("ChangeParams", function() { it("needs more than half to change params", async function() { const newParams = [ - 0x20, // maxExtraDataSize + 0x30, // maxExtraDataSize "tc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -740,24 +666,15 @@ describe("ChangeParams", function() { await node.rpc.chain.getTransaction({ transactionHash: hash }) ).not.be.null; } - try { - await node.sendPayTx({ fee: 10 }); - expect.fail(); - } catch (e) { - expect(e).is.similarTo(ERROR.TOO_LOW_FEE); - } + const params = await node.rpc.chain.getCommonParams({}); + expect(+params!.maxExtraDataSize!).to.be.deep.equal(0x30); }); describe("with stake parameters", async function() { it("change", async function() { const newParams = [ - 0x20, // maxExtraDataSize + 0x30, // maxExtraDataSize "tc", // networkID - 11, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 0, // termSeconds @@ -805,28 +722,14 @@ describe("ChangeParams", function() { ).be.true; } - try { - await node.sendPayTx({ fee: 10 }); - expect.fail(); - } catch (e) { - expect(e).is.similarTo(ERROR.TOO_LOW_FEE); - } - - const params = await node.rpc.chain.getCommonParams({ - blockNumber: null - }); - expect(+params!.minPayCost!).to.be.deep.equal(11); + const params = await node.rpc.chain.getCommonParams({}); + expect(+params!.maxExtraDataSize!).to.be.deep.equal(0x30); }); it("nomination expiration cannot be zero", async function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds @@ -877,11 +780,6 @@ describe("ChangeParams", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds @@ -932,11 +830,6 @@ describe("ChangeParams", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds @@ -987,11 +880,6 @@ describe("ChangeParams", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds @@ -1042,11 +930,6 @@ describe("ChangeParams", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds @@ -1097,11 +980,6 @@ describe("ChangeParams", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds @@ -1152,11 +1030,6 @@ describe("ChangeParams", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds @@ -1207,11 +1080,6 @@ describe("ChangeParams", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds @@ -1262,11 +1130,6 @@ describe("ChangeParams", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod 100, // termSeconds diff --git a/test/src/e2e/termChange.test.ts b/test/src/e2e/termChange.test.ts index 0d91329126..903fc00e24 100644 --- a/test/src/e2e/termChange.test.ts +++ b/test/src/e2e/termChange.test.ts @@ -64,11 +64,6 @@ describe("Term change", function() { const newParams = [ 0x20, // maxExtraDataSize "tc", // networkID - 10, // minPayCost - 10, // minCreateShardCost - 10, // minSetShardOwnersCost - 10, // minSetShardUsersCost - 10, // minCustomCost 4194304, // maxBodySize 16384, // snapshotPeriod termSeconds, // termSeconds diff --git a/test/src/e2e/verification.test.ts b/test/src/e2e/verification.test.ts index d5487a7bce..2d52966838 100644 --- a/test/src/e2e/verification.test.ts +++ b/test/src/e2e/verification.test.ts @@ -328,33 +328,6 @@ describe("solo - 1 node", function() { it("Users"); }); - [0, 9].forEach(function(fee) { - it(`Sending invalid transactions (low fee): ${fee}`, async function() { - const seq = (await node.rpc.chain.getSeq({ - address: faucetAddress.toString(), - blockNumber: null - }))!; - const signed = node.testFramework.core - .createPayTransaction({ - recipient, - quantity: 0 - }) - .sign({ - secret: faucetSecret, - fee, - seq - }); - try { - await node.rpc.mempool.sendSignedTransaction({ - tx: signed.rlpBytes().toString("hex") - }); - expect.fail(); - } catch (e) { - expect(e).is.similarTo(ERROR.TOO_LOW_FEE); - } - }); - }); - afterEach(function() { if (this.currentTest!.state === "failed") { node.keepLogs(); diff --git a/test/src/scheme/mempool.json b/test/src/scheme/mempool.json index 1e667ec7bf..0476110218 100644 --- a/test/src/scheme/mempool.json +++ b/test/src/scheme/mempool.json @@ -15,11 +15,6 @@ "params": { "maxExtraDataSize": "0x20", "networkID": "tc", - "minPayCost" : 10, - "minCreateShardCost" : 10, - "minSetShardOwnersCost" : 10, - "minSetShardUsersCost" : 10, - "minCustomCost" : 10, "maxBodySize": 4194304, "snapshotPeriod": 16384, "termSeconds": 0, diff --git a/test/src/scheme/solo.json b/test/src/scheme/solo.json index ea836f183b..b068de7f1c 100644 --- a/test/src/scheme/solo.json +++ b/test/src/scheme/solo.json @@ -15,11 +15,6 @@ "params": { "maxExtraDataSize": "0x20", "networkID": "tc", - "minPayCost" : 10, - "minCreateShardCost" : 10, - "minSetShardOwnersCost" : 10, - "minSetShardUsersCost" : 10, - "minCustomCost" : 10, "maxBodySize": 4194304, "snapshotPeriod": 16384, "termSeconds": 0, diff --git a/test/src/scheme/tendermint-dynval.json b/test/src/scheme/tendermint-dynval.json index 5f763515bf..e3f8e76a39 100644 --- a/test/src/scheme/tendermint-dynval.json +++ b/test/src/scheme/tendermint-dynval.json @@ -55,11 +55,6 @@ "params": { "maxExtraDataSize": "0x20", "networkID": "tc", - "minPayCost": 10, - "minCreateShardCost": 10, - "minSetShardOwnersCost": 10, - "minSetShardUsersCost": 10, - "minCustomCost": 10, "maxBodySize": 4194304, "snapshotPeriod": 16384, "termSeconds": 0, diff --git a/test/src/scheme/tendermint-int.json b/test/src/scheme/tendermint-int.json index c774b8df5b..6e59f38532 100644 --- a/test/src/scheme/tendermint-int.json +++ b/test/src/scheme/tendermint-int.json @@ -54,11 +54,6 @@ "params": { "maxExtraDataSize": "0x20", "networkID": "tc", - "minPayCost" : 12, - "minCreateShardCost" : 10, - "minSetShardOwnersCost" : 10, - "minSetShardUsersCost" : 10, - "minCustomCost" : 10, "maxBodySize": 4194304, "snapshotPeriod": 16384, "termSeconds": 0, diff --git a/test/src/scheme/tendermint-tps.json b/test/src/scheme/tendermint-tps.json index a8bb8ee258..f979c675b3 100644 --- a/test/src/scheme/tendermint-tps.json +++ b/test/src/scheme/tendermint-tps.json @@ -54,11 +54,6 @@ "params": { "maxExtraDataSize": "0x20", "networkID": "tc", - "minPayCost" : 10, - "minCreateShardCost" : 10, - "minSetShardOwnersCost" : 10, - "minSetShardUsersCost" : 10, - "minCustomCost" : 10, "maxBodySize": 4194304, "snapshotPeriod": 16384, "termSeconds": 0, diff --git a/test/src/sdk/core/types.ts b/test/src/sdk/core/types.ts index 482e9a3ba5..fdc5318513 100644 --- a/test/src/sdk/core/types.ts +++ b/test/src/sdk/core/types.ts @@ -5,11 +5,6 @@ export type NetworkId = string; export interface CommonParams { maxExtraDataSize: U64; networkID: NetworkId; - minPayCost: U64; - minCreateShardCost: U64; - minSetShardOwnersCost: U64; - minSetShardUsersCost: U64; - minCustomCost: U64; maxBodySize: U64; snapshotPeriod: U64; termSeconds: U64; diff --git a/types/src/common_params.rs b/types/src/common_params.rs index 2d49394dfa..f264d8290d 100644 --- a/types/src/common_params.rs +++ b/types/src/common_params.rs @@ -24,12 +24,6 @@ pub struct CommonParams { max_extra_data_size: usize, /// Network id. network_id: NetworkId, - /// Minimum transaction cost. - min_pay_transaction_cost: u64, - min_create_shard_transaction_cost: u64, - min_set_shard_owners_transaction_cost: u64, - min_set_shard_users_transaction_cost: u64, - min_custom_transaction_cost: u64, /// Maximum size of block body. max_body_size: usize, /// Snapshot creation period in unit of block numbers. @@ -55,21 +49,6 @@ impl CommonParams { pub fn network_id(&self) -> NetworkId { self.network_id } - pub fn min_pay_transaction_cost(&self) -> u64 { - self.min_pay_transaction_cost - } - pub fn min_create_shard_transaction_cost(&self) -> u64 { - self.min_create_shard_transaction_cost - } - pub fn min_set_shard_owners_transaction_cost(&self) -> u64 { - self.min_set_shard_owners_transaction_cost - } - pub fn min_set_shard_users_transaction_cost(&self) -> u64 { - self.min_set_shard_users_transaction_cost - } - pub fn min_custom_transaction_cost(&self) -> u64 { - self.min_custom_transaction_cost - } pub fn max_body_size(&self) -> usize { self.max_body_size } @@ -170,11 +149,6 @@ impl From for CommonParams { Self { max_extra_data_size: p.max_extra_data_size.into(), network_id: p.network_id, - min_pay_transaction_cost: p.min_pay_cost.into(), - min_create_shard_transaction_cost: p.min_create_shard_cost.into(), - min_set_shard_owners_transaction_cost: p.min_set_shard_owners_cost.into(), - min_set_shard_users_transaction_cost: p.min_set_shard_users_cost.into(), - min_custom_transaction_cost: p.min_custom_cost.into(), max_body_size: p.max_body_size.into(), snapshot_period: p.snapshot_period.into(), term_seconds: p.term_seconds.into(), @@ -197,11 +171,6 @@ impl From for Params { let mut result: Params = Params { max_extra_data_size: p.max_extra_data_size().into(), network_id: p.network_id(), - min_pay_cost: p.min_pay_transaction_cost().into(), - min_create_shard_cost: p.min_create_shard_transaction_cost().into(), - min_set_shard_owners_cost: p.min_set_shard_owners_transaction_cost().into(), - min_set_shard_users_cost: p.min_set_shard_users_transaction_cost().into(), - min_custom_cost: p.min_custom_transaction_cost().into(), max_body_size: p.max_body_size().into(), snapshot_period: p.snapshot_period().into(), term_seconds: p.term_seconds().into(), @@ -225,14 +194,9 @@ impl From for Params { impl Encodable for CommonParams { fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(19) + s.begin_list(14) .append(&self.max_extra_data_size) .append(&self.network_id) - .append(&self.min_pay_transaction_cost) - .append(&self.min_create_shard_transaction_cost) - .append(&self.min_set_shard_owners_transaction_cost) - .append(&self.min_set_shard_users_transaction_cost) - .append(&self.min_custom_transaction_cost) .append(&self.max_body_size) .append(&self.snapshot_period) .append(&self.term_seconds) @@ -251,42 +215,32 @@ impl Encodable for CommonParams { impl Decodable for CommonParams { fn decode(rlp: &Rlp<'_>) -> Result { let size = rlp.item_count()?; - if size != 19 { + if size != 14 { return Err(DecoderError::RlpIncorrectListLen { - expected: 19, + expected: 14, got: size, }) } let max_extra_data_size = rlp.val_at(0)?; let network_id = rlp.val_at(1)?; - let min_pay_transaction_cost = rlp.val_at(2)?; - let min_create_shard_transaction_cost = rlp.val_at(3)?; - let min_set_shard_owners_transaction_cost = rlp.val_at(4)?; - let min_set_shard_users_transaction_cost = rlp.val_at(5)?; - let min_custom_transaction_cost = rlp.val_at(6)?; - let max_body_size = rlp.val_at(7)?; - let snapshot_period = rlp.val_at(8)?; + let max_body_size = rlp.val_at(2)?; + let snapshot_period = rlp.val_at(3)?; - let term_seconds = rlp.val_at(9)?; - let nomination_expiration = rlp.val_at(10)?; - let custody_period = rlp.val_at(11)?; - let release_period = rlp.val_at(12)?; - let max_num_of_validators = rlp.val_at(13)?; - let min_num_of_validators = rlp.val_at(14)?; - let delegation_threshold = rlp.val_at(15)?; - let min_deposit = rlp.val_at(16)?; - let max_candidate_metadata_size = rlp.val_at(17)?; - let era = rlp.val_at(18)?; + let term_seconds = rlp.val_at(4)?; + let nomination_expiration = rlp.val_at(5)?; + let custody_period = rlp.val_at(6)?; + let release_period = rlp.val_at(7)?; + let max_num_of_validators = rlp.val_at(8)?; + let min_num_of_validators = rlp.val_at(9)?; + let delegation_threshold = rlp.val_at(10)?; + let min_deposit = rlp.val_at(11)?; + let max_candidate_metadata_size = rlp.val_at(12)?; + let era = rlp.val_at(13)?; Ok(Self { max_extra_data_size, network_id, - min_pay_transaction_cost, - min_create_shard_transaction_cost, - min_set_shard_owners_transaction_cost, - min_set_shard_users_transaction_cost, - min_custom_transaction_cost, max_body_size, snapshot_period, term_seconds, @@ -358,11 +312,6 @@ mod tests { let s = r#"{ "maxExtraDataSize": "0x20", "networkID" : "tc", - "minPayCost" : 10, - "minCreateShardCost" : 12, - "minSetShardOwnersCost" : 13, - "minSetShardUsersCost" : 14, - "minCustomCost" : 16, "maxBodySize" : 4194304, "snapshotPeriod": 16384, "termSeconds": 3600, @@ -380,11 +329,6 @@ mod tests { let deserialized = CommonParams::from(params.clone()); assert_eq!(deserialized.max_extra_data_size, 0x20); assert_eq!(deserialized.network_id, "tc".into()); - assert_eq!(deserialized.min_pay_transaction_cost, 10); - assert_eq!(deserialized.min_create_shard_transaction_cost, 12); - assert_eq!(deserialized.min_set_shard_owners_transaction_cost, 13); - assert_eq!(deserialized.min_set_shard_users_transaction_cost, 14); - assert_eq!(deserialized.min_custom_transaction_cost, 16); assert_eq!(deserialized.max_body_size, 4_194_304); assert_eq!(deserialized.snapshot_period, 16_384); assert_eq!(deserialized.term_seconds, 3600); @@ -407,11 +351,6 @@ mod tests { let s = r#"{ "maxExtraDataSize": "0x20", "networkID" : "tc", - "minPayCost" : 10, - "minCreateShardCost" : 12, - "minSetShardOwnersCost" : 13, - "minSetShardUsersCost" : 14, - "minCustomCost" : 16, "maxBodySize" : 4194304, "snapshotPeriod": 16384, "termSeconds": 3600, @@ -429,11 +368,6 @@ mod tests { let deserialized = CommonParams::from(params.clone()); assert_eq!(deserialized.max_extra_data_size, 0x20); assert_eq!(deserialized.network_id, "tc".into()); - assert_eq!(deserialized.min_pay_transaction_cost, 10); - assert_eq!(deserialized.min_create_shard_transaction_cost, 12); - assert_eq!(deserialized.min_set_shard_owners_transaction_cost, 13); - assert_eq!(deserialized.min_set_shard_users_transaction_cost, 14); - assert_eq!(deserialized.min_custom_transaction_cost, 16); assert_eq!(deserialized.max_body_size, 4_194_304); assert_eq!(deserialized.snapshot_period, 16_384); assert_eq!(deserialized.term_seconds, 3600);