diff --git a/Cargo.lock b/Cargo.lock index 7270d40..f83192d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,17 +81,6 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "ahash" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" -dependencies = [ - "getrandom 0.2.12", - "once_cell", - "version_check", -] - [[package]] name = "ahash" version = "0.8.11" @@ -845,6 +834,9 @@ name = "bitflags" version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +dependencies = [ + "serde", +] [[package]] name = "bitvec" @@ -1127,11 +1119,12 @@ dependencies = [ [[package]] name = "config" -version = "0.13.4" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" +checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" dependencies = [ "async-trait", + "convert_case 0.6.0", "json5", "lazy_static", "nom", @@ -1140,7 +1133,7 @@ dependencies = [ "rust-ini", "serde", "serde_json", - "toml 0.5.11", + "toml", "yaml-rust", ] @@ -1180,6 +1173,26 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom 0.2.12", + "once_cell", + "tiny-keccak", +] + [[package]] name = "const_fn" version = "0.4.9" @@ -1198,6 +1211,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "cookie" version = "0.14.4" @@ -1487,7 +1509,7 @@ version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ - "convert_case", + "convert_case 0.4.0", "proc-macro2", "quote", "rustc_version 0.4.0", @@ -1554,9 +1576,12 @@ dependencies = [ [[package]] name = "dlv-list" -version = "0.3.0" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", +] [[package]] name = "doc-comment" @@ -2033,9 +2058,6 @@ name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.8", -] [[package]] name = "hashbrown" @@ -2043,7 +2065,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.11", + "ahash", ] [[package]] @@ -2052,7 +2074,7 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" dependencies = [ - "ahash 0.8.11", + "ahash", "allocator-api2", ] @@ -2115,10 +2137,11 @@ dependencies = [ [[package]] name = "hotshot-types" -version = "0.1.9" -source = "git+https://github.com/EspressoSystems/hotshot-types?tag=0.1.9#4c8dffbb3b47c35d9bc465cc6520d06da578f9ec" +version = "0.1.11" +source = "git+https://github.com/EspressoSystems/hotshot-types?tag=0.1.11#65a06f75612f529c11e97c4320f1f6d0f49ba81e" dependencies = [ "anyhow", + "ark-bls12-381", "ark-bn254", "ark-ec", "ark-ed-on-bn254", @@ -2157,11 +2180,12 @@ dependencies = [ "tokio", "tracing", "typenum", + "versioned-binary-serialization", ] [[package]] name = "hs-builder-api" -version = "0.1.3" +version = "0.1.6" dependencies = [ "async-trait", "clap", @@ -2169,10 +2193,11 @@ dependencies = [ "futures", "hotshot-types", "serde", - "snafu 0.7.5", + "snafu 0.8.2", "tagged-base64", "tide-disco", - "toml 0.8.11", + "toml", + "versioned-binary-serialization", ] [[package]] @@ -2786,9 +2811,9 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" [[package]] name = "maud" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0bab19cef8a7fe1c18a43e881793bfc9d4ea984befec3ae5bd0415abf3ecf00" +checksum = "df518b75016b4289cdddffa1b01f2122f4a49802c93191f3133f6dc2472ebcaa" dependencies = [ "itoa", "maud_macros", @@ -2797,14 +2822,14 @@ dependencies = [ [[package]] name = "maud_macros" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0be95d66c3024ffce639216058e5bae17a83ecaf266ffc6e4d060ad447c9eed2" +checksum = "fa453238ec218da0af6b11fc5978d3b5c3a45ed97b722391a2a11f3306274e18" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.53", ] [[package]] @@ -2999,12 +3024,12 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" [[package]] name = "ordered-multimap" -version = "0.4.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" +checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" dependencies = [ "dlv-list", - "hashbrown 0.12.3", + "hashbrown 0.13.2", ] [[package]] @@ -3299,7 +3324,6 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn 1.0.109", "version_check", ] @@ -3564,13 +3588,14 @@ dependencies = [ [[package]] name = "ron" -version = "0.7.1" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" +checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ - "base64 0.13.1", - "bitflags 1.3.2", + "base64 0.21.7", + "bitflags 2.4.2", "serde", + "serde_derive", ] [[package]] @@ -3591,9 +3616,9 @@ dependencies = [ [[package]] name = "rust-ini" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" +checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" dependencies = [ "cfg-if", "ordered-multimap", @@ -4133,15 +4158,15 @@ checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" -version = "0.25.0" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" [[package]] name = "strum_macros" -version = "0.25.3" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ "heck 0.4.1", "proc-macro2", @@ -4388,12 +4413,12 @@ dependencies = [ [[package]] name = "tide-disco" -version = "0.4.6" -source = "git+https://github.com/EspressoSystems/tide-disco.git?tag=v0.4.6#4ced31cef8aae769994098d245e026c127801b74" +version = "0.5.0" +source = "git+https://github.com/EspressoSystems/tide-disco.git?tag=v0.5.0#07e489171089650cebfaca9ca6a6a6ddd843610d" dependencies = [ + "anyhow", "async-std", "async-trait", - "bincode", "clap", "config", "derivative", @@ -4420,20 +4445,21 @@ dependencies = [ "shellexpand", "signal-hook", "signal-hook-async-std", - "snafu 0.7.5", + "snafu 0.8.2", "strum", "strum_macros", "surf", "tagged-base64", "tide", "tide-websockets", - "toml 0.8.11", + "toml", "tracing", "tracing-distributed", "tracing-futures", "tracing-log", "tracing-subscriber", "url", + "versioned-binary-serialization", ] [[package]] @@ -4613,15 +4639,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - [[package]] name = "toml" version = "0.8.11" @@ -4914,6 +4931,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" + [[package]] name = "universal-hash" version = "0.4.0" @@ -5012,6 +5035,18 @@ version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "versioned-binary-serialization" +version = "0.1.2" +source = "git+https://github.com/EspressoSystems/versioned-binary-serialization.git?tag=0.1.2#6874f91a3c8d64acc24fe0abe4ad93c35b75eb9d" +dependencies = [ + "anyhow", + "bincode", + "displaydoc", + "serde", + "serde_with", +] + [[package]] name = "waker-fn" version = "1.1.1" diff --git a/Cargo.toml b/Cargo.toml index 234acf9..e18e8db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hs-builder-api" -version = "0.1.5" +version = "0.1.6" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -10,9 +10,10 @@ async-trait = "0.1" clap = { version = "4.4", features = ["derive", "env"] } derive_more = "0.99" futures = "0.3" -hotshot-types = { git = "https://github.com/EspressoSystems/hotshot-types", tag = "0.1.10" } +hotshot-types = { git = "https://github.com/EspressoSystems/hotshot-types", tag = "0.1.11" } serde = { version = "1.0", features = ["derive"] } -snafu = { version = "0.7", features = ["backtraces"] } +snafu = "0.8" tagged-base64 = { git = "https://github.com/EspressoSystems/tagged-base64", tag = "0.3.4" } -tide-disco = { git = "https://github.com/EspressoSystems/tide-disco.git", tag = "v0.4.6" } +tide-disco = { git = "https://github.com/EspressoSystems/tide-disco.git", tag = "v0.5.0" } toml = "0.8" +versioned-binary-serialization = { git = "https://github.com/EspressoSystems/versioned-binary-serialization.git", tag = "0.1.2" } diff --git a/src/api.rs b/src/api.rs index 66058b2..62f2edf 100644 --- a/src/api.rs +++ b/src/api.rs @@ -14,12 +14,13 @@ use std::fs; use std::path::Path; use tide_disco::api::{Api, ApiError}; use toml::{map::Entry, Value}; +use versioned_binary_serialization::version::StaticVersionType; -pub(crate) fn load_api( +pub(crate) fn load_api( path: Option>, default: &str, extensions: impl IntoIterator, -) -> Result, ApiError> { +) -> Result, ApiError> { let mut toml = match path { Some(path) => load_toml(path.as_ref())?, None => toml::from_str(default).map_err(|err| ApiError::CannotReadToml { diff --git a/src/builder.rs b/src/builder.rs index 6cfd65a..2302667 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -15,6 +15,7 @@ use tide_disco::{ method::{ReadState, WriteState}, Api, RequestError, StatusCode, }; +use versioned_binary_serialization::version::StaticVersionType; use crate::{ api::load_api, @@ -108,7 +109,9 @@ impl tide_disco::error::Error for Error { } } -pub fn define_api(options: &Options) -> Result, ApiError> +pub fn define_api( + options: &Options, +) -> Result, ApiError> where State: 'static + Send + Sync + ReadState, ::State: Send + Sync + BuilderDataSource, @@ -119,7 +122,7 @@ where &'a TaggedBase64, >>::Error: Display, { - let mut api = load_api::( + let mut api = load_api::( options.api_path.as_ref(), include_str!("../api/builder.toml"), options.extensions.clone(), @@ -166,13 +169,15 @@ where Ok(api) } -pub fn submit_api(options: &Options) -> Result, ApiError> +pub fn submit_api( + options: &Options, +) -> Result, ApiError> where State: 'static + Send + Sync + WriteState, ::State: Send + Sync + AcceptsTxnSubmits, Types: NodeType, { - let mut api = load_api::( + let mut api = load_api::( options.api_path.as_ref(), include_str!("../api/submit.toml"), options.extensions.clone(), @@ -181,7 +186,7 @@ where .post("submit_txn", |req, state| { async move { let tx = req - .body_auto::<::Transaction>() + .body_auto::<::Transaction, Ver>(Ver::instance()) .context(TxnUnpackSnafu)?; state.submit_txn(tx).await.context(TxnSubmitSnafu)?; Ok(())