Skip to content

Conversation

0xrusowsky
Copy link
Contributor

Motivation

Historically, vm.parseJson has had a limitation where fields had to be sorted in alphabetical order. However, now that we are integrating solar everywhere, there is an opportunity to leverage it to deterministically figure out the struct fields and their order, and overcome this limitation.

Solution

Introduce a new field struct_defs to the struct Cheatcodes, which gives it access to a hashmap that stores all struct definitions and their (sorted) fields (with their type):

pub struct StructDefinitions(Arc<HashMap<String, Vec<(String, String)>>>);

@0xrusowsky 0xrusowsky moved this to In Progress in Foundry Jul 22, 2025
@0xrusowsky 0xrusowsky added this to the v1.4.0 milestone Jul 22, 2025
@0xrusowsky 0xrusowsky self-assigned this Jul 22, 2025
@0xrusowsky 0xrusowsky moved this from In Progress to Ready For Review in Foundry Jul 29, 2025
@zerosnacks
Copy link
Member

@klkvr / @DaniPopes when time permits, would you mind reviewing this? I think you two are the most familiar with the JSON cheatcode / Solar HIR

@DaniPopes DaniPopes mentioned this pull request Aug 15, 2025
6 tasks
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be able to be implemented by passing along the solar context from the build output #11307

@@ -369,14 +369,15 @@ fn persist_caller(ccx: &mut CheatsCtxt) {
}

/// Performs an Ethereum JSON-RPC request to the given endpoint.
fn rpc_call(url: &str, method: &str, params: &str) -> Result {
fn rpc_call(struct_defs: &StructDefinitions, url: &str, method: &str, params: &str) -> Result {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's pass along state instead of struct_defs to all necessary functions

@@ -863,7 +864,7 @@ mod tests {
root: PathBuf::from(&env!("CARGO_MANIFEST_DIR")),
..Default::default()
};
Cheatcodes::new(Arc::new(config))
Cheatcodes::new(Arc::new(config), StructDefinitions::default())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep the new signature to the bare minimum required and add builder-style fns for extra stuff

@0xrusowsky
Copy link
Contributor Author

#11307

should i wait for yours to be merge so that we don't need to reimplement?

@grandizzy grandizzy moved this from Ready For Review to Blocked in Foundry Aug 18, 2025
@jenpaff
Copy link
Collaborator

jenpaff commented Aug 18, 2025

blocked until we have the required implementation in solar

@onbjerg onbjerg added the T-blocked Type: blocked label Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-blocked Type: blocked
Projects
Status: Blocked
Development

Successfully merging this pull request may close these issues.

5 participants