pluralistic-rs
gs-index
gs-log

😱 screaming fast pluralistic calculator in Rust
🛠️ composable command-line indexer in Rust
🔄 resumable chain logger in TypeScript

pluralistic-rs

  • re-implementation of pluralistic.js in Rust
  • same output for the core QF formula
  • goals:
    • performance
    • correctness (in the QF sense)
    • correctness (in the engineering sense)
    • building block for other projects

pluralistic-rs - Results

  • 10x faster calculation
  • calculates a round of 130k votes in 40ms
  • performance useful for matching estimates
  • 2 matching cap methods - cap and redistribute

img

pluralistic-rs - Next steps

  • fuzz testing
  • further performance optimizations
  • pairwise QF

Why index anyway?

What the blockchain offers:

ProjectCreated  id:    0x123
MetadataUpdated title: My Project
OwnerAdded      name:  Alice
ProjectCreated  id:    0x456
OwnerRemoved    name:  Bob
...             ...    ...

What apps want:

“What projects are out there?”
“Who owns project 0x123?”
“How is project 0x456 called?”

Indexing turns blockchain logs into a format that allows answering the questions that our apps are interested in.

gs-index · use cases

Index local or remote historical data:

$ cat 'event_log.ndjson' | gs-index | psql mydb
$ curl 'https://some.s3.bucket/event_log.ndjson' | gs-index | psql mydb

gs-index · use cases

Index only specific events:

$ cat 'event_log.ndjson' |
  jq 'select(.name=="ProjectCreated" or .name=="RoundCreated")' |
  gs-index |
  psql mydb

gs-index · use cases

Log on one machine, index on another:

gs-index · use cases

Continuously index live events while keeping a log:

$ gs-log --chains '58008:origin..ongoing' |
  tee 'event_log.ndjson' |
  gs-index |
  psql mydb

gs-index · use cases

Resume indexing after an interruption:

$ cat 'event_log.ndjson' |
  gs-log --resume |
  tee --append 'event_log.ndjson' |
  gs-index |
  psql mydb

gs-index · use cases

Publish events from a server, listen on a client:

$ gs-log >'event_log.ndjson' &
$ websocket-tail -p 8080 'event_log.ndjson'
const ws = new WebSocket("/events.ndjson?events=ProjectCreated,RoundCreated");
ws.on("message", (msg) => {
  const event = JSON.parse(msg.data);
  if (event.data.type === "ProjectCreated") {
    displayNotification("Someone just created a project!");
  }
});

That’s all!

Josef:

  • discord: atris. or @Josef on #grants-stack-builders
  • twitter: atris_eth

Max:

  • discord: MaxInt#4220 or @Max | Gitcoin on #grants-stack-builders
  • twitter: MaxIsBuilding