Zilliqa / scilla

Scilla - A Smart Contract Intermediate Level Language
https://scilla-lang.org
GNU General Public License v3.0
240 stars 78 forks source link

Re-enable REPLICATE_CONTRACT #1180

Open jjcnn opened 2 years ago

jjcnn commented 2 years ago

The REPLICATE_CONTRACT feature has been disabled due to lack of blockchain support. The code is currently commented out, and should be reintroduced (and re-tested) once blockchain support has been implemented.

This issue depends on https://zilliqa-jira.atlassian.net/browse/ZIL-4698.

jjcnn commented 2 years ago

Assigning this to milestone 0.14 as this is a feature request from the community.

jjcnn commented 2 years ago

The commit that disables the feature is here: https://github.com/Zilliqa/scilla/pull/1181/commits/d1f137aa587d3c9e917e348a310d71046ee36882

Note that only the commented-out pieces of code need to be reintroduced, and the test output updated. The change related to bcfetch_args in the parser is a bugfix, and now works as intended.

jjcnn commented 1 year ago

Possibly rethink the concrete syntax for this.

The current syntax is

x <-& REPLICATE_CONTRACT addr y1 y2 y3

This means that we assign values to the replicated contract's parameters based on the order of the actual parameters, and this is inconsistent with how we invoke transitions.

What we ought to do is something like this:

x <-& REPLICATE_CONTRACT addr { param1 : y1; param2 : y2; param3 : y3}

Now we can rely on the name paramX to determine which value should be assigned to which parameter.

This further allows for a partial static typecheck of the statement: If addr is known to have type ByStr20 with contract (param1 : Uint128) end, then we know that param1 should be one of the parameter names in REPLICATE_CONTRACT, and we know that its assigned value should be Uint128. Note that the type of addr might not list all of the contract's parameters, so the type's parameters should be a subset of the ones listed in REPLICATE_CONTRACT.