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

Commit

Permalink
chore: update deps and add multicall3 test case
Browse files Browse the repository at this point in the history
  • Loading branch information
magicalne committed Oct 10, 2022
1 parent 0ce56e5 commit 0fe70c1
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 44 deletions.
1 change: 1 addition & 0 deletions c/polyjuice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,7 @@ int run_polyjuice() {
}

/* Godwoken syscall: SET_RETURN_DATA */
debug_print_int("set return data size", res.output_size);
ret = context.sys_set_program_return_data(&context,
(uint8_t *)res.output_data,
res.output_size);
Expand Down
2 changes: 1 addition & 1 deletion deps/godwoken-scripts
11 changes: 0 additions & 11 deletions devtools/ci/integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,16 @@ SCRIPT_DIR=$(realpath $(dirname $0))
PROJECT_ROOT=$(dirname $(dirname $SCRIPT_DIR))
TESTS_DIR=$PROJECT_ROOT/polyjuice-tests
DEPS_DIR=$PROJECT_ROOT/integration-test
GODWOKEN_DIR=$DEPS_DIR/godwoken
ETHEREUM_TEST_DIR=$DEPS_DIR/ethereum-tests

mkdir -p $DEPS_DIR
if [ -d "$GODWOKEN_DIR" ]
then
echo "godwoken project already exists"
else
git clone --depth=1 https://github.com/nervosnetwork/godwoken.git $GODWOKEN_DIR
fi
# clone ethereum/test
if [ -d "$ETHEREUM_TEST_DIR" ]
then
echo "ethereum test project already exists"
else
git clone --depth=1 https://github.com/ethereum/tests.git $ETHEREUM_TEST_DIR
fi
cd $GODWOKEN_DIR
git fetch origin develop
git checkout FETCH_HEAD
git submodule update --init --recursive --depth=1

cd $PROJECT_ROOT
git submodule update --init --recursive --depth=1
Expand Down
81 changes: 57 additions & 24 deletions polyjuice-tests/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions polyjuice-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ name = "lib"
path = "src/lib.rs"

[dependencies]
gw-types = { path = "../integration-test/godwoken/crates/types" }
gw-common = { path = "../integration-test/godwoken/crates/common" }
gw-db = { path = "../integration-test/godwoken/crates/db" }
gw-store = { path = "../integration-test/godwoken/crates/store" }
gw-config = { path = "../integration-test/godwoken/crates/config" }
gw-traits = { path = "../integration-test/godwoken/crates/traits" }
gw-generator = { path = "../integration-test/godwoken/crates/generator"}
gw-types = { git = "https://github.com/magicalne/godwoken.git", branch = "inc_ret_data" }
gw-common = { git = "https://github.com/magicalne/godwoken.git", branch = "inc_ret_data" }
gw-db = { git = "https://github.com/magicalne/godwoken.git", branch = "inc_ret_data" }
gw-store = { git = "https://github.com/magicalne/godwoken.git", branch = "inc_ret_data" }
gw-config = { git = "https://github.com/magicalne/godwoken.git", branch = "inc_ret_data" }
gw-traits = { git = "https://github.com/magicalne/godwoken.git", branch = "inc_ret_data" }
gw-generator = { git = "https://github.com/magicalne/godwoken.git", branch = "inc_ret_data" }
ckb-vm = { version = "=0.21.3", features = ["detect-asm"] }
ckb-vm-definitions = "=0.21.3"

Expand Down
8 changes: 7 additions & 1 deletion polyjuice-tests/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub struct MockChain {
block_producer: RegistryAddress,
block_number: u64,
timestamp: SystemTime,
l2tx_cycle_limit: u64,
}

impl MockChain {
Expand All @@ -97,9 +98,14 @@ impl MockChain {
block_producer,
block_number: 0u64,
timestamp,
l2tx_cycle_limit: L2TX_MAX_CYCLES,
})
}

pub fn set_max_cycles(&mut self, max_cycles: u64) {
self.l2tx_cycle_limit = max_cycles;
}

fn new_block_info(&self) -> anyhow::Result<BlockInfo> {
let timestamp = self
.timestamp
Expand Down Expand Up @@ -261,7 +267,7 @@ impl MockChain {
&self.ctx.state,
&block_info,
&raw_tx,
L2TX_MAX_CYCLES,
self.l2tx_cycle_limit,
None,
)?;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call[]","name":"calls","type":"tuple[]"}],"name":"aggregate","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes[]","name":"returnData","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"allowFailure","type":"bool"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call3[]","name":"calls","type":"tuple[]"}],"name":"aggregate3","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"allowFailure","type":"bool"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call3Value[]","name":"calls","type":"tuple[]"}],"name":"aggregate3Value","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call[]","name":"calls","type":"tuple[]"}],"name":"blockAndAggregate","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes32","name":"blockHash","type":"bytes32"},{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getBasefee","outputs":[{"internalType":"uint256","name":"basefee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBlockNumber","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"chainid","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockCoinbase","outputs":[{"internalType":"address","name":"coinbase","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockDifficulty","outputs":[{"internalType":"uint256","name":"difficulty","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockGasLimit","outputs":[{"internalType":"uint256","name":"gaslimit","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentBlockTimestamp","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getEthBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastBlockHash","outputs":[{"internalType":"bytes32","name":"blockHash","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"requireSuccess","type":"bool"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call[]","name":"calls","type":"tuple[]"}],"name":"tryAggregate","outputs":[{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bool","name":"requireSuccess","type":"bool"},{"components":[{"internalType":"address","name":"target","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"internalType":"struct Multicall3.Call[]","name":"calls","type":"tuple[]"}],"name":"tryBlockAndAggregate","outputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes32","name":"blockHash","type":"bytes32"},{"components":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"internalType":"struct Multicall3.Result[]","name":"returnData","type":"tuple[]"}],"stateMutability":"payable","type":"function"}]
Loading

0 comments on commit 0fe70c1

Please sign in to comment.