Skip to content

Commit 481c8c4

Browse files
committed
Zero values instead of Option
1 parent c88f72c commit 481c8c4

4 files changed

Lines changed: 12 additions & 19 deletions

File tree

substrate/frame/revive/rpc/src/client.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,7 @@ impl Client {
665665
transactions_root: extrinsics_root,
666666
number: header.number.into(),
667667
timestamp: timestamp.into(),
668-
difficulty: Some(0u32.into()),
669-
base_fee_per_gas: runtime_api.gas_price().await.ok(),
668+
base_fee_per_gas: runtime_api.gas_price().await.ok().unwrap_or_default(),
670669
gas_limit,
671670
gas_used,
672671
receipts_root: extrinsics_root,

substrate/frame/revive/rpc/src/fee_history_provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl FeeHistoryProvider {
4747
let block_number: SubstrateBlockNumber =
4848
block.number.try_into().expect("Block number is always valid");
4949

50-
let base_fee = block.base_fee_per_gas.unwrap_or_default().as_u128();
50+
let base_fee = block.base_fee_per_gas.as_u128();
5151
let gas_used = block.gas_used.as_u128();
5252
let gas_used_ratio = (gas_used as f64) / (block.gas_limit.as_u128() as f64);
5353
let mut result = FeeHistoryCacheItem { base_fee, gas_used_ratio, rewards: vec![] };

substrate/frame/revive/rpc/src/receipt_provider.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<B: BlockInfoProvider> ReceiptProvider<B> {
381381
topics,
382382
transaction_hash: H256::from_slice(&transaction_hash),
383383
transaction_index: U256::from(transaction_index as u64),
384-
removed: None,
384+
removed: false,
385385
})
386386
})
387387
.fetch_all(&self.pool)

substrate/frame/revive/src/evm/api/rpc_types_gen.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,13 @@ fn deserialize_input_or_data<'d, D: Deserializer<'d>>(d: D) -> Result<InputOrDat
7878
#[serde(rename_all = "camelCase")]
7979
pub struct Block {
8080
/// Base fee per gas
81-
#[serde(skip_serializing_if = "Option::is_none")]
82-
pub base_fee_per_gas: Option<U256>,
81+
pub base_fee_per_gas: U256,
8382
/// Blob gas used
84-
#[serde(skip_serializing_if = "Option::is_none")]
85-
pub blob_gas_used: Option<U256>,
83+
pub blob_gas_used: U256,
8684
/// Difficulty
87-
#[serde(skip_serializing_if = "Option::is_none")]
88-
pub difficulty: Option<U256>,
85+
pub difficulty: U256,
8986
/// Excess blob gas
90-
#[serde(skip_serializing_if = "Option::is_none")]
91-
pub excess_blob_gas: Option<U256>,
87+
pub excess_blob_gas: U256,
9288
/// Extra data
9389
pub extra_data: Bytes,
9490
/// Gas limit
@@ -131,11 +127,9 @@ pub struct Block {
131127
/// Uncles
132128
pub uncles: Vec<H256>,
133129
/// Withdrawals
134-
#[serde(default, skip_serializing_if = "Vec::is_empty")]
135130
pub withdrawals: Vec<Withdrawal>,
136131
/// Withdrawals root
137-
#[serde(skip_serializing_if = "Option::is_none")]
138-
pub withdrawals_root: Option<H256>,
132+
pub withdrawals_root: H256,
139133
}
140134

141135
/// Block number or tag
@@ -251,7 +245,7 @@ pub struct GenericTransaction {
251245
pub access_list: Option<AccessList>,
252246
/// blobVersionedHashes
253247
/// List of versioned blob hashes associated with the transaction's EIP-4844 data blobs.
254-
#[serde(default, skip_serializing_if = "Vec::is_empty")]
248+
#[serde(default)]
255249
pub blob_versioned_hashes: Vec<H256>,
256250
/// blobs
257251
/// Raw blob data.
@@ -483,10 +477,10 @@ pub struct Log {
483477
/// log index
484478
pub log_index: U256,
485479
/// removed
486-
#[serde(skip_serializing_if = "Option::is_none")]
487-
pub removed: Option<bool>,
480+
#[serde(default)]
481+
pub removed: bool,
488482
/// topics
489-
#[serde(default, skip_serializing_if = "Vec::is_empty")]
483+
#[serde(default)]
490484
pub topics: Vec<H256>,
491485
/// transaction hash
492486
pub transaction_hash: H256,

0 commit comments

Comments
 (0)