From 3fabbab417ab71a346023ff7ff88ceee77eda6ea Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 9 Jul 2021 22:21:08 +0000 Subject: [PATCH] Add storage-proto build.rs and readme (backport #18353) (#18562) * Add storage-proto build.rs and readme (#18353) * Use build.rs for storage-proto generation * Add readme * Single use statements (cherry picked from commit c2e7d39154e67f3aac3b235f183994ca11e5f37d) # Conflicts: # Cargo.lock # storage-proto/build-proto/Cargo.lock # storage-proto/build-proto/Cargo.toml * Fix conflicts Co-authored-by: Tyera Eulberg Co-authored-by: Tyera Eulberg --- Cargo.lock | 78 ++++ storage-bigtable/src/access_token.rs | 24 +- storage-bigtable/src/bigtable.rs | 24 +- storage-bigtable/src/compression.rs | 6 +- storage-bigtable/src/lib.rs | 37 +- storage-bigtable/src/root_ca_certificate.rs | 6 +- storage-proto/.gitignore | 1 + storage-proto/Cargo.toml | 3 + storage-proto/README.md | 5 + storage-proto/build-proto/.gitignore | 1 - storage-proto/build-proto/Cargo.lock | 360 ------------------ storage-proto/build-proto/Cargo.toml | 15 - .../{build-proto/src/main.rs => build.rs} | 6 +- .../proto/solana.storage.confirmed_block.rs | 148 ------- .../solana.storage.transaction_by_addr.rs | 124 ------ storage-proto/src/convert.rs | 40 +- storage-proto/src/lib.rs | 20 +- 17 files changed, 176 insertions(+), 722 deletions(-) create mode 100644 storage-proto/.gitignore create mode 100644 storage-proto/README.md delete mode 100644 storage-proto/build-proto/.gitignore delete mode 100644 storage-proto/build-proto/Cargo.lock delete mode 100644 storage-proto/build-proto/Cargo.toml rename storage-proto/{build-proto/src/main.rs => build.rs} (80%) delete mode 100644 storage-proto/proto/solana.storage.confirmed_block.rs delete mode 100644 storage-proto/proto/solana.storage.transaction_by_addr.rs diff --git a/Cargo.lock b/Cargo.lock index 2747541119..c7ecf0052a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1327,6 +1327,12 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "fixedbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" + [[package]] name = "flate2" version = "1.0.14" @@ -1690,6 +1696,15 @@ dependencies = [ "ahash 0.4.6", ] +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "hermit-abi" version = "0.1.13" @@ -2561,6 +2576,12 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + [[package]] name = "native-tls" version = "0.2.7" @@ -2969,6 +2990,16 @@ dependencies = [ "ucd-trie", ] +[[package]] +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +dependencies = [ + "fixedbitset", + "indexmap", +] + [[package]] name = "pickledb" version = "0.4.1" @@ -3139,6 +3170,24 @@ dependencies = [ "prost-derive", ] +[[package]] +name = "prost-build" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "355f634b43cdd80724ee7848f95770e7e70eefa6dcf14fea676216573b8fd603" +dependencies = [ + "bytes 1.0.1", + "heck", + "itertools 0.10.1", + "log 0.4.11", + "multimap", + "petgraph", + "prost", + "prost-types", + "tempfile", + "which", +] + [[package]] name = "prost-derive" version = "0.8.0" @@ -5457,6 +5506,7 @@ dependencies = [ "solana-account-decoder", "solana-sdk", "solana-transaction-status", + "tonic-build", ] [[package]] @@ -6480,6 +6530,18 @@ dependencies = [ "tracing-futures", ] +[[package]] +name = "tonic-build" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25db9a497663a9a779693ef67b6e6aef8345b3d3ff8d50ef92eae6c88cb1e386" +dependencies = [ + "proc-macro2 1.0.24", + "prost-build", + "quote 1.0.6", + "syn 1.0.60", +] + [[package]] name = "tower" version = "0.4.8" @@ -6655,6 +6717,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" + [[package]] name = "unicode-width" version = "0.1.7" @@ -6956,6 +7024,16 @@ dependencies = [ "tokio-tls", ] +[[package]] +name = "which" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" +dependencies = [ + "libc", + "thiserror", +] + [[package]] name = "winapi" version = "0.2.8" diff --git a/storage-bigtable/src/access_token.rs b/storage-bigtable/src/access_token.rs index 60335b802b..e73962b2b2 100644 --- a/storage-bigtable/src/access_token.rs +++ b/storage-bigtable/src/access_token.rs @@ -1,16 +1,18 @@ /// A module for managing a Google API access token -use goauth::{ - auth::{JwtClaims, Token}, - credentials::Credentials, -}; -use log::*; -use smpl_jwt::Jwt; -use std::{ - sync::{ - atomic::{AtomicBool, Ordering}, - {Arc, RwLock}, +use { + goauth::{ + auth::{JwtClaims, Token}, + credentials::Credentials, + }, + log::*, + smpl_jwt::Jwt, + std::{ + sync::{ + atomic::{AtomicBool, Ordering}, + {Arc, RwLock}, + }, + time::Instant, }, - time::Instant, }; pub use goauth::scopes::Scope; diff --git a/storage-bigtable/src/bigtable.rs b/storage-bigtable/src/bigtable.rs index 3e4e142a6a..a3d4b172d5 100644 --- a/storage-bigtable/src/bigtable.rs +++ b/storage-bigtable/src/bigtable.rs @@ -1,16 +1,18 @@ // Primitives for reading/writing BigTable tables -use crate::{ - access_token::{AccessToken, Scope}, - compression::{compress_best, decompress}, - root_ca_certificate, -}; -use log::*; -use std::time::{Duration, Instant}; -use thiserror::Error; -use tonic::{ - codegen::InterceptedService, metadata::MetadataValue, transport::ClientTlsConfig, Request, - Status, +use { + crate::{ + access_token::{AccessToken, Scope}, + compression::{compress_best, decompress}, + root_ca_certificate, + }, + log::*, + std::time::{Duration, Instant}, + thiserror::Error, + tonic::{ + codegen::InterceptedService, metadata::MetadataValue, transport::ClientTlsConfig, Request, + Status, + }, }; mod google { diff --git a/storage-bigtable/src/compression.rs b/storage-bigtable/src/compression.rs index 665f93b469..866369729a 100644 --- a/storage-bigtable/src/compression.rs +++ b/storage-bigtable/src/compression.rs @@ -1,5 +1,7 @@ -use enum_iterator::IntoEnumIterator; -use std::io::{self, BufReader, Read, Write}; +use { + enum_iterator::IntoEnumIterator, + std::io::{self, BufReader, Read, Write}, +}; #[derive(Debug, Serialize, Deserialize, IntoEnumIterator)] pub enum CompressionMethod { diff --git a/storage-bigtable/src/lib.rs b/storage-bigtable/src/lib.rs index 254c9406f3..fe99b994d0 100644 --- a/storage-bigtable/src/lib.rs +++ b/storage-bigtable/src/lib.rs @@ -1,23 +1,24 @@ #![allow(clippy::integer_arithmetic)] -use log::*; -use serde::{Deserialize, Serialize}; -use solana_sdk::{ - clock::{Slot, UnixTimestamp}, - deserialize_utils::default_on_eof, - pubkey::Pubkey, - signature::Signature, - sysvar::is_sysvar_id, - transaction::{Transaction, TransactionError}, +use { + log::*, + serde::{Deserialize, Serialize}, + solana_sdk::{ + clock::{Slot, UnixTimestamp}, + deserialize_utils::default_on_eof, + pubkey::Pubkey, + signature::Signature, + sysvar::is_sysvar_id, + transaction::{Transaction, TransactionError}, + }, + solana_storage_proto::convert::{generated, tx_by_addr}, + solana_transaction_status::{ + ConfirmedBlock, ConfirmedTransaction, ConfirmedTransactionStatusWithSignature, Reward, + TransactionByAddrInfo, TransactionConfirmationStatus, TransactionStatus, + TransactionStatusMeta, TransactionWithStatusMeta, + }, + std::{collections::HashMap, convert::TryInto}, + thiserror::Error, }; -use solana_storage_proto::convert::generated; -use solana_storage_proto::convert::tx_by_addr; -use solana_transaction_status::{ - ConfirmedBlock, ConfirmedTransaction, ConfirmedTransactionStatusWithSignature, Reward, - TransactionByAddrInfo, TransactionConfirmationStatus, TransactionStatus, TransactionStatusMeta, - TransactionWithStatusMeta, -}; -use std::{collections::HashMap, convert::TryInto}; -use thiserror::Error; #[macro_use] extern crate serde_derive; diff --git a/storage-bigtable/src/root_ca_certificate.rs b/storage-bigtable/src/root_ca_certificate.rs index e0d43231d4..80147dd3f8 100644 --- a/storage-bigtable/src/root_ca_certificate.rs +++ b/storage-bigtable/src/root_ca_certificate.rs @@ -1,5 +1,7 @@ -use std::{fs::File, io::Read}; -use tonic::transport::Certificate; +use { + std::{fs::File, io::Read}, + tonic::transport::Certificate, +}; pub fn load() -> Result { // Respect the standard GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable if present, diff --git a/storage-proto/.gitignore b/storage-proto/.gitignore new file mode 100644 index 0000000000..65d7bf492b --- /dev/null +++ b/storage-proto/.gitignore @@ -0,0 +1 @@ +proto/ diff --git a/storage-proto/Cargo.toml b/storage-proto/Cargo.toml index da2236180b..97512e4a31 100644 --- a/storage-proto/Cargo.toml +++ b/storage-proto/Cargo.toml @@ -25,3 +25,6 @@ name = "solana_storage_proto" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] + +[build-dependencies] +tonic-build = "0.5.0" diff --git a/storage-proto/README.md b/storage-proto/README.md new file mode 100644 index 0000000000..7dc760e011 --- /dev/null +++ b/storage-proto/README.md @@ -0,0 +1,5 @@ +# Storage Protobufs + +The `solana-storage-proto` structs used in `src/convert.rs` and elsewhere are +auto-generated from protobuf definitions on build. To update these structs, +simply make the desired edits to `src/*.proto` files. diff --git a/storage-proto/build-proto/.gitignore b/storage-proto/build-proto/.gitignore deleted file mode 100644 index 2f7896d1d1..0000000000 --- a/storage-proto/build-proto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target/ diff --git a/storage-proto/build-proto/Cargo.lock b/storage-proto/build-proto/Cargo.lock deleted file mode 100644 index ef4ba7bc2e..0000000000 --- a/storage-proto/build-proto/Cargo.lock +++ /dev/null @@ -1,360 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anyhow" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1fd36ffbb1fb7c834eac128ea8d0e310c5aeb635548f9d58861e1308d46e71c" - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "bytes" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "fixedbitset" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" - -[[package]] -name = "getrandom" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hashbrown" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" - -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "indexmap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "itertools" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" -dependencies = [ - "either", -] - -[[package]] -name = "libc" -version = "0.2.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" - -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "multimap" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" - -[[package]] -name = "petgraph" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" -dependencies = [ - "fixedbitset", - "indexmap", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "prost" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5e2533f59d08fcf364fd374ebda0692a70bd6d7e66ef97f306f45c6c5d8020" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355f634b43cdd80724ee7848f95770e7e70eefa6dcf14fea676216573b8fd603" -dependencies = [ - "bytes", - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prost", - "prost-types", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "600d2f334aa05acb02a755e217ef1ab6dea4d51b58b7846588b747edec04efba" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "603bbd6394701d13f3f25aada59c7de9d35a6a5887cfc156181234a44002771b" -dependencies = [ - "bytes", - "prost", -] - -[[package]] -name = "proto" -version = "1.7.5" -dependencies = [ - "tonic-build", -] - -[[package]] -name = "quote" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom", - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "syn" -version = "1.0.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -dependencies = [ - "cfg-if", - "libc", - "rand", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tonic-build" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db9a497663a9a779693ef67b6e6aef8345b3d3ff8d50ef92eae6c88cb1e386" -dependencies = [ - "proc-macro2", - "prost-build", - "quote", - "syn", -] - -[[package]] -name = "unicode-segmentation" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "which" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" -dependencies = [ - "libc", - "thiserror", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/storage-proto/build-proto/Cargo.toml b/storage-proto/build-proto/Cargo.toml deleted file mode 100644 index 61bf1eea76..0000000000 --- a/storage-proto/build-proto/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -authors = ["Solana Maintainers "] -description = "Blockchain, Rebuilt for Scale" -edition = "2018" -homepage = "https://solana.com/" -license = "Apache-2.0" -name = "proto" -publish = false -repository = "https://github.com/solana-labs/solana" -version = "1.7.5" - -[workspace] - -[dependencies] -tonic-build = "0.5.0" diff --git a/storage-proto/build-proto/src/main.rs b/storage-proto/build.rs similarity index 80% rename from storage-proto/build-proto/src/main.rs rename to storage-proto/build.rs index 50acaceb7a..426813f733 100644 --- a/storage-proto/build-proto/src/main.rs +++ b/storage-proto/build.rs @@ -1,8 +1,10 @@ fn main() -> Result<(), std::io::Error> { let manifest_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let out_dir = manifest_dir.join("../proto"); - let proto_files = manifest_dir.join("../src"); + let out_dir = manifest_dir.join("proto"); + let proto_files = manifest_dir.join("src"); + + std::fs::create_dir_all(out_dir.clone())?; println!("Protobuf directory: {}", proto_files.display()); println!("output directory: {}", out_dir.display()); diff --git a/storage-proto/proto/solana.storage.confirmed_block.rs b/storage-proto/proto/solana.storage.confirmed_block.rs deleted file mode 100644 index d2253b04ed..0000000000 --- a/storage-proto/proto/solana.storage.confirmed_block.rs +++ /dev/null @@ -1,148 +0,0 @@ -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ConfirmedBlock { - #[prost(string, tag = "1")] - pub previous_blockhash: ::prost::alloc::string::String, - #[prost(string, tag = "2")] - pub blockhash: ::prost::alloc::string::String, - #[prost(uint64, tag = "3")] - pub parent_slot: u64, - #[prost(message, repeated, tag = "4")] - pub transactions: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "5")] - pub rewards: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "6")] - pub block_time: ::core::option::Option, - #[prost(message, optional, tag = "7")] - pub block_height: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct ConfirmedTransaction { - #[prost(message, optional, tag = "1")] - pub transaction: ::core::option::Option, - #[prost(message, optional, tag = "2")] - pub meta: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Transaction { - #[prost(bytes = "vec", repeated, tag = "1")] - pub signatures: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, - #[prost(message, optional, tag = "2")] - pub message: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Message { - #[prost(message, optional, tag = "1")] - pub header: ::core::option::Option, - #[prost(bytes = "vec", repeated, tag = "2")] - pub account_keys: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec>, - #[prost(bytes = "vec", tag = "3")] - pub recent_blockhash: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "4")] - pub instructions: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct MessageHeader { - #[prost(uint32, tag = "1")] - pub num_required_signatures: u32, - #[prost(uint32, tag = "2")] - pub num_readonly_signed_accounts: u32, - #[prost(uint32, tag = "3")] - pub num_readonly_unsigned_accounts: u32, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct TransactionStatusMeta { - #[prost(message, optional, tag = "1")] - pub err: ::core::option::Option, - #[prost(uint64, tag = "2")] - pub fee: u64, - #[prost(uint64, repeated, tag = "3")] - pub pre_balances: ::prost::alloc::vec::Vec, - #[prost(uint64, repeated, tag = "4")] - pub post_balances: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "5")] - pub inner_instructions: ::prost::alloc::vec::Vec, - #[prost(string, repeated, tag = "6")] - pub log_messages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, - #[prost(message, repeated, tag = "7")] - pub pre_token_balances: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "8")] - pub post_token_balances: ::prost::alloc::vec::Vec, - #[prost(message, repeated, tag = "9")] - pub rewards: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct TransactionError { - #[prost(bytes = "vec", tag = "1")] - pub err: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct InnerInstructions { - #[prost(uint32, tag = "1")] - pub index: u32, - #[prost(message, repeated, tag = "2")] - pub instructions: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CompiledInstruction { - #[prost(uint32, tag = "1")] - pub program_id_index: u32, - #[prost(bytes = "vec", tag = "2")] - pub accounts: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", tag = "3")] - pub data: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct TokenBalance { - #[prost(uint32, tag = "1")] - pub account_index: u32, - #[prost(string, tag = "2")] - pub mint: ::prost::alloc::string::String, - #[prost(message, optional, tag = "3")] - pub ui_token_amount: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UiTokenAmount { - #[prost(double, tag = "1")] - pub ui_amount: f64, - #[prost(uint32, tag = "2")] - pub decimals: u32, - #[prost(string, tag = "3")] - pub amount: ::prost::alloc::string::String, - #[prost(string, tag = "4")] - pub ui_amount_string: ::prost::alloc::string::String, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Reward { - #[prost(string, tag = "1")] - pub pubkey: ::prost::alloc::string::String, - #[prost(int64, tag = "2")] - pub lamports: i64, - #[prost(uint64, tag = "3")] - pub post_balance: u64, - #[prost(enumeration = "RewardType", tag = "4")] - pub reward_type: i32, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Rewards { - #[prost(message, repeated, tag = "1")] - pub rewards: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UnixTimestamp { - #[prost(int64, tag = "1")] - pub timestamp: i64, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct BlockHeight { - #[prost(uint64, tag = "1")] - pub block_height: u64, -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum RewardType { - Unspecified = 0, - Fee = 1, - Rent = 2, - Staking = 3, - Voting = 4, -} diff --git a/storage-proto/proto/solana.storage.transaction_by_addr.rs b/storage-proto/proto/solana.storage.transaction_by_addr.rs deleted file mode 100644 index 5425eaab4e..0000000000 --- a/storage-proto/proto/solana.storage.transaction_by_addr.rs +++ /dev/null @@ -1,124 +0,0 @@ -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct TransactionByAddr { - #[prost(message, repeated, tag = "1")] - pub tx_by_addrs: ::prost::alloc::vec::Vec, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct TransactionByAddrInfo { - #[prost(bytes = "vec", tag = "1")] - pub signature: ::prost::alloc::vec::Vec, - #[prost(message, optional, tag = "2")] - pub err: ::core::option::Option, - #[prost(uint32, tag = "3")] - pub index: u32, - #[prost(message, optional, tag = "4")] - pub memo: ::core::option::Option, - #[prost(message, optional, tag = "5")] - pub block_time: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct Memo { - #[prost(string, tag = "1")] - pub memo: ::prost::alloc::string::String, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct TransactionError { - #[prost(enumeration = "TransactionErrorType", tag = "1")] - pub transaction_error: i32, - #[prost(message, optional, tag = "2")] - pub instruction_error: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct InstructionError { - #[prost(uint32, tag = "1")] - pub index: u32, - #[prost(enumeration = "InstructionErrorType", tag = "2")] - pub error: i32, - #[prost(message, optional, tag = "3")] - pub custom: ::core::option::Option, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct UnixTimestamp { - #[prost(int64, tag = "1")] - pub timestamp: i64, -} -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct CustomError { - #[prost(uint32, tag = "1")] - pub custom: u32, -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum TransactionErrorType { - AccountInUse = 0, - AccountLoadedTwice = 1, - AccountNotFound = 2, - ProgramAccountNotFound = 3, - InsufficientFundsForFee = 4, - InvalidAccountForFee = 5, - AlreadyProcessed = 6, - BlockhashNotFound = 7, - InstructionError = 8, - CallChainTooDeep = 9, - MissingSignatureForFee = 10, - InvalidAccountIndex = 11, - SignatureFailure = 12, - InvalidProgramForExecution = 13, - SanitizeFailure = 14, - ClusterMaintenance = 15, - AccountBorrowOutstandingTx = 16, -} -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] -#[repr(i32)] -pub enum InstructionErrorType { - GenericError = 0, - InvalidArgument = 1, - InvalidInstructionData = 2, - InvalidAccountData = 3, - AccountDataTooSmall = 4, - InsufficientFunds = 5, - IncorrectProgramId = 6, - MissingRequiredSignature = 7, - AccountAlreadyInitialized = 8, - UninitializedAccount = 9, - UnbalancedInstruction = 10, - ModifiedProgramId = 11, - ExternalAccountLamportSpend = 12, - ExternalAccountDataModified = 13, - ReadonlyLamportChange = 14, - ReadonlyDataModified = 15, - DuplicateAccountIndex = 16, - ExecutableModified = 17, - RentEpochModified = 18, - NotEnoughAccountKeys = 19, - AccountDataSizeChanged = 20, - AccountNotExecutable = 21, - AccountBorrowFailed = 22, - AccountBorrowOutstanding = 23, - DuplicateAccountOutOfSync = 24, - Custom = 25, - InvalidError = 26, - ExecutableDataModified = 27, - ExecutableLamportChange = 28, - ExecutableAccountNotRentExempt = 29, - UnsupportedProgramId = 30, - CallDepth = 31, - MissingAccount = 32, - ReentrancyNotAllowed = 33, - MaxSeedLengthExceeded = 34, - InvalidSeeds = 35, - InvalidRealloc = 36, - ComputationalBudgetExceeded = 37, - PrivilegeEscalation = 38, - ProgramEnvironmentSetupFailure = 39, - ProgramFailedToComplete = 40, - ProgramFailedToCompile = 41, - Immutable = 42, - IncorrectAuthority = 43, - BorshIoError = 44, - AccountNotRentExempt = 45, - InvalidAccountOwner = 46, - ArithmeticOverflow = 47, - UnsupportedSysvar = 48, - IllegalOwner = 49, -} diff --git a/storage-proto/src/convert.rs b/storage-proto/src/convert.rs index 9ad5dd9b5c..7460bdf0e3 100644 --- a/storage-proto/src/convert.rs +++ b/storage-proto/src/convert.rs @@ -1,22 +1,24 @@ -use crate::{StoredExtendedRewards, StoredTransactionStatusMeta}; -use solana_account_decoder::parse_token::{real_number_string_trimmed, UiTokenAmount}; -use solana_sdk::{ - hash::Hash, - instruction::CompiledInstruction, - instruction::InstructionError, - message::{Message, MessageHeader}, - pubkey::Pubkey, - signature::Signature, - transaction::Transaction, - transaction::TransactionError, -}; -use solana_transaction_status::{ - ConfirmedBlock, InnerInstructions, Reward, RewardType, TransactionByAddrInfo, - TransactionStatusMeta, TransactionTokenBalance, TransactionWithStatusMeta, -}; -use std::{ - convert::{TryFrom, TryInto}, - str::FromStr, +use { + crate::{StoredExtendedRewards, StoredTransactionStatusMeta}, + solana_account_decoder::parse_token::{real_number_string_trimmed, UiTokenAmount}, + solana_sdk::{ + hash::Hash, + instruction::CompiledInstruction, + instruction::InstructionError, + message::{Message, MessageHeader}, + pubkey::Pubkey, + signature::Signature, + transaction::Transaction, + transaction::TransactionError, + }, + solana_transaction_status::{ + ConfirmedBlock, InnerInstructions, Reward, RewardType, TransactionByAddrInfo, + TransactionStatusMeta, TransactionTokenBalance, TransactionWithStatusMeta, + }, + std::{ + convert::{TryFrom, TryInto}, + str::FromStr, + }, }; pub mod generated { diff --git a/storage-proto/src/lib.rs b/storage-proto/src/lib.rs index a132a8797f..2a21b6b937 100644 --- a/storage-proto/src/lib.rs +++ b/storage-proto/src/lib.rs @@ -1,13 +1,15 @@ -use serde::{Deserialize, Serialize}; -use solana_account_decoder::{ - parse_token::{real_number_string_trimmed, UiTokenAmount}, - StringAmount, +use { + serde::{Deserialize, Serialize}, + solana_account_decoder::{ + parse_token::{real_number_string_trimmed, UiTokenAmount}, + StringAmount, + }, + solana_sdk::{deserialize_utils::default_on_eof, transaction::Result}, + solana_transaction_status::{ + InnerInstructions, Reward, RewardType, TransactionStatusMeta, TransactionTokenBalance, + }, + std::str::FromStr, }; -use solana_sdk::{deserialize_utils::default_on_eof, transaction::Result}; -use solana_transaction_status::{ - InnerInstructions, Reward, RewardType, TransactionStatusMeta, TransactionTokenBalance, -}; -use std::str::FromStr; pub mod convert;