glow icon indicating copy to clipboard operation
glow copied to clipboard

Handle Compilation for 0 / 1 Transactions in Glow Contract

Open kwannoel opened this issue 3 years ago • 5 comments

In GitLab by @kwanzknoel on May 24, 2021, 15:17

Currently compilation does not handle the case where first transaction is also the last.

Reproducing the issue

transfer.glow

#lang glow
@interaction([Sender, Recipient])
let transfer = (price : Nat) => {
  deposit! Sender -> price;

  withdraw! Recipient <- price;
};

transfer.glow only has 1 transaction, because there is no interaction (e.g. @publish! A -> x) with the contract after its initial creation-and-destruction step (the only transaction).

The compiler does not currently handle this, and compilation fails when running the contract via glow start-interaction.

From the Trace below, this occurs when we do lookup-live-variables and call hash-ref which compiles down to (##structure-ref ...).

Trace

In thread primordial:
0  clan/exception#call-with-logged-exceptions__%                               
1  ##dynamic-env-bind                                                          
2  mukn/glow/runtime/program#lookup-live-variables                             
3  mukn/glow/runtime/participant-runtime#create-frame-variables                
4  mukn/glow/runtime/participant-runtime#prepare-create-contract-transaction   
5  mukn/glow/runtime/participant-runtime#deploy-contract                       
6  mukn/glow/runtime/participant-runtime#run-active-code-block                 
7  mukn/glow/runtime/participant-runtime#execute-1                             
8  mukn/glow/runtime/participant-runtime#execute                               
9  ##dynamic-env-bind                                                          
10 mukn/glow/runtime/reify-contract-parameters#run                             
11 mukn/glow/cli/interaction#start-interaction__%                              
12 ##dynamic-env-bind                                                          
13 ##call-with-values                                                          
14 clan/exit#call-print-exit                                                   
15 ##dynamic-env-bind                                                          
16 ##start-main                                                                
17 ##kernel-handlers                                                           
*** ERROR IN clan/exception#call-with-logged-exceptions__% -- (Argument 1) Instance of #<type #81 ci> expected
(##structure-ref #f 2 '#<type #81 ci> #f)

kwannoel avatar Sep 22 '21 05:09 kwannoel

In GitLab by @kwanzknoel on May 24, 2021, 15:21

changed the description

kwannoel avatar Sep 22 '21 05:09 kwannoel

In GitLab by @kwanzknoel on May 24, 2021, 15:21

changed the description

kwannoel avatar Sep 22 '21 05:09 kwannoel

In GitLab by @kwanzknoel on May 24, 2021, 15:24

changed the description

kwannoel avatar Sep 22 '21 05:09 kwannoel

In GitLab by @kwanzknoel on May 24, 2021, 15:37

changed the description

kwannoel avatar Sep 22 '21 05:09 kwannoel

In GitLab by @kwanzknoel on May 24, 2021, 16:00

changed the description

kwannoel avatar Sep 22 '21 05:09 kwannoel