Skip to content

Commit

Permalink
SVM: Move protobuf into separate conformance crate (anza-xyz#1946)
Browse files Browse the repository at this point in the history
* init svm-conformance crate

* svm-conformance: add protos

* svm: use svm-conformance for tests

* svm: drop protos
  • Loading branch information
buffalojoec authored and samkim-crypto committed Jul 31, 2024
1 parent f8deb45 commit 2d71367
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 24 deletions.
12 changes: 10 additions & 2 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ members = [
"storage-proto",
"streamer",
"svm",
"svm-conformance",
"test-validator",
"thin-client",
"tokens",
Expand Down Expand Up @@ -395,6 +396,7 @@ solana-storage-bigtable = { path = "storage-bigtable", version = "=2.1.0" }
solana-storage-proto = { path = "storage-proto", version = "=2.1.0" }
solana-streamer = { path = "streamer", version = "=2.1.0" }
solana-svm = { path = "svm", version = "=2.1.0" }
solana-svm-conformance = { path = "svm-conformance", version = "=2.1.0" }
solana-system-program = { path = "programs/system", version = "=2.1.0" }
solana-test-validator = { path = "test-validator", version = "=2.1.0" }
solana-thin-client = { path = "thin-client", version = "=2.1.0" }
Expand Down
1 change: 0 additions & 1 deletion programs/sbf/Cargo.lock

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

21 changes: 21 additions & 0 deletions svm-conformance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "solana-svm-conformance"
description = "Solana SVM conformance"
documentation = "https://docs.rs/solana-svm-conformance"
version = { workspace = true }
authors = { workspace = true }
repository = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
edition = { workspace = true }
publish = false

[dependencies]
prost = { workspace = true }
prost-types = { workspace = true }

[build-dependencies]
prost-build = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
15 changes: 15 additions & 0 deletions svm-conformance/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
fn main() {
let proto_base_path = std::path::PathBuf::from("proto");
let protos = ["context.proto", "invoke.proto", "sysvar.proto", "txn.proto"];
let protos_path: Vec<_> = protos
.iter()
.map(|name| proto_base_path.join(name))
.collect();

protos_path
.iter()
.for_each(|proto| println!("cargo:rerun-if-changed={}", proto.display()));

prost_build::compile_protos(protos_path.as_ref(), &[proto_base_path])
.expect("Failed to compile protobuf files");
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions svm-conformance/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod proto {
include!(concat!(env!("OUT_DIR"), "/org.solana.sealevel.v1.rs"));
}
3 changes: 1 addition & 2 deletions svm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,19 @@ bincode = { workspace = true }
lazy_static = { workspace = true }
libsecp256k1 = { workspace = true }
prost = { workspace = true }
prost-types = { workspace = true }
rand = { workspace = true }
solana-bpf-loader-program = { workspace = true }
solana-compute-budget-program = { workspace = true }
solana-logger = { workspace = true }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
# See order-crates-for-publishing.py for using this unusual `path = "."`
solana-svm = { path = ".", features = ["dev-context-only-utils"] }
solana-svm-conformance = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[build-dependencies]
prost-build = { workspace = true }
rustc_version = { workspace = true }

[features]
Expand Down
14 changes: 0 additions & 14 deletions svm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,4 @@ fn main() {
println!("cargo:rustc-cfg=RUSTC_WITH_SPECIALIZATION");
}
}

let proto_base_path = std::path::PathBuf::from("proto");
let protos = ["context.proto", "invoke.proto", "sysvar.proto", "txn.proto"];
let protos_path: Vec<_> = protos
.iter()
.map(|name| proto_base_path.join(name))
.collect();

protos_path
.iter()
.for_each(|proto| println!("cargo:rerun-if-changed={}", proto.display()));

prost_build::compile_protos(protos_path.as_ref(), &[proto_base_path])
.expect("Failed to compile protobuf files");
}
7 changes: 2 additions & 5 deletions svm/tests/conformance.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use {
crate::{
mock_bank::{MockBankCallback, MockForkGraph},
proto::{InstrEffects, InstrFixture},
transaction_builder::SanitizedTransactionBuilder,
},
lazy_static::lazy_static,
Expand Down Expand Up @@ -43,6 +42,7 @@ use {
TransactionProcessingEnvironment,
},
},
solana_svm_conformance::proto::{InstrEffects, InstrFixture},
std::{
collections::{HashMap, HashSet},
env,
Expand All @@ -55,9 +55,6 @@ use {
},
};

mod proto {
include!(concat!(env!("OUT_DIR"), "/org.solana.sealevel.v1.rs"));
}
mod mock_bank;
mod transaction_builder;

Expand Down Expand Up @@ -151,7 +148,7 @@ fn run_from_folder(base_dir: &PathBuf, run_as_instr: &HashSet<OsString>) {
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).expect("Failed to read file");

let fixture = proto::InstrFixture::decode(buffer.as_slice()).unwrap();
let fixture = InstrFixture::decode(buffer.as_slice()).unwrap();
let execute_as_instr = run_as_instr.contains(&filename);
run_fixture(fixture, filename, execute_as_instr);
}
Expand Down

0 comments on commit 2d71367

Please sign in to comment.