-
Notifications
You must be signed in to change notification settings - Fork 45
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
rpc: sync state api #51
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
syntax = "proto3"; | ||
package account_id; | ||
|
||
message AccountId { | ||
// A miden account is defined with a little bit of proof-of-work, the id itself | ||
// is defined as the first word of a hash digest. For this reason account ids | ||
// can be considered as random values, because of that the encoding bellow uses | ||
// fixed 64 bits, instead of zig-zag encoding. | ||
fixed64 id = 1; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
syntax = "proto3"; | ||
package merkle; | ||
|
||
import "digest.proto"; | ||
|
||
message MerklePath { | ||
repeated digest.Digest siblings = 1; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax = "proto3"; | ||
package mmr; | ||
|
||
import "digest.proto"; | ||
|
||
message MmrDelta { | ||
uint64 forest = 1; | ||
repeated digest.Digest data = 2; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax = "proto3"; | ||
package note; | ||
|
||
import "digest.proto"; | ||
import "merkle.proto"; | ||
|
||
message Note { | ||
uint32 block_num = 1; | ||
uint32 note_index = 2; | ||
digest.Digest note_hash = 3; | ||
uint64 sender = 4; | ||
uint64 tag = 5; | ||
uint32 num_assets = 6; | ||
merkle.MerklePath merkle_path = 7; | ||
} | ||
bobbinth marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
syntax = "proto3"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved the requests/responses to a separate module. The reason is that for the time being the rpc and store are using the same definitions. Having them defined once means they are the same type to the Rust compiler, and there is no need to perform additional casting. For the long run this will probably change, for example, if we add distributed tracing the RPC will need to forward a token to the Store, and probably will be more reasons to change the messages. But for now it is probably best to keep this simple. |
||
package requests; | ||
|
||
import "account_id.proto"; | ||
import "digest.proto"; | ||
|
||
message CheckNullifiersRequest { | ||
repeated digest.Digest nullifiers = 1; | ||
} | ||
|
||
message FetchBlockHeaderByNumberRequest { | ||
// The block number of the target block. | ||
// | ||
// If not provided, means latest know block. | ||
optional uint32 block_num = 1; | ||
} | ||
|
||
// State synchronization request. | ||
message SyncStateRequest { | ||
// Send updates to the client starting at this block. | ||
uint32 block_num = 1; | ||
|
||
repeated account_id.AccountId account_ids = 2; | ||
|
||
// Tags and nullifiers are filters, both filters correspond to the high | ||
// 16bits of the real values shifted to the right `>> 48`. | ||
repeated uint32 note_tags = 3; | ||
repeated uint32 nullifiers = 4; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
syntax = "proto3"; | ||
package responses; | ||
|
||
import "account_id.proto"; | ||
import "block_header.proto"; | ||
import "digest.proto"; | ||
import "merkle.proto"; | ||
import "mmr.proto"; | ||
import "tsmt.proto"; | ||
|
||
message CheckNullifiersResponse { | ||
// Each requested nullifier has its corresponding nullifier proof at the | ||
// same position. | ||
repeated tsmt.NullifierProof proofs = 1; | ||
} | ||
|
||
message FetchBlockHeaderByNumberResponse { | ||
block_header.BlockHeader block_header = 1; | ||
} | ||
|
||
message AccountHashUpdate { | ||
account_id.AccountId account_id = 1; | ||
digest.Digest account_hash = 2; | ||
uint32 block_num = 3; | ||
} | ||
|
||
message NullifierUpdate { | ||
digest.Digest nullifier = 1; | ||
uint32 block_num = 2; | ||
} | ||
|
||
message NoteSyncRecord { | ||
uint32 note_index = 2; | ||
digest.Digest note_hash = 3; | ||
uint64 sender = 4; | ||
uint64 tag = 5; | ||
uint32 num_assets = 6; | ||
merkle.MerklePath merkle_path = 7; | ||
} | ||
|
||
message SyncStateResponse { | ||
// number of the latest block in the chain | ||
uint32 chain_tip = 1; | ||
|
||
// block header of the block with the first note matching the specified criteria | ||
block_header.BlockHeader block_header = 2; | ||
|
||
// data needed to update the partial MMR from `block_ref` to `block_header.block_num` | ||
mmr.MmrDelta mmr_delta = 3; | ||
|
||
// Merkle path in the updated chain MMR to the block at `block_header.block_num` | ||
merkle.MerklePath block_path = 4; | ||
|
||
// a list of account hashes updated after `block_ref` but not after `block_header.block_num` | ||
repeated AccountHashUpdate accounts = 5; | ||
|
||
// a list of all notes together with the Merkle paths from `block_header.note_root` | ||
repeated NoteSyncRecord notes = 6; | ||
|
||
// a list of nullifiers created between `block_ref` and `block_header.block_num` | ||
repeated NullifierUpdate nullifiers = 7; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protobuf's commets are just two forward slashes. This was translated by prost as:
Because the forward slash was considered part of the comment