Skip to content

Commit

Permalink
eip1559 support
Browse files Browse the repository at this point in the history
Co-authored-by: simonjiao <[email protected]>
  • Loading branch information
harryliisme3 and simonjiao committed Jan 19, 2023
1 parent 5e114a5 commit c57a032
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 13 deletions.
3 changes: 3 additions & 0 deletions src/components/config/src/abci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct CheckPointConfig {
// Fix the amount in the delegators that staking did not modify when it punished the validator.
pub fix_delegators_am_height: u64,
pub validators_limit_v2_height: u64,
pub enable_eip1559_height: u64,
}

impl CheckPointConfig {
Expand Down Expand Up @@ -127,6 +128,7 @@ impl CheckPointConfig {
proper_gas_set_height: 0,
fix_delegators_am_height: 0,
validators_limit_v2_height: 0,
enable_eip1559_height: 0,
};
#[cfg(not(feature = "debug_env"))]
let config = CheckPointConfig {
Expand Down Expand Up @@ -156,6 +158,7 @@ impl CheckPointConfig {
fix_undelegation_missing_reward_height: 3000000,
fix_delegators_am_height: 30000000,
validators_limit_v2_height: 30000000,
enable_eip1559_height: 40000000,
};
let content = toml::to_string(&config).unwrap();
file.write_all(content.as_bytes()).unwrap();
Expand Down
1 change: 1 addition & 0 deletions src/components/contracts/primitives/rpc-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description = "RPC traits of Ethereum."
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
ethereum = { version = "0.12.0", default-features = false, features = ["with-serde"] }
ethereum-types = "0.13.1"
futures = "0.3.16"
jsonrpc-core = { git = "https://github.com/FindoraNetwork/jsonrpc.git", package = "jsonrpc-core" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ use std::ops::Deref;

use crate::types::{Bytes, Transaction};
use ethereum_types::{Bloom as H2048, H160, H256, U256};
use serde::ser::Error;
use serde::{Serialize, Serializer};
use serde::{ser::Error, Serialize, Serializer};

/// Block Transactions
#[derive(Debug)]
Expand Down Expand Up @@ -90,6 +89,9 @@ pub struct Block {
pub transactions: BlockTransactions,
/// Size in bytes
pub size: Option<U256>,
/// Base Fee for post-EIP1559 blocks.
#[serde(skip_serializing_if = "Option::is_none")]
pub base_fee_per_gas: Option<U256>,
}

/// Block header representation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pub struct CallRequest {
pub to: Option<H160>,
/// Gas Price
pub gas_price: Option<U256>,
/// EIP-1559 Max base fee the caller is willing to pay
pub max_fee_per_gas: Option<U256>,
/// EIP-1559 Priority fee the caller is paying to the block author
pub max_priority_fee_per_gas: Option<U256>,
/// Gas
pub gas: Option<U256>,
/// Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ pub struct Receipt {
// NOTE(niklasad1): Unknown after EIP98 rules, if it's missing then skip serializing it
#[serde(skip_serializing_if = "Option::is_none", rename = "status")]
pub status_code: Option<U64>,
/// Effective gas price. Pre-eip1559 this is just the gasprice. Post-eip1559 this is base fee + priority fee.
pub effective_gas_price: U256,
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::types::Bytes;
use ethereum::AccessListItem;
use ethereum_types::{H160, H256, H512, U256, U64};
use serde::ser::SerializeStruct;
use serde::{Serialize, Serializer};
use serde::{ser::SerializeStruct, Serialize, Serializer};
use std::{
collections::HashMap,
sync::{Arc, Mutex},
Expand All @@ -46,7 +46,14 @@ pub struct Transaction {
/// Transfered value
pub value: U256,
/// Gas Price
pub gas_price: U256,
#[serde(skip_serializing_if = "Option::is_none")]
pub gas_price: Option<U256>,
/// eip1559. Max BaseFeePerGas the user is willing to pay.
#[serde(skip_serializing_if = "Option::is_none")]
pub max_fee_per_gas: Option<U256>,
/// eip1559.The miner's tip.
#[serde(skip_serializing_if = "Option::is_none")]
pub max_priority_fee_per_gas: Option<U256>,
/// Gas
pub gas: U256,
/// Data
Expand All @@ -67,6 +74,9 @@ pub struct Transaction {
pub r: U256,
/// The S field of the signature.
pub s: U256,
/// eip1559. Pre-pay to warm storage access.
#[cfg_attr(feature = "std", serde(skip_serializing_if = "Option::is_none"))]
pub access_list: Option<Vec<AccessListItem>>,
}

/// Local Transaction Status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
//! `TransactionRequest` type
use crate::types::Bytes;
use ethereum::AccessListItem;
use ethereum_types::{H160, U256};
use serde::{Deserialize, Serialize};

/// Transaction request coming from RPC
#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
#[serde(rename_all = "camelCase")]
pub struct TransactionRequest {
Expand All @@ -32,7 +33,14 @@ pub struct TransactionRequest {
/// Recipient
pub to: Option<H160>,
/// Gas Price
#[serde(default)]
pub gas_price: Option<U256>,
/// Max BaseFeePerGas the user is willing to pay.
#[serde(default)]
pub max_fee_per_gas: Option<U256>,
/// The miner's tip.
#[serde(default)]
pub max_priority_fee_per_gas: Option<U256>,
/// Gas
pub gas: Option<U256>,
/// Value of transaction in wei
Expand All @@ -41,4 +49,7 @@ pub struct TransactionRequest {
pub data: Option<Bytes>,
/// Transaction's nonce
pub nonce: Option<U256>,
/// Pre-pay to warm storage access.
#[serde(default)]
pub access_list: Option<Vec<AccessListItem>>,
}
Loading

0 comments on commit c57a032

Please sign in to comment.