Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with new block message proto #84

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 86 additions & 130 deletions protobuf/CasperMessage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,84 +21,44 @@ option (scalapb.options) = {
preserve_unknown_fields: false
};

message HasBlockRequestProto {
option (scalapb.message).extends = "CasperMessageProto";
bytes hash = 1;
}

message HasBlockProto {
option (scalapb.message).extends = "CasperMessageProto";
bytes hash = 1;
}

message BlockRequestProto {
option (scalapb.message).extends = "CasperMessageProto";
bytes hash = 1;
}

message ForkChoiceTipRequestProto {
option (scalapb.message).extends = "CasperMessageProto";
}
// ---------- Approved block ---------

// ---------- Signing Protocol ---------
message ApprovedBlockCandidateProto {
message ApprovedBlockProto {
option (scalapb.message).extends = "CasperMessageProto";
BlockMessageProto block = 1 [(scalapb.field).no_box = true];
int32 requiredSigs = 2;
}

message UnapprovedBlockProto {
message ApprovedBlockRequestProto {
option (scalapb.message).extends = "CasperMessageProto";
ApprovedBlockCandidateProto candidate = 1 [(scalapb.field).no_box = true];
int64 timestamp = 2;
int64 duration = 3;
}

message Signature {
bytes publicKey = 1;
string algorithm = 2;
bytes sig = 3;
string identifier = 1;
bool trimState = 2;
}

message BlockApprovalProto {
message NoApprovedBlockAvailableProto {
option (scalapb.message).extends = "CasperMessageProto";
ApprovedBlockCandidateProto candidate = 1 [(scalapb.field).no_box = true];
Signature sig = 2 [(scalapb.field).no_box = true];
string identifier = 1;
string nodeIdentifer = 2;
}

message ApprovedBlockProto {
// ------- End Approved block --------

message ForkChoiceTipRequestProto {
option (scalapb.message).extends = "CasperMessageProto";
ApprovedBlockCandidateProto candidate = 1 [(scalapb.field).no_box = true];
repeated Signature sigs = 2;
}

message ApprovedBlockRequestProto {
message HasBlockRequestProto {
option (scalapb.message).extends = "CasperMessageProto";
string identifier = 1;
bool trimState = 2;
bytes hash = 1;
}

message NoApprovedBlockAvailableProto {
message HasBlockProto {
option (scalapb.message).extends = "CasperMessageProto";
string identifier = 1;
string nodeIdentifer = 2;
bytes hash = 1;
}

// ------- End Signing Protocol --------

// --------- Core Protocol --------
message BlockMessageProto {
message BlockRequestProto {
option (scalapb.message).extends = "CasperMessageProto";
bytes blockHash = 1; // obtained by hashing the information in the header
HeaderProto header = 2 [(scalapb.field).no_box = true];
BodyProto body = 3 [(scalapb.field).no_box = true];
repeated JustificationProto justifications = 4; // map of all validators to latest blocks based on current view
bytes sender = 5; // public key of the validator that created the block
int32 seqNum = 6; // number of blocks created by the validator
bytes sig = 7; // signature generated by signing `hash(hash(justification) concat blockHash)`.
string sigAlgorithm = 8; // name of the algorithm used to sign
string shardId = 9; // identifier of the shard where the block was created
bytes extraBytes = 10;
bytes hash = 1;
}

message BlockHashMessageProto {
Expand All @@ -107,58 +67,58 @@ message BlockHashMessageProto {
bytes blockCreator = 2;
}

message BlockMetadataInternal {
// This message in mapped to a different Scala class because of protobuf's inability to create map<bytes, int64> for
// bonds.
option (scalapb.message).type = "coop.rchain.models.BlockMetadata";

bytes blockHash = 1;
repeated bytes parents = 2 [(scalapb.field).collection_type="collection.immutable.List"];
bytes sender = 3;
repeated JustificationProto justifications = 4 [(scalapb.field).collection_type="collection.immutable.List"];
repeated BondProto bonds = 5 [(scalapb.field).collection_type="collection.immutable.List"];
int64 blockNum = 6;
int32 seqNum = 7;
bool invalid = 8; // whether the block was marked as invalid
bool directlyFinalized = 9; // whether the block has been last finalized block (LFB)
bool finalized = 10;// whether the block is finalized
}
// --------- Core Protocol --------

message HeaderProto {
repeated bytes parentsHashList = 1; //list of parent block hashes
int64 timestamp = 5;
int64 version = 6;
bytes extraBytes = 7;
message BlockMessageProto {
option (scalapb.message).extends = "CasperMessageProto";
int32 version = 1; // version number to define how block is serialized and hashed
string shardId = 2; // identifier of the shard where the block was created
bytes blockHash = 3; // obtained by hashing all information in the block except signature
int64 blockNumber = 4;
bytes sender = 5; // public key of the validator that created the block
int64 seqNum = 6; // number of blocks created by the validator
bytes preStateHash = 7; // hash of the tuplespace contents before new deploys
bytes postStateHash = 8; // hash of the tuplespace contents after new deploys
repeated bytes justifications = 9 [(scalapb.field).collection_type="List"]; // map of all validators to latest blocks based on current view
repeated BondProto bonds = 10 [(scalapb.field).collection_type="List"]; // validators and their stakes
// Rejected data in finalized fringe
repeated bytes rejectedDeploys = 11 [(scalapb.field).collection_type="List"];
repeated bytes rejectedBlocks = 12 [(scalapb.field).collection_type="List"];
repeated bytes rejectedSenders = 13 [(scalapb.field).collection_type="List"];
// Rholang execution trace
RholangStateProto state = 14 [(scalapb.field).no_box = true];
// Block signature
string sigAlgorithm = 15; // name of the algorithm used to sign
bytes sig = 16; // signature generated by signing blockHash
}

/**
* Note: deploys are uniquely keyed by `user`, `timestamp`.
*
* **TODO**: details of signatures and payment. See RHOL-781
*/
message DeployDataProto {
bytes deployer = 1; //public key
string term = 2; //rholang source code to deploy (will be parsed into `Par`)
int64 timestamp = 3; //millisecond timestamp
bytes sig = 4; //signature of (hash(term) + timestamp) using private key
string sigAlgorithm = 5; //name of the algorithm used to sign
int64 phloPrice = 7; //phlo price
int64 phloLimit = 8; //phlo limit for the deployment
int64 validAfterBlockNumber = 10;
string shardId = 11;//shard ID to prevent replay of deploys between shards
bytes deployer = 1; // public key
string term = 2; // Rholang source code to deploy (will be parsed into `Par`)
int64 timestamp = 3; // number for user to create different signature for the same deploy data
bytes sig = 4; // signature of (hash(term) + timestamp) using private key
string sigAlgorithm = 5; // name of the algorithm used to sign
int64 phloPrice = 7; // phlo price
int64 phloLimit = 8; // phlo limit for the deployment
int64 validAfterBlockNumber = 10;
string shardId = 11; // shard ID to prevent replay of deploys between shards
}

message RholangStateProto {
repeated ProcessedDeployProto deploys = 1;
repeated ProcessedSystemDeployProto systemDeploys = 2;
}

message ProcessedDeployProto {
DeployDataProto deploy = 1 [(scalapb.field).no_box = true];
PCost cost = 2 [(scalapb.field).no_box = true];
repeated EventProto deployLog = 3; //the new terms and comm. rule reductions from this deploy
bool errored = 5; //true if deploy encountered a user error
string systemDeployError = 6;
DeployDataProto deploy = 1 [(scalapb.field).no_box = true]; // user deploy
PCost cost = 2 [(scalapb.field).no_box = true]; // cost for execution of user deploy
repeated EventProto deployLog = 3; // Rholang execution trace for deploy
bool errored = 4; // true if deploy encountered a user error
string systemDeployError = 5; // error message for system deploy
}

message SlashSystemDeployDataProto {
bytes invalidBlockHash = 1;
bytes issuerPublicKey = 2;
bytes slashedValidator = 1;
}

message CloseBlockSystemDeployDataProto{
Expand All @@ -172,38 +132,15 @@ message SystemDeployDataProto{
}

message ProcessedSystemDeployProto {
SystemDeployDataProto systemDeploy = 1 [(scalapb.field).no_box = true];
repeated EventProto deployLog = 2;
string errorMsg = 3;
}

message BodyProto {
RChainStateProto state = 1 [(scalapb.field).no_box = true];
repeated ProcessedDeployProto deploys = 2;
repeated ProcessedSystemDeployProto systemDeploys = 3;
bytes extraBytes = 4;
repeated RejectedDeployProto rejectedDeploys = 5;
SystemDeployDataProto systemDeploy = 1 [(scalapb.field).no_box = true];
repeated EventProto deployLog = 2;
string errorMsg = 3;
}

message RejectedDeployProto{
bytes sig = 1;
}

message JustificationProto {
bytes validator = 1;
bytes latestBlockHash = 2;
}

message RChainStateProto {
bytes preStateHash = 1; //hash of the tuplespace contents before new deploys
bytes postStateHash = 2; //hash of the tuplespace contents after new deploys

//Internals of what will be the "blessed" PoS contract
//(which will be part of the tuplespace in the real implementation).
repeated BondProto bonds = 3;
int64 blockNumber = 4;
}

message EventProto {
oneof event_instance {
ProduceEventProto produce = 1;
Expand Down Expand Up @@ -239,6 +176,7 @@ message BondProto {
bytes validator = 1;
int64 stake = 2;
}

// --------- End Core Protocol --------

// --------- Last finalized state --------
Expand All @@ -250,7 +188,7 @@ message StoreNodeKeyProto {

message StoreItemsMessageRequestProto {
option (scalapb.message).extends = "CasperMessageProto";
repeated StoreNodeKeyProto startPath = 1 [(scalapb.field).collection_type="collection.immutable.List"];
repeated StoreNodeKeyProto startPath = 1 [(scalapb.field).collection_type="List"];
int32 skip = 2;
int32 take = 3;
}
Expand All @@ -262,10 +200,28 @@ message StoreItemProto {

message StoreItemsMessageProto {
option (scalapb.message).extends = "CasperMessageProto";
repeated StoreNodeKeyProto startPath = 1 [(scalapb.field).collection_type="collection.immutable.List"];
repeated StoreNodeKeyProto lastPath = 2 [(scalapb.field).collection_type="collection.immutable.List"];
repeated StoreItemProto historyItems = 3 [(scalapb.field).collection_type="collection.immutable.List"];
repeated StoreItemProto dataItems = 4 [(scalapb.field).collection_type="collection.immutable.List"];
repeated StoreNodeKeyProto startPath = 1 [(scalapb.field).collection_type="List"];
repeated StoreNodeKeyProto lastPath = 2 [(scalapb.field).collection_type="List"];
repeated StoreItemProto historyItems = 3 [(scalapb.field).collection_type="List"];
repeated StoreItemProto dataItems = 4 [(scalapb.field).collection_type="List"];
}

// --------- End Last finalized state --------

// --------- Internal types ---------

message BlockMetadataProto {
bytes blockHash = 1;
int64 blockNum = 2;
bytes sender = 3;
int64 seqNum = 4;
repeated bytes justifications = 5 [(scalapb.field).collection_type="List"];
repeated BondProto bonds = 6 [(scalapb.field).collection_type="List"];
bool invalid = 7; // whether the block was marked as invalid

bool directlyFinalized = 20; // whether the block has been last finalized block (LFB)
bool finalized = 21; // whether the block is finalized
repeated bytes parents = 22 [(scalapb.field).collection_type="List"];
}

// --------- End Internal types ---------
Loading