f1r3fly-models 0.1.0

Common data model types for the F1r3fly blockchain, including protobuf definitions and Rust implementations
Documentation
syntax = "proto3";

package rspace_plus_plus_types;

import "RhoTypes.proto";
import "scalapb/scalapb.proto";

option (scalapb.options) = {
  package_name: "coop.rchain.models.rspace_plus_plus_types"
  preserve_unknown_fields: false
};

/**
 * This is the first value of the tuple for the return type of the
 * Consume/Produce functions
 *
 * See rspace/src/main/scala/coop/rchain/rspace/ISpace.scala
 */
message ContResultProto {
  rhoapi.TaggedContinuation continuation = 1;
  bool persistent = 2;
  repeated rhoapi.Par channels = 3;
  repeated rhoapi.BindPattern patterns = 4;
  bool peek = 5;
}

/**
 * This is the second value of the tuple for the return type of the
 * Consume/Produce functions
 *
 * 'RSpaceResult' because Rust has a standard name type 'Result'
 *
 * See rspace/src/main/scala/coop/rchain/rspace/ISpace.scala
 */
message RSpaceResultProto {
  rhoapi.Par channel = 1;
  rhoapi.ListParWithRandom matchedDatum = 2;
  rhoapi.ListParWithRandom removedDatum = 3;
  bool persistent = 4;
}

/**
 * This is the tuple that is returned from the Consume function
 */
message ConsumeResult {
  ContResultProto contResult = 1;
  repeated RSpaceResultProto results = 2;
}

/**
 * This is the tuple that is returned from the Produce function
 */
 message ProduceResult {
  ContResultProto contResult = 1;
  repeated RSpaceResultProto results = 2;
  ProduceProto produce = 3;
}

/**
 * Protobuf message representation of 'Datum'
 * One of the data structures returned in 'to_map' / 'toMap'
 *
 * See rspace/src/main/scala/coop/rchain/rspace/internal.scala
 */
message DatumProto {
  rhoapi.ListParWithRandom a = 1;
  bool persist = 2;
  ProduceProto source = 3;
}

/**
 * Protobuf message representation of 'WaitingContinuation'
 * This one of the data structures returned in 'to_map' / 'toMap'
 *
 * See rspace/src/main/scala/coop/rchain/rspace/internal.scala
 */
message WaitingContinuationProto {
  repeated rhoapi.BindPattern patterns = 1;
  rhoapi.TaggedContinuation continuation = 2;
  bool persist = 3;
  repeated SortedSetElement peeks = 4;
  ConsumeProto source = 5;
}

/**
 * This message is needed on the Scala side because the
 * 'project/StacksafeScalapbGenerator.scala' file prohibits packable fields
 */
message SortedSetElement {
  int32 value = 1;
}

/**
 * Protobuf message representation of 'Produce'
 *
 * See rspace/src/main/scala/coop/rchain/rspace/trace/Event.scala
 */
message ProduceProto {
  bytes channelHash = 1;
  bytes hash = 2;
  bool persistent = 3;
  bool isDeterministic = 4;
  repeated bytes outputValue = 5;
}

/**
 * Protobuf message representation of 'Consume'
 *
 * See rspace/src/main/scala/coop/rchain/rspace/trace/Event.scala
 */
message ConsumeProto {
  repeated bytes channelHashes = 1;
  bytes hash = 2;
  bool persistent = 3;
}

message StoreToMapValue {
  repeated DatumProto data = 1;
  repeated WaitingContinuationProto wks = 2;
}

message StoreToMapEntry {
  repeated rhoapi.Par key = 1;
  StoreToMapValue value = 2;
}

/**
 * Return type for 'to_map' / 'toMap'
 */
message StoreToMapResult {
  repeated StoreToMapEntry mapEntries = 1;
}

/**
 * Data structure for 'consume' function parameters
 */
message ConsumeParams {
  repeated rhoapi.Par channels = 1;
  repeated rhoapi.BindPattern patterns = 2;
  rhoapi.TaggedContinuation continuation = 3;
  bool persist = 4;
  repeated SortedSetElement peeks = 5;
}

/**
 * Data structure for 'install' function parameters
 */
