Skip to content

Instantly share code, notes, and snippets.

@jmcph4
Created December 28, 2024 08:19
Show Gist options
  • Select an option

  • Save jmcph4/6748c8a07284ce8c0a9ded098147225e to your computer and use it in GitHub Desktop.

Select an option

Save jmcph4/6748c8a07284ce8c0a9ded098147225e to your computer and use it in GitHub Desktop.

System Information

Version: 8ad7d05

$ uname -a
Linux [REDACTED] 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux
$ reth --version
reth Version: 1.1.0
Commit SHA: 1ba631ba9581973e7c6cadeea92cfe1802aceb4a
Build Timestamp: 2024-10-10T18:21:22.096485546Z
Build Features: asm_keccak,jemalloc
Build Profile: maxperf
$ rustc --version
rustc 1.82.0 (f6e511eec 2024-10-15)

Actual Behaviour

use alloy::providers::{ProviderBuilder, WsConnect};

const CHECKPOINT_PATH: &str = "checkpoint.json";
const RPC_URL: &str = "ws://localhost:8546";

#[tokio::main]
async fn main() -> eyre::Result<()> {
    let provider = ProviderBuilder::new().on_ws(WsConnect::new(RPC_URL)).await?;
    let (_, pools, _) = amms::sync::checkpoint::sync_amms_from_checkpoint(
        CHECKPOINT_PATH,
        10_000,
        provider,
    )
    .await?;
    dbg!(&pools);
    Ok(())
}
[package]
name = "checkpoint"
version = "0.1.0"
edition = "2021"

[dependencies]
alloy = { version = "0.6", features = ["full"] }
amms = { git = "https://github.com/darkforestry/amms-rs.git", rev = "8ad7d05" }
eyre = "0.6.12"
tokio = { version = "1.42.0", features = ["full"] }
$ echo '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' | websocat ws://localhost:8546
{"jsonrpc":"2.0","id":1,"result":"0x1478124"}
$ cat checkpoint.json | jq
{
  "timestamp": 1729741405,
  "block_number": 21032844,
  "factories": [
    {
      "UniswapV2Factory": {
        "address": "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f",
        "creation_block": 0,
        "fee": 300
      }
    }
  ],
  "amms": [
    {
      "UniswapV2Pool": {
        "address": "0x0d4a11d5eeaac28ec3f61d100daf4d40471f1852",
        "token_a": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
        "token_a_decimals": 18,
        "token_b": "0xdac17f958d2ee523a2206206994597c13d831ec7",
        "token_b_decimals": 6,
        "reserve_0": 21514261909298515000000,
        "reserve_1": 54907480851938,
        "fee": 300
      }
    }
  ]
}
$ cargo run

This hangs indefinitely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment