Skip to content

Commit

Permalink
Merge branch 'main' into fkrell/block_scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
sveitser authored Sep 28, 2023
2 parents 3737155 + 92dfbad commit 21ce6a6
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 54 deletions.
13 changes: 8 additions & 5 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ ESPRESSO_SEQUENCER4_API_PORT=50004
ESPRESSO_SEQUENCER_URL=http://sequencer0:$ESPRESSO_SEQUENCER_API_PORT
ESPRESSO_SEQUENCER_STORAGE_PATH=/store/sequencer
ESPRESSO_SEQUENCER_L1_PORT=8545
ESPRESSO_SEQUENCER_L1_WS_PORT=8546
ESPRESSO_SEQUENCER_L1_PROVIDER=http://demo-l1-network:$ESPRESSO_SEQUENCER_L1_PORT
ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS=0x5fbdb2315678afecb367f032d93f642f64180aa3
ESPRESSO_SEQUENCER_L1_WS_PROVIDER=ws://demo-l1-network:$ESPRESSO_SEQUENCER_L1_WS_PORT
ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG=true
ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS=0x0116686e2291dbd5e317f47fadbfb43b599786ef
ESPRESSO_SEQUENCER_ETH_MNEMONIC="test test test test test test test test test test test junk"
ESPRESSO_SEQUENCER_HOTSHOT_ACCOUNT_INDEX=0
ESPRESSO_SEQUENCER_HOTSHOT_ACCOUNT_INDEX=5
ESPRESSO_COMMITMENT_TASK_PORT=60000

# Example rollup demo variables
ESPRESSO_DEMO_ROLLUP_PORT=8084
ESPRESSO_DEMO_L1_PROVIDER=$ESPRESSO_SEQUENCER_L1_PROVIDER
ESPRESSO_DEMO_L1_HTTP_PROVIDER=$ESPRESSO_SEQUENCER_L1_PROVIDER
ESPRESSO_DEMO_L1_WS_PROVIDER=$ESPRESSO_SEQUENCER_L1_WS_PROVIDER
ESPRESSO_DEMO_HOTSHOT_ADDRESS=$ESPRESSO_SEQUENCER_HOTSHOT_ADDRESS
ESPRESSO_DEMO_ROLLUP_ADDRESS=0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
ESPRESSO_DEMO_ROLLUP_MNEMONIC="test test test test test test test test test test test junk"
ESPRESSO_DEMO_ROLLUP_ACCOUNT_INDEX=1
ESPRESSO_DEMO_ROLLUP_ACCOUNT_INDEX=7

# Foundry
# The mnemonic used by foundry to deploy contracts.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:

