-
Notifications
You must be signed in to change notification settings - Fork 17
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: constructor support #31
feat: constructor support #31
Conversation
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.
Looks good! Has some conflicts now
thanks Leo, will push something before eod |
SECTIONS | ||
{ | ||
/DISCARD/ : { | ||
*(.eh_frame) | ||
*(.eh_frame_hdr) | ||
*(.eh_frame.*) | ||
} | ||
} | ||
|
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.
@leonardoalt apparently newer rustc versions create an llvm section for exception handling (.eh_frame
) which they didn't use to.
this section caused me a lot of compilation issues because it was being allocated in a "forbidden" memory region by our interpreter.
it took me a while, but thanks to some AI help i ended up with this modification of the linker script, which maintains the same elf codegen as before the version bump (it simply discard the .eh_frame
).
"-C", "link-arg=-T../r5-rust-rt.x", | ||
"-C", "inline-threshold=275" | ||
"-C", "link-arg=-T../../r5-rust-rt.x", | ||
"-C", "llvm-args=--inline-threshold=275" |
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.
fyi, i also updated the rustflags as i was getting deprecation warnings
and last but not least, i also moved all the contracts under an |
implements contract constructors with with the following design choices:
fn new(..constructor_args) -> Self
nomenclature. Note that returningSelf
is irrelevant (therefore not enforced) and was simply used in the ERC20 example to make it feel more familiar for readers.fn deploy_contract(db: &mut InMemoryDB, bytecode: Bytes)
to also takeencoded_args: Option<Vec<u8>>
as an argument.Option
cause it feels more explicit, but we could also useVec<u8>
and check whether it is empty or notdeploy
feature flag, no function selector is needed, hence why i decided to only use the encoded args (to minimize initcode size)