Skip to content
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

Decomposed schema crate. #30

Merged
merged 5 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/protobuf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ env:

jobs:
compatibility:
runs-on: ubuntu-latest
runs-on: [ubuntu-22.04-github-hosted-16core]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify: Is this change somehow related to decomposing the schema crate, or is it a general change that would be performed anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is flaky on the default worker, now that a lot of stuff needs to get compiled.

steps:
# github.base_ref -> github.head_ref for pull_request
# github.event.before -> github.event.after for push
- uses: mozilla-actions/[email protected]
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref || github.event.before }}
path: before
Expand All @@ -40,7 +40,7 @@ jobs:
perl -ne 'print "$1\n" if /PROTOBUF_DESCRIPTOR="(.*)"/'
`find ./before/node/target/debug/build/*/output`
| xargs cat > ./before.binpb
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.event.after }}
path: after
Expand Down
26 changes: 4 additions & 22 deletions node/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ members = [
"actors/network",
"actors/sync_blocks",
"libs/roles",
"libs/schema",
"libs/storage",
"tools",
"libs/utils",
Expand All @@ -32,7 +31,6 @@ zksync_consensus_executor = { path = "actors/executor" }
zksync_consensus_network = { path = "actors/network" }
zksync_consensus_sync_blocks = { path = "actors/sync_blocks" }
zksync_consensus_roles = { path = "libs/roles" }
zksync_consensus_schema = { path = "libs/schema" }
zksync_consensus_storage = { path = "libs/storage" }
zksync_consensus_tools = { path = "tools" }
zksync_consensus_utils = { path = "libs/utils" }
Expand Down
1 change: 0 additions & 1 deletion node/actors/bft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ zksync_concurrency.workspace = true
zksync_consensus_crypto.workspace = true
zksync_consensus_network.workspace = true
zksync_consensus_roles.workspace = true
zksync_consensus_schema.workspace = true
zksync_consensus_storage.workspace = true
zksync_consensus_utils.workspace = true
zksync_protobuf.workspace = true
Expand Down
5 changes: 4 additions & 1 deletion node/actors/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ zksync_consensus_bft.workspace = true
zksync_consensus_crypto.workspace = true
zksync_consensus_network.workspace = true
zksync_consensus_roles.workspace = true
zksync_consensus_schema.workspace = true
zksync_consensus_storage.workspace = true
zksync_consensus_sync_blocks.workspace = true
zksync_consensus_utils.workspace = true
zksync_protobuf.workspace = true

anyhow.workspace = true
prost.workspace = true
rand.workspace = true
tracing.workspace = true
vise.workspace = true

[dev-dependencies]
tokio.workspace = true

[build-dependencies]
zksync_protobuf.workspace = true
11 changes: 11 additions & 0 deletions node/actors/executor/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//! Generates rust code from protobufs.
fn main() {
zksync_protobuf::build::Config {
input_root: "src/config/proto".into(),
proto_root: "zksync/executor/config".into(),
dependencies: vec![],
protobuf_crate: "::zksync_protobuf".parse().unwrap(),
}
.generate()
.expect("generate(config)");
}
2 changes: 1 addition & 1 deletion node/actors/executor/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::{
use zksync_consensus_crypto::{read_required_text, Text, TextFmt};
use zksync_consensus_network::{consensus, gossip};
use zksync_consensus_roles::{node, validator};
use zksync_consensus_schema::proto::executor::config as proto;
use zksync_protobuf::{read_required, required, ProtoFmt};

pub mod proto;
#[cfg(test)]
mod tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
// the validator set) or move it to a separate config file.
syntax = "proto3";

package zksync.schema.executor.config;
package zksync.executor.config;

// (public key, ip address) of a gossip network node.
message NodeAddr {
Expand Down
2 changes: 2 additions & 0 deletions node/actors/executor/src/config/proto/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#![allow(warnings)]
include!(concat!(env!("OUT_DIR"), "/src/config/proto/gen.rs"));
2 changes: 1 addition & 1 deletion node/actors/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod testonly;
#[cfg(test)]
mod tests;

pub use self::config::{ConsensusConfig, ExecutorConfig, GossipConfig};
pub use self::config::{proto, ConsensusConfig, ExecutorConfig, GossipConfig};

/// Validator-related part of [`Executor`].
#[derive(Debug)]
Expand Down
6 changes: 5 additions & 1 deletion node/actors/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license.workspace = true
zksync_concurrency.workspace = true
zksync_consensus_crypto.workspace = true
zksync_consensus_roles.workspace = true
zksync_consensus_schema.workspace = true
zksync_consensus_utils.workspace = true
zksync_protobuf.workspace = true

Expand All @@ -19,6 +18,7 @@ async-trait.workspace = true
im.workspace = true
once_cell.workspace = true
pin-project.workspace = true
prost.workspace = true
rand.workspace = true
snow.workspace = true
thiserror.workspace = true
Expand All @@ -29,3 +29,7 @@ vise.workspace = true
pretty_assertions.workspace = true
test-casing.workspace = true
tokio.workspace = true

[build-dependencies]
zksync_consensus_roles.workspace = true
zksync_protobuf.workspace = true
29 changes: 29 additions & 0 deletions node/actors/network/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! Generates rust code from protobufs.
fn main() {
zksync_protobuf::build::Config {
input_root: "src/proto".into(),
proto_root: "zksync/network".into(),
dependencies: vec![
(
"::zksync_protobuf::proto".parse().unwrap(),
&zksync_protobuf::proto::DESCRIPTOR,
),
(
"::zksync_consensus_roles::proto".parse().unwrap(),
&zksync_consensus_roles::proto::DESCRIPTOR,
),
],
protobuf_crate: "::zksync_protobuf".parse().unwrap(),
}
.generate()
.expect("generate()");

zksync_protobuf::build::Config {
input_root: "src/mux/tests/proto".into(),
proto_root: "zksync/network/mux/tests".into(),
dependencies: vec![],
protobuf_crate: "::zksync_protobuf".parse().unwrap(),
}
.generate()
.expect("generate()");
}
3 changes: 1 addition & 2 deletions node/actors/network/src/consensus/handshake/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::{frame, noise};
use crate::{frame, noise, proto::consensus as proto};
use anyhow::Context as _;
use zksync_concurrency::{ctx, time};
use zksync_consensus_crypto::ByteFmt;
use zksync_consensus_roles::{node, validator};
use zksync_consensus_schema::proto::network::consensus as proto;
use zksync_protobuf::{read_required, ProtoFmt};

#[cfg(test)]
Expand Down
3 changes: 1 addition & 2 deletions node/actors/network/src/gossip/handshake/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use super::Config;
use crate::{frame, noise};
use crate::{frame, noise, proto::gossip as proto};
use anyhow::Context as _;
use zksync_concurrency::{ctx, time};
use zksync_consensus_crypto::ByteFmt;
use zksync_consensus_roles::node;
use zksync_consensus_schema::proto::network::gossip as proto;
use zksync_protobuf::{read_required, required, ProtoFmt};

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions node/actors/network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod mux;
mod noise;
mod pool;
mod preface;
pub mod proto;
mod rpc;
mod state;
pub mod testonly;
Expand Down
2 changes: 1 addition & 1 deletion node/actors/network/src/mux/handshake.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::CapabilityId;
use crate::proto::mux as proto;
use anyhow::Context as _;
use std::collections::HashMap;
use zksync_consensus_schema::proto::network::mux as proto;
use zksync_protobuf::required;

pub(super) struct Handshake {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use std::{
},
};
use zksync_concurrency::{ctx, scope, testonly::abort_on_panic};
use zksync_consensus_schema::proto::network::mux_test as proto;
use zksync_consensus_utils::no_copy::NoCopy;
mod proto;

fn assert_partition(sets: &[u16]) {
let mut sum = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package zksync.schema.network.mux_test;
package zksync.network.mux.tests;

message Req {
optional bytes input = 1;
Expand Down
2 changes: 2 additions & 0 deletions node/actors/network/src/mux/tests/proto/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#![allow(warnings)]
include!(concat!(env!("OUT_DIR"), "/src/mux/tests/proto/gen.rs"));
3 changes: 1 addition & 2 deletions node/actors/network/src/preface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
//!
//! Hence, the preface protocol is used to enable encryption
//! and multiplex between mutliple endpoints available on the same TCP port.
use crate::{frame, metrics, noise};
use crate::{frame, metrics, noise, proto::preface as proto};
use zksync_concurrency::{ctx, time};
use zksync_consensus_schema::proto::network::preface as proto;
use zksync_protobuf::{required, ProtoFmt};

/// Timeout on executing the preface protocol.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "proto3";

package zksync.schema.network.consensus;
package zksync.network.consensus;

import "zksync/schema/roles/validator.proto";
import "zksync/roles/validator.proto";
import "zksync/std.proto";

// First message exchanged in the encrypted session.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";

package zksync.schema.network.gossip;
package zksync.network.gossip;

import "zksync/schema/roles/node.proto";
import "zksync/schema/roles/validator.proto";
import "zksync/roles/node.proto";
import "zksync/roles/validator.proto";

// First message exchanged in the encrypted session.
message Handshake {
Expand Down
2 changes: 2 additions & 0 deletions node/actors/network/src/proto/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#![allow(warnings)]
include!(concat!(env!("OUT_DIR"), "/src/proto/gen.rs"));
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package zksync.schema.network.mux;
package zksync.network.mux;

import "zksync/std.proto";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package zksync.schema.network.ping;
package zksync.network.ping;

message PingReq {
optional bytes data = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package zksync.schema.network.preface;
package zksync.network.preface;

// Every connection starts with the following preface:
// 1. client sends Encryption msg to server.
Expand Down
3 changes: 1 addition & 2 deletions node/actors/network/src/rpc/consensus.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Defines RPC for passing consensus messages.
use crate::mux;
use crate::{mux, proto::consensus as proto};
use zksync_concurrency::{limiter, time};
use zksync_consensus_roles::validator;
use zksync_consensus_schema::proto::network::consensus as proto;
use zksync_protobuf::{read_required, ProtoFmt};

/// Consensus RPC.
Expand Down
Loading
Loading