streamingfast / substreams

Powerful Blockchain streaming data engine, based on StreamingFast Firehose technology.
Apache License 2.0
164 stars 45 forks source link

Substreams Sink to KV (raw) #93

Closed maoueh closed 1 year ago

maoueh commented 1 year ago

We are going to write a sink substreams-sink-kv that will be a plain binary like other sink we have as well as a "library" that is going to be used on a follow-up task (putting a GraphQL API on top of the sink tool).

So the goal of this task is to:

Keyspace Consideration

This way, one could write indexes, and query indexes without duplicating the data. Also, this allows us to support stores that do not distinguish between an empty value and an absent key.

Important When doing the work, let's keep in mind that it going to be used as a "library" on the follow-up task which is to create a GraphQL API on top of it (https://github.com/streamingfast/substreams/issues/94).

abourget commented 1 year ago

Keyspace:

This way, one could write indexes, and query indexes without duplicating the data. Also, this allows us to support stores that do not distinguish between an empty value and an absent key.

abourget commented 1 year ago
message BatchUpdate {
  repeated KVOperation kv_ops = 1;
//  repeated IndexOperation index_ops = 2;
}
message KVOperation {
  Operation operation = 1;
  KV kv = 2;
}
//message IndexOperation {
//  Operation operation = 1;
//  Index index = 2;
//}
enum Operation {
  UNKNOWN = 0;    // Protobuf default should not be used
  SET = 1;
  DELETE = 2;
}
message KV {
  string key = 1;
  bytes value = 2;
}
//message Index {
//  string key = 1;
//  string pointer = 2;
//}
sduchesneau commented 1 year ago

how is there some kind of problem between wasm-time and kvdb around the zstd encoder/decoder since we don't require wasm-time for any insertion and grpc-based reading?

When we get to prototyping the wasm-based "resolvers", we can figure out those minor issues imho

sduchesneau commented 1 year ago