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

feat: cairo runner #30

Merged
merged 12 commits into from
Nov 17, 2023
Merged

Conversation

greged93
Copy link
Contributor

Adds the cairo runner to the code base, and allows to run fibonnaci! Resolves #18

@@ -0,0 +1,8 @@
CAIRO_0_PATH=cairo_programs/cairo_0
Copy link
Member

Choose a reason for hiding this comment

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

do we have a strategy for cairo1 files as well?
with another cairo-compile binary? or rather scarb?
it can wait

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think Lambda does it but installing the cairo-1 compiler and then just compiling. We don't really have to handle scarb right? Scarb is more to compile whole projects, if we are just compiling a couple of single files, should be able to use the raw compiler.

Copy link
Member

Choose a reason for hiding this comment

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

can we add the cairo-format formatter as well (you can copy/paste from kakarot)

Copy link
Member

Choose a reason for hiding this comment

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

is this the fibonacci implementation used in other repo? as it's not the most efficient one

Copy link
Member

Choose a reason for hiding this comment

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

see also the cairo paper, section 3.4 Cairo programs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you want the cairo paper optimized one? It seems hard to read but can do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just tried with low level, it's nice, can update if you want

Comment on lines +44 to +46
this.initializeSegments();
const result = this.initializeMainEntrypoint();
this.initializeVm();
Copy link
Member

Choose a reason for hiding this comment

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

this is confusing because we get as intermediary result result which is eventually returned. Why not

    this.initializeSegments();
    this.initializeVm();
    return this.initializeMainEntrypoint();    

but I think that the content of these functions should be inlined here, they are small and it doesn't help readability

Copy link
Member

Choose a reason for hiding this comment

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

after pulling the PR locally, I definitely think that you should inline everything and remove all the initializeX functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mmmmm that might be a lot of code inlined into one function, worried this will not improve the lisibility nor the testing.

Copy link
Member

Choose a reason for hiding this comment

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

you case use default in all the switch instead of leaving the switch to return

Copy link
Member

Choose a reason for hiding this comment

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

also plz put the early return in the branches to keep the main case at the most top level

Copy link
Member

@ClementWalter ClementWalter left a comment

Choose a reason for hiding this comment

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

the src/vm/virtualMachine.ts file is hard to read

@ClementWalter ClementWalter merged commit 5c151a3 into kkrt-labs:main Nov 17, 2023
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.

dev: implement runInstruction for the vm
3 participants