Skip to content

Commit

Permalink
remove web3 feature (#947)
Browse files Browse the repository at this point in the history
* remove web3 feature

* clean Makefile

* fix lint
  • Loading branch information
shaorongqiang authored Apr 27, 2023
1 parent e14fc9a commit 322787b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 189 deletions.
25 changes: 0 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ build_release_debug: tendermint_goleveldb
cargo build --features="debug_env" --release --bins -p abciapp -p finutils
$(call pack,release)

build_release_web3: tendermint_cleveldb
cargo build --features="web3_service debug_env" --release --bins -p abciapp -p finutils
$(call pack,release)

build_bench_release: tendermint_goleveldb
cargo build --features="debug_env benchmark" --release --bins -p abciapp -p finutils
$(call pack,release)
Expand Down Expand Up @@ -320,27 +316,6 @@ ci_build_image_dockerhub_arm:
@ docker run --rm --privileged tonistiigi/binfmt:latest --install all
@ docker buildx build --platform linux/arm64/v8 -t $(DOCKERHUB_URL)/findorad:$(IMAGE_TAG) -f container/Dockerfile-goleveldb-arm . --push


# ========================== build RPC node===========================

build_release_web3_goleveldb: tendermint_goleveldb
cargo build --features="web3_service debug_env" --release --bins -p abciapp -p finutils
$(call pack,release)

ci_build_release_web3_binary_image:
sed -i "s/^ENV VERGEN_SHA_EXTERN .*/ENV VERGEN_SHA_EXTERN ${VERGEN_SHA_EXTERN}/g" container/Dockerfile-enterprise-web3
docker build -t findorad-binary-image:$(IMAGE_TAG) -f container/Dockerfile-enterprise-web3 .

ci_build_image_web3:
@ if [ -d "./binary" ]; then \
rm -rf ./binary || true; \
fi
@ docker run --rm -d --name findorad-binary findorad-binary-image:$(IMAGE_TAG)
@ docker cp findorad-binary:/binary ./binary
@ docker rm -f findorad-binary
@ docker build -t $(PUBLIC_ECR_URL)/$(ENV)/findorad:$(IMAGE_TAG) -f container/Dockerfile-goleveldb .


# ========================== push image and clean up===========================

ci_push_image:
Expand Down
52 changes: 0 additions & 52 deletions container/Dockerfile-enterprise-web3

This file was deleted.

6 changes: 0 additions & 6 deletions src/components/abciapp/src/abci/server/callback/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,28 +549,24 @@ pub fn commit(s: &mut ABCISubmissionServer, req: &RequestCommit) -> ResponseComm
let nonce_map = if let Ok(mut nonce_map) = NONCE_MAP.lock() {
take(&mut *nonce_map)
} else {
error!("{}", "");
Default::default()
};

let code_map = if let Ok(mut code_map) = CODE_MAP.lock() {
take(&mut *code_map)
} else {
error!("{}", "");
Default::default()
};

let balance_map = if let Ok(mut balance_map) = BALANCE_MAP.lock() {
take(&mut *balance_map)
} else {
error!("{}", "");
Default::default()
};

let state_list = if let Ok(mut state_list) = STATE_UPDATE_LIST.lock() {
take(&mut *state_list)
} else {
error!("{}", "");
Default::default()
};

Expand All @@ -583,14 +579,12 @@ pub fn commit(s: &mut ABCISubmissionServer, req: &RequestCommit) -> ResponseComm
let txs = if let Ok(mut txs) = TXS.lock() {
take(&mut *txs)
} else {
error!("{}", "");
Default::default()
};

let receipts = if let Ok(mut receipts) = RECEIPTS.lock() {
take(&mut *receipts)
} else {
error!("{}", "");
Default::default()
};

Expand Down
60 changes: 20 additions & 40 deletions src/components/contracts/baseapp/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
use crate::extensions::SignedExtra;
use abci::*;
use config::abci::global_cfg::CFG;
use enterprise_web3::{
Setter, PENDING_CODE_MAP, PENDING_STATE_UPDATE_LIST, REDIS_CLIENT,
REMOVE_PENDING_CODE_MAP, REMOVE_PENDING_STATE_UPDATE_LIST,
};
use fp_core::context::RunTxMode;
use fp_evm::BlockId;
use fp_types::{
Expand All @@ -10,8 +14,8 @@ use fp_utils::tx::EvmRawTxWrapper;
use module_evm::utils::{deposit_asset_event_topic_str, parse_deposit_asset_event};
use primitive_types::U256;
use ruc::*;
use std::{mem::take, ops::DerefMut};
use tracing::{debug, error, info};

impl crate::BaseApp {
/// info implements the ABCI interface.
/// - Returns chain info (las height and hash where the node left off)
Expand Down Expand Up @@ -78,43 +82,33 @@ impl crate::BaseApp {
};

if let Ok(tx) = convert_unchecked_transaction::<SignedExtra>(raw_tx) {
#[cfg(feature = "enterprise-web3")]
let tmp_tx = tx.clone();
let check_fn = |mode: RunTxMode| {
let ctx = {
let mut ctx = self.check_state.clone();
ctx.run_mode = mode;
ctx
};
let result = self.modules.process_tx::<SignedExtra>(ctx, tx);
let result = self.modules.process_tx::<SignedExtra>(ctx, tx.clone());
match result {
Ok(ar) => {
#[cfg(feature = "enterprise-web3")]
{
use enterprise_web3::{
Setter, PENDING_CODE_MAP, PENDING_STATE_UPDATE_LIST,
REDIS_CLIENT,
};
use std::{collections::HashMap, mem::replace};
if CFG.enable_enterprise_web3 {
let code_map =
if let Ok(mut code_map) = PENDING_CODE_MAP.lock() {
replace(&mut *code_map, HashMap::new())
take(&mut *code_map)
} else {
error!("{}", "");
Default::default()
};
let state_list = if let Ok(mut state_list) =
PENDING_STATE_UPDATE_LIST.lock()
{
replace(&mut *state_list, vec![])
take(&mut *state_list)
} else {
error!("{}", "");
Default::default()
};
if 0 == ar.code {
if let fp_types::actions::Action::Ethereum(
fp_types::actions::ethereum::Action::Transact(tx),
) = tmp_tx.function
) = tx.function
{
let redis_pool =
REDIS_CLIENT.lock().expect("REDIS_CLIENT error");
Expand All @@ -136,9 +130,9 @@ impl crate::BaseApp {
for state in state_list.iter() {
setter
.set_pending_state(
state.address.clone(),
state.index.clone(),
state.value.clone(),
state.address,
state.index,
state.value,
)
.map_err(|e| error!("{e:?}"))
.unwrap_or(());
Expand Down Expand Up @@ -220,41 +214,30 @@ impl crate::BaseApp {

if let Ok(tx) = convert_unchecked_transaction::<SignedExtra>(raw_tx) {
let ctx = self.retrieve_context(RunTxMode::Deliver).clone();
#[cfg(feature = "enterprise-web3")]
let tmp_tx = tx.clone();
let ret = self.modules.process_tx::<SignedExtra>(ctx, tx);

let ret = self.modules.process_tx::<SignedExtra>(ctx, tx.clone());
match ret {
Ok(ar) => {
#[cfg(feature = "enterprise-web3")]
{
use enterprise_web3::{
Setter, REDIS_CLIENT, REMOVE_PENDING_CODE_MAP,
REMOVE_PENDING_STATE_UPDATE_LIST,
};
use std::{mem::replace, ops::DerefMut};
if CFG.enable_enterprise_web3 {
let code_map =
if let Ok(mut code_map) = REMOVE_PENDING_CODE_MAP.lock() {
let m = code_map.deref_mut();
let map = replace(m, vec![]);
map.clone()
take(m)
} else {
error!("{}", "");
Default::default()
};
let state_list = if let Ok(mut state_list) =
REMOVE_PENDING_STATE_UPDATE_LIST.lock()
{
let v = state_list.deref_mut();
let v2 = replace(v, vec![]);
v2.clone()
take(v)
} else {
error!("{}", "");
Default::default()
};
if 0 == ar.code {
if let fp_types::actions::Action::Ethereum(
fp_types::actions::ethereum::Action::Transact(tx),
) = tmp_tx.function
) = tx.function
{
let redis_pool =
REDIS_CLIENT.lock().expect("REDIS_CLIENT error");
Expand All @@ -277,10 +260,7 @@ impl crate::BaseApp {

for (address, index) in state_list.iter() {
setter
.remove_pending_state(
address.clone(),
index.clone(),
)
.remove_pending_state(*address, *index)
.map_err(|e| error!("{:?}", e))
.unwrap_or(());
}
Expand Down
Loading

0 comments on commit 322787b

Please sign in to comment.