aleeusgr / potential-robot

minimal dApp testing suite
MIT License
3 stars 2 forks source link

Error: tx invalid (not finalized or slot out of range) #106

Closed aleeusgr closed 1 year ago

aleeusgr commented 1 year ago
          Error: tx invalid (not finalized or slot out of range)

❯ assert node_modules/@hyperionbt/helios/helios.js:282:9 ❯ NetworkEmulator.submitTx node_modules/@hyperionbt/helios/helios.js:38456:9 ❯ tests/helios-vesting-cancel.test.ts:137:30 135| 136| await tx.finalize(networkParams, ownerAddress, [spareUtxo]); 137| const txId = await network.submitTx(tx);

Originally posted by @aleeusgr in https://github.com/aleeusgr/potential-robot/issues/104#issuecomment-1560839916

aleeusgr commented 1 year ago

https://github.com/aleeusgr/potential-robot/blob/ee83e60b62775bde4563e6cc4bb48c3f7c3296a7/tests/helios-vesting-cancel.test.ts#L114-L117

aleeusgr commented 1 year ago

how do I get current time from the Emulator

aleeusgr commented 1 year ago

Hello again! Than for the answer on GitHub. How can I find out what is the number of the current slot in the Emulator?

Now I have an error about slot being out of range.

I suspect it's about lines where I set validTo and validAfter. What I did is just to look up last line in preprod.json for the initial time,

https://github.com/aleeusgr/potential-robot/blob/ee83e60b62775bde4563e6cc4bb48c3f7c3296a7/tests/helios-vesting-cancel.test.ts#L114-L120 , but I have no way of knowing what time is now, since I advanced the emulator several times.

I looked in the doc pages but I found only slotToTime conversion.

aleeusgr commented 1 year ago
+ {                                                                                                        [100/1857]
  +   collateral: [                                                                                                    
  +     {                                                                                                              
  +       origOutput: {                                                                                                
  +         address: {                                                                                                 
  +           bech32: 'addr_test1vz2a83z0d5gceyghfrjqpaqu2f98evk8q6swje2c5ddqmaca2vhfl',                               
  +           hex: '6095d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',                                       
  +         },                                                                                                         
  +         datum: null,                                                                                               
  +         refScript: null,
  +         value: {
  +           assets: {},
  +           lovelace: '50000000',
  +         },
  +       },
  +       txId: '0000000000000000000000000000000000000000000000000000000000000001',
  +       utxoIdx: '0',
  +     },
  +   ],
  +   collateralReturn: null,
  +   fee: '210425',
  +   firstValidSlot: '21425484',
  +   inputs: [
  +     {
  +       origOutput: {
  +         address: {
  +           bech32: 'addr_test1wqzs96thkxedr0jpak4ar9qp6ew58uwexmuz99ah93ckv0q6z8ey4',
+           hex: '700502e977b1b2d1be41edabd19401d65d43f1d936f82297b72c71663c',                              [73/1857]
  +         },
  +         datum: {
  +           inlineCbor: '9f581c95d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7581c3b61a40bc5872219ce830fb9c7
92d8d53fb87921f590287057e4e3b41b000001867b8b7b00ff',
  +           inlineSchema: {
  +             list: [
  +               {
  +                 bytes: '95d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
  +               },
  +               {
  +                 bytes: '3b61a40bc5872219ce830fb9c792d8d53fb87921f590287057e4e3b4',
  +               },
  +               {
  +                 int: 1677109984000,
  +               },
  +             ],
  +           },
  +         },
  +         refScript: null,
  +         value: {
  +           assets: {
  +             '49b106e698de78171de2faf35932635e1085c12508ca87718a2d4487': {
  +               '56657374696e67204b6579': '1',
  +             },
  +           },
  +           lovelace: '10000000',
+         },                                                                                                [46/1857]
  +       },
  +       txId: '21df94e55f1bd5a533db39be4b9cad35924ce60d4c0037aa64c35d028cd4a41f',
  +       utxoIdx: '0',
  +     },
  +     {
  +       origOutput: {
  +         address: {
  +           bech32: 'addr_test1vz2a83z0d5gceyghfrjqpaqu2f98evk8q6swje2c5ddqmaca2vhfl',
  +           hex: '6095d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
  +         },
  +         datum: null,
  +         refScript: null,
  +         value: {
  +           assets: {},
  +           lovelace: '9753780',
  +         },
  +       },
  +       txId: '21df94e55f1bd5a533db39be4b9cad35924ce60d4c0037aa64c35d028cd4a41f',
  +       utxoIdx: '1',
  +     },
  +   ],
  +   lastValidSlot: '21497784',
  +   metadataHash: null,
  +   minted: null,
  +   outputs: [
+     {                                                                                                              
  +       address: {                                                                                                   
  +         bech32: 'addr_test1vz2a83z0d5gceyghfrjqpaqu2f98evk8q6swje2c5ddqmaca2vhfl',
  +         hex: '6095d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
  +       },
  +       datum: null,
  +       refScript: null,
  +       value: {
  +         assets: {
  +           '49b106e698de78171de2faf35932635e1085c12508ca87718a2d4487': {
  +             '56657374696e67204b6579': '1',
  +           },
  +         },
  +         lovelace: '10000000',
  +       },
  +     },
  +     {
  +       address: {
  +         bech32: 'addr_test1vz2a83z0d5gceyghfrjqpaqu2f98evk8q6swje2c5ddqmaca2vhfl',
  +         hex: '6095d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
  +       },
  +       datum: null,
  +       refScript: null,
  +       value: {
  +         assets: {},
  +         lovelace: '9543355',
+       },
  +     },
  +   ],
  +   refInputs: [],
  +   scriptDataHash: 'd1baf438740aa9215d0c4ae329922803781c17d726b78555d1ca002af5c346cc',
  +   signers: [
  +     '95d3c44f6d118c911748e400f41c524a7cb2c706a0e96558a35a0df7',
  +   ],
  + }
