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.
should we convert to boxed instead?
There was a problem hiding this comment.
I would panic here. Silently converting can have a side-effect on performance
There was a problem hiding this comment.
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.
It should be intentionally called with to_boxed not silently converted.
There was a problem hiding this comment.
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.
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.
Changed to convert into the boxed variant inside insert_boxed. updated docs and the test which no longer needs a map
This adds a test which serves as an example for adding custom instructions which require some context. This also adds
convert_boxedandinsert_boxedwhich should make it easier to do this using the revm builder.