Skip to content

Commit

Permalink
Merge branch 'develop_eip1559' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
harryliisme3 committed Nov 29, 2022
2 parents 6fd5ede + 32ae058 commit 8a4f6cb
Show file tree
Hide file tree
Showing 48 changed files with 1,644 additions and 351 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ build_release_goleveldb:
cargo build --release --bins -p abciapp -p finutils
$(call pack,release)

check: tendermint_goleveldb
cargo check --release --bins -p abciapp -p finutils
$(call pack,release)

# Build for goleveldb
build_release_musl_goleveldb: tendermint_goleveldb
cargo build --release --bins -p abciapp -p finutils --target=x86_64-unknown-linux-musl
Expand Down
2 changes: 1 addition & 1 deletion src/components/abciapp/src/abci/server/callback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ pub fn end_block(
if td_height <= CFG.checkpoint.disable_evm_block_height
|| td_height >= CFG.checkpoint.enable_frc20_height
{
let _ = s.account_base_app.write().end_block(req);
s.account_base_app.write().end_block(req);
}

// mint coinbase, cache system transactions to ledger
Expand Down
8 changes: 8 additions & 0 deletions src/components/config/src/abci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,14 @@ pub struct CheckPointConfig {
pub nonce_bug_fix_height: u64,
pub proper_gas_set_height: u64,


// https://github.com/FindoraNetwork/platform/pull/434
// 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,
// Note: This field only used to qa02.
pub qa02_prismxx_asset: i64,
pub enable_eip1559_height: u64,
}

impl CheckPointConfig {
Expand Down Expand Up @@ -127,6 +131,8 @@ impl CheckPointConfig {
proper_gas_set_height: 0,
fix_delegators_am_height: 0,
validators_limit_v2_height: 0,
qa02_prismxx_asset: 0,
enable_eip1559_height: 0,
};
#[cfg(not(feature = "debug_env"))]
let config = CheckPointConfig {
Expand Down Expand Up @@ -156,6 +162,8 @@ impl CheckPointConfig {
fix_undelegation_missing_reward_height: 3000000,
fix_delegators_am_height: 30000000,
validators_limit_v2_height: 30000000,
qa02_prismxx_asset: 30000000,
enable_eip1559_height: 40000000,
};
let content = toml::to_string(&config).unwrap();
file.write_all(content.as_bytes()).unwrap();
Expand Down
3 changes: 2 additions & 1 deletion src/components/contracts/baseapp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ serde_json = "1.0.40"
attohttpc = { version = "0.18", default-features = false, features = ["compress", "json", "tls-rustls"] }
base64 = "0.13"
once_cell = "1.10.0"

storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0" }
sha3 = "0.8"

config = { path = "../../config"}


# primitives
fp-core = {path = "../primitives/core"}
fp-evm = {path = "../primitives/evm"}
Expand All @@ -53,7 +55,6 @@ evm-precompile-sha3fips = { path = "../modules/evm/precompile/sha3fips" }
evm-precompile-eth-pairings = { path = "../modules/evm/precompile/eth-pairings" }
evm-precompile = {path = "../modules/evm/precompile"}


[features]
abci_mock = []
web3_service = ["enterprise-web3", "module-account/web3_service", "module-ethereum/web3_service", "module-evm/web3_service"]
37 changes: 36 additions & 1 deletion src/components/contracts/baseapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod tm_events;

use crate::modules::ModuleManager;
use abci::Header;
use ethereum::BlockV0 as Block;
use ethereum::BlockV2 as Block;
use evm_precompile::{self, FindoraPrecompiles};
use fin_db::{FinDB, RocksDB};
use fp_core::context::Context as Context2;
Expand All @@ -24,6 +24,7 @@ use fp_core::{
transaction::{ActionResult, Executable, ValidateUnsigned},
};
use fp_evm::BlockId;
use fp_traits::evm::FeeCalculator as FeeCalculator2;
use fp_traits::{
account::{AccountAsset, FeeCalculator},
base::BaseProvider,
Expand Down Expand Up @@ -54,6 +55,23 @@ const CHAIN_STATE_PATH: &str = "state.db";
const CHAIN_HISTORY_DATA_PATH: &str = "history.db";
const BLOCKS_IN_DAY: u64 = 4 * 60 * 24;

const INITIAL_BASE_FEE: u64 = 1000000000;
const ELASTICITY_MULTIPLIER: u64 = 2;
const BASE_FEE_MAX_CHANGE_DENOMINATOR: u64 = 8;

#[inline(always)]
pub fn get_initial_base_fee() -> U256 {
U256::from(INITIAL_BASE_FEE)
}
#[inline(always)]
pub fn get_elasticity_multiplier() -> U256 {
U256::from(ELASTICITY_MULTIPLIER)
}
#[inline(always)]
pub fn get_base_fee_max_change_denominator() -> U256 {
U256::from(BASE_FEE_MAX_CHANGE_DENOMINATOR)
}

#[derive(Clone)]
pub struct BaseApp {
/// application name from abci.Info
Expand Down Expand Up @@ -467,4 +485,21 @@ impl BaseProvider for BaseApp {
None
}
}

/// Return the base fee at the given height.
#[allow(clippy::comparison_chain, clippy::question_mark)]
fn base_fee(&self, id: Option<BlockId>) -> Option<U256> {
let _ = id;
Some(
<BaseApp as module_evm::Config>::FeeCalculator::min_gas_price(
self.current_block_number()?.as_u64(),
),
)
}

/// Return `true` if the request BlockId is post-eip1559.
/// Do not be used.
fn is_eip1559(&self, _id: Option<BlockId>) -> bool {
false
}
}
2 changes: 1 addition & 1 deletion src/components/contracts/modules/account/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.0.0"
noah = { git = "https://github.com/FindoraNetwork/noah", tag = "v0.3.0" }

[features]
web3_service = ["enterprise-web3"]
web3_service = ["enterprise-web3"]
10 changes: 10 additions & 0 deletions src/components/contracts/modules/account/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,14 @@ impl<C: Config> AccountAsset<Address> for App<C> {
) -> Result<()> {
Allowances::insert(ctx.state.write().borrow_mut(), owner, spender, &amount)
}

fn income(ctx: &Context, who: &Address, value: U256) -> Result<()> {
if value.is_zero() {
return Ok(());
}

let mut sa = Self::account_of(ctx, who, None).c(d!("account does not exist"))?;
sa.balance = sa.balance.checked_add(value).c(d!("balance overflow"))?;
AccountStore::insert(ctx.state.write().borrow_mut(), who, &sa)
}
}
Loading

0 comments on commit 8a4f6cb

Please sign in to comment.