forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,939 additions
and
1,774 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
[package] | ||
name = "sui-network" | ||
version = "0.1.0" | ||
version = "0.0.0" | ||
authors = ["Mysten Labs <[email protected]>"] | ||
license = "Apache-2.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[dependencies] | ||
bytes = "1.1.0" | ||
futures = "0.3.21" | ||
async-trait = "0.1.53" | ||
tokio = { version = "1.17.0", features = ["full"] } | ||
tracing = { version = "0.1.34", features = ["log"] } | ||
tokio-util = { version = "0.7.1", features = ["codec"] } | ||
tracing = "0.1.34" | ||
tonic = "0.7" | ||
prost = "0.10" | ||
bincode = "1.3.3" | ||
serde = "1.0.136" | ||
|
||
sui-types = { path = "../sui_types" } | ||
|
||
|
||
[package.metadata.cargo-udeps.ignore] | ||
normal = ["net2"] | ||
[dev-dependencies] | ||
tonic-build = { version = "0.7", features = [ "prost", "transport" ] } | ||
prost-build = "0.10.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# sui-network | ||
|
||
## Changing an RPC service | ||
|
||
The general process for changing an RPC service is as follows: | ||
1. Change the corresponding `.proto` file in the `proto` directory | ||
2. Run `cargo test --test bootstrap` to re-run the code generation. | ||
Generated rust files are in the `src/generated` directory. | ||
3. Update any other corresponding logic that would have been affected by | ||
the interface change, e.g. the server implementation of the service or | ||
usages of the generated client. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
syntax = "proto3"; | ||
|
||
package sui.common; | ||
|
||
// A bincode encoded payload. This is intended to be used in the short-term | ||
// while we don't have good protobuf definitions for sui types | ||
message BincodeEncodedPayload { | ||
bytes payload = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
syntax = "proto3"; | ||
|
||
package sui.validator; | ||
|
||
import "common.proto"; | ||
|
||
// The Validator interface | ||
service Validator { | ||
rpc Transaction (common.BincodeEncodedPayload) returns (common.BincodeEncodedPayload) {} | ||
rpc ConfirmationTransaction (common.BincodeEncodedPayload) returns (common.BincodeEncodedPayload) {} | ||
rpc ConsensusTransaction (common.BincodeEncodedPayload) returns (common.BincodeEncodedPayload) {} | ||
rpc AccountInfo (common.BincodeEncodedPayload) returns (common.BincodeEncodedPayload) {} | ||
rpc ObjectInfo (common.BincodeEncodedPayload) returns (common.BincodeEncodedPayload) {} | ||
rpc TransactionInfo (common.BincodeEncodedPayload) returns (common.BincodeEncodedPayload) {} | ||
rpc BatchInfo (common.BincodeEncodedPayload) returns (stream common.BincodeEncodedPayload) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#[path = "generated/sui.validator.rs"] | ||
#[rustfmt::skip] | ||
mod validator; | ||
|
||
#[path = "generated/sui.common.rs"] | ||
#[rustfmt::skip] | ||
mod common; | ||
|
||
pub use common::BincodeEncodedPayload; | ||
pub use validator::{ | ||
validator_client::ValidatorClient, | ||
validator_server::{Validator, ValidatorServer}, | ||
}; | ||
|
||
impl BincodeEncodedPayload { | ||
pub fn deserialize<T: serde::de::DeserializeOwned>(&self) -> Result<T, bincode::Error> { | ||
bincode::deserialize(self.payload.as_ref()) | ||
} | ||
|
||
pub fn try_from<T: serde::Serialize>(value: &T) -> Result<Self, bincode::Error> { | ||
let payload = bincode::serialize(value)?.into(); | ||
Ok(Self { payload }) | ||
} | ||
} | ||
|
||
impl From<bytes::Bytes> for BincodeEncodedPayload { | ||
fn from(payload: bytes::Bytes) -> Self { | ||
Self { payload } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/// A bincode encoded payload. This is intended to be used in the short-term | ||
/// while we don't have good protobuf definitions for sui types | ||
#[derive(Clone, PartialEq, ::prost::Message)] | ||
pub struct BincodeEncodedPayload { | ||
#[prost(bytes="bytes", tag="1")] | ||
pub payload: ::prost::bytes::Bytes, | ||
} |
Oops, something went wrong.