-
Notifications
You must be signed in to change notification settings - Fork 572
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: add convert_boxed and insert_boxed for InstructionTable #1194
feat: add convert_boxed and insert_boxed for InstructionTable #1194
Conversation
Also adds an example for an instruction with captured context
instruction: BoxedInstruction<'a, H>, | ||
) -> Result<(), InsertError> { | ||
match self { | ||
Self::Plain(_) => Err(InsertError::NotBoxed), |
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.
should we convert to boxed instead?
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.
I would panic here. Silently converting can have a side-effect on performance
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.
but there's no other way to use custom instructions, the only way is to box all of them, so I think it'd be reasonable to convert here
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.
It should be intentionally called with to_boxed
not silently converted.
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.
this would make evm setup fallible and force unwrap with a preceding call to to_boxed, i think this makes it a lot less convenient to use, and since additional instructions are only supported by boxing all of them, converting them here seems reasonable to me
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.
That is the point to fail and make it explicit to call, this would look something like.
table.convert_to_box();
table.insert_boxed(instr);
It is redundant but explicit on what is going on.
Not the point I would die on, so lets convert it to boxed inside insert_boxed
.
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.
Changed to convert into the boxed variant inside insert_boxed
. updated docs and the test which no longer needs a map
…loy#1194) * feat: add into_box and insert_boxed for InstructionTable Also adds an example for an instruction with captured context * fix tests with clones * fix valgrind * fix valgrind again * convert to boxed in insert_boxed * update docs for insert_boxed * make convert_boxed more concise * Update crates/interpreter/src/instructions/opcode.rs * Update crates/interpreter/src/instructions/opcode.rs
This adds a test which serves as an example for adding custom instructions which require some context. This also adds
convert_boxed
andinsert_boxed
which should make it easier to do this using the revm builder.