aleeusgr commented 1 year ago

https://github.com/aleeusgr/potential-robot/blob/b661223307fbd64db658c4fbcfeaaa7e572a614a/tests/helios-vesting-cancel.test.ts#L140-L145

christianschmitz commented 1 year ago

Have you tried omitting the validTo and validFrom calls, and then "initialize" the NetworkParams for emulator use? https://www.hyperion-bt.org/helios-book/api/reference/networkemulator.html#initnetworkparams

Currently the emulator starts at 0, and it's very hard to get it to correspond to real time

christianschmitz commented 1 year ago

I've been trying to automate everything related to the tx validity time-range

aleeusgr commented 1 year ago

removing validTo and validAfter:

Error: Trace: line 16                                                                                                  
Trace: line 132 of IR in '__helios__common__field_0'                                                                   
Trace: line 138 of IR in '__core__headList'                                                                            
RuntimeError on line 138 of IR: empty list      ```

https://github.com/aleeusgr/potential-robot/blob/f71149fb6e16a61380050516a53fd68c1f0448a2/src/vesting.js#L16

christianschmitz commented 1 year ago

I'm sorry, v0.13.14 of Helios doesn't support that feature yet. You have to upgrade to be able to do that.

aleeusgr commented 1 year ago

@christianschmitz thank you for the heads up.

I bumped the version to 0.14.0, and it broke my lockAda tx. the problem is in the script that mints vesting key nft:

aleeusgr commented 1 year ago

Have you tried omitting the validTo and validFrom calls, and then "initialize" the NetworkParams for emulator use? https://www.hyperion-bt.org/helios-book/api/reference/networkemulator.html#initnetworkparams

Currently the emulator starts at 0, and it's very hard to get it to correspond to real time

aleeusgr commented 1 year ago

https://discord.com/channels/997177025972424815/1000802369744937001/1111207996471660564

aleeusgr commented 1 year ago

Based on docs, it's not clear to me how NetworkEmulator's initNetworkParams(networkParams: helios.NetworkParams): helios.NetworkParams is supposed to work; it seems like it has a chicken/egg problem.

Once there is a NetworkParams object for it, slotToTime and timeToSlot 💚

https://www.hyperion-bt.org/helios-book/api/reference/networkemulator.html#initnetworkparams https://www.hyperion-bt.org/helios-book/api/reference/networkparams.html#slottotime

aleeusgr commented 1 year ago

https://www.hyperion-bt.org/helios-book/lang/builtins/tx.html?highlight=time_range#time_range

https://www.hyperion-bt.org/helios-book/lang/builtins/timerange.html

aleeusgr commented 1 year ago

https://github.com/aleeusgr/potential-robot/pull/104/commits/0d39da36d6e17b5e01f6f866f9624a8fd1020193