Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Clean up serde rename and use rename_all = camelCase when possible #9823

Merged
merged 13 commits into from
Oct 29, 2018
6 changes: 3 additions & 3 deletions ethcore/wasm/run/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ethjson::bytes::Bytes;
pub enum Source {
Raw(Cow<'static, String>),
Constructor {
#[serde(rename="constructor")]
#[serde(rename = "constructor")]
source: Cow<'static, String>,
arguments: Bytes,
sender: Address,
Expand All @@ -42,13 +42,13 @@ impl Source {
}

#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Fixture {
pub caption: Cow<'static, String>,
pub source: Source,
pub address: Option<Address>,
pub sender: Option<Address>,
pub value: Option<Uint>,
#[serde(rename="gasLimit")]
pub gas_limit: Option<u64>,
pub payload: Option<Bytes>,
pub storage: Option<Vec<StorageEntry>>,
Expand All @@ -62,12 +62,12 @@ pub struct StorageEntry {
}

#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CallLocator {
pub sender: Option<Address>,
pub receiver: Option<Address>,
pub value: Option<Uint>,
pub data: Option<Bytes>,
#[serde(rename="codeAddress")]
pub code_address: Option<Address>,
}

Expand Down
4 changes: 2 additions & 2 deletions json/src/blockchain/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ use blockchain::transaction::Transaction;
/// Blockchain test block deserializer.
#[derive(Debug, PartialEq, Deserialize)]
pub struct Block {
#[serde(rename="blockHeader")]
#[serde(rename = "blockHeader")]
header: Option<Header>,
rlp: Bytes,
transactions: Option<Vec<Transaction>>,
#[serde(rename="uncleHeaders")]
#[serde(rename = "uncleHeaders")]
uncles: Option<Vec<Header>>,
}

Expand Down
10 changes: 5 additions & 5 deletions json/src/blockchain/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ use spec::{ForkSpec, Genesis, Seal, Ethereum};

/// Blockchain deserialization.
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BlockChain {
/// Genesis block header.
#[serde(rename="genesisBlockHeader")]
#[serde(rename = "genesisBlockHeader")]
pub genesis_block: Header,
/// Genesis block rlp.
#[serde(rename="genesisRLP")]
#[serde(rename = "genesisRLP")]
pub genesis_rlp: Option<Bytes>,
/// Blocks.
pub blocks: Vec<Block>,
/// Post state.
#[serde(rename="postState")]
pub post_state: State,
/// Pre state.
#[serde(rename="pre")]
#[serde(rename = "pre")]
pub pre_state: State,
/// Hash of best block.
#[serde(rename="lastblockhash")]
#[serde(rename = "lastblockhash")]
pub best_block: H256,
/// Network.
pub network: ForkSpec,
Expand Down
15 changes: 5 additions & 10 deletions json/src/blockchain/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,43 @@ use bytes::Bytes;

/// Blockchain test header deserializer.
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Header {
/// Blocks bloom.
pub bloom: Bloom,
/// Blocks author.
#[serde(rename="coinbase")]
#[serde(rename = "coinbase")]
pub author: Address,
/// Difficulty.
pub difficulty: Uint,
#[serde(rename="extraData")]
/// Extra data.
pub extra_data: Bytes,
/// Gas limit.
#[serde(rename="gasLimit")]
pub gas_limit: Uint,
/// Gas used.
#[serde(rename="gasUsed")]
pub gas_used: Uint,
/// Hash.
pub hash: H256,
#[serde(rename="mixHash")]
/// Mix hash.
pub mix_hash: H256,
/// Seal nonce.
pub nonce: H64,
/// Block number.
pub number: Uint,
/// Parent hash.
#[serde(rename="parentHash")]
pub parent_hash: H256,
/// Receipt root.
#[serde(rename="receiptTrie")]
#[serde(rename = "receiptTrie")]
pub receipts_root: H256,
/// State root.
#[serde(rename="stateRoot")]
pub state_root: H256,
/// Timestamp.
pub timestamp: Uint,
/// Transactions root.
#[serde(rename="transactionsTrie")]
#[serde(rename = "transactionsTrie")]
pub transactions_root: H256,
/// Uncles hash.
#[serde(rename="uncleHash")]
#[serde(rename = "uncleHash")]
pub uncles_hash: H256,
}

Expand Down
3 changes: 1 addition & 2 deletions json/src/blockchain/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ use bytes::Bytes;

/// Blockchain test transaction deserialization.
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Transaction {
data: Bytes,
#[serde(rename="gasLimit")]
gas_limit: Uint,
#[serde(rename="gasPrice")]
gas_price: Uint,
nonce: Uint,
r: Uint,
Expand Down
14 changes: 1 addition & 13 deletions json/src/spec/authority_round.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,37 @@ use super::ValidatorSet;

/// Authority params deserialization.
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthorityRoundParams {
/// Block duration, in seconds.
#[serde(rename="stepDuration")]
pub step_duration: Uint,
/// Valid authorities
pub validators: ValidatorSet,
/// Starting step. Determined automatically if not specified.
/// To be used for testing only.
#[serde(rename="startStep")]
pub start_step: Option<Uint>,
/// Block at which score validation should start.
#[serde(rename="validateScoreTransition")]
pub validate_score_transition: Option<Uint>,
/// Block from which monotonic steps start.
#[serde(rename="validateStepTransition")]
pub validate_step_transition: Option<Uint>,
/// Whether transitions should be immediate.
#[serde(rename="immediateTransitions")]
pub immediate_transitions: Option<bool>,
/// Reward per block in wei.
#[serde(rename="blockReward")]
pub block_reward: Option<Uint>,
/// Block at which the block reward contract should start being used.
#[serde(rename="blockRewardContractTransition")]
pub block_reward_contract_transition: Option<Uint>,
/// Block reward contract address (setting the block reward contract
/// overrides the static block reward definition).
#[serde(rename="blockRewardContractAddress")]
pub block_reward_contract_address: Option<Address>,
/// Block reward code. This overrides the block reward contract address.
#[serde(rename="blockRewardContractCode")]
pub block_reward_contract_code: Option<Bytes>,
/// Block at which maximum uncle count should be considered.
#[serde(rename="maximumUncleCountTransition")]
pub maximum_uncle_count_transition: Option<Uint>,
/// Maximum number of accepted uncles.
#[serde(rename="maximumUncleCount")]
pub maximum_uncle_count: Option<Uint>,
/// Block at which empty step messages should start.
#[serde(rename="emptyStepsTransition")]
pub empty_steps_transition: Option<Uint>,
/// Maximum number of accepted empty steps.
#[serde(rename="maximumEmptySteps")]
pub maximum_empty_steps: Option<Uint>,
}

Expand Down
2 changes: 1 addition & 1 deletion json/src/spec/basic_authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ use super::ValidatorSet;

/// Authority params deserialization.
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BasicAuthorityParams {
/// Block duration.
#[serde(rename="durationLimit")]
pub duration_limit: Uint,
/// Valid authorities
pub validators: ValidatorSet,
Expand Down
4 changes: 1 addition & 3 deletions json/src/spec/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ pub struct AltBn128Pairing {

/// Pricing variants.
#[derive(Debug, PartialEq, Deserialize, Clone)]
#[serde(rename_all = "snake_case")]
pub enum Pricing {
/// Linear pricing.
#[serde(rename="linear")]
Linear(Linear),
/// Pricing for modular exponentiation.
#[serde(rename="modexp")]
Modexp(Modexp),
/// Pricing for alt_bn128_pairing exponentiation.
#[serde(rename="alt_bn128_pairing")]
AltBn128Pairing(AltBn128Pairing),
}

Expand Down
7 changes: 2 additions & 5 deletions json/src/spec/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,20 @@ use super::{Ethash, BasicAuthority, AuthorityRound, Tendermint, NullEngine, Inst

/// Engine deserialization.
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum Engine {
/// Null engine.
#[serde(rename="null")]
Null(NullEngine),
/// Instantly sealing engine.
#[serde(rename="instantSeal")]
InstantSeal(Option<InstantSeal>),
/// Ethash engine.
#[serde(rename = "Ethash")]
Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

Ethash(Ethash),
/// BasicAuthority engine.
#[serde(rename="basicAuthority")]
BasicAuthority(BasicAuthority),
/// AuthorityRound engine.
#[serde(rename="authorityRound")]
AuthorityRound(AuthorityRound),
/// Tendermint engine.
#[serde(rename="tendermint")]
Tendermint(Tendermint)
}

Expand Down
24 changes: 1 addition & 23 deletions json/src/spec/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,89 +31,67 @@ pub enum BlockReward {

/// Deserializable doppelganger of EthashParams.
#[derive(Clone, Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EthashParams {
/// See main EthashParams docs.
#[serde(rename="minimumDifficulty")]
#[serde(deserialize_with="uint::validate_non_zero")]
pub minimum_difficulty: Uint,
/// See main EthashParams docs.
#[serde(rename="difficultyBoundDivisor")]
#[serde(deserialize_with="uint::validate_non_zero")]
pub difficulty_bound_divisor: Uint,
/// See main EthashParams docs.
#[serde(rename="difficultyIncrementDivisor")]
#[serde(default, deserialize_with="uint::validate_optional_non_zero")]
pub difficulty_increment_divisor: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="metropolisDifficultyIncrementDivisor")]
#[serde(default, deserialize_with="uint::validate_optional_non_zero")]
pub metropolis_difficulty_increment_divisor: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="durationLimit")]
pub duration_limit: Option<Uint>,

/// See main EthashParams docs.
#[serde(rename="homesteadTransition")]
pub homestead_transition: Option<Uint>,
/// Reward per block in wei.
#[serde(rename="blockReward")]
pub block_reward: Option<BlockReward>,
/// Block at which the block reward contract should start being used.
#[serde(rename="blockRewardContractTransition")]
pub block_reward_contract_transition: Option<Uint>,
/// Block reward contract address (setting the block reward contract
/// overrides all other block reward parameters).
#[serde(rename="blockRewardContractAddress")]
pub block_reward_contract_address: Option<Address>,
/// Block reward code. This overrides the block reward contract address.
#[serde(rename="blockRewardContractCode")]
pub block_reward_contract_code: Option<Bytes>,

/// See main EthashParams docs.
#[serde(rename="daoHardforkTransition")]
pub dao_hardfork_transition: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="daoHardforkBeneficiary")]
pub dao_hardfork_beneficiary: Option<Address>,
/// See main EthashParams docs.
#[serde(rename="daoHardforkAccounts")]
pub dao_hardfork_accounts: Option<Vec<Address>>,

/// See main EthashParams docs.
#[serde(rename="difficultyHardforkTransition")]
pub difficulty_hardfork_transition: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="difficultyHardforkBoundDivisor")]
#[serde(default, deserialize_with="uint::validate_optional_non_zero")]
pub difficulty_hardfork_bound_divisor: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="bombDefuseTransition")]
pub bomb_defuse_transition: Option<Uint>,

