Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
Merge pull request #76 from nervosnetwork/fix-inner-call-revert
Browse files Browse the repository at this point in the history
Fix evmone.evm_memory management
  • Loading branch information
jjyr authored Aug 24, 2021
2 parents 67616ab + 518c251 commit 034a437
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 34 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CFLAGS_MBEDTLS := -Ideps/mbedtls/include
CFLAGS_EVMONE := -Ideps/evmone/lib/evmone -Ideps/evmone/include -Ideps/evmone/evmc/include
CFLAGS_SMT := -Ideps/godwoken-scripts/c/deps/sparse-merkle-tree/c
CFLAGS_GODWOKEN := -Ideps/godwoken-scripts/c
CFLAGS := -O3 -Ic/ripemd160 $(CFLAGS_CKB_STD) $(CFLAGS_EVMONE) $(CFLAGS_INTX) $(CFLAGS_BN128) $(CFLAGS_ETHASH) $(CFLAGS_CRYPTO_ALGORITHMS) $(CFLAGS_MBEDTLS) $(CFLAGS_SMT) $(CFLAGS_GODWOKEN) $(CFLAGS_SECP) -Wall -g -fdata-sections -ffunction-sections
CFLAGS := -O3 -Ic/ripemd160 $(CFLAGS_CKB_STD) $(CFLAGS_EVMONE) $(CFLAGS_INTX) $(CFLAGS_BN128) $(CFLAGS_ETHASH) $(CFLAGS_CRYPTO_ALGORITHMS) $(CFLAGS_MBEDTLS) $(CFLAGS_SMT) $(CFLAGS_GODWOKEN) $(CFLAGS_SECP) -Wall -g -fdata-sections -ffunction-sections
CXXFLAGS := $(CFLAGS) -std=c++1z
LDFLAGS := -Wl,--gc-sections

Expand Down Expand Up @@ -50,6 +50,8 @@ clean-via-docker:
mkdir -p build
docker run --rm -v `pwd`:/code ${BUILDER_DOCKER} bash -c "cd /code && make clean"

dist: clean-via-docker all-via-docker

build/generator: c/generator.c $(GENERATOR_DEPS)
cd $(SECP_DIR) && (git apply workaround-fix-g++-linking.patch || true) && cd - # apply patch
$(CXX) $(CFLAGS) $(LDFLAGS) -Ibuild -o $@ c/generator.c $(ALL_OBJS) -DNO_DEBUG_LOG
Expand Down Expand Up @@ -171,5 +173,5 @@ fmt:

