Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat syscalls as nodes #112

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

THenry14
Copy link
Member

Closes #88

Introduced changes

  • Remove syscalls from samples list, and treat them as separate nodes
  • Allow to pass custom resource map with resources cost different to default one

Checklist

  • Linked relevant issue
  • Updated relevant documentation (README.md)
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

Minimal example:
obraz

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good to know we have 0.13.2.1 on mainnet now xD

Comment on lines +54 to +55
#[arg(long)]
versioned_constants_path: Option<Utf8PathBuf>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should document it, it is not obvious that it is a file with costs . Also we should state that if not provided the default will be used which is constants for 0.13.2.1.

I also wonder if the name is not misleading, since we don't need all the constants, just the costs

@@ -72,10 +76,14 @@ fn main() -> Result<()> {
);
}

let os_resources_map = read_and_parse_versioned_constants_file(&cli.versioned_constants_path)
.expect("Failed to parse versioned constants file");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
.expect("Failed to parse versioned constants file");
.context("Failed to parse versioned constants file")?;

This shouldn't panic as it is user error

Comment on lines +217 to +220
#[derive(Debug, Serialize, Deserialize)]
pub struct OsResources {
pub execute_syscalls: HashMap<DeprecatedSyscallSelector, VmExecutionResources>,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is profiler specific, shouldn't be in this crate especially since we will migrate to use cairo-annotations crate

Comment on lines +84 to +86
let parsed_resources = json_value
.get("os_resources")
.expect("Field 'os_resources' not found in versioned constants file");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let parsed_resources = json_value
.get("os_resources")
.expect("Field 'os_resources' not found in versioned constants file");
let parsed_resources = json_value
.get("os_resources")
.context("Field 'os_resources' not found in versioned constants file")?;

This is a user error, shouldn't panic

Comment on lines +79 to +80
let os_resources_map = read_and_parse_versioned_constants_file(&cli.versioned_constants_path)
.expect("Failed to parse versioned constants file");
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] imo should be in line 65 so reading from files is close to each other

"validated": "VALID"
},
"os_resources": {
"execute_syscalls": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we remove everything else and just leave what's needed

{
    "CallContract": {
        "n_steps": 827,
        "builtin_instance_counter": {
            "range_check_builtin": 15
        },
        "n_memory_holes": 0
    },
    // ....

then we can have

pub type SyscallResourcesMap = HashMap<DeprecatedSyscallSelector, VmExecutionResources>;

}
}

pub fn read_and_parse_versioned_constants_file(path: &Option<Utf8PathBuf>) -> Result<OsResources> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function being here mixes abstraction layers. It just reads from the file, while the trace_reader module ([nit] should be name trace_builder or sth like that now that I think about it, but not relevant here) is about logic related to trace building.

It should be in a separate file I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Syscalls as nodes in trace tree
2 participants