rchain / hackathon-2020

Apache License 2.0
3 stars 1 forks source link

Sponsored data APIs #21

Open leithaus opened 4 years ago

leithaus commented 4 years ago

Description: Implement sponsored data API.

Motivation/Impact/Importance: allows on-chain data to be sponsored by advertisers and other sponsors.

Completion/Success Criteria: Provide a modified version of for-comprehension with an additional parameter for sponsorship tokens. When sufficient tokens are supplied the data brought back is free of sponsored impressions. When insufficient tokens are supplied sponsored impressions are delivered along with the data. Likewise, extend send to mark it as storing sponsored impressions. Bonus points: 1. Extend the model to include sponsored deployments and not just sponsored data.

Link to specs and additional info : https://drive.google.com/drive/folders/1yWb8-92OfzVtccsm9hNW1AR7HtUsyxzO Current Interpreter code https://github.com/rchain/rchain/tree/dev/rholang/src/main/scala/coop/rchain/rholang https://github.com/rchain/rchain/tree/dev/rholang (The read.me needs a review and may be old)

Mentors : @leithaus

Team :

Skills : Scala required, Rholang knowledge helps. Interest in implementing translators, interpreters, compilers etc.

Judgment criteria :

Rchain Priority :

dckc commented 3 years ago

building rnode: https://github.com/rchain/rchain/blob/dev/DEVELOPER.md

dckc commented 3 years ago

@9rb offers to get @raviclalwani in touch with @leithaus

experimenting at the rholang level:

new result, publish, read, contentCh in {
  contract publish(@withAds, @withoutAds, @price /* @url?*/, return ) = {
    contentCh!({"with": withAds, "without": withoutAds, "price": price})
    |
    return!(Nil)
  }
  |
  contract read(/*@url?,*/ @tokens, return) = {
    for (@current <<- contentCh) {
      match current {
        {"with": with, "without": without, "price": price} => {
          if(tokens >= price) {
            return!(without)
          } else {
            return!(with)
          }
        }
      }
    }
  }
  |

  // testing... publisher:
  new ack in {
    publish!("interesting story... buy my product.",
    "interesting story",
    10, *ack)
  }
  |
  // reader...
  new x in {
    read!(11, *x) |
    for (@stuff <- x) {
      result!(stuff)
    }
  }
}

https://rchain.coop/hackathon#dev-apis esp https://developer.rchain.coop/rholang-playground (https://rgov1.netlify.app/ is like the playground but has auto-indentation support)

https://github.com/rchain/rchain/blob/dev/rholang/src/main/bnfc/rholang_mercury.cf BNFC is a parser generator, i.e. compiler compiler

https://github.com/rchain/rchain/blob/dev/rholang/src/main/scala/coop/rchain/rholang/interpreter/Reduce.scala

dckc commented 3 years ago

raw notes from chat with @leithaus ... why not just a contract...

directly typable

status quo: consistency constraint: what you put in a name, you get back out (modulo concurrency...) a: x!(q) b: for (<-x) gets q only all pay.

new idea: to get it out pristine, you pay additionally your data gets stored, but stuff "grows" on it... grows sponsored content

types... threads in java are not directly visible. likewise, if this were a contract, it wouldn't be evident to types. statically evident from syntax