-
Notifications
You must be signed in to change notification settings - Fork 6
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
MTG-703 Adding peer to peer consistency checks #316
base: main
Are you sure you want to change the base?
Changes from all commits
bc89e6b
c7492a7
7e0e616
bf3253d
395c02e
a1cdfab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
syntax = "proto3"; | ||
|
||
import "google/protobuf/empty.proto"; | ||
|
||
package consistencyapi; | ||
|
||
// The very early grand epoch on a given peer | ||
message BbgmEarlistGrandEpoch { | ||
optional uint32 grand_epoch = 1; | ||
} | ||
|
||
// List of all grand epochs for a bubblegum tree | ||
message BbgmGrandEpochForTreeList { | ||
repeated BbgmGrandEpochChecksumForTree list = 1; | ||
} | ||
|
||
message BbgmGrandEpochChecksumForTree { | ||
uint32 grand_epoch = 1; | ||
optional bytes checksum = 2; | ||
} | ||
|
||
message BbgmGrandEpochList { | ||
repeated BbgmGrandEpoch list = 1; | ||
} | ||
|
||
message BbgmGrandEpoch { | ||
uint32 grand_epoch = 1; | ||
bytes tree_pubkey = 2; | ||
optional bytes checksum = 3; | ||
} | ||
|
||
message BbgmEpochList { | ||
repeated BbgmEpoch list = 1; | ||
} | ||
|
||
message BbgmEpoch { | ||
uint32 epoch = 1; | ||
bytes tree_pubkey = 2; | ||
optional bytes checksum = 3; | ||
} | ||
|
||
message BbgmChangeList { | ||
repeated BbgmChange list = 1; | ||
} | ||
|
||
message BbgmChange { | ||
bytes tree_pubkey = 1; | ||
uint64 slot = 2; | ||
uint64 seq = 3; | ||
string signature = 4; | ||
} | ||
|
||
// Request object for getting grand epoch trees checksums | ||
message GetBbgmGrandEpochsReq { | ||
// Grand epoch number | ||
uint32 grand_epoch = 1; | ||
// Maximum amount of tree checksums to return | ||
optional uint64 limit = 2; | ||
// Return trees checksums that are after given | ||
optional bytes after = 3; | ||
} | ||
|
||
// Request object for getting all grand epoch checksums for a given tree | ||
message GetBbgmGrandEpochsForTreeReq { | ||
bytes tree_pubkey = 1; | ||
} | ||
|
||
// Request object for getting epoch tree checksums in the geven grand epoch | ||
message GetBbgmEpochsReq { | ||
// Public key of the bubblegum tree, checksum should be returned for | ||
bytes tree_pubkey = 1; | ||
// Number of grand epoch which nested epochs should be returned | ||
uint32 grand_epoch = 2; | ||
} | ||
|
||
message BbgmChangePosition { | ||
uint64 slot = 1; | ||
uint64 seq = 2; | ||
} | ||
|
||
// Request object for getting list of individual bubblegum tree changes | ||
// that happened in the given epoch | ||
message GetBbgmChangesReq { | ||
// Pubkey of bubblegum tree | ||
bytes tree_pubkey = 1; | ||
// Number of epoch changes are listed from | ||
uint32 epoch = 2; | ||
// Maximum amount of bubblegum changes to return | ||
optional uint64 limit = 3; | ||
// Return changes after given position | ||
optional BbgmChangePosition after = 4; | ||
} | ||
|
||
// Represents account NFT grand bucket checksum. | ||
message AccGrandBucketChecksum { | ||
uint32 grand_bucket = 1; | ||
optional bytes checksum = 2; | ||
} | ||
|
||
// List of account NFT grand bucket checksums. | ||
message AccGrandBucketChecksumsList { | ||
repeated AccGrandBucketChecksum list = 1; | ||
} | ||
|
||
message AccBucketChecksum { | ||
uint32 bucket = 1; | ||
optional bytes checksum = 2; | ||
} | ||
|
||
message AccBucketChecksumsList { | ||
repeated AccBucketChecksum list = 1; | ||
} | ||
|
||
// Represents last tracked account NFT change | ||
message Acc { | ||
bytes account_pubkey = 1; | ||
uint64 slot = 2; | ||
uint64 write_version = 3; | ||
uint64 data_hash = 4; | ||
} | ||
|
||
// Represents list of last tracked account NFT changes | ||
message AccList { | ||
repeated Acc list = 1; | ||
} | ||
|
||
message GetAccBucketsReq { | ||
uint32 grand_bucket = 1; | ||
} | ||
|
||
message GetAccReq { | ||
// number of bucket | ||
uint32 bucket = 1; | ||
// maximum amount of account latest states to return | ||
optional uint64 limit = 2; | ||
// return account that are after the given | ||
optional bytes after = 3; | ||
} | ||
|
||
service BbgmConsistencyService { | ||
// Returns earliest grand epoch avaible on the peer. | ||
rpc GetBbgmEarliestGrandEpoch(google.protobuf.Empty) returns (BbgmEarlistGrandEpoch); | ||
|
||
// Request all the bubblegum grand epochs checksums for the given tree | ||
rpc GetBbgmGrandEpochsForTree(GetBbgmGrandEpochsForTreeReq) returns (BbgmGrandEpochForTreeList); | ||
|
||
// Request list of tree checksums in the given grand epoch | ||
// No need to use stream since in the worst case the response size | ||
// is still significanly less than 1 MB | ||
rpc GetBbgmGrandEpochChecksums(GetBbgmGrandEpochsReq) returns (BbgmGrandEpochList); | ||
rpc GetBbgmEpochChecksumsInGrandEpoch(GetBbgmEpochsReq) returns (BbgmEpochList); | ||
rpc GetBbgmChangesInEpoch(GetBbgmChangesReq) returns (BbgmChangeList); | ||
|
||
// Propose bubblegum changes to a peer, that has these changes missing. | ||
// Can be called after after the "get changes" API is called, and a portion | ||
// of missing bubblegum changes detected on the peer. | ||
rpc ProposeMissingBbgmChanges(BbgmChangeList) returns (google.protobuf.Empty); | ||
} | ||
|
||
service AccConsistencyService { | ||
rpc GetAccGrandBucketChecksums(google.protobuf.Empty) returns (AccGrandBucketChecksumsList); | ||
rpc GetAccBucketChecksumsInGrandBucket(GetAccBucketsReq) returns (AccBucketChecksumsList); | ||
rpc GetAccsInBucket(GetAccReq) returns (AccList); | ||
|
||
rpc ProposeMissingAccChanges(AccList) returns (google.protobuf.Empty); | ||
} | ||
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. nit: newline |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,8 +21,11 @@ pub struct Client { | |||||
|
||||||
impl Client { | ||||||
pub async fn connect(peer_discovery: impl PeerDiscovery) -> Result<Self, GrpcError> { | ||||||
let url = Uri::from_str(peer_discovery.get_gapfiller_peer_addr().as_str()) | ||||||
.map_err(|e| GrpcError::UriCreate(e.to_string()))?; | ||||||
Client::connect_to_url(peer_discovery.get_gapfiller_peer_addr().as_str()).await | ||||||
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.
Suggested change
Just a preference of style, feel free to ignore |
||||||
} | ||||||
|
||||||
pub async fn connect_to_url(url_str: &str) -> Result<Self, GrpcError> { | ||||||
let url = Uri::from_str(url_str).map_err(|e| GrpcError::UriCreate(e.to_string()))?; | ||||||
let channel = Channel::builder(url).connect().await?; | ||||||
|
||||||
Ok(Self { | ||||||
|
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.
Are we ok with converting
i64
asu64
? In case it cannot be negative, why thenTokenAccount
stores it as i64? Some kind of restrictions from the DB?