Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix docker compose setup #32

Merged
merged 3 commits into from
Apr 17, 2024
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
28 changes: 27 additions & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,30 @@ services:
image: ghcr.io/foundry-rs/foundry:latest
ports:
- "8545:8545"
command: ["anvil --block-time 2"]
command: ["anvil --block-time 2 --host 0.0.0.0"]

# blockchain:
# image: ethereum/client-go:alltools-stable
# hostname: blockchain
# command: >
# geth --datadir /root/datadir --dev --http --ws
# --http.api eth,web3,net,debug
# --http.addr "0.0.0.0"
# --ws.addr "0.0.0.0"
# --ws.port 8545
# --http.vhosts "*"
# --http.corsdomain "https://remix.ethereum.org"
# --rpc.gascap 0
# --rpc.txfeecap 0
# --vmdebug
# volumes:
# - geth_datadir:/root/datadir
# ports:
# - "30303:30303"
# - "8545:8545"
# stdin_open: true
# tty: true
# restart: unless-stopped

# volumes:
# geth_datadir:
4 changes: 3 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ impl App {
) -> eyre::Result<Provider<Ws>> {
let url = self.db.get_network_rpc(chain_id, RpcKind::Ws).await?;

let ws = Ws::connect(url.as_str()).await?;
let ws = Ws::connect(url.as_str())
.await
.context("Connecting to WS provider")?;
let provider = Provider::new(ws);

Ok(provider)
Expand Down
1 change: 1 addition & 0 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ impl Database {
nonce,
current_nonce,
max_inflight_txs,
max_queued_txs,
gas_price_limits,
enabled
FROM relayers
Expand Down
2 changes: 2 additions & 0 deletions src/tasks/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ pub async fn index_chain(app: Arc<App>, chain_id: u64) -> eyre::Result<()> {
let ws_rpc = app.ws_provider(chain_id).await?;
let rpc = app.http_provider(chain_id).await?;

tracing::info!("Subscribing to new blocks");
// Subscribe to new block with the WS client which uses an unbounded receiver, buffering the stream
let mut blocks_stream = ws_rpc.subscribe_blocks().await?;

// Get the first block from the stream, backfilling any missing blocks from the latest block in the db to the chain head
tracing::info!("Backfilling blocks");
if let Some(latest_block) = blocks_stream.next().await {
backfill_to_block(app.clone(), chain_id, &rpc, latest_block)
.await?;
Expand Down