Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,23 @@ jobs:
CXX: clang++
CC: clang
run: export PATH="/scilla/0/bin:$PATH" && ./scripts/js_test.sh
bundler_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Install Rust
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install default toolchain
run: rustup show active-toolchain || rustup toolchain install
- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Install PDM
uses: pdm-project/setup-pdm@v4
- uses: Swatinem/rust-cache@v2
- name: bundler-spec-test framework
env:
CXX: clang++
CC: clang
run: ./scripts/bundler_test.sh
# bundler_test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v6
# with:
# submodules: recursive
# - name: Install Rust
# run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && echo "$HOME/.cargo/bin" >> $GITHUB_PATH
# - name: Install default toolchain
# run: rustup show active-toolchain || rustup toolchain install
# - name: Install foundry
# uses: foundry-rs/foundry-toolchain@v1
# - name: Install PDM
# uses: pdm-project/setup-pdm@v4
# - uses: Swatinem/rust-cache@v2
# - name: bundler-spec-test framework
# env:
# CXX: clang++
# CC: clang
# run: ./scripts/bundler_test.sh
12 changes: 12 additions & 0 deletions bundler_tests/alto-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"network-name": "local",
"environment": "development",
"bundle-mode": "manual",
"safe-mode": true,
"rpc-url": "http://localhost:8545",
"port": 3000,
"executor-private-keys": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"utility-private-key": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"entrypoints": "0x4337084d9e255ff0702461cf8895ce9e3b5ff108",
"enable-debug-endpoints": true
}
32 changes: 25 additions & 7 deletions bundler_tests/config-bundler-spec-tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ api_servers = [
]
eth_chain_id = 1337

