Skip to content

Commit

Permalink
Merge branch 'develop' into feat/aleksuss/silo
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss authored Aug 3, 2023
2 parents 9a17263 + 0d0dfb7 commit 0c14bc1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions engine-modexp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ autobenches = false
[dependencies]
hex.workspace = true
num.workspace = true
ibig.workspace = true
ibig = { workspace = true, optional = true }

[features]
default = ["std"]
std = ["num/std", "ibig/std", "hex/std"]
bench = []
std = ["num/std", "hex/std"]
bench = ["ibig"]
3 changes: 2 additions & 1 deletion engine-modexp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct AuroraModExp;

impl ModExpAlgorithm for AuroraModExp {
fn modexp(base: &[u8], exp: &[u8], modulus: &[u8]) -> Vec<u8> {
modexp_ibig(base, exp, modulus)
modexp(base, exp, modulus)
}
}

Expand All @@ -37,6 +37,7 @@ pub fn modexp(base: &[u8], exp: &[u8], modulus: &[u8]) -> Vec<u8> {
result.to_big_endian()
}

#[cfg(feature = "bench")]
pub fn modexp_ibig(base: &[u8], exp: &[u8], modulus: &[u8]) -> Vec<u8> {
use num::Zero;

Expand Down
6 changes: 3 additions & 3 deletions engine-tests/src/tests/modexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,18 @@ fn bench_modexp_standalone() {

// These contracts run the modexp precompile in an infinite loop using strategically selecting
// input that can take a long time to run with some modexp implementations. It should be
// possible to burn 30M EVM gas (the GAS_LIMIT for this transactions) within 1 second.
// possible to burn 30M EVM gas (the GAS_LIMIT for these transactions) within 1 second.
// This test checks this is case for these specially chosen modexp inputs.
do_bench(
&mut standalone,
&mut signer,
"../etc/tests/modexp-bench/res/evm_contract_1.hex",
);
/*do_bench( // TODO: re-enable this in the future
do_bench(
&mut standalone,
&mut signer,
"../etc/tests/modexp-bench/res/evm_contract_2.hex",
);*/
);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion engine-tests/src/tests/repro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn repro_Emufid2() {
block_timestamp: 1_662_118_048_636_713_538,
input_path: "src/tests/res/input_Emufid2.hex",
evm_gas_used: 1_156_364,
near_gas_used: 286,
near_gas_used: 296,
});
}

Expand Down
5 changes: 5 additions & 0 deletions engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ mod contract {
let mut io = Runtime;
let mut state = state::get_state(&io).sdk_unwrap();

require_running(&state);
require_owner_only(&state, &io.predecessor_account_id());

let key_manager =
Expand All @@ -639,6 +640,8 @@ mod contract {
pub extern "C" fn add_relayer_key() {
let mut io = Runtime;
let state = state::get_state(&io).sdk_unwrap();

require_running(&state);
require_key_manager_only(&state, &io.predecessor_account_id());

let public_key = serde_json::from_slice::<RelayerKeyArgs>(&io.read_input().to_vec())
Expand Down Expand Up @@ -675,6 +678,8 @@ mod contract {
pub extern "C" fn remove_relayer_key() {
let mut io = Runtime;
let state = state::get_state(&io).sdk_unwrap();

require_running(&state);
require_key_manager_only(&state, &io.predecessor_account_id());

let args: RelayerKeyArgs = serde_json::from_slice(&io.read_input().to_vec())
Expand Down

0 comments on commit 0c14bc1

Please sign in to comment.