Skip to content

Commit

Permalink
upgrade evm
Browse files Browse the repository at this point in the history
* evm upgrade to 0.36.0

* lint error fix
  • Loading branch information
harryliisme3 committed Jan 29, 2023
1 parent 996f59a commit 0069928
Show file tree
Hide file tree
Showing 79 changed files with 874 additions and 645 deletions.
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 @@ -282,7 +282,7 @@ pub fn deliver_tx(

resp.code = 1;
resp.log =
format!("deliver convert account tx failed: {:?}", err);
format!("deliver convert account tx failed: {err:?}");
return resp;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/abciapp/src/abci/server/tx_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub fn forward_txn_with_mode(
)
};

let tendermint_reply = format!("http://{}", url);
let tendermint_reply = format!("http://{url}");
if 2000 > TX_PENDING_CNT.fetch_add(1, Ordering::Relaxed) {
POOL.spawn_ok(async move {
ruc::info_omit!(attohttpc::post(&tendermint_reply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ impl QueryApi {
});

for (host, port) in addrs.iter() {
hdr = hdr.bind(&format!("{}:{}", host, port)).c(d!())?
hdr = hdr.bind(&format!("{host}:{port}")).c(d!())?
}

hdr.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl SubmissionApi {
web::get().to(txn_status::<RNG, TF>),
)
})
.bind(&format!("{}:{}", host, port))
.bind(&format!("{host}:{port}"))
.c(d!())?
.run();

Expand Down
6 changes: 3 additions & 3 deletions src/components/abciapp/src/bins/findorad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ fn node_command() -> Result<()> {
ctrlc::set_handler(move || {
//info_omit!(kill(Pid::from_raw(0), Signal::SIGINT));
pnk!(abcid_child.kill().c(d!()));
pnk!(abcid_child.wait().c(d!()).map(|s| println!("{}", s)));
pnk!(abcid_child.wait().c(d!()).map(|s| println!("{s}",)));

pnk!(tendermint_child.kill());
pnk!(tendermint_child.wait().c(d!()).map(|s| println!("{}", s)));
pnk!(tendermint_child.wait().c(d!()).map(|s| println!("{s}",)));

pnk!(send.send(()));
})
Expand Down Expand Up @@ -163,7 +163,7 @@ fn init_command() -> Result<()> {
fn pack() -> Result<()> {
let bin_path_orig = get_bin_path().c(d!())?;
let bin_name = bin_path_orig.file_name().c(d!())?.to_str().c(d!())?;
let bin_path = format!("/tmp/{}", bin_name);
let bin_path = format!("/tmp/{bin_name}",);
fs::copy(bin_path_orig, &bin_path).c(d!())?;

let mut f = OpenOptions::new().append(true).open(bin_path).c(d!())?;
Expand Down
12 changes: 6 additions & 6 deletions src/components/config/src/abci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ impl CheckPointConfig {
return Some(config);
}
Err(error) => {
panic!("failed to create file: {:?}", error)
panic!("failed to create file: {error:?}")
}
};
} else {
panic!("failed to open file: {:?}", error)
panic!("failed to open file: {error:?}")
}
}
};
Expand Down Expand Up @@ -451,7 +451,7 @@ pub mod global_cfg {
.value_of("checkpoint-file")
.map(|v| v.to_owned())
.unwrap_or_else(|| String::from("./checkpoint.toml"));
println!("{}", checkpoint_path);
println!("{checkpoint_path}");

let res = Config {
abci_host: ah,
Expand Down Expand Up @@ -558,7 +558,7 @@ pub mod global_cfg {
.into_iter()
.rev()
.for_each(|h| {
println!(" {}", h);
println!(" {h}");
});
exit(0);
}
Expand All @@ -576,7 +576,7 @@ pub mod global_cfg {
|| m.is_present("snapshot-rollback-to")
|| m.is_present("snapshot-rollback-to-exact")
{
println!("\x1b[31;01m\n{}\x1b[00m", HINTS);
println!("\x1b[31;01m\n{HINTS}\x1b[00m",);

let (h, strict) = m
.value_of("snapshot-rollback-to-exact")
Expand All @@ -588,7 +588,7 @@ pub mod global_cfg {
} else {
None
};
cfg.rollback(h, strict).map_err(|e| d!("{}", e))?;
cfg.rollback(h, strict).map_err(|e| d!("{e}",))?;
exit(0);
}
Ok(())
Expand Down
18 changes: 9 additions & 9 deletions src/components/contracts/baseapp/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl crate::BaseApp {

let ctx = self.create_query_context(Some(req.height as u64), req.prove);
if let Err(e) = ctx {
return err_resp(format!("Cannot create query context with err: {}!", e));
return err_resp(format!("Cannot create query context with err: {e}!",));
}

match path.remove(0) {
Expand Down Expand Up @@ -144,14 +144,14 @@ impl crate::BaseApp {
}
resp.code = ar.code;
if ar.code != 0 {
info!(target: "baseapp", "Transaction check error, action result {:?}", ar);
info!(target: "baseapp", "Transaction check error, action result {ar:?}", );
resp.log = ar.log;
}
}
Err(e) => {
info!(target: "baseapp", "Transaction check error: {}", e);
info!(target: "baseapp", "Transaction check error: {e}", );
resp.code = 1;
resp.log = format!("Transaction check error: {}", e);
resp.log = format!("Transaction check error: {e}",);
}
}
};
Expand Down Expand Up @@ -294,9 +294,9 @@ impl crate::BaseApp {
resp
}
Err(e) => {
error!(target: "baseapp", "Ethereum transaction deliver error: {}", e);
error!(target: "baseapp", "Ethereum transaction deliver error: {e}", );
resp.code = 1;
resp.log = format!("Ethereum transaction deliver error: {}", e);
resp.log = format!("Ethereum transaction deliver error: {e}",);
resp
}
}
Expand Down Expand Up @@ -334,8 +334,8 @@ impl crate::BaseApp {
.write()
.commit(block_height)
.unwrap_or_else(|e| {
println!("{:?}", e);
panic!("Failed to commit chain state at height: {}", block_height)
println!("{e:?}",);
panic!("Failed to commit chain state at height: {block_height}",)
});

// Commit module data based on root_hash
Expand All @@ -347,7 +347,7 @@ impl crate::BaseApp {
.write()
.commit(block_height)
.unwrap_or_else(|_| {
panic!("Failed to commit chain db at height: {}", block_height)
panic!("Failed to commit chain db at height: {block_height}",)
});

// Reset the deliver state, but keep the ethereum cache
Expand Down
6 changes: 3 additions & 3 deletions src/components/contracts/baseapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl BaseApp {
}

fn validate_height(&self, height: i64) -> Result<()> {
ensure!(height >= 1, format!("invalid height: {}", height));
ensure!(height >= 1, format!("invalid height: {height}",));
let mut expected_height =
self.chain_state.read().height().unwrap_or_default() as i64;
if expected_height == 0 {
Expand All @@ -320,7 +320,7 @@ impl BaseApp {
}
ensure!(
height == expected_height,
format!("invalid height: {}; expected: {}", height, expected_height)
format!("invalid height: {height}; expected: {expected_height}")
);
Ok(())
}
Expand Down Expand Up @@ -356,7 +356,7 @@ impl BaseProvider for BaseApp {
fn account_of(&self, who: &Address, height: Option<u64>) -> Result<SmartAccount> {
let ctx = self.create_query_context(height, false)?;
module_account::App::<Self>::account_of(&ctx, who, height)
.ok_or(eg!(format!("account does not exist: {}", who)))
.ok_or(eg!(format!("account does not exist: {who}",)))
}

fn current_block(&self, id: Option<BlockId>) -> Option<Block> {
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/baseapp/src/modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl ModuleManager {
self.template_module.query_route(ctx, path, req)
} else {
resp.code = 1;
resp.log = format!("Invalid query module route: {}!", module_name);
resp.log = format!("Invalid query module route: {module_name}!",);
resp
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/modules/account/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<C: Config> AccountAsset<Address> for App<C> {
}

let mut target_account = Self::account_of(ctx, target, None)
.c(d!(format!("account: {} does not exist", target)))?;
.c(d!(format!("account: {target} does not exist",)))?;
target_account.balance = target_account
.balance
.checked_sub(balance)
Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/modules/account/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn setup() -> Context {
.unwrap()
.as_nanos();
let mut path = temp_dir();
path.push(format!("temp-findora-db–{}", time));
path.push(format!("temp-findora-db–{time}",));

let fdb = FinDB::open(path).unwrap();
let chain_state = Arc::new(RwLock::new(ChainState::new(
Expand All @@ -29,7 +29,7 @@ fn setup() -> Context {
)));

let mut rocks_path = temp_dir();
rocks_path.push(format!("temp-rocks-db–{}", time));
rocks_path.push(format!("temp-rocks-db–{time}",));

let rdb = RocksDB::open(rocks_path).unwrap();
let chain_db = Arc::new(RwLock::new(ChainState::new(
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/modules/ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ readme = "README.md"
abci = "0.7.2"
ethereum = { version = "0.12.0", default-features = false, features = ["with-serde"] }
ethereum-types = { version = "0.13.1", default-features = false }
evm = { version = "0.35.0", default-features = false, features = ["with-serde"] }
evm = { version = "0.36.0", default-features = false, features = ["with-serde"] }
tracing = "0.1"
rand = "0.8"
rlp = "0.5"
Expand Down
4 changes: 2 additions & 2 deletions src/components/contracts/modules/ethereum/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ impl<C: Config> App<C> {
return Ok(ActionResult {
code: 1,
data: vec![],
log: format!("{}", e),
log: format!("{e}",),
gas_wanted: gas_limit.low_u64(),
gas_used: 0,
events,
Expand Down Expand Up @@ -343,7 +343,7 @@ impl<C: Config> App<C> {
let message_len = data[36..68].iter().sum::<u8>();
let body: &[u8] = &data[68..68 + message_len as usize];
if let Ok(reason) = std::str::from_utf8(body) {
message = format!("{} {}", message, reason);
message = format!("{message} {reason}");
}
}
(3, message)
Expand Down
3 changes: 1 addition & 2 deletions src/components/contracts/modules/ethereum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,7 @@ impl<C: Config> ValidateUnsigned for App<C> {
let total_payment = transaction.value.saturating_add(fee);
if balance < total_payment {
return Err(eg!(format!(
"InsufficientBalance, origin: {:?}, actual balance {}, but expected payment {}",
origin, balance, total_payment
"InsufficientBalance, origin: {origin:?}, actual balance {balance}, but expected payment {total_payment}",
)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn setup() -> Context {
.unwrap()
.as_nanos();
let mut path = temp_dir();
path.push(format!("temp-findora-db–{}", time));
path.push(format!("temp-findora-db–{time}",));

let fdb = FinDB::open(path).unwrap();
let chain_state = Arc::new(RwLock::new(ChainState::new(
Expand All @@ -28,7 +28,7 @@ fn setup() -> Context {
)));

let mut rocks_path = temp_dir();
rocks_path.push(format!("temp-rocks-db–{}", time));
rocks_path.push(format!("temp-rocks-db–{time}",));

let rdb = RocksDB::open(rocks_path).unwrap();
let chain_db = Arc::new(RwLock::new(ChainState::new(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn test_abci_deliver_tx() {
resp.code, resp.log
);

println!("transfer resp: {:?}", resp);
println!("transfer resp: {resp:?}",);

// initial balance = 100_0000_0000_0000_0000_u64, gas limit = 21000, transfer balance = 10
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/modules/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "README.md"
[dependencies]
abci = "0.7.2"
ethereum-types = { version = "0.13.1", default-features = false }
evm = { version = "0.35.0", default-features = false, features = ["with-serde"] }
evm = { version = "0.36.0", default-features = false, features = ["with-serde"] }
evm-runtime = { version = "0.35.0", default-features = false }
evm-gasometer = { version = "0.30.0", default-features = false }
ethereum = { version = "0.12.0", default-features = false, features = ["with-serde"] }
Expand Down
2 changes: 1 addition & 1 deletion src/components/contracts/modules/evm/precompile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "MODEXP precompiles for EVM module."
readme = "README.md"

[dependencies]
evm = { version = "0.35.0", default-features = false, features = ["with-serde"] }
evm = { version = "0.36.0", default-features = false, features = ["with-serde"] }
module-evm = { path = "../../../modules/evm"}
ethereum-types = "0.13.1"
evm-precompile-basic = { path = "./basic" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description = "Basic precompiles for EVM module."
readme = "README.md"

[dependencies]
evm = { version = "0.35.0", default-features = false, features = ["with-serde"] }
evm = { version = "0.36.0", default-features = false, features = ["with-serde"] }
module-evm = { path = "../../../../modules/evm"}
ripemd = "0.1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"

[dependencies]
eth_pairings = { git = "https://github.com/FindoraNetwork/eip1962", branch = "master" }
evm = { version = "0.35.0", default-features = false, features = ["with-serde"] }
evm = { version = "0.36.0", default-features = false, features = ["with-serde"] }
evm-precompile-utils = { path = "../utils"}
tracing = "0.1"
module-evm = { path = "../../../../modules/evm"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
mod tests;

use eth_pairings::public_interface::{perform_operation, ApiError, OperationType};
use evm::executor::stack::{PrecompileFailure, PrecompileOutput};
use evm::{Context, ExitError, ExitSucceed};
use evm::executor::stack::{PrecompileFailure, PrecompileHandle, PrecompileOutput};
use evm::{
// Context,
ExitError,
ExitSucceed,
};
use evm_precompile_utils::{EvmDataReader, EvmDataWriter, EvmResult, Gasometer};
use module_evm::precompile::{FinState, Precompile, PrecompileId, PrecompileResult};
use tracing::debug;
Expand All @@ -25,11 +29,12 @@ pub enum Call {

impl Precompile for EthPairing {
fn execute(
input: &[u8],
target_gas: Option<u64>,
_context: &Context,
handle: &mut impl PrecompileHandle,
_state: &FinState,
) -> PrecompileResult {
let input = handle.input();
let target_gas = handle.gas_limit();

let mut input = EvmDataReader::new(input);
let selector = match input.read_selector::<Call>() {
Ok(v) => v,
Expand Down Expand Up @@ -86,11 +91,11 @@ impl EthPairing {

Ok(PrecompileOutput {
exit_status: ExitSucceed::Returned,
cost: gasometer.used_gas(),
// cost: gasometer.used_gas(),
output: EvmDataWriter::new()
.write_raw_bytes(result.as_slice())
.build(),
logs: vec![],
// logs: vec![],
})
}
}
Loading

0 comments on commit 0069928

Please sign in to comment.