Skip to content

Commit

Permalink
fix fn exec (#943)
Browse files Browse the repository at this point in the history
Co-authored-by: shaorongqiang <[email protected]>
  • Loading branch information
shaorongqiang and shiran555 authored Apr 26, 2023
1 parent 22f6764 commit e14fc9a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/components/abciapp/src/abci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ use {
config::abci::{global_cfg::CFG, ABCIConfig},
futures::executor::ThreadPool,
lazy_static::lazy_static,
ledger::converter::{LOWLEVEL_DATA_MAX, LOWLEVEL_DATA_MIN},
ruc::*,
std::{
env, fs, mem,
net::SocketAddr,
sync::{atomic::AtomicBool, Arc},
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread,
},
};
Expand All @@ -46,6 +50,8 @@ pub fn run() -> Result<()> {

env::set_var("BNC_DATA_DIR", format!("{}/__bnc__", &config.ledger_dir));

LOWLEVEL_DATA_MIN.swap(CFG.checkpoint.lowlevel_data_min as i64, Ordering::Relaxed);
LOWLEVEL_DATA_MAX.swap(CFG.checkpoint.lowlevel_data_max as i64, Ordering::Relaxed);
if CFG.enable_query_service {
env::set_var("FINDORAD_KEEP_HIST", "1");
}
Expand Down
1 change: 1 addition & 0 deletions src/components/abciapp/src/abci/server/callback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub fn info(s: &mut ABCISubmissionServer, req: &RequestInfo) -> ResponseInfo {
let h = state.get_tendermint_height() as i64;
TENDERMINT_BLOCK_HEIGHT.swap(h, Ordering::Relaxed);
LEDGER_TENDERMINT_BLOCK_HEIGHT.swap(h, Ordering::Relaxed);

resp.set_last_block_height(h);
if 0 < h {
if CFG.checkpoint.disable_evm_block_height < h
Expand Down
14 changes: 9 additions & 5 deletions src/ledger/src/converter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ use {
fp_types::{crypto::MultiSigner, H160},
ruc::*,
serde::{Deserialize, Serialize},
std::sync::atomic::Ordering,
std::sync::atomic::{AtomicI64, Ordering},
zei::xfr::{
sig::XfrPublicKey,
structs::{AssetType, XfrAmount, XfrAssetType},
},
};
#[allow(missing_docs)]
pub static LOWLEVEL_DATA_MIN: AtomicI64 = AtomicI64::new(0);
#[allow(missing_docs)]
pub static LOWLEVEL_DATA_MAX: AtomicI64 = AtomicI64::new(0);

#[inline(always)]
fn is_empty(x: &Option<Vec<u8>>) -> bool {
let td_height = LEDGER_TENDERMINT_BLOCK_HEIGHT.load(Ordering::Relaxed) as u64;
let td_height = LEDGER_TENDERMINT_BLOCK_HEIGHT.load(Ordering::Relaxed);
let lowlevel_data_min = LOWLEVEL_DATA_MIN.load(Ordering::Relaxed);
let lowlevel_data_max = LOWLEVEL_DATA_MAX.load(Ordering::Relaxed);

if td_height > CFG.checkpoint.lowlevel_data_min
&& td_height < CFG.checkpoint.lowlevel_data_max
{
if td_height > lowlevel_data_min && td_height < lowlevel_data_max {
match x {
Some(v) => !v.is_empty(),
None => false,
Expand Down

0 comments on commit e14fc9a

Please sign in to comment.