/// See main EthashParams docs.
#[serde(rename="eip100bTransition")]
pub eip100b_transition: Option<Uint>,

/// See main EthashParams docs.
#[serde(rename="ecip1010PauseTransition")]
pub ecip1010_pause_transition: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="ecip1010ContinueTransition")]
pub ecip1010_continue_transition: Option<Uint>,

/// See main EthashParams docs.
#[serde(rename="ecip1017EraRounds")]
pub ecip1017_era_rounds: Option<Uint>,

/// Delays of difficulty bombs.
#[serde(rename="difficultyBombDelays")]
pub difficulty_bomb_delays: Option<BTreeMap<Uint, Uint>>,

/// EXPIP-2 block height
#[serde(rename="expip2Transition")]
pub expip2_transition: Option<Uint>,
/// EXPIP-2 duration limit
#[serde(rename="expip2DurationLimit")]
pub expip2_duration_limit: Option<Uint>,
}

Expand Down
8 changes: 1 addition & 7 deletions json/src/spec/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use spec::Seal;

/// Spec genesis.
#[derive(Debug, PartialEq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Genesis {
/// Seal.
pub seal: Seal,
Expand All @@ -33,26 +34,19 @@ pub struct Genesis {
/// Block timestamp, defaults to 0.
pub timestamp: Option<Uint>,
/// Parent hash, defaults to 0.
#[serde(rename="parentHash")]
pub parent_hash: Option<H256>,
/// Gas limit.
#[serde(rename="gasLimit")]
#[serde(deserialize_with="uint::validate_non_zero")]
pub gas_limit: Uint,
/// Transactions root.
#[serde(rename="transactionsRoot")]
pub transactions_root: Option<H256>,
/// Receipts root.
#[serde(rename="receiptsRoot")]
pub receipts_root: Option<H256>,
/// State root.
#[serde(rename="stateRoot")]
pub state_root: Option<H256>,
/// Gas used.
#[serde(rename="gasUsed")]
pub gas_used: Option<Uint>,
/// Extra data.
#[serde(rename="extraData")]
pub extra_data: Option<Bytes>,
}

Expand Down
4 changes: 2 additions & 2 deletions json/src/spec/hardcoded_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ use uint::Uint;

/// Spec hardcoded sync.
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HardcodedSync {
/// Hexadecimal of the RLP encoding of the header of the block to start synchronization from.
pub header: String,
/// Total difficulty including the block of `header`.
#[serde(rename="totalDifficulty")]
pub total_difficulty: Uint,
/// Ordered trie roots of blocks before and including `header`.
#[serde(rename="CHTs")]
#[serde(rename = "CHTs")]
pub chts: Vec<H256>,
}

Expand Down
Loading