Contract factories and bytecode introspection #796
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "factories"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Created by: radrow
This PR adds support for
CLONE
,CLONE_G
,CREATE
andBYTECODE_HASH
opcodes. fixes #197The syntax details are under discussion. Forum thread
Created by: UlfNorell
This will cause some interoperability issues between contracts using the old and the new compiler, if there are entrypoints taking singleton record types as arguments or returning them as results.
Also, this PR doesn't actually change this??
Created by: UlfNorell
Created by: UlfNorell
Note that this fails because
l
isn't actually aLowerDisorderAnarchy
contract.Created by: UlfNorell
Also failing tests for new type errors (main contract and varargs stuff)
Created by: UlfNorell
last_declaration_must_be_main_contract
is whataeso_ast_to_fcode
throws.Created by: UlfNorell
Expected a main contract
Created by: UlfNorell
Don't we need to check that it's an entrypoint here?
Created by: UlfNorell
This doesn't let us clone or get byte code hash of ourselves, right? This was one of the features asked for in #295.
This is something we probably want to fix later though, and the current design allows for it, as long as we add a contract type for the main contract.
Created by: UlfNorell
Missing
mk_error
for this one. Alsotype_error
doesn't throw an exception (it returnstrue
) so you need to return an actual type here. Suggestion:fresh_uvar(Ann)
.Created by: UlfNorell
Created by: UlfNorell
"point it out" or "point to it"
"the
main
keyword"Created by: UlfNorell
Created by: UlfNorell
io_lib:format/1
does not existCreated by: UlfNorell
Use also in
pp_why_record
Created by: UlfNorell
Created by: UlfNorell
Consider renaming
main_contract
context?Created by: UlfNorell
We're not checking that the main contract is last anywhere else, so this needs to be a proper error.
Created by: UlfNorell
Created by: UlfNorell
Handle in
pp_fexpr
Created by: UlfNorell
Future optimizations:
Chain.create
Created by: UlfNorell
Not actually SCode.
FateCode
maybe?Created by: UlfNorell
This seems bad. This string is hashed and put on-chain so that people can verify the origin of on-chain contracts. This should be
source_hash
instead, with a hash of something like the full contract source + the name of the child contract.Created by: UlfNorell
This field is not used by
aeser_contract_code:serialize
.Created by: UlfNorell
Created by: UlfNorell
This seems wrong. The compiler (
ast_to_fcode
) will put the arguments in the order they are listed in the type, so two functions with named arguments listed in different orders will get compiled differently.Created by: UlfNorell
Not actually pure.
Created by: UlfNorell
Here would be a good place to compute source hashes for child contracts and store them in the
ChildContracts
map.Created by: UlfNorell
Review: Changes requested
Reviewed together with @hanssv
Created by: radrow
clone
if the contract was created previouslyCreated by: radrow
Let's postpone it to the next iteration
Created by: radrow
contract_def
Created by: radrow
identify_main_contract
will now move it to the endCreated by: radrow
So what's wrong?
Created by: radrow
Let's move it to the next iteration
Created by: UlfNorell
last_declartion_must_be_contract
vslast_declaration_must_be_MAIN_contract
Created by: hanssv
Just had a quick look at the fixes and it looks promising! There is still a bunch of new errors not covered by tests and dialyzer seems unhappy.
Created by: hanssv
🙌
Created by: UlfNorell
This is not a grammatically correct use of affine. If you really want to use affine it would be "The charged gas is an affine function of the size of the serialized bytecode", but I would say "increases linearly with" instead.
Created by: UlfNorell
affine
Created by: UlfNorell
Is this different from contracts deployed manually (
Call.value
not being set)?. If so, what's the reason for this?Created by: radrow
It isn't different. I just got concerned that people using factories may want to validate the
create
value withCall.value
(which also I did when testing the opcodes, as it was absolutely intuitive)Created by: radrow
The more you know, fixed
Created by: UlfNorell
Review: Approved
Created by: hanssv
Review: Approved
Merged by: radrow at 2021-05-18 10:21:57 UTC