Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci test #996

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 0 additions & 92 deletions .github/workflows/RPCNodeRelease.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ members = [
"src/components/contracts/modules/evm/precompile/modexp",
"src/components/contracts/modules/evm/precompile/sha3fips",
"src/components/contracts/modules/evm/precompile/anemoi",
"src/components/contracts/modules/evm/precompile/blake2",
"src/components/contracts/modules/evm/precompile/bn128",
"src/components/contracts/modules/evm/precompile/utils",
"src/components/contracts/modules/evm/precompile/utils/macro",
"src/components/contracts/modules/xhub",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ build_musl_fn_macos_base:
build_musl_fn_macos:
docker build -t musl_fn_macos -f container/Dockerfile-fn-musl-macos .
docker run -d --rm --name fn_macos musl_fn_macos
docker cp fn_macos:/volume/target/x86_64-apple-darwin/release/fn fn
docker cp fn_macos:/platform/target/x86_64-apple-darwin/release/fn fn
tar -czvf fn_macos.tar.gz fn
rm fn

Expand Down
93 changes: 78 additions & 15 deletions src/components/abciapp/src/abci/server/callback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
//! # Impl function of tendermint ABCI
//!

use globutils::wallet;
use ledger::{
data_model::ASSET_TYPE_FRA,
staking::{FF_ADDR_EXTRA_120_0000, FF_ADDR_LIST},
};
use zei::xfr::asset_record::AssetRecordType;

mod utils;

use {
Expand Down Expand Up @@ -29,7 +36,7 @@ use {
ledger::{
converter::is_convert_account,
data_model::Operation,
staking::KEEP_HIST,
staking::{evm::EVM_STAKING, KEEP_HIST, VALIDATOR_UPDATE_BLOCK_ITV},
store::{
api_cache,
fbnc::{new_mapx, Mapx},
Expand Down Expand Up @@ -470,6 +477,33 @@ pub fn end_block(

let mut la = s.la.write();

if header.height == CFG.checkpoint.evm_staking_inital_height {
let ledger_state = la.get_committed_state().read();
let staking = ledger_state.get_staking();
let validators = staking
.validator_get_current()
.map(|v| v.get_validators().values().cloned().collect::<Vec<_>>())
.unwrap_or_default();

let delegations = staking
.get_global_delegation_records()
.values()
.map(|v| (v.id, v.clone()))
.collect();
let coinbase_balance = staking.coinbase_balance();

if let Err(e) = EVM_STAKING.get().c(d!()).and_then(|staking| {
staking.write().import_validators(
&validators,
&delegations,
coinbase_balance,
)
}) {
tracing::error!(target: "evm staking", "import_validators error:{:?}", e);
panic!()
};
}

// mint coinbase, cache system transactions to ledger
{
let laa = la.get_committed_state().read();
Expand All @@ -485,25 +519,54 @@ pub fn end_block(
if !la.all_commited() && la.block_txn_count() != 0 {
pnk!(la.end_block());
}
if td_height <= CFG.checkpoint.evm_staking_inital_height {
if let Ok(Some(vs)) = ruc::info!(staking::get_validators(
la.get_committed_state().read().get_staking().deref(),
begin_block_req.last_commit_info.as_ref()
)) {
resp.set_validator_updates(RepeatedField::from_vec(vs));
}

if let Ok(Some(vs)) = ruc::info!(staking::get_validators(
la.get_committed_state().read().get_staking().deref(),
begin_block_req.last_commit_info.as_ref()
)) {
resp.set_validator_updates(RepeatedField::from_vec(vs));
staking::system_ops(
&mut la.get_committed_state().write(),
&header,
begin_block_req.last_commit_info.as_ref(),
&begin_block_req.byzantine_validators.as_slice(),
);
}

staking::system_ops(
&mut la.get_committed_state().write(),
&header,
begin_block_req.last_commit_info.as_ref(),
&begin_block_req.byzantine_validators.as_slice(),
);

if td_height <= CFG.checkpoint.disable_evm_block_height
let evm_resp = 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);
let mut sum = 0;
let ledger = la.get_committed_state().read();
let mut addrs = FF_ADDR_LIST.to_vec();
addrs.push(FF_ADDR_EXTRA_120_0000);
for fra_addr in addrs.iter() {
for (_, (utxo, _)) in pnk!(wallet::public_key_from_bech32(fra_addr)
.and_then(|pub_key| ledger.get_owned_utxos(&pub_key)))
{
if AssetRecordType::NonConfidentialAmount_NonConfidentialAssetType
== utxo.0.record.get_record_type()
&& Some(ASSET_TYPE_FRA) == utxo.0.record.asset_type.get_asset_type()
{
if let Some(v) = utxo.0.record.amount.get_amount() {
sum += v;
};
}
}
}

s.account_base_app.write().end_block(req, sum)
} else {
Default::default()
};

if td_height > CFG.checkpoint.evm_staking_inital_height
&& 0 == TENDERMINT_BLOCK_HEIGHT.load(Ordering::Relaxed)
% VALIDATOR_UPDATE_BLOCK_ITV
{
resp.validator_updates = evm_resp.validator_updates;
}

resp
Expand Down
9 changes: 6 additions & 3 deletions src/components/abciapp/src/abci/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use {
},
baseapp::BaseApp as AccountBaseAPP,
config::abci::global_cfg::CFG,
ledger::store::LedgerState,
ledger::{staking::evm::EVM_STAKING, store::LedgerState},
parking_lot::RwLock,
rand_chacha::ChaChaRng,
rand_core::SeedableRng,
Expand Down Expand Up @@ -70,7 +70,10 @@ impl ABCISubmissionServer {
))
}
};

let account_base_app = Arc::new(RwLock::new(account_base_app));
if EVM_STAKING.set(account_base_app.clone()).is_err() {
return Err(eg!("Invalid usage."));
}
let prng = rand_chacha::ChaChaRng::from_entropy();
Ok(ABCISubmissionServer {
la: Arc::new(RwLock::new(
Expand All @@ -81,7 +84,7 @@ impl ABCISubmissionServer {
)
.c(d!())?,
)),
account_base_app: Arc::new(RwLock::new(account_base_app)),
account_base_app,
})
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/components/abciapp/src/abci/staking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
//! Business logic based on [**Ledger Staking**](ledger::staking).
//!

use ledger::staking::evm::EVM_STAKING_MINTS;

mod whoami;

#[cfg(test)]
Expand Down Expand Up @@ -468,6 +470,13 @@ pub fn system_mint_pay(

mint_entries.append(&mut mints);

//Mints from evm staking
for mint in EVM_STAKING_MINTS.lock().drain(..).map(|(pk, amount)| {
MintEntry::new(MintKind::Other, pk, None, amount, ASSET_TYPE_FRA)
}) {
mint_entries.push(mint)
}

if mint_entries.is_empty() {
None
} else {
Expand Down
28 changes: 28 additions & 0 deletions src/components/config/src/abci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ pub struct CheckPointConfig {

#[serde(default = "def_validator_whitelist_v3")]
pub validator_whitelist_v3: Vec<String>,

#[serde(default = "def_max_gas_price_limit")]
pub max_gas_price_limit: i64,

#[serde(default = "def_evm_staking_inital_height")]
pub evm_staking_inital_height: i64,

#[serde(default = "def_evm_staking_address")]
pub evm_staking_address: String,
}

fn def_fix_check_replay() -> u64 {
Expand Down Expand Up @@ -205,6 +214,19 @@ fn def_validator_whitelist_v3_height() -> u64 {
fn def_validator_whitelist_v3() -> Vec<String> {
DEFAULT_CHECKPOINT_CONFIG.validator_whitelist_v3.clone()
}

fn def_max_gas_price_limit() -> i64 {
DEFAULT_CHECKPOINT_CONFIG.max_gas_price_limit
}

fn def_evm_staking_inital_height() -> i64 {
DEFAULT_CHECKPOINT_CONFIG.evm_staking_inital_height
}

fn def_evm_staking_address() -> String {
DEFAULT_CHECKPOINT_CONFIG.evm_staking_address.clone()
}

#[cfg(feature = "debug_env")]
lazy_static! {
static ref DEFAULT_CHECKPOINT_CONFIG: CheckPointConfig = CheckPointConfig {
Expand Down Expand Up @@ -246,6 +268,9 @@ lazy_static! {
validator_whitelist_v2: vec![],
validator_whitelist_v3_height: 0,
validator_whitelist_v3: vec![],
max_gas_price_limit: 0,
evm_staking_inital_height: 128,
evm_staking_address: "0x84db796A3F8F02396f82219e3197933d15960771".to_owned(),
};
}

Expand Down Expand Up @@ -577,6 +602,9 @@ lazy_static! {
"37D3228A650F591522698BECDF42DCE5D1113D88".to_string(),
"577F8548D8F834D39D26350D2A3A928F478AF5FD".to_string(),
],
max_gas_price_limit: 5000000,
evm_staking_inital_height: 5000000,
evm_staking_address: "".to_owned(),
};
}

Expand Down
1 change: 1 addition & 0 deletions src/components/contracts/baseapp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ serde_json = "1.0.40"
storage = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.5" }
fin_db = { git = "https://github.com/FindoraNetwork/storage.git", tag = "v1.1.5" }
sha3 = "0.8"
zei = { git = "https://github.com/FindoraNetwork/zei", branch = "stable-main" }

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

Expand Down
Loading
Loading