clean:
rm -rf build/*
cd $(SECP_DIR) && [ -f "Makefile" ] && make distclean && make clean
cd $(SECP_DIR) && [ -f "Makefile" ] && make distclean && make clean || echo "skip secp256k1 clean"
rm -rf $(SECP256K1_SRC)
2 changes: 1 addition & 1 deletion deps/evmone
8 changes: 4 additions & 4 deletions devtools/ci/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ if [ -d "$GODWOKEN_DIR" ]
then
echo "godwoken project already exists"
else
git clone --depth=1 https://github.com/nervosnetwork/godwoken.git $GODWOKEN_DIR
git clone -b master https://github.com/nervosnetwork/godwoken.git $GODWOKEN_DIR
fi
cd $GODWOKEN_DIR
git pull -r origin master
git checkout 4e65efde86bb16aafc6d29aee1bf6f586077eaf6
git submodule update --init --recursive

cd tests-deps/godwoken-scripts/c
git pull -r origin master
git submodule update --init --recursive
# git pull -r origin master
# git submodule update --init --recursive
make all-via-docker

cd $PROJECT_ROOT
Expand Down
8 changes: 4 additions & 4 deletions polyjuice-tests/src/test_cases/create2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fn test_create2() {
block_number,
);
block_number += 1;
// [Deploy Create2Impl] used cycles: 805376 < 810K
helper::check_cycles("Deploy Create2Impl", run_result.used_cycles, 810_000);
// [Deploy Create2Impl] used cycles: 819215 < 820K
helper::check_cycles("Deploy Create2Impl", run_result.used_cycles, 820_000);
// println!(
// "result {}",
// serde_json::to_string_pretty(&RunResult::from(run_result)).unwrap()
Expand Down Expand Up @@ -100,8 +100,8 @@ fn test_create2() {
&raw_tx,
)
.expect("construct");
// [Create2Impl.deploy(...)] used cycles: 1197555 < 1210K
helper::check_cycles("Create2Impl.deploy(...)", run_result.used_cycles, 1210_000);
// [Create2Impl.deploy(...)] used cycles: 1197555 < 1230K
helper::check_cycles("Create2Impl.deploy(...)", run_result.used_cycles, 1230_000);
state.apply_run_result(&run_result).expect("update state");
run_result
};
Expand Down
6 changes: 3 additions & 3 deletions polyjuice-tests/src/test_cases/delegatecall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ fn test_delegatecall() {
block_producer_id,
block_number,
);
// [Deploy DelegateCall] used cycles: 742217 < 750K
helper::check_cycles("Deploy DelegateCall", run_result.used_cycles, 750_000);
// [Deploy DelegateCall] used cycles: 753698 < 760K
helper::check_cycles("Deploy DelegateCall", run_result.used_cycles, 760_000);
block_number += 1;
// println!(
// "result {}",
Expand Down Expand Up @@ -131,7 +131,7 @@ fn test_delegatecall() {
&raw_tx,
)
.expect("construct");
helper::check_cycles("DelegateCall", run_result.used_cycles, 1_430_000);
helper::check_cycles("DelegateCall", run_result.used_cycles, 1_440_000);
state.apply_run_result(&run_result).expect("update state");
// println!(
// "result {}",
Expand Down
8 changes: 4 additions & 4 deletions polyjuice-tests/src/test_cases/ecrecover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ fn test_ecrecover() {
block_producer_id,
1,
);
// [Deploy HeadTail Contract] used cycles: 1590800 < 1600K
// [Deploy HeadTail Contract] used cycles: 1645593 < 1650K
helper::check_cycles(
"Deploy HeadTail Contract",
run_result.used_cycles,
1_600_000,
1_650_000,
);
// println!(
// "result {}",
Expand Down Expand Up @@ -92,8 +92,8 @@ fn test_ecrecover() {
&raw_tx,
)
.expect("construct");
// [recover] used cycles: 2604412 < 2610K
helper::check_cycles("verify|recover", run_result.used_cycles, 2_610_000);
// [recover] used cycles: 2604412 < 2660K
helper::check_cycles("verify|recover", run_result.used_cycles, 2_660_000);
state.apply_run_result(&run_result).expect("update state");
assert_eq!(
run_result.return_data,
Expand Down
8 changes: 4 additions & 4 deletions polyjuice-tests/src/test_cases/erc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ fn test_erc20() {
block_producer_id,
1,
);
// [Deploy ERC20] used cycles: 1004236 < 1010K
helper::check_cycles("Deploy ERC20", run_result.used_cycles, 1_010_000);
// [Deploy ERC20] used cycles: 1018075 < 1020K
helper::check_cycles("Deploy ERC20", run_result.used_cycles, 1_020_000);

let contract_account_script =
new_account_script(&mut state, creator_account_id, from_id1, false);
Expand Down Expand Up @@ -168,8 +168,8 @@ fn test_erc20() {
&raw_tx,
)
.expect("construct");
// [ERC20 contract method_x] used cycles: 942107 < 950K
helper::check_cycles("ERC20 contract method_x", run_result.used_cycles, 950_000);
// [ERC20 contract method_x] used cycles: 942107 < 960K
helper::check_cycles("ERC20 contract method_x", run_result.used_cycles, 960_000);
state.apply_run_result(&run_result).expect("update state");
assert_eq!(
run_result.return_data,
Expand Down
4 changes: 2 additions & 2 deletions polyjuice-tests/src/test_cases/heap_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ fn test_heap_momory() {
&raw_tx,
)
.expect("success to malloc memory");
// [newMemory less than 512K] used cycles: 3454814 < 3465K
helper::check_cycles("new Memory", run_result.used_cycles, 3_465_000);
// [newMemory less than 512K] used cycles: 3454814 -> 6405492 < 6500K
helper::check_cycles("new Memory", run_result.used_cycles, 6_500_000);
println!(
"\t new byte(about {}K) => call result {:?}",
16 * 32,
Expand Down
8 changes: 4 additions & 4 deletions polyjuice-tests/src/test_cases/invalid_sudt_erc20_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ fn test_invalid_sudt_erc20_proxy() {
block_producer_id,
1,
);
// [Deploy InvalidSudtERC20Proxy] used cycles: 1421789 < 1430K
// [Deploy InvalidSudtERC20Proxy] used cycles: 1457382 < 1460K
helper::check_cycles(
"Deploy InvalidSudtERC20Proxy",
run_result.used_cycles,
1_430_000,
1_460_000,
);

let contract_account_script =
Expand Down Expand Up @@ -166,11 +166,11 @@ fn test_invalid_sudt_erc20_proxy() {

if *success {
let run_result = result.expect("execute");
// used cycles: 844202 < 850K
// used cycles: 844202 < 870K
helper::check_cycles(
"ERC20.{balanceOf|transfer}",
run_result.used_cycles,
850_000,
870_000,
);
state.apply_run_result(&run_result).expect("update state");
assert_eq!(
Expand Down
8 changes: 4 additions & 4 deletions polyjuice-tests/src/test_cases/recover_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ fn test_recover_account() {
block_producer_id,
0,
);
// Deploy RecoverAccount Contract used cycles = 682404 < 690K
// Deploy RecoverAccount Contract used cycles = 690541 < 700K
helper::check_cycles(
"Deploy RecoverAccount Contract",
run_result.used_cycles,
690_000,
700_000,
);
let contract_account_script =
new_account_script(&mut state, creator_account_id, from_id, false);
Expand Down Expand Up @@ -99,11 +99,11 @@ fn test_recover_account() {
&raw_tx,
)
.expect("construct");
// [RecoverAccount.recover(message, signature, code_hash)] used cycles: 648630 < 660K
// [RecoverAccount.recover(message, signature, code_hash)] used cycles: 648630 < 670K
helper::check_cycles(
"RecoverAccount.recover(message, signature, code_hash)",
run_result.used_cycles,
660_000,
670_000,
);
state.apply_run_result(&run_result).expect("update state");
let mut script_args = vec![0u8; 32 + 20];
Expand Down
4 changes: 2 additions & 2 deletions polyjuice-tests/src/test_cases/simple_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ fn test_simple_wallet() {
block_producer_id,
block_number,
);
// [Deploy SimpleWallet Contract] used cycles: 1741377 < 1750K
helper::check_cycles("Deploy SimpleWallet", run_result.used_cycles, 1_750_000);
// [Deploy SimpleWallet Contract] used cycles: 1803600 < 1810K
helper::check_cycles("Deploy SimpleWallet", run_result.used_cycles, 1_810_000);

let account_script = helper::new_account_script(&mut state, creator_account_id, from_id, false);
let _contract_account_id = state
Expand Down

0 comments on commit 034a437

Please sign in to comment.