- name: Audit
# See https://github.com/libp2p/rust-libp2p/issues/4327 for RUSTSEC-2022-0093
run: cargo audit --ignore RUSTSEC-2022-0093 --ignore RUSTSEC-2023-0052 --ignore RUSTSEC-2023-0053
run: cargo audit --ignore RUSTSEC-2022-0093 --ignore RUSTSEC-2023-0052 --ignore RUSTSEC-2023-0053 --ignore RUSTSEC-2023-0063
10 changes: 5 additions & 5 deletions contract-bindings/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ pub struct TestClients {
impl TestClients {
pub fn new(provider: &Provider<Http>, chain_id: u64) -> Self {
Self {
deployer: get_test_client(0, provider, chain_id),
deployer: get_test_client(5, provider, chain_id),
funded: vec![
get_test_client(1, provider, chain_id),
get_test_client(2, provider, chain_id),
get_test_client(3, provider, chain_id),
get_test_client(6, provider, chain_id),
get_test_client(7, provider, chain_id),
get_test_client(8, provider, chain_id),
],
block_driver: get_test_client(4, provider, chain_id),
block_driver: get_test_client(9, provider, chain_id),
}
}
}
Expand Down
21 changes: 13 additions & 8 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ networks:

services:
demo-l1-network:
image: ghcr.io/foundry-rs/foundry:latest
image: ghcr.io/espressosystems/geth-l1:main
ports:
- $ESPRESSO_SEQUENCER_L1_PORT:8545
# The way the foundry image handles arguments is strange, the double quotes
# make it work here.
command: "'anvil --host 0.0.0.0 --chain-id 1337 --block-time $L1_BLOCK_TIME_SEC --accounts 20'"
healthcheck:
test: ["CMD", "cast", "chain-id"]
- $ESPRESSO_SEQUENCER_L1_WS_PORT:8546
volumes:
- "./geth-config/genesis.json:/genesis.json"
- "./geth-config/test-jwt-secret.txt:/config/test-jwt-secret.txt"

orchestrator:
image: ghcr.io/espressosystems/espresso-sequencer/orchestrator:main
Expand Down Expand Up @@ -70,6 +69,7 @@ services:
- ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_STORAGE_PATH
- ESPRESSO_SEQUENCER_L1_PROVIDER
- ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG
- RUST_LOG
- RUST_LOG_FORMAT
depends_on:
Expand All @@ -90,6 +90,7 @@ services:
- ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_STORAGE_PATH
- ESPRESSO_SEQUENCER_L1_PROVIDER
- ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG
- RUST_LOG
- RUST_LOG_FORMAT
depends_on:
Expand All @@ -110,6 +111,7 @@ services:
- ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_STORAGE_PATH
- ESPRESSO_SEQUENCER_L1_PROVIDER
- ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG
- RUST_LOG
- RUST_LOG_FORMAT
depends_on:
Expand All @@ -130,6 +132,7 @@ services:
- ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_STORAGE_PATH
- ESPRESSO_SEQUENCER_L1_PROVIDER
- ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG
- RUST_LOG
- RUST_LOG_FORMAT
depends_on:
Expand All @@ -150,6 +153,7 @@ services:
- ESPRESSO_SEQUENCER_API_PORT
- ESPRESSO_SEQUENCER_STORAGE_PATH
- ESPRESSO_SEQUENCER_L1_PROVIDER
- ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG
- RUST_LOG
- RUST_LOG_FORMAT
depends_on:
Expand All @@ -168,6 +172,7 @@ services:
- ESPRESSO_COMMITMENT_TASK_PORT
- ESPRESSO_SEQUENCER_URL
- ESPRESSO_SEQUENCER_L1_PROVIDER
- ESPRESSO_SEQUENCER_L1_USE_LATEST_BLOCK_TAG
- RUST_LOG
- RUST_LOG_FORMAT
depends_on:
Expand All @@ -181,8 +186,8 @@ services:
image: ghcr.io/espressosystems/espresso-sequencer/example-rollup:main
environment:
- ESPRESSO_SEQUENCER_URL
- ESPRESSO_DEMO_L1_PROVIDER
- ESPRESSO_DEMO_ROLLUP_ADDRESS
- ESPRESSO_DEMO_L1_HTTP_PROVIDER
- ESPRESSO_DEMO_L1_WS_PROVIDER
- ESPRESSO_DEMO_HOTSHOT_ADDRESS
- ESPRESSO_DEMO_ROLLUP_PORT
- ESPRESSO_DEMO_ROLLUP_MNEMONIC
Expand Down
30 changes: 19 additions & 11 deletions example-l2/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ type HotShotClient = surf_disco::Client<hotshot_query_service::Error>;
#[derive(Clone, Debug)]
pub struct ExecutorOptions {
pub sequencer_url: Url,
pub l1_provider: Url,
pub l1_http_provider: Url,
pub l1_ws_provider: Url,
pub rollup_account_index: u32,
pub rollup_mnemonic: String,
pub hotshot_address: Address,
Expand All @@ -40,7 +41,8 @@ pub async fn run_executor(opt: &ExecutorOptions, state: Arc<RwLock<State>>) {
let ExecutorOptions {
rollup_account_index,
sequencer_url,
l1_provider,
l1_http_provider,
l1_ws_provider,
hotshot_address,
rollup_address,
rollup_mnemonic,
Expand All @@ -52,15 +54,18 @@ pub async fn run_executor(opt: &ExecutorOptions, state: Arc<RwLock<State>>) {
hotshot.connect(None).await;

// Connect to the layer one HotShot contract.
let l1 = connect_rpc(l1_provider, rollup_mnemonic, *rollup_account_index, None)
.await
.expect("unable to connect to L1, hotshot commitment task exiting");
let l1 = connect_rpc(
l1_http_provider,
rollup_mnemonic,
*rollup_account_index,
None,
)
.await
.expect("unable to connect to L1, hotshot commitment task exiting");

// Create a socket connection to the L1 to subscribe to contract events
// This assumes that the L1 node supports both HTTP and Websocket connections
let mut ws_url = l1_provider.clone();
ws_url.set_scheme("ws").unwrap();
let socket_provider = Provider::<Ws>::connect(ws_url)
let socket_provider = Provider::<Ws>::connect(l1_ws_provider)
.await
.expect("Unable to make websocket connection to L1");

Expand Down Expand Up @@ -454,7 +459,8 @@ mod test {
let rollup_opt = ExecutorOptions {
sequencer_url,
rollup_account_index: test_l1.clients.funded[1].index,
l1_provider: anvil.url(),
l1_http_provider: anvil.url(),
l1_ws_provider: anvil.ws_url(),
rollup_mnemonic: TEST_MNEMONIC.to_string(),
hotshot_address: test_l1.hotshot.address(),
rollup_address: test_rollup.contract.address(),
Expand Down Expand Up @@ -548,7 +554,8 @@ mod test {
let rollup_opt = ExecutorOptions {
sequencer_url: sequencer_url.clone(),
rollup_account_index: test_l1.clients.funded[1].index,
l1_provider: anvil.url(),
l1_http_provider: anvil.url(),
l1_ws_provider: anvil.ws_url(),
rollup_mnemonic: TEST_MNEMONIC.to_string(),
hotshot_address: test_l1.hotshot.address(),
rollup_address: test_rollup.contract.address(),
Expand Down Expand Up @@ -619,7 +626,8 @@ mod test {

let rollup_opt = ExecutorOptions {
sequencer_url,
l1_provider: anvil.url(),
l1_http_provider: anvil.url(),
l1_ws_provider: anvil.ws_url(),
rollup_account_index: test_l1.clients.funded[1].index,
rollup_mnemonic: TEST_MNEMONIC.to_string(),
hotshot_address: test_l1.hotshot.address(),
Expand Down
12 changes: 6 additions & 6 deletions example-l2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ pub struct Options {
pub sequencer_url: Url,

/// URL of layer 1 Ethereum JSON-RPC provider.
#[clap(long, env = "ESPRESSO_DEMO_L1_PROVIDER")]
pub l1_provider: Url,
#[clap(long, env = "ESPRESSO_DEMO_L1_HTTP_PROVIDER")]
pub l1_http_provider: Url,

/// URL of layer 1 Ethereum JSON-RPC provider.
#[clap(long, env = "ESPRESSO_DEMO_L1_WS_PROVIDER")]
pub l1_ws_provider: Url,

/// Address of HotShot contract on layer 1.
#[clap(long, env = "ESPRESSO_DEMO_HOTSHOT_ADDRESS")]
pub hotshot_address: Address,

/// Address of Rollup contract on layer 1.
#[clap(long, env = "ESPRESSO_DEMO_ROLLUP_ADDRESS")]
pub rollup_address: Address,

/// Mnemonic phrase for the rollup wallet.
///
/// This is the wallet that will be used to send batch proofs of transaction validity to the rollup
Expand Down
25 changes: 13 additions & 12 deletions example-l2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,29 @@ async fn main() {
sequencer_url: opt.sequencer_url.clone(),
};

let executor_options = ExecutorOptions {
hotshot_address: opt.hotshot_address,
l1_provider: opt.l1_provider.clone(),
rollup_account_index: opt.rollup_account_index,
rollup_address: opt.rollup_address,
rollup_mnemonic: opt.rollup_mnemonic.clone(),
sequencer_url: opt.sequencer_url.clone(),
output_stream: None,
};

let serve_api = async {
serve(&api_options, state.clone()).await.unwrap();
};

let initial_state = { state.read().await.commit() };

tracing::info!("Deploying Rollup contracts");
let provider = create_provider(&opt.l1_provider);
let provider = create_provider(&opt.l1_http_provider);
let test_system = TestL1System::new(provider, opt.hotshot_address)
.await
.unwrap();
deploy_example_contract(&test_system, initial_state).await;
let rollup_contract = deploy_example_contract(&test_system, initial_state).await;

let executor_options = ExecutorOptions {
hotshot_address: opt.hotshot_address,
l1_http_provider: opt.l1_http_provider.clone(),
l1_ws_provider: opt.l1_ws_provider.clone(),
rollup_address: rollup_contract.address(),
rollup_account_index: opt.rollup_account_index,
rollup_mnemonic: opt.rollup_mnemonic.clone(),
sequencer_url: opt.sequencer_url.clone(),
output_stream: None,
};

tracing::info!("Launching Example Rollup API and Executor");
join!(run_executor(&executor_options, state.clone()), serve_api,);
Expand Down
38 changes: 38 additions & 0 deletions genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"config": {
"chainId": 900,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"clique": {
"period": 3,
"epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x6511b40b",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x1c9c380",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"f39fd6e51aad88f6f4ce6ab8827279cfffb92266": {
"balance": "0x200000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": "0x3b9aca00"
}
Loading

0 comments on commit 21ce6a6

Please sign in to comment.