Skip to content

Commit

Permalink
feat(avalanche-types): bump up rpcchainvm protocol version to 32 (#157)
Browse files Browse the repository at this point in the history
* feat(avalanche-types): bump up rpcchainvm protocol version to 33

ref. https://github.com/ava-labs/avalanchego/blob/v1.11.0/version/constants.go

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* 32

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* remove version

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* make it compile

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* fix lint

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* more updates

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* remove unused

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* remove unused

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* bump up to 33

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

* comment out subnet feature

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

---------

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho authored Feb 27, 2024
1 parent 77dfb10 commit 5557e18
Show file tree
Hide file tree
Showing 22 changed files with 4,194 additions and 3,787 deletions.
25 changes: 2 additions & 23 deletions core/network/examples/peer_outbound_ping.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::{
array,
env::args,
io,
net::{IpAddr, SocketAddr},
str::FromStr,
time::{Duration, SystemTime},
time::Duration,
};

use avalanche_types::{ids::Id, message};
use avalanche_types::message;
use network::peer::outbound;

/// cargo run --example peer_outbound_ping -- [PEER IP] [STAKING PORT]
Expand Down Expand Up @@ -38,26 +37,6 @@ fn main() -> io::Result<()> {
let mut stream = connector.connect(addr, Duration::from_secs(10))?;
log::info!("peer certificate:\n\n{}", stream.peer_certificate_pem);

log::info!("sending version...");
let now = SystemTime::now();
let now_unix = now
.duration_since(SystemTime::UNIX_EPOCH)
.expect("unexpected None duration_since")
.as_secs();
let tracked_subnets: [Id; 5] =
array::from_fn(|_| Id::from_slice(&random_manager::secure_bytes(32).unwrap()));

let msg = message::version::Message::default()
.network_id(1000000)
.my_time(now_unix)
.ip_addr(addr.ip())
.ip_port(0)
.my_version("avalanche/1.2.3".to_string())
.sig(random_manager::secure_bytes(64).unwrap())
.tracked_subnets(tracked_subnets);
let msg = msg.serialize().expect("failed serialize");
stream.write(&msg)?;

log::info!("sending ping...");
let ping_msg = message::ping::Message::default();
let ping_msg_bytes = ping_msg.serialize()?;
Expand Down
14 changes: 9 additions & 5 deletions crates/avalanche-types/scripts/protobuf_codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# protocol version is the version of the gRPC proto definitions
# as defined by the avalanchego rpcchainvm.
# ref. https://github.com/ava-labs/avalanchego/blob/v1.9.11/version/constants.go#L15-L17
PROTOCOL_VERSION='29'
# ref. https://github.com/ava-labs/avalanchego/blob/v1.11.0/version/constants.go
PROTOCOL_VERSION='33'

if ! [[ "$0" =~ scripts/protobuf_codegen.sh ]]; then
echo "must be run from repository root"
Expand All @@ -29,9 +29,9 @@ fi
# protoc plugin "protoc-gen-prost-crate" is required
#
# e.g.,
# cargo install protoc-gen-prost-crate --version 0.3.1
# cargo install protoc-gen-prost-crate --version 0.4.0
# ref. https://crates.io/crates/protoc-gen-prost-crate
PROTOC_GEN_PROST_CRATE_VERSION=0.3.1
PROTOC_GEN_PROST_CRATE_VERSION=0.4.0
if [[ $(protoc-gen-prost-crate --version | cut -f2 -d' ') != "${PROTOC_GEN_PROST_CRATE_VERSION}" ]]; then
echo "could not find protoc-gen-prost-crate version ${PROTOC_GEN_PROST_CRATE_VERSION} is it installed + in PATH?"
exit 255
Expand All @@ -44,7 +44,11 @@ rm -rf ./protos/avalanche

# pull source from buf registry
echo "Pulling proto source for protocol version: ${PROTOCOL_VERSION}..."
buf export buf.build/ava-labs/avalanche:v"${PROTOCOL_VERSION}" -o ./protos/avalanche

# TODO: needs registry updates on https://buf.build/ava-labs/avalanche/tree/main
# buf export buf.build/ava-labs/avalanche:v"${PROTOCOL_VERSION}" -o ./protos/avalanche

buf export buf.build/ava-labs/avalanche:main -o ./protos/avalanche

echo "Re-generating proto stubs..."
buf generate
Expand Down
1 change: 0 additions & 1 deletion crates/avalanche-types/src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ pub mod pull_query;
pub mod push_query;
pub mod put;
pub mod state_summary_frontier;
pub mod version;

pub fn ip_addr_to_bytes(ip_addr: std::net::IpAddr) -> Vec<u8> {
match ip_addr {
Expand Down
209 changes: 0 additions & 209 deletions crates/avalanche-types/src/message/version.rs

This file was deleted.

4 changes: 2 additions & 2 deletions crates/avalanche-types/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ pub mod pb;
#[doc(hidden)]
pub use pb::*;

/// ref. <https://github.com/ava-labs/avalanchego/blob/v1.10.1/version/constants.go#L15-L17>
pub const PROTOCOL_VERSION: u32 = 28;
/// ref. <https://github.com/ava-labs/avalanchego/blob/v1.11.0/version/constants.go>
pub const PROTOCOL_VERSION: u32 = 33;
Loading

0 comments on commit 5557e18

Please sign in to comment.