Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add section on cost accounting

...

  • Start with empty tuplespace.
  • Evaluate send: @0!(1).
    • no receive reading from @0 channel in the tuplespace - store the send.
  • Tuplespace state: @0!(1).
  • Evaluate receive: for(x <- @0) { @1!(x) }:
    • There is a send on @0 channel in the tuplespace, retrieve it.
    • Validate that the pattern guard of the continuation matches data being sent on the channel. Since our pattern is a free variable (`x`x) it will match anything.
    • Substitute occurrences of x in the continuation with the data received and execute. This will result in sending 1 over the @1 channel.
  • Tuplespace state: @1(1).

...

Unforgeable names are very much like object references in languages like Python or Java.  Internally, they act like pointers, but there's no way in the language to supply an integer and get a reference to the object living at that address.  An unforgeable name is implemented internally as a 256-bit identifier, and that identifier is visible on the blockchain, but there is no language production that takes 256 bits and returns the corresponding name.  Unforgeable names are created with the new x in {...} production. The only way to get hold of an unforgeable name is to be in the lexical scope of that name or to receive it as part of a message. The algorithm used for generating the 256-bit random numbers is based on Blake2b512.

Cost Accounting

Every Rholang program has a cost associated with running it. Rholang programs are charged:

  • when performing a substitution. Cost is proportional to the binary size of the data after substitution 
  • when performing a spatial match - overall cost is an accumulated cost of all equality checks performed on all patterns against the data being matched. This is also the case when evaluating a consume or produce since this results in performing a spatial match on data under channel in question in search for matching program which results in COMM event.
  • when stored in the Tuplespace - cost is proportional to the binary size of the data being stored.