-
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 #8 from rainshowerLabs/0.3.2-bug-fixes-optimizations
0.3.2 bug fixes optimizations
- Loading branch information
Showing
10 changed files
with
135 additions
and
65 deletions.
There are no files selected for viewing
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,6 +1,6 @@ | ||
[package] | ||
name = "sothis" | ||
version = "0.3.1" | ||
version = "0.3.2" | ||
edition = "2021" | ||
authors = ["makemake <[email protected]>"] | ||
license = "GPL-3.0-or-later" | ||
|
@@ -23,3 +23,4 @@ rlp = "0.5.2" | |
serde = { version = "1.0.163", features = ["derive"] } | ||
serde_json = "1.0.96" | ||
tokio = { version = "1.28.1", features = ["full"] } | ||
url = "2.4.0" |
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,48 @@ | ||
from http.server import BaseHTTPRequestHandler, HTTPServer | ||
import json | ||
|
||
|
||
class DummyRPCHandler(BaseHTTPRequestHandler): | ||
def _set_response(self, status_code=200): | ||
self.send_response(status_code) | ||
self.send_header('Content-type', 'application/json') | ||
self.end_headers() | ||
|
||
def do_POST(self): | ||
content_length = int(self.headers['Content-Length']) | ||
request_body = self.rfile.read(content_length) | ||
rpc_request = json.loads(request_body) | ||
|
||
if rpc_request['method'] == 'eth_blockNumber': | ||
response = { | ||
"jsonrpc": "2.0", | ||
"id": rpc_request['id'], | ||
"result": "0x123456" # Dummy block number | ||
} | ||
else: | ||
response = { | ||
"jsonrpc": "2.0", | ||
"id": rpc_request['id'], | ||
"error": { | ||
"code": -32601, | ||
"message": "Method not found" | ||
} | ||
} | ||
|
||
self._set_response() | ||
self.wfile.write(json.dumps(response).encode()) | ||
|
||
def do_GET(self): | ||
self._set_response(404) | ||
self.wfile.write(b'Not found') | ||
|
||
|
||
def run_server(): | ||
server_address = ('localhost', 8000) | ||
httpd = HTTPServer(server_address, DummyRPCHandler) | ||
print('Dummy RPC server is running on http://localhost:8000...') | ||
httpd.serve_forever() | ||
|
||
|
||
if __name__ == '__main__': | ||
run_server() |
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 |
---|---|---|
|
@@ -33,7 +33,7 @@ lazy_static! { | |
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let matches = Command::new("sothis") | ||
.version("0.3.1") | ||
.version("0.3.2") | ||
.author("makemake <[email protected]>") | ||
.about("Tool for replaying historical transactions. Designed to be used with anvil or hardhat.") | ||
.arg(Arg::new("source_rpc") | ||
|
@@ -131,13 +131,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | |
"historic" => { | ||
println!("Replaying in historic mode..."); | ||
|
||
let block: String = matches.get_one::<String>("terminal_block").expect("required").to_string(); | ||
let block = format_number_input(&block); | ||
let terminal_block: String = matches.get_one::<String>("terminal_block").expect("required").to_string(); | ||
let terminal_block = format_number_input(&terminal_block); | ||
|
||
let replay_rpc: String = matches.get_one::<String>("replay_rpc").expect("required").to_string(); | ||
let replay_rpc = RpcConnection::new(replay_rpc); | ||
|
||
replay_historic_blocks(source_rpc, replay_rpc, hex_to_decimal(&block)?).await?; | ||
replay_historic_blocks(source_rpc, replay_rpc, hex_to_decimal(&terminal_block)?).await?; | ||
}, | ||
"live" => { | ||
println!("Replaying live blocks..."); | ||
|
@@ -149,16 +149,22 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | |
} | ||
"track" => { | ||
println!("Tracking state variable..."); | ||
println!("Send SIGTERM or SIGINT to serialize to JSON, write and stop."); | ||
println!("Send SIGTERM or SIGINT (ctrl-c) to serialize to JSON, write and stop."); | ||
|
||
let contract_address: String = matches.get_one::<String>("contract_address").expect("required").to_string(); | ||
let storage_slot: String = matches.get_one::<String>("storage_slot").expect("required").to_string(); | ||
let storage_slot = U256::from_dec_str(&storage_slot)?; | ||
|
||
// If terminal_block is set by the user use that, otherwise have it be none | ||
let terminal_block: Option<u64> = matches.get_one::<String>("terminal_block").map(|x| x.parse().expect("Invalid terminal block")); | ||
|
||
if terminal_block == None { | ||
println!("No terminal block set, tracking indefinitely."); | ||
} | ||
|
||
track_state(source_rpc, storage_slot, contract_address).await?; | ||
track_state(source_rpc, storage_slot, contract_address, terminal_block).await?; | ||
} | ||
&_ => { | ||
// handle this properly later | ||
panic!("Mode does not exist!"); | ||
}, | ||
} | ||
|
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
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
Oops, something went wrong.