-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from rainshowerLabs/0.5.0
0.5.0 release
- Loading branch information
Showing
16 changed files
with
896 additions
and
824 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
/.venv |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
[package] | ||
name = "sothis" | ||
version = "0.4.0" | ||
version = "0.5.0" | ||
edition = "2021" | ||
authors = ["makemake <[email protected]>"] | ||
license = "AGPL-3.0-only" | ||
license = "MPL-2.0" | ||
description = "Tool for replaying historical EVM state." | ||
readme = "README.md" | ||
homepage = "https://github.com/makemake-kbo/sothis" | ||
repository = "https://github.com/makemake-kbo/sothis" | ||
homepage = "https://github.com/rainshowerLabs/sothis" | ||
repository = "https://github.com/rainshowerLabs/sothis" | ||
keywords = ["cli", "ethereum", "foundry", "reth", "revm"] | ||
categories = ["command-line-utilities"] | ||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = "4.3.0" | ||
ctrlc = "3.4.0" | ||
ethers = {version = "2.0.7", features = ["legacy"]} | ||
regex = "1.9.1" | ||
reqwest = { version = "0.11.18", features = ["blocking", "json"] } | ||
serde = { version = "1.0.163", features = ["derive"] } | ||
serde_json = "1.0.96" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import sys | ||
import re | ||
|
||
def is_valid_eth_address(hex_str): | ||
return len(hex_str) == 42 and hex_str[:2] == "0x" and all(c in "0123456789abcdefABCDEF" for c in hex_str[2:]) | ||
|
||
def hex_to_decimal(match): | ||
hex_str = match.group(0) | ||
if is_valid_eth_address(hex_str): | ||
return hex_str # Ignore valid Ethereum addresses | ||
decimal_num = str(int(hex_str, 16)) | ||
return decimal_num | ||
|
||
def convert_hex_to_decimal_in_file(file_path): | ||
try: | ||
with open(file_path, 'r') as file: | ||
content = file.read() | ||
|
||
# Use regular expression to find all hexadecimal numbers in the content | ||
pattern = r'0x[0-9A-Fa-f]+' | ||
converted_content = re.sub(pattern, hex_to_decimal, content) | ||
|
||
with open(file_path, 'w') as file: | ||
file.write(converted_content) | ||
|
||
print(f"Conversion successful. Hex numbers in '{file_path}' (excluding Ethereum addresses) converted to decimal.") | ||
except FileNotFoundError: | ||
print(f"Error: File '{file_path}' not found.") | ||
except Exception as e: | ||
print(f"Error occurred: {e}") | ||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) != 2: | ||
print("Usage: python script.py <file_path>") | ||
else: | ||
file_path = sys.argv[1] | ||
convert_hex_to_decimal_in_file(file_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
use clap::{Command, Arg}; | ||
|
||
|
||
// This is not the recommended way to set clap args but it works and its too late to change it now | ||
pub fn create_match() -> clap::Command { | ||
let matches = Command::new("sothis") | ||
.version("0.5.0") | ||
.author("makemake <[email protected]>") | ||
.about("Tool for replaying historical transactions. Designed to be used with anvil or hardhat.") | ||
.arg(Arg::new("source_rpc") | ||
.long("source_rpc") | ||
.short('s') | ||
.num_args(1..) | ||
.required(true) | ||
.help("HTTP JSON-RPC of the node we're querying data from")) | ||
.arg(Arg::new("replay_rpc") | ||
.long("replay_rpc") | ||
.short('r') | ||
.num_args(1..) | ||
.help("HTTP JSON-RPC of the node we're replaying data to")) | ||
.arg(Arg::new("mode") | ||
.long("mode") | ||
.short('m') | ||
.num_args(1..) | ||
.default_value("historic") | ||
.help("Choose between live, historic, track, fast_track, or call_track")) | ||
.arg(Arg::new("terminal_block") | ||
.long("terminal_block") | ||
.short('b') | ||
.num_args(1..) | ||
.required_if_eq("mode", "historic") | ||
.help("Block we're replaying until")) | ||
.arg(Arg::new("exit_on_tx_fail") | ||
.long("exit_on_tx_fail") | ||
.num_args(0..) | ||
.help("Exit the program if a transaction fails")) | ||
.arg(Arg::new("block_listen_time") | ||
.long("block_listen_time") | ||
.short('t') | ||
.num_args(1..) | ||
.default_value("500") | ||
.help("Time in ms to check for new blocks.")) | ||
.arg(Arg::new("entropy_threshold") | ||
.long("entropy_threshold") | ||
.num_args(1..) | ||
.default_value("0.07") | ||
.help("Set the percentage of failed transactions to trigger a warning")) | ||
.arg(Arg::new("replay_delay") | ||
.long("replay_delay") | ||
.short('d') | ||
.num_args(1..) | ||
.default_value("0") | ||
.help("Default delay for block replay in ms")) | ||
.arg(Arg::new("send_as_unsigned") | ||
.long("send_as_unsigned") | ||
.num_args(0..) | ||
.help("Exit the program if a transaction fails")) | ||
.arg(Arg::new("no_setup") | ||
.long("no_setup") | ||
.num_args(0..) | ||
.help("Start replaying immediately.")) | ||
.arg(Arg::new("decimal") | ||
.long("decimal") | ||
.num_args(0..) | ||
.help("Start replaying immediately.")) | ||
.arg(Arg::new("contract_address") | ||
.long("contract_address") | ||
.short('c') | ||
.num_args(1..) | ||
.required_if_eq("mode", "track") | ||
.required_if_eq("mode", "fast_track") | ||
.help("Address of the contract we're tracking storage.")) | ||
.arg(Arg::new("storage_slot") | ||
.long("storage_slot") | ||
.short('l') | ||
.num_args(1..) | ||
.required_if_eq("mode", "track") | ||
.required_if_eq("mode", "fast_track") | ||
.help("Storage slot for the variable we're tracking")) | ||
.arg(Arg::new("calldata") | ||
.long("calldata") | ||
.short('a') | ||
.num_args(1..) | ||
.required_if_eq("mode", "call_track") | ||
.help("Storage slot for the variable we're tracking")) | ||
.arg(Arg::new("origin_block") | ||
.long("origin_block") | ||
.short('o') | ||
.num_args(1..) | ||
.required_if_eq("mode", "fast_track") | ||
.help("First block sothis will look at.")) | ||
.arg(Arg::new("query_interval") | ||
.long("query_interval") | ||
.short('q') | ||
.num_args(1..) | ||
.help("First block sothis will look at.")) | ||
.arg(Arg::new("path") | ||
.long("path") | ||
.short('p') | ||
.num_args(1..) | ||
.default_value(".") | ||
.help("Path to file we're writing to")) | ||
.arg(Arg::new("filename") | ||
.long("filename") | ||
.short('f') | ||
.num_args(1..) | ||
.default_value("") | ||
.help("Name of the file.")); | ||
|
||
return matches; | ||
} |
Oops, something went wrong.