consensus.scilla_address = "http://localhost:13000"
consensus.scilla_address = "http://localhost:3333"
consensus.consensus_timeout = { secs = 15, nanos = 0 }
consensus.genesis_deposits = [
["b27aebb3b54effd7af87c4a064a711554ee0f3f5abf56ca910b46422f2b21603bc383d42eb3b927c4c3b0b8381ca30a3", "12D3KooWESMZ2ttSxDwjfnNe23sHCqsJf6sNEKwgHkdgtCHDsbWU", "10000000000000000000000000", "7E5F4552091A69125d5DfCb7b8C2659029395Bdf", "99F7f7C00526426b8dCA99302e96d85A0e5fd400"],
Expand All @@ -18,17 +18,35 @@ consensus.genesis_accounts = [
["2B5AD5c4795c026514f8317c7a215E218DcCD6cF", "5000000000000000000000"],
["6813Eb9362372EEF6200f3b1dbC3f819671cBA69", "5000000000000000000000"],
["1efF47bc3a10a45D4B230B5d10E37751FE6AA718", "5000000000000000000000"],
# spec-tests
["f39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "5000000000000000000000"],
["90F8bf6A479f320ead074411a4B0e7944Ea8c9C1", "5000000000000000000000"],
["3fAB184622Dc19b6109349B94811493BF2a45362", "5000000000000000000000"],
# geth account
# ["71562b71999873db5b286df957af199ec94617f7", "5000000000000000000000"],
# hardhat addresses
["f39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "10000000000000000000000"], # 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
["70997970c51812dc3a010c7d01b50e0d17dc79c8", "10000000000000000000000"], # 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
# bundler-spec-test
["90F8bf6A479f320ead074411a4B0e7944Ea8c9C1", "10000000000000000000000"], # 0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d
# Arachnid account
# ["3fAB184622Dc19b6109349B94811493BF2a45362", "10000000000000000000000"],
# executor
]

# Reward parameters
consensus.rewards_per_hour = "51_000_000_000_000_000_000_000"
consensus.blocks_per_hour = 3600
consensus.blocks_per_hour = 36
consensus.minimum_stake = "10_000_000_000_000_000_000_000_000"
# Gas parameters
consensus.eth_block_gas_limit = 84000000
# spec-tests
consensus.gas_price = "0"
consensus.gas_price = "1"


# ==entrypoint addr= 0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108
# reusing "SimpleAccountFactory" at 0x13E9ed32155810FDbd067D4522C492D6f68E5944
# reusing "TestCounter" at 0x7FfFfe05FeeA7902AffBe5D991800Dd9F3d0460F
# reusing "Simple7702Account" at 0x4Cd241E8d1510e30b2076397afc7508Ae59C66c9

# entrypointSimulationContractV7: "0x703575F1c54Bd480e1431b3bFfDBf55722CF6025"
# entrypointSimulationContractV8: "0xBC8Befa8737D4D46D78b397D0a587d15AA4c16C1"
# entrypointSimulationContractV9: "0xB5B76553126c6075bef9b6313aE567aB2c5d7DFc"
# pimlicoSimulationContract: "0x8D72441022399e256Dcbea0eA183EbD031d37B7C"
# 0xe74a3c7427cda785e0000d42a705b1f3fd371e09
48 changes: 23 additions & 25 deletions scripts/bundler_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,47 @@ export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

echo "Installing nvm"
nvm install 22.12
nvm install 22.22

echo "Using node version 22.12"
nvm use 22.12
echo "Using node version 22.22"
nvm use 22.22
node --version

# link solc directly to skip download
mkdir -p $HOME/.solcx/
ln -s $(which solc) $HOME/.solcx/solc-v0.8.28

# Update bundler-spec-tests, hacking the remote origin url as SSH does not work in CI
git clone --depth 1 https://github.com/eth-infinitism/bundler-spec-tests.git --branch version-0.8-addrs
pushd bundler-spec-tests/
git config --file=.gitmodules submodule.@rip7560.url https://github.com/eth-infinitism/rip7560_contracts.git
pdm install && pdm run update-deps-remote
popd

# wait till ZQ2 runs
timeout 60 bash -c 'until curl -sf http://localhost:4201/health; do sleep 1; done'
timeout 60 bash -c 'until curl -o /dev/null -sf http://localhost:4201/health; do sleep 1; done'

# Pre install contracts
echo "Install Entrypoint v0.8"
npm install @account-abstraction/contracts
cast publish --rpc-url http://localhost:4200 0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222
cast send --rpc-url http://localhost:4200 --private-key 0x0000000000000000000000000000000000000000000000000000000000000004 0x4e59b44847b379578588920cA78FbF26c0B4956C "$(node -e "const {bytecode} = require('@account-abstraction/contracts/artifacts/EntryPoint.json'); console.log('0x0a59dbff790c23c976a548690c27297883cc66b4c67024f9117b0238995e35e9' + bytecode.slice(2))")"
npm install hardhat@3.5.0
pushd bundler-spec-tests/@account-abstraction/
yarn deploy --network proxy
popd

# Install Bundler
echo "Install Alto-Bundler"
npm install @pimlico/alto
npx alto \
-r http://localhost:4200 \
--port 3000 \
-e 0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108 \
-x 0x0000000000000000000000000000000000000000000000000000000000000002 \
-u 0x0000000000000000000000000000000000000000000000000000000000000003 \
--enable-debug-endpoints true > /tmp/alto_log.txt 2>&1 &
timeout 60 bash -c 'until curl -sf http://localhost:3000/health; do sleep 1; done'

# Update bundler-spec-tests, hacking the remote origin url as SSH does not work in CI
git clone --depth 1 https://github.com/eth-infinitism/bundler-spec-tests.git --branch version-0.8-addrs
cd bundler-spec-tests/
git config --file=.gitmodules submodule.@rip7560.url https://github.com/eth-infinitism/rip7560_contracts.git
pdm install && pdm run update-deps

# link solc directly to skip download
mkdir -p $HOME/.solcx/
ln -s $(which solc) $HOME/.solcx/solc-v0.8.28
npx alto --config bundler_tests/alto-config.json > /tmp/alto_log.txt 2>&1 &
timeout 60 bash -c 'until curl -o /dev/null -sf http://localhost:3000/health; do sleep 1; done'

# Run spec tests
pushd bundler-spec-tests/
pdm test \
--url http://localhost:3000 \
--entry-point 0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108 \
--ethereum-node http://localhost:4200 \
tests/single/rpc/
popd

# cleanup
retVal=$?
Expand Down
20 changes: 12 additions & 8 deletions zilliqa/src/api/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use alloy::{
eips::BlockId,
rpc::types::{
TransactionRequest,
BlockOverrides, TransactionRequest,
state::{AccountOverride, StateOverride},
},
};
Expand Down Expand Up @@ -61,15 +61,14 @@ pub fn debug_trace_call(params: Params, node: &Arc<Node>) -> Result<GethTrace> {
let call_params: TransactionRequest = params.next()?;
let block_id: BlockId = params.optional_next()?.unwrap_or_default();
let options: GethDebugTracingCallOptions = params.optional_next()?.unwrap_or_default();
crate::api::eth::expect_end_of_params(&mut params, 1, 3)?;

anyhow::ensure!(
options.block_overrides.is_none(),
"block_overrides unexpected"
);
anyhow::ensure!(options.tx_index.is_none(), "tx_index unexpected");

let overrides = options.state_overrides.clone().unwrap_or_default();

let (mut evm_state, block) = {
let block = node.get_block(block_id)?;
let block = build_errored_response_for_missing_block(block_id, block)?;
Expand All @@ -81,9 +80,12 @@ pub fn debug_trace_call(params: Params, node: &Arc<Node>) -> Result<GethTrace> {
"State required to execute request does not exist"
);

tracing::trace!("debug contract: block={block:?} overrides={overrides:?}");
let state_overrides = options.state_overrides.clone().unwrap_or_default();
let block_overrides = options.block_overrides.clone().unwrap_or_default();

tracing::trace!(?state_overrides, ?block_overrides, ?block, "debug contract");

apply_state_overrides(&mut evm_state, &node.clone(), overrides)?;
apply_state_overrides(&mut evm_state, &node.clone(), state_overrides)?;

let result = node.debug_trace_call(&mut evm_state, &block, call_params, options)?;

Expand All @@ -97,7 +99,9 @@ pub fn eth_call(params: Params, node: &Arc<Node>) -> Result<String> {
let mut params = params.sequence();
let call_params: TransactionRequest = params.next()?;
let block_id: BlockId = params.optional_next()?.unwrap_or_default();
let overrides: StateOverride = params.optional_next()?.unwrap_or_default();
let state_overrides: StateOverride = params.optional_next()?.unwrap_or_default();
let block_overrides: BlockOverrides = params.optional_next()?.unwrap_or_default();
crate::api::eth::expect_end_of_params(&mut params, 1, 4)?;

let (mut evm_state, block) = {
let block = node.get_block(block_id)?;
Expand All @@ -109,9 +113,9 @@ pub fn eth_call(params: Params, node: &Arc<Node>) -> Result<String> {
return Err(anyhow!("State required to execute request does not exist"));
}

tracing::trace!("call_contract: block={block:?} overrides={overrides:?}");
tracing::trace!(?block, ?state_overrides, ?block_overrides, "call_contract");

apply_state_overrides(&mut evm_state, &node.clone(), overrides)?;
apply_state_overrides(&mut evm_state, &node.clone(), state_overrides)?;

let result = evm_state.call_contract(
call_params.from.unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion zilliqa/src/api/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub fn build_errored_response_for_missing_block(
}
}

fn expect_end_of_params(seq: &mut ParamsSequence, min: u32, max: u32) -> Result<()> {
pub fn expect_end_of_params(seq: &mut ParamsSequence, min: u32, max: u32) -> Result<()> {
// Styled after the geth error message.
let msg = if min != max {
format!("too many arguments, want at most {max}")
Expand Down
15 changes: 0 additions & 15 deletions zilliqa/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,21 +969,6 @@ impl Node {
// .and_then(|s| duration_str::parse(s).ok())
// .unwrap_or_default();

/*
GethDebugTracingCallOptions {
tracing_options: GethDebugTracingOptions {
tracer: Some(GethDebugTracerType::JsTracer(
validation_tracer_js().to_string(),
)),
timeout: Some(self.tracer_timeout.clone()),
..Default::default()
},
state_overrides: Some(state_override),
block_overrides: None,
tx_index: None,
},
*/

let _timeout = timeout
.map(|s| duration_str::parse_std(s).unwrap_or_default())
.unwrap_or(Duration::from_mins(1)); // 1-min default
Expand Down
4 changes: 2 additions & 2 deletions zilliqa/src/node_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl NodeLauncher {
// A standalone RPC server is provided mainly to implement the API extensions needed to enable bundler support.
// A decision may be made to enable the same extensions on the regular API in the future, and to directly incorporate it to the main JSON-RPC.
let bundler_api = api::bundler::rpc_module(node.clone(), &crate::api::bundler_enabled());
let rpc_middleware = RpcServiceBuilder::new().layer(RpcLoggerLayer::new(1_000));
let rpc_middleware = RpcServiceBuilder::new().layer(RpcLoggerLayer::new(10_000));
let bundler_rpc = jsonrpsee::server::ServerBuilder::new()
.set_config(
ServerConfig::builder()
Expand All @@ -151,7 +151,7 @@ impl NodeLauncher {
.build(),
)
.set_rpc_middleware(rpc_middleware)
.build((Ipv4Addr::UNSPECIFIED, 4200)) // hard-coded port number
.build((Ipv4Addr::UNSPECIFIED, 8545)) // hard-coded port number
.await;
match bundler_rpc {
Ok(server) => {
Expand Down
Loading