Commit 31037e64 authored by clabby's avatar clabby

Use `geth dump` rather than `geth snapshot dump`

parent 82c004ef
...@@ -15,7 +15,7 @@ Options: ...@@ -15,7 +15,7 @@ Options:
1. To begin, create a geth snapshot: 1. To begin, create a geth snapshot:
```sh ```sh
geth snapshot dump --nostorage >> snapshot.txt geth dump --iterative --nostorage >> snapshot.txt
``` ```
1. Once the snapshot has been generated, feed it into the CLI: 1. Once the snapshot has been generated, feed it into the CLI:
```sh ```sh
......
use clap::Parser; use clap::Parser;
use ethers::utils::{hex, keccak256};
use eyre::Result; use eyre::Result;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{ use std::{
...@@ -18,13 +17,12 @@ struct EofCrawler { ...@@ -18,13 +17,12 @@ struct EofCrawler {
#[derive(Serialize, Deserialize, Debug)] #[derive(Serialize, Deserialize, Debug)]
struct SnapshotAccount { struct SnapshotAccount {
/// The bytecode of the account /// The key of the account in the global state trie
code: Option<String>, key: String,
/// The public key of the account
#[serde(rename(deserialize = "key"))]
public_key: String,
/// The address of the account /// The address of the account
address: Option<String>, address: Option<String>,
/// The bytecode of the account
code: Option<String>,
} }
fn main() -> Result<()> { fn main() -> Result<()> {
...@@ -56,16 +54,9 @@ fn main() -> Result<()> { ...@@ -56,16 +54,9 @@ fn main() -> Result<()> {
// Check if the account is a contract, and if it is, check if it has an EOF // Check if the account is a contract, and if it is, check if it has an EOF
// prefix. // prefix.
let mut contract: SnapshotAccount = serde_json::from_str(&buf)?; let contract: SnapshotAccount = serde_json::from_str(&buf)?;
if let Some(code) = contract.code.as_ref() { if let Some(code) = contract.code.as_ref() {
if &code[2..4].to_uppercase() == "EF" { if &code[2..4].to_uppercase() == "EF" {
// Derive the address of the account from the public key.
// address = keccak256(public_key)[12:]
let address = {
let public_key = hex::decode(&contract.public_key[2..])?;
format!("0x{}", hex::encode(&keccak256(&public_key)[12..]))
};
contract.address = Some(address);
eof_contracts.push(contract); eof_contracts.push(contract);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment