diff --git a/codechain/constants.rs b/codechain/constants.rs index b57736a6e1..2d7dbd0bca 100644 --- a/codechain/constants.rs +++ b/codechain/constants.rs @@ -16,4 +16,4 @@ pub const DEFAULT_CONFIG_PATH: &'static str = "codechain/config/presets/config.dev.toml"; pub const DEFAULT_KEYS_PATH: &'static str = "keys"; -pub const DEFAULT_NETWORK_ID: u64 = 0x11; +pub const DEFAULT_NETWORK_ID: u32 = 0x11; diff --git a/core/src/client/test_client.rs b/core/src/client/test_client.rs index 9cc7dac73b..968007a114 100644 --- a/core/src/client/test_client.rs +++ b/core/src/client/test_client.rs @@ -198,7 +198,7 @@ impl TestBlockChainClient { let parcel = Parcel { nonce: U256::zero(), fee: U256::from(10), - network_id: 0u64, + network_id: 0, action: Action::ChangeShardState { transactions: vec![], changes: vec![], @@ -266,7 +266,7 @@ impl TestBlockChainClient { let parcel = Parcel { nonce: U256::zero(), fee: U256::from(10), - network_id: 0u64, + network_id: 0, action: Action::ChangeShardState { transactions, changes: vec![], diff --git a/core/src/miner/local_parcels.rs b/core/src/miner/local_parcels.rs index 60ee69e616..1e9d976dc1 100644 --- a/core/src/miner/local_parcels.rs +++ b/core/src/miner/local_parcels.rs @@ -222,7 +222,7 @@ mod tests { changes: vec![], signatures: vec![], }, - network_id: 0u64, + network_id: 0, }; SignedParcel::new_with_sign(parcel, keypair.private()) } diff --git a/core/src/spec/spec.rs b/core/src/spec/spec.rs index 44a2daed49..7cc2803c56 100644 --- a/core/src/spec/spec.rs +++ b/core/src/spec/spec.rs @@ -49,7 +49,7 @@ pub struct CommonParams { /// Maximum size of metadata. pub max_metadata_size: usize, /// Network id. - pub network_id: u64, + pub network_id: u32, /// Minimum parcel cost. pub min_parcel_cost: U256, /// Maximum size of block body. @@ -62,10 +62,11 @@ pub struct CommonParams { impl From for CommonParams { fn from(p: cjson::spec::Params) -> Self { + let network_id: u64 = p.network_id.into(); Self { max_extra_data_size: p.max_extra_data_size.into(), max_metadata_size: p.max_metadata_size.into(), - network_id: p.network_id.into(), + network_id: network_id as u32, min_parcel_cost: p.min_parcel_cost.into(), max_body_size: p.max_body_size.into(), snapshot_period: p.snapshot_period.into(), diff --git a/docs/parcel.rst b/docs/parcel.rst index ee06265e2a..8511d1e318 100644 --- a/docs/parcel.rst +++ b/docs/parcel.rst @@ -28,7 +28,7 @@ A parcel would look something like this: pub struct Parcel { pub nonce: U256, pub fee: U256, - pub network_id: u64, + pub network_id: u32, pub action: Action, } @@ -46,4 +46,4 @@ A parcel would look something like this: } The fee of the parcel would determine its priority, meaning, how quickly it gets processed. In addition, there is -also a minimum fee that can be set. The nonce property exists for the purpose of preventing replay attacks. \ No newline at end of file +also a minimum fee that can be set. The nonce property exists for the purpose of preventing replay attacks. diff --git a/key/src/address.rs b/key/src/address.rs index b431d4f4d9..f37b20e6d5 100644 --- a/key/src/address.rs +++ b/key/src/address.rs @@ -168,7 +168,7 @@ pub struct FullAddress { } impl FullAddress { - pub fn create_version0(network_id: u64, address: Address) -> Result { + pub fn create_version0(network_id: u32, address: Address) -> Result { let network = match network_id { // FIXME: 0x11 is the network id for SOLO 0x11 => Network::Mainnet, diff --git a/rpc/src/v1/impls/account.rs b/rpc/src/v1/impls/account.rs index ebf89fbea1..a7b33c71c7 100644 --- a/rpc/src/v1/impls/account.rs +++ b/rpc/src/v1/impls/account.rs @@ -26,11 +26,11 @@ use super::super::traits::Account; pub struct AccountClient { account_provider: Arc, - network_id: u64, + network_id: u32, } impl AccountClient { - pub fn new(ap: &Arc, network_id: u64) -> Self { + pub fn new(ap: &Arc, network_id: u32) -> Self { AccountClient { account_provider: ap.clone(), network_id, diff --git a/rpc/src/v1/impls/chain.rs b/rpc/src/v1/impls/chain.rs index b34c80c9ab..7922511efa 100644 --- a/rpc/src/v1/impls/chain.rs +++ b/rpc/src/v1/impls/chain.rs @@ -192,7 +192,7 @@ where } } - fn get_network_id(&self) -> Result { + fn get_network_id(&self) -> Result { Ok(self.client.common_params().network_id) } diff --git a/rpc/src/v1/traits/chain.rs b/rpc/src/v1/traits/chain.rs index e68b917718..b540808228 100644 --- a/rpc/src/v1/traits/chain.rs +++ b/rpc/src/v1/traits/chain.rs @@ -114,7 +114,7 @@ build_rpc_trait! { /// Return the network id that is used in this chain. # [rpc(name = "chain_getNetworkId")] - fn get_network_id(&self) -> Result; + fn get_network_id(&self) -> Result; /// Execute Transactions # [rpc(name = "chain_executeTransactions")] diff --git a/rpc/src/v1/types/parcel.rs b/rpc/src/v1/types/parcel.rs index 29f398c408..a085278146 100644 --- a/rpc/src/v1/types/parcel.rs +++ b/rpc/src/v1/types/parcel.rs @@ -27,7 +27,7 @@ pub struct Parcel { pub parcel_index: Option, pub nonce: U256, pub fee: U256, - pub network_id: u64, + pub network_id: u32, pub action: Action, pub hash: H256, pub sig: Signature, diff --git a/spec/Parcel.md b/spec/Parcel.md index 3930541b14..799f824ccd 100644 --- a/spec/Parcel.md +++ b/spec/Parcel.md @@ -12,7 +12,7 @@ struct Parcel { expiration_time: Option, nonce: U256, fee: U256, - network_id: u64, + network_id: u32, action: Action, } @@ -68,7 +68,7 @@ enum Transaction { ```rust AssetMint { - network_id: u64, + network_id: u32, shard_id: u32, metadata: String, registrar: Option
, diff --git a/state/src/impls/top_level.rs b/state/src/impls/top_level.rs index 19d8556034..3a526708ce 100644 --- a/state/src/impls/top_level.rs +++ b/state/src/impls/top_level.rs @@ -403,7 +403,7 @@ impl TopLevelState { fn apply_action( &mut self, action: &Action, - network_id: &u64, + network_id: &u32, fee_payer: &Address, fee_payer_public: &Public, ) -> StateResult { diff --git a/types/src/parcel/parcel.rs b/types/src/parcel/parcel.rs index c0be537cf4..ae294bb808 100644 --- a/types/src/parcel/parcel.rs +++ b/types/src/parcel/parcel.rs @@ -28,7 +28,7 @@ pub struct Parcel { /// Amount of CCC to be paid as a cost for distributing this parcel to the network. pub fee: U256, /// Mainnet or Testnet - pub network_id: u64, + pub network_id: u32, pub action: Action, } diff --git a/types/src/transaction/transaction.rs b/types/src/transaction/transaction.rs index 69ac491aab..75c31a336c 100644 --- a/types/src/transaction/transaction.rs +++ b/types/src/transaction/transaction.rs @@ -58,14 +58,14 @@ pub struct AssetTransferOutput { pub enum Transaction { #[serde(rename_all = "camelCase")] CreateWorld { - network_id: u64, + network_id: u32, shard_id: ShardId, nonce: u64, owners: Vec
, }, #[serde(rename_all = "camelCase")] SetWorldOwners { - network_id: u64, + network_id: u32, shard_id: ShardId, world_id: WorldId, nonce: u64, @@ -73,7 +73,7 @@ pub enum Transaction { }, #[serde(rename_all = "camelCase")] AssetMint { - network_id: u64, + network_id: u32, shard_id: ShardId, metadata: String, registrar: Option
, @@ -83,7 +83,7 @@ pub enum Transaction { }, #[serde(rename_all = "camelCase")] AssetTransfer { - network_id: u64, + network_id: u32, burns: Vec, inputs: Vec, outputs: Vec, @@ -145,7 +145,7 @@ impl Transaction { blake256(&*self.without_script().rlp_bytes()) } - pub fn network_id(&self) -> u64 { + pub fn network_id(&self) -> u32 { match self { Transaction::CreateWorld { network_id,