rchain-community / js2rho

experimental JavaScript to Rholang translator
3 stars 1 forks source link

CapTP using RhoTypes.proto under Agoric @endo/marshal #16

Open dckc opened 2 years ago

dckc commented 2 years ago

@erights you expressed interest in the details when, after presenting marshal types and such, I said it's remarkable how much it looks like rholang.

Note the correspondence between marshal types and the rholang data structures in RhoTypes.proto (see also: cheat sheet, BNFC grammar):

@agoric/marshal rholang  
CopyArray Elist  
CopySet ESet  
CopyMap EMap
CopyTagged ??  
??  ETuple  
??  Par  
     
(pattern/matcher) EMatches
     
boolean g_bool  
bignum@@ g_int  
string g_string  
  g_uri  
  g_byte_array
null Nil The Nil process is a Par with no sends, receives, etc.
undefined

I wonder about a Justin context with makeCopySet and such in scope, bound to Set. It would look even more like rholang.

A possible fun project:

cc @Bill-Kunj , @jimscarver , @michaelfig

see also: OCapn cc @cwebber

dckc commented 2 years ago

some type-directed prototyping: marshal-rhoproto.js

dckc commented 2 years ago

ordering?

rholang terms are totally ordered; that's too strong for remotables. plus I wonder if the arbitrary things like whether strings or numbers go first are consistent with compareKeys.

Here's hoping there are interesting interop targets that don't depend on the orders on both sides being exactly the same.

dckc commented 2 years ago

ag-solo as outboard IBC implementation for rnode

once we get rnode and ag-solo talking CapTP, rnode can talk IBC via ag-solo.

cosmos-testnet <-IBC-> ag-solo <-CapTP-> rnode

see also:

tgrospic commented 2 years ago

ordering?

rholang terms are totally ordered; that's too strong for remotables. plus I wonder if the arbitrary things like whether strings or numbers go first are consistent with compareKeys.

Here's hoping there are interesting interop targets that don't depend on the orders on both sides being exactly the same.

Rholang terms are normalized with total ordering so that they be hashed, but it's not required on the protocol level.

dckc commented 2 years ago

progress in office hours today:

https://github.com/rchain-community/js2rho/blob/captp/lib/capTPTool.js 331e08d

we saw in https://rhobot.net/rnode-log/ :

19:10:02.835 [INFO ] [node-runner-23      ] [c.r.c.MultiParentCasperImpl  ] - Received DeployData #1647112202396 -- {"type": "CTP_BOOTSTRAP", "epoch": 0, "questionID": "myid#1"}, Sig: 30440220603abc6545a6...20457cafead7228c134e, SigAlgorithm: secp256k1, ValidAfterBlockNumber: 146

cc @jimscarver

dckc commented 2 years ago

@Bill-Kunj I just found a smaller implementation of (some part of) CapTP: https://github.com/Agoric/agoric-sdk/blob/master/packages/solo/src/captp.js

https://github.com/Agoric/agoric-sdk/tree/b7c2a9b3205ccf348959cc22fc474f40137e416d

dckc commented 2 years ago

More progress today, with @David405 @jimscarver cc @Bill-Kunj

https://discord.com/channels/257555930173014017/687879575451336760/975035826067107900

~/projects/js2rho
11:24 connolly@jambox$ node lib/capTPTool.js 
TODO: start polling; call dispatch when a message is available
startTerm {
  deployRequest: {
    data: {
      term: '\n' +
        'new ack(`rho:rchain:deployId`), deployerId(`rho:rchain:deployerId`) in {\n' +
        '  match {[*deployerId, "3a240a220a2075a41673f53fb857d320099a088d796f2fc5a521c24db04f5c02c2864097f4d6"]} {\n' +
        '    {*target} => target!({"type": "CTP_BOOTSTRAP", "epoch": 0, "questionID": "myid#1"}, *ack)\n' +
        '  }\n' +
        '}',
      timestamp: 1652545499613,
      phloPrice: 1,
      phloLimit: 250000,
      validAfterBlockNumber: 158
    },
    sigAlgorithm: 'secp256k1',
    signature: '3045022100dabcdac473f2db8fc97cd21eeab45fefa7f03d13ccbd5e2fe718fff7dfadb68c02205fb1605685b7373974699211a31ffd72bdd88fc5ffa98255fbff8d824879d7aa',
    deployer: '04be064356846e36e485408df50b877dd99ba406d87208add4c92b3c7d4e4c663c2fbc6a1e6534c7e5c0aec00b26486fad1daf20079423b7c8ebffbbdff3682b58'
  }
}

new ack(`rho:rchain:deployId`), deployerId(`rho:rchain:deployerId`) in {
  match {[*deployerId, "3a240a220a2075a41673f53fb857d320099a088d796f2fc5a521c24db04f5c02c2864097f4d6"]} {
    {*target} => target!({"type": "CTP_BOOTSTRAP", "epoch": 0, "questionID": "myid#1"}, *ack)
  }
}