-
Notifications
You must be signed in to change notification settings - Fork 50
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
Cairo1 runner fixes #675
base: main
Are you sure you want to change the base?
Cairo1 runner fixes #675
Conversation
…arguments and initial gas to the memory
Current changes in the existing code feature: General:
|
* Add parsing logic for input user args * Add flags for available gas, input user args, writing args to memory * Fix unit tests for user arguments parsing * Lint the PR * Add user args to hint context * Refactor the code * Fix unconditional append of ExternalWriteArgsToMemory, bug fixes in integration tests * Add fixes of the call size calculation and include ExternalWriteArgsToMemory hint when gas present * Add layouts for integration tests * Add error handling * Fixes in entry code generation * Address changes mentioned in a discussion * Add comment regarding writing to memory in a hint for the future reference in the integration tests with args * Changes in calculations of the initial PC offset, CALL opcode offset incremented by mainFuncOffset, writing user args to the AP in the hint * Turn back VM config to private field * Add error handling on assign of `userArgs` to the initial scope * Lint project * Bump go version from 1.20 -> 1.21 (#678) * Bump go version from 1.20 -> 1.21 * Update golangci-lint * Simplify the Makefile * Correction in the makefile
integration_tests/cairo_vm_test.go
Outdated
@@ -182,7 +179,7 @@ func TestCairoFiles(t *testing.T) { | |||
{"./cairo_zero_hint_tests/", true}, | |||
{"./cairo_zero_file_tests/", true}, | |||
{"./builtin_tests/", true}, | |||
// {"./cairo_1_programs/", false}, | |||
{"./cairo_1_programs/", false}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably you'll need to leave the comment here, as the tests are not passing yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
if userArgs != nil { | ||
err := context.ScopeManager.AssignVariable("userArgs", userArgs) | ||
if err != nil { | ||
panic(fmt.Errorf("assign userArgs: %v", err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you leave a comment here that this line should not be reachable since the context was just initialized above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/runner/gas.go
Outdated
"github.com/NethermindEth/cairo-vm-go/pkg/vm/memory" | ||
mem "github.com/NethermindEth/cairo-vm-go/pkg/vm/memory" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why both? I would use the one without the alias only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
pkg/runner/gas.go
Outdated
|
||
const ( | ||
ConstToken TokenGasCost = iota + 1 | ||
HoleToken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using this one? The rest I understand refer to builtins but I think for this one if you are going to leave it here then you should add a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for ConstToken
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it is not necessary for now, removed the unused tokens
MulModToken | ||
) | ||
|
||
func getTokenGasCost(token TokenGasCost) (uint64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I know these values come from the rust vm, could you pls add a comment with a link to the source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@@ -25,6 +25,7 @@ const ( | |||
AddModeType | |||
MulModType | |||
GasBuiltinType | |||
SystemType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this one refer to? I see you only use it in emulatedBuiltins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, this is something I thought might be useful in the future, but it turned out not
No description provided.