message InstallParams {
  repeated rhoapi.Par channels = 1;
  repeated rhoapi.BindPattern patterns = 2;
  rhoapi.TaggedContinuation continuation = 3;
}

/**
 * Data structure for 'spatial_match_result' function return type
 */
message FreeMapProto {
  map<int32, rhoapi.Par> entries = 1;
}

/**
 * Protobuf message representation of 'Checkpoint'
 *
 * See rspace/src/main/scala/coop/rchain/rspace/Checkpoint.scala
 */
message CheckpointProto {
  bytes root = 1;
  repeated EventProto log = 2;
}

message ChannelsProto {
  repeated rhoapi.Par channels = 1;
}

message DatumsProto {
  repeated DatumProto datums = 1;
}

message WaitingContinuationsProto {
  repeated WaitingContinuationProto wks = 1;
}

message JoinProto {
  repeated rhoapi.Par join = 1;
}

message JoinsProto {
  repeated JoinProto joins = 1;
}

/**
 * Protobuf message representation of 'HotStoreState'
 */
message HotStoreStateProto {
  repeated StoreStateContMapEntry continuations = 1;
  repeated StoreStateInstalledContMapEntry installedContinuations = 2;
  repeated StoreStateDataMapEntry data = 3;
  repeated StoreStateJoinsMapEntry joins = 4;
  repeated StoreStateInstalledJoinsMapEntry installedJoins = 5;
}

message StoreStateContMapEntry {
  repeated rhoapi.Par key = 1;
  repeated WaitingContinuationProto value = 2;
}

message StoreStateInstalledContMapEntry {
  repeated rhoapi.Par key = 1;
  WaitingContinuationProto value = 2;
}

message StoreStateDataMapEntry {
  rhoapi.Par key = 1;
  repeated DatumProto value = 2;
}

message StoreStateJoinsMapEntry {
  rhoapi.Par key = 1;
  repeated JoinProto value = 2;
}

message StoreStateInstalledJoinsMapEntry {
  rhoapi.Par key = 1;
  repeated JoinProto value = 2;
}

message ProduceCounterMapEntry {
  ProduceProto key = 1;
  int32 value = 2;
}

/**
 * Protobuf message representation of 'SoftCheckpoint'
 *
 * See rspace/src/main/scala/coop/rchain/rspace/Checkpoint.scala
 */
message SoftCheckpointProto {
  HotStoreStateProto cacheSnapshot = 1;
  repeated EventProto log = 2;
  repeated ProduceCounterMapEntry produceCounter = 3;
}

message IOEventProto {
  oneof io_event_type {
    ProduceProto produce = 1;
    ConsumeProto consume = 2;
  }
}

// Define the Event message with a oneof field
message EventProto {
  oneof event_type {
    CommProto comm = 1;
    IOEventProto io_event = 2;
  }
}

message CommProto {
  ConsumeProto consume = 1;
  repeated ProduceProto produces = 2;
  repeated SortedSetElement peeks = 3;
  repeated ProduceCounterMapEntry times_repeated = 4;
}

message LogProto {
  repeated EventProto log = 1;
}

message HashProto {
  bytes hash = 1;
}

message ItemProto {
  bytes key_hash = 1;
  bytes value = 2;
}

message ItemsProto {
  repeated ItemProto items = 1;
}

message ByteVectorProto {
  bytes byte_vector = 1;
}

message PathElement {
  bytes key_hash = 1;
  bytes optional_byte = 2;
}

message ExporterParams {
  repeated PathElement path = 1;
  int32 skip = 2;
  int32 take = 3;
}

message TrieNodeProto {
  bytes hash = 1;
  bool is_leaf = 2;
  repeated PathElement path = 3;
}

message TrieNodesProto {
  repeated TrieNodeProto nodes = 1;
}

message KeysProto {
  repeated HashProto keys = 1;
}

message StoreItemsProto {
  repeated ItemProto items = 1;
  repeated PathElement last_path = 2;
}

message HistoryAndDataItems {
  StoreItemsProto history_items = 1;
  StoreItemsProto data_items = 2;
}

message ValidateStateParams {
  repeated ItemProto history_items = 1;
  repeated ItemProto data_items = 2;
  repeated PathElement start_path = 3;
  int32 chunk_size = 4;
  int32 skip = 5;
}