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

VM - Jump table #3116

Closed
wants to merge 11 commits into from
Closed

VM - Jump table #3116

wants to merge 11 commits into from

Conversation

shargon
Copy link
Member

@shargon shargon commented Feb 6, 2024

Close #2987

@shargon shargon self-assigned this Feb 6, 2024
@shargon
Copy link
Member Author

shargon commented Feb 6, 2024

@Jim8y could you help me to fill the rest of the opcodes, with this change we can versioning the vm in ApplicationEngine, also the methods will me in different files, and I think that it will be faster than a big switch

@Jim8y
Copy link
Contributor

Jim8y commented Feb 7, 2024

Already being done in #3100

@shargon
Copy link
Member Author

shargon commented Feb 7, 2024

Already being done in #3100

Is not the same, this is upgradeable, we can have one jumpTable per fork

@Jim8y
Copy link
Contributor

Jim8y commented Feb 7, 2024

then a bref explaination of how it work please, kinda weird to me.

@shargon
Copy link
Member Author

shargon commented Feb 7, 2024

then a bref explaination of how it work please, kinda weird to me.

Ethereum works like that, basically, you have an array of 255 functions, each method is the logic of the opcode, this is stored in a class for example JmpVM_Cockatrice, if you have a different logic because you find a bug in the opcode PUSH1, then, you create a new object exactly like the previous one, but in this position JmpTable[Opcode.PUSH1] you set the new logic.

Then during the VM creation, you send the jump table that you want to use, so is easy to versioning each opcode, also, you avoid a big switch, because with the opcode, you know exactly the method that you must execute.

Reference: https://github.com/ethereum/go-ethereum/blob/master/core/vm/jump_table.go

@Jim8y Jim8y mentioned this pull request Feb 7, 2024
12 tasks
@Jim8y
Copy link
Contributor

Jim8y commented Feb 7, 2024

how do we know when to use the new method when to use the old one? VM can not get access to the height

@shargon
Copy link
Member Author

shargon commented Feb 7, 2024

how do we know when to use the new method when to use the old one? VM can not get access to the height

This is handle by ApplicationEngine

@shargon
Copy link
Member Author

shargon commented Feb 7, 2024

how do we know when to use the new method when to use the old one? VM can not get access to the height

Let me refactor, because currently we need to do it without a new class, we have problems with isJumping for example, change it to internal, is not a good solution

@Jim8y
Copy link
Contributor

Jim8y commented Feb 7, 2024

@AnnaShaleva please join the dicussion here

@shargon shargon closed this Feb 7, 2024
@shargon shargon deleted the vm-jumptable branch February 7, 2024 11:41
@shargon
Copy link
Member Author

shargon commented Feb 7, 2024

Follow in #3120 (@Jim8y you should have rights there)

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.

vm: Versioning the VM
2 participants