Skip to content

Commit 2e5759d

Browse files
authored
💥 minimize verifier-storage overhead (#18)
1 parent 418ae31 commit 2e5759d

3 files changed

Lines changed: 12 additions & 72 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rainblock/protocol",
3-
"version": "1.2.0",
3+
"version": "2.0.0",
44
"description": "Protocol Buffer Definitions for Rainblock",
55
"main": "generated_ts/index.js",
66
"types": "generated_ts/index.d.ts",

src/verifierStorage.proto

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,82 +20,23 @@ message UpdateMsg {
2020
bytes merkle_tree_nodes = 1;
2121
// RLP serialization of the new block
2222
bytes rlp_block = 2;
23-
// A list of state update operations for the new block
23+
// A list of state update operations for the new block.
2424
repeated UpdateOp operations = 3;
2525
}
2626

27-
// UpdateOp to update the state in the storage nodes
27+
// Used for each update to the node's merkle tree.
2828
message UpdateOp {
29-
// A state update operation can be either an ValueChangeOp,
30-
// DeletionOp, CreationOP or an ExecutionOp
31-
oneof updates {
32-
ValueChangeOp value = 1;
33-
DeletionOp delete = 2;
34-
CreationOp create = 3;
35-
ExecutionOp execute = 4;
36-
}
37-
}
38-
39-
// ValueChangeOp to modify the balance and nonce of an account in global state
40-
message ValueChangeOp {
41-
// Address of the account to be modified
42-
bytes account = 1; // 20 byte big endian account number
43-
// Modified account balance
44-
bytes value = 2; // 32 byte big endian unsigned integer
45-
// Number of times an account is modified;
46-
// required to update the account nonce
47-
uint32 changes = 3;
48-
}
49-
50-
// DeletionOp to delete an existing account in the global state
51-
message DeletionOp {
52-
// Address of the account to be deleted
53-
bytes account = 1; // 20 byte big endian account number
54-
}
55-
56-
// CreationOp to create a new account in the global state
57-
message CreationOp {
58-
// Address of the an account to be created
59-
bytes account = 1; // 20 byte big endian account number
60-
// Balance of the new account
61-
bytes value = 2; // 32 byte big endian unsigned integer
62-
// Code to initialize the account with
63-
bytes code = 3;
64-
// A list of key, value pairs corresponding to the account storage
65-
repeated StorageInsertion storage = 4;
66-
}
67-
68-
// ExecutionOp to modify an accounts balance and storage in the global state
69-
// resulting from a contract execution
70-
message ExecutionOp {
71-
// Address of the account
72-
bytes account = 1; // 20 byte big endian account number
73-
// Account's updated balance
74-
bytes value = 2; // 32 byte big endian unsigned integer
75-
// Account's updated storage entries
76-
repeated StorageUpdate storage = 3;
29+
bytes account = 1; // 20 bytes, BE account number
30+
bytes balance = 2; // 32 bytes, BE new balance. May not be present if the balance is unchanged.
31+
uint32 updates = 3; // Increment by one for each nonce update. May not be present if the nonce is unchanged.
32+
repeated StorageUpdate storage_update = 4; // Storage updates, if any.
33+
bytes code = 5; // Code bytes, only applicable for creation of a contract account.
34+
bool deleted = 6; // Set if the account was deleted. All other fields, if present, are ignored.
7735
}
7836

7937
// StorageUpdate op to update a global state account's internal storgage
8038
message StorageUpdate {
81-
// Storage entries (insert new/modified entries or
82-
// delete existing entries)
83-
oneof updates {
84-
StorageInsertion inserts = 1;
85-
StorageDeletion deletes = 2;
86-
}
87-
}
88-
89-
// StorageInsertion op to insert a new storgae entry into a global state account
90-
message StorageInsertion {
91-
// Storage entry to be inserted or updated
9239
bytes key = 1; // 32 byte big endian unsigned integer
9340
// New or updated value of the storage entry
94-
bytes value = 2; // 32 byte big endian unsigned integer
95-
}
96-
97-
// StorageDeletion op to delete an account's internal storage entry
98-
message StorageDeletion {
99-
// Storage entry to be deleted
100-
bytes key = 1; // 32 byte big endian unsigned integer
41+
bytes value = 2; // 32 byte big endian unsigned integer, or 0 if the key was deleted.
10142
}

ts/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { VerifierService, VerifierClient, IVerifierServer, IVerifierClient } from '../generated/clientVerifier_grpc_pb'
22
import { TransactionRequest, TransactionReply, ErrorCode } from '../generated/clientVerifier_pb';
33
import { VerifierStorageService, VerifierStorageClient, IVerifierStorageClient, IVerifierStorageService, IVerifierStorageServer } from '../generated/verifierStorage_grpc_pb'
4-
import { UpdateMsg, UpdateOp, ValueChangeOp, DeletionOp, CreationOp, ExecutionOp, StorageDeletion, StorageInsertion, StorageUpdate } from '../generated/verifierStorage_pb';
4+
import { UpdateMsg, UpdateOp, StorageUpdate } from '../generated/verifierStorage_pb';
55
import { StorageNodeClient, StorageNodeService, IStorageNodeClient, IStorageNodeServer } from '../generated/clientStorage_grpc_pb';
66
import { MerklePatriciaTreeNode, RPCWitness, CodeRequest, CodeReply, AccountRequest, AccountReply, StorageRequest, StorageReply, BlockHashReply, BlockHashRequest } from '../generated/clientStorage_pb';
77

@@ -11,8 +11,7 @@ import * as grpc from 'grpc';
1111

1212
export { VerifierService, VerifierClient, TransactionRequest, TransactionReply, IVerifierClient,
1313
IVerifierServer, ErrorCode, VerifierStorageService, VerifierStorageClient, IVerifierStorageClient,
14-
IVerifierStorageServer, UpdateMsg, UpdateOp, ValueChangeOp, DeletionOp, CreationOp, ExecutionOp,
15-
StorageDeletion, StorageInsertion, StorageUpdate,
14+
IVerifierStorageServer, UpdateMsg, UpdateOp, StorageUpdate,
1615
StorageNodeClient, StorageNodeService, IStorageNodeClient, IStorageNodeServer,
1716
MerklePatriciaTreeNode, RPCWitness, CodeRequest, CodeReply, AccountRequest, AccountReply,
1817
StorageRequest, StorageReply, BlockHashReply, BlockHashRequest,

0 commit comments

Comments
 (0)