From 8dc594356738da680269b22fcc722b9875ec9fc6 Mon Sep 17 00:00:00 2001 From: Sishan Long Date: Fri, 25 Oct 2024 15:51:39 -0700 Subject: [PATCH 1/4] added trait Transaction to calc tx size --- Cargo.lock | 51 ++++++++++++------- Cargo.toml | 28 +++++----- sequencer/src/block/full_payload/payload.rs | 6 +-- .../v0/impls/block/full_payload/payload.rs | 19 +++---- types/src/v0/impls/transaction.rs | 12 ++++- 5 files changed, 70 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f720e0b25..5ce0d90741 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4113,7 +4113,7 @@ dependencies = [ [[package]] name = "hotshot" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "async-broadcast", @@ -4154,13 +4154,14 @@ dependencies = [ "tokio", "tracing", "url", + "utils", "vbs", ] [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "async-trait", "clap", @@ -4179,7 +4180,7 @@ dependencies = [ [[package]] name = "hotshot-builder-core" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?tag=0.1.53#2922d96b85c4b71abd516f1aaf9f4c522cec8b07" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#84f882b2d05ae49e0762640e5f2e80f65e0d9733" dependencies = [ "anyhow", "async-broadcast", @@ -4236,7 +4237,7 @@ dependencies = [ [[package]] name = "hotshot-events-service" version = "0.1.49" -source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=0.1.51#8d4092ef01a5a6c9151df4a29fa3218726f91016" +source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?branch=sishan/trait_builder_transaction#7d2a201f54effcc249b5ff3290cb9fa3e2df8fed" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -4262,7 +4263,7 @@ dependencies = [ [[package]] name = "hotshot-example-types" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "async-broadcast", @@ -4276,6 +4277,7 @@ dependencies = [ "ethereum-types", "futures", "hotshot", + "hotshot-builder-api", "hotshot-task", "hotshot-task-impls", "hotshot-types", @@ -4295,7 +4297,7 @@ dependencies = [ [[package]] name = "hotshot-fakeapi" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4315,7 +4317,7 @@ dependencies = [ [[package]] name = "hotshot-macros" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "derive_builder", "proc-macro2", @@ -4326,7 +4328,7 @@ dependencies = [ [[package]] name = "hotshot-orchestrator" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4355,7 +4357,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" version = "0.1.62" -source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=0.1.66#ff01ee1f804e2e211f5ee17b7b374861220ac984" +source = "git+https://github.com/EspressoSystems/hotshot-query-service?branch=sishan/trait_builder_transaction#e427feabc90d054caec2e66436d7be3a8c95b5e0" dependencies = [ "anyhow", "ark-serialize", @@ -4408,7 +4410,7 @@ dependencies = [ [[package]] name = "hotshot-stake-table" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "ark-bn254", "ark-ed-on-bn254", @@ -4470,7 +4472,7 @@ dependencies = [ [[package]] name = "hotshot-task" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "async-broadcast", @@ -4480,12 +4482,13 @@ dependencies = [ "futures", "tokio", "tracing", + "utils", ] [[package]] name = "hotshot-task-impls" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "async-broadcast", @@ -4515,6 +4518,7 @@ dependencies = [ "tokio", "tracing", "url", + "utils", "vbs", "vec1", ] @@ -4522,7 +4526,7 @@ dependencies = [ [[package]] name = "hotshot-testing" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "async-broadcast", @@ -4568,7 +4572,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "ark-bn254", @@ -4620,6 +4624,7 @@ dependencies = [ "tracing", "typenum", "url", + "utils", "vbs", "vec1", ] @@ -5829,7 +5834,7 @@ dependencies = [ [[package]] name = "libp2p-networking" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.78-patch4#e8abb17d990560d6c92489522d218b99d2089db3" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" dependencies = [ "anyhow", "async-compatibility-layer", @@ -6218,7 +6223,7 @@ dependencies = [ [[package]] name = "marketplace-builder-core" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?tag=0.1.53#2922d96b85c4b71abd516f1aaf9f4c522cec8b07" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#84f882b2d05ae49e0762640e5f2e80f65e0d9733" dependencies = [ "anyhow", "async-broadcast", @@ -6260,7 +6265,7 @@ dependencies = [ [[package]] name = "marketplace-builder-shared" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?tag=0.1.53#2922d96b85c4b71abd516f1aaf9f4c522cec8b07" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#84f882b2d05ae49e0762640e5f2e80f65e0d9733" dependencies = [ "anyhow", "async-broadcast", @@ -7591,7 +7596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.77", @@ -9165,7 +9170,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d1e02fca405f6280643174a50c942219f0bbf4dbf7d480f1dd864d6f211ae5" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.77", @@ -10735,6 +10740,14 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "utils" +version = "0.5.78" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +dependencies = [ + "tracing", +] + [[package]] name = "uuid" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index 12048e445c..25a029d564 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,24 +57,24 @@ dyn-clone = "1.0" ethers = { version = "2.0", features = ["solc"] } futures = "0.3" -hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.78-patch4" } +hotshot = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } # Hotshot imports -hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.78-patch4" } -hotshot-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.1.53" } -marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.1.53" } -marketplace-builder-shared = { git = "https://github.com/EspressoSystems/marketplace-builder-core", tag = "0.1.53" } -hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.51" } -hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.78-patch4" } -hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.66" } -hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.78-patch4" } +hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "sishan/trait_builder_transaction" } +hotshot-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "sishan/trait_builder_transaction" } +marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "sishan/trait_builder_transaction" } +marketplace-builder-shared = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "sishan/trait_builder_transaction" } +hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", branch = "sishan/trait_builder_transaction" } +hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } +hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", branch = "sishan/trait_builder_transaction" } +hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" } -hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.78-patch4" } -hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.78-patch4" } -hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.78-patch4" } -libp2p-networking = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.78-patch4" } +hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } +hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } +hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } +libp2p-networking = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } hotshot-contract-adapter = { version = "0.1.0", path = "contracts/rust/adapter" } # Temporary, used to pull in the mock auction results provider -hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.78-patch4" } +hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } # Push CDN imports cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", features = [ diff --git a/sequencer/src/block/full_payload/payload.rs b/sequencer/src/block/full_payload/payload.rs index 52c45abe46..10c56371dd 100644 --- a/sequencer/src/block/full_payload/payload.rs +++ b/sequencer/src/block/full_payload/payload.rs @@ -103,11 +103,11 @@ impl Payload { let mut ns_builders = BTreeMap::::new(); for tx in transactions.into_iter() { // accounting for block byte length limit - block_byte_len += tx.payload().len() + NsPayloadBuilder::tx_table_entry_byte_len(); if !ns_builders.contains_key(&tx.namespace()) { // each new namespace adds overhead - block_byte_len += - NsTableBuilder::entry_byte_len() + NsPayloadBuilder::tx_table_header_byte_len(); + block_byte_len += tx.minimum_block_size(true); + } else { + block_byte_len += tx.minimum_block_size(false); } if block_byte_len > max_block_byte_len { tracing::warn!("transactions truncated to fit in maximum block byte length {max_block_byte_len}"); diff --git a/types/src/v0/impls/block/full_payload/payload.rs b/types/src/v0/impls/block/full_payload/payload.rs index d40be7d4ed..0a62c770f9 100644 --- a/types/src/v0/impls/block/full_payload/payload.rs +++ b/types/src/v0/impls/block/full_payload/payload.rs @@ -4,6 +4,7 @@ use async_trait::async_trait; use committable::Committable; use hotshot_query_service::availability::QueryablePayload; use hotshot_types::data::ViewNumber; +use hotshot_types::traits::block_contents::Transaction as HotShotTransaction; use hotshot_types::{ traits::{BlockPayload, EncodeBytes}, utils::BuilderCommitment, @@ -13,11 +14,12 @@ use jf_vid::VidScheme; use sha2::Digest; use thiserror::Error; +use crate::Transaction; use crate::{ v0::impls::{NodeState, ValidatedState}, v0_1::ChainConfig, Index, Iter, NamespaceId, NsIndex, NsPayload, NsPayloadBuilder, NsPayloadRange, NsTable, - NsTableBuilder, Payload, PayloadByteLen, SeqTypes, Transaction, TxProof, + NsTableBuilder, Payload, PayloadByteLen, SeqTypes, TxProof, }; #[derive(serde::Deserialize, serde::Serialize, Error, Debug, Eq, PartialEq)] @@ -79,23 +81,22 @@ impl Payload { >::Error, > { // accounting for block byte length limit - let max_block_byte_len: usize = u64::from(chain_config.max_block_size) - .try_into() - .expect("too large max block size for architecture"); - let mut block_byte_len = NsTableBuilder::header_byte_len(); + let max_block_byte_len = u64::from(chain_config.max_block_size); + let mut block_byte_len = NsTableBuilder::header_byte_len() as u64; // add each tx to its namespace let mut ns_builders = BTreeMap::::new(); for tx in transactions.into_iter() { - let mut tx_size = tx.payload().len() + NsPayloadBuilder::tx_table_entry_byte_len(); + let mut tx_size = 0; if !ns_builders.contains_key(&tx.namespace()) { // each new namespace adds overhead - tx_size += - NsTableBuilder::entry_byte_len() + NsPayloadBuilder::tx_table_header_byte_len(); + tx_size += tx.minimum_block_size(true); + } else { + tx_size += tx.minimum_block_size(false); } if tx_size > max_block_byte_len { - // skip this transaction since it excceds the block size limit + // skip this transaction since it exceeds the block size limit tracing::warn!( "skip the transaction to fit in maximum block byte length {max_block_byte_len}, transaction size {tx_size}" ); diff --git a/types/src/v0/impls/transaction.rs b/types/src/v0/impls/transaction.rs index 32c2cc0c0d..638ffa8302 100644 --- a/types/src/v0/impls/transaction.rs +++ b/types/src/v0/impls/transaction.rs @@ -5,6 +5,8 @@ use serde::{de::Error, Deserialize, Deserializer}; use crate::{NamespaceId, Transaction}; +use super::{NsPayloadBuilder, NsTableBuilder}; + impl From for NamespaceId { fn from(value: u32) -> Self { Self(value as u64) @@ -79,7 +81,15 @@ impl Transaction { } } -impl HotShotTransaction for Transaction {} +impl HotShotTransaction for Transaction { + fn minimum_block_size(&self, new_ns: bool) -> u64 { + let mut len = self.payload().len() + NsPayloadBuilder::tx_table_entry_byte_len(); + if new_ns { + len += NsTableBuilder::entry_byte_len() + NsPayloadBuilder::tx_table_header_byte_len(); + } + len as u64 + } +} impl Committable for Transaction { fn commit(&self) -> Commitment { From a3fd9d1d318647e624857ab116562eaa6b4d121a Mon Sep 17 00:00:00 2001 From: Sishan Long Date: Mon, 28 Oct 2024 13:07:57 -0700 Subject: [PATCH 2/4] remove param --- Cargo.lock | 36 +++++++++---------- sequencer/src/block/full_payload/payload.rs | 9 ++--- .../v0/impls/block/full_payload/payload.rs | 9 +---- types/src/v0/impls/transaction.rs | 19 +++++++--- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ce0d90741..0aaae2dc2d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4113,7 +4113,7 @@ dependencies = [ [[package]] name = "hotshot" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "async-broadcast", @@ -4161,7 +4161,7 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "async-trait", "clap", @@ -4180,7 +4180,7 @@ dependencies = [ [[package]] name = "hotshot-builder-core" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#84f882b2d05ae49e0762640e5f2e80f65e0d9733" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#784fe95fa235ee8404fd10c1359b7cde0ef5a0ba" dependencies = [ "anyhow", "async-broadcast", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "hotshot-events-service" version = "0.1.49" -source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?branch=sishan/trait_builder_transaction#7d2a201f54effcc249b5ff3290cb9fa3e2df8fed" +source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?branch=sishan/trait_builder_transaction#085b911bd7611021c44f0a314ce6b636b0547439" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -4263,7 +4263,7 @@ dependencies = [ [[package]] name = "hotshot-example-types" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "async-broadcast", @@ -4297,7 +4297,7 @@ dependencies = [ [[package]] name = "hotshot-fakeapi" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4317,7 +4317,7 @@ dependencies = [ [[package]] name = "hotshot-macros" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "derive_builder", "proc-macro2", @@ -4328,7 +4328,7 @@ dependencies = [ [[package]] name = "hotshot-orchestrator" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4357,7 +4357,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" version = "0.1.62" -source = "git+https://github.com/EspressoSystems/hotshot-query-service?branch=sishan/trait_builder_transaction#e427feabc90d054caec2e66436d7be3a8c95b5e0" +source = "git+https://github.com/EspressoSystems/hotshot-query-service?branch=sishan/trait_builder_transaction#0ccd2ff2c5b8c5c68586e43d8275090a0b6d68bf" dependencies = [ "anyhow", "ark-serialize", @@ -4410,7 +4410,7 @@ dependencies = [ [[package]] name = "hotshot-stake-table" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "ark-bn254", "ark-ed-on-bn254", @@ -4472,7 +4472,7 @@ dependencies = [ [[package]] name = "hotshot-task" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "async-broadcast", @@ -4488,7 +4488,7 @@ dependencies = [ [[package]] name = "hotshot-task-impls" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "async-broadcast", @@ -4526,7 +4526,7 @@ dependencies = [ [[package]] name = "hotshot-testing" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "async-broadcast", @@ -4572,7 +4572,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "ark-bn254", @@ -5834,7 +5834,7 @@ dependencies = [ [[package]] name = "libp2p-networking" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "anyhow", "async-compatibility-layer", @@ -6223,7 +6223,7 @@ dependencies = [ [[package]] name = "marketplace-builder-core" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#84f882b2d05ae49e0762640e5f2e80f65e0d9733" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#784fe95fa235ee8404fd10c1359b7cde0ef5a0ba" dependencies = [ "anyhow", "async-broadcast", @@ -6265,7 +6265,7 @@ dependencies = [ [[package]] name = "marketplace-builder-shared" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#84f882b2d05ae49e0762640e5f2e80f65e0d9733" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#784fe95fa235ee8404fd10c1359b7cde0ef5a0ba" dependencies = [ "anyhow", "async-broadcast", @@ -10743,7 +10743,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "utils" version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#f242f097b86547213d6301fb7251dbfe2188741e" +source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" dependencies = [ "tracing", ] diff --git a/sequencer/src/block/full_payload/payload.rs b/sequencer/src/block/full_payload/payload.rs index 10c56371dd..bc1101887e 100644 --- a/sequencer/src/block/full_payload/payload.rs +++ b/sequencer/src/block/full_payload/payload.rs @@ -102,13 +102,8 @@ impl Payload { // add each tx to its namespace let mut ns_builders = BTreeMap::::new(); for tx in transactions.into_iter() { - // accounting for block byte length limit - if !ns_builders.contains_key(&tx.namespace()) { - // each new namespace adds overhead - block_byte_len += tx.minimum_block_size(true); - } else { - block_byte_len += tx.minimum_block_size(false); - } + // accounting for block byte length limit + block_byte_len += tx.size_in_block(!ns_builders.contains_key(&tx.namespace())); if block_byte_len > max_block_byte_len { tracing::warn!("transactions truncated to fit in maximum block byte length {max_block_byte_len}"); break; diff --git a/types/src/v0/impls/block/full_payload/payload.rs b/types/src/v0/impls/block/full_payload/payload.rs index 0a62c770f9..5948467837 100644 --- a/types/src/v0/impls/block/full_payload/payload.rs +++ b/types/src/v0/impls/block/full_payload/payload.rs @@ -4,7 +4,6 @@ use async_trait::async_trait; use committable::Committable; use hotshot_query_service::availability::QueryablePayload; use hotshot_types::data::ViewNumber; -use hotshot_types::traits::block_contents::Transaction as HotShotTransaction; use hotshot_types::{ traits::{BlockPayload, EncodeBytes}, utils::BuilderCommitment, @@ -87,13 +86,7 @@ impl Payload { // add each tx to its namespace let mut ns_builders = BTreeMap::::new(); for tx in transactions.into_iter() { - let mut tx_size = 0; - if !ns_builders.contains_key(&tx.namespace()) { - // each new namespace adds overhead - tx_size += tx.minimum_block_size(true); - } else { - tx_size += tx.minimum_block_size(false); - } + let tx_size = tx.size_in_block(!ns_builders.contains_key(&tx.namespace())); if tx_size > max_block_byte_len { // skip this transaction since it exceeds the block size limit diff --git a/types/src/v0/impls/transaction.rs b/types/src/v0/impls/transaction.rs index 638ffa8302..d2a15cc1ed 100644 --- a/types/src/v0/impls/transaction.rs +++ b/types/src/v0/impls/transaction.rs @@ -62,6 +62,15 @@ impl Transaction { self.payload } + pub fn size_in_block(&self, new_ns: bool) -> u64 { + if new_ns { + // each new namespace adds overhead, therefore it includes `NsTableBuilder::entry_byte_len() + NsPayloadBuilder::tx_table_header_byte_len()` + self.minimum_block_size() + } else { + (self.payload().len() + NsPayloadBuilder::tx_table_entry_byte_len()) as u64 + } + } + #[cfg(any(test, feature = "testing"))] pub fn random(rng: &mut dyn rand::RngCore) -> Self { use rand::Rng; @@ -82,11 +91,11 @@ impl Transaction { } impl HotShotTransaction for Transaction { - fn minimum_block_size(&self, new_ns: bool) -> u64 { - let mut len = self.payload().len() + NsPayloadBuilder::tx_table_entry_byte_len(); - if new_ns { - len += NsTableBuilder::entry_byte_len() + NsPayloadBuilder::tx_table_header_byte_len(); - } + fn minimum_block_size(&self) -> u64 { + let len = self.payload().len() + + NsPayloadBuilder::tx_table_entry_byte_len() + + NsTableBuilder::entry_byte_len() + + NsPayloadBuilder::tx_table_header_byte_len(); len as u64 } } From 1809cc87af72648b15439a8a8e1024609b2a93da Mon Sep 17 00:00:00 2001 From: Sishan Long Date: Mon, 28 Oct 2024 14:44:03 -0700 Subject: [PATCH 3/4] upd comment --- types/src/v0/impls/transaction.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/src/v0/impls/transaction.rs b/types/src/v0/impls/transaction.rs index d2a15cc1ed..663c0365c6 100644 --- a/types/src/v0/impls/transaction.rs +++ b/types/src/v0/impls/transaction.rs @@ -64,7 +64,8 @@ impl Transaction { pub fn size_in_block(&self, new_ns: bool) -> u64 { if new_ns { - // each new namespace adds overhead, therefore it includes `NsTableBuilder::entry_byte_len() + NsPayloadBuilder::tx_table_header_byte_len()` + // each new namespace adds overhead + // here self.minimum_block_size() = `self.payload().len() + NsPayloadBuilder::tx_table_entry_byte_len() + NsTableBuilder::entry_byte_len() + NsPayloadBuilder::tx_table_header_byte_len()` self.minimum_block_size() } else { (self.payload().len() + NsPayloadBuilder::tx_table_entry_byte_len()) as u64 From 9bf604deeffa0a66b07ce1f07235cbdcf17d9066 Mon Sep 17 00:00:00 2001 From: Sishan Long Date: Mon, 28 Oct 2024 17:42:32 -0700 Subject: [PATCH 4/4] bump hotshot --- Cargo.lock | 58 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 28 +++++++++++++------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0aaae2dc2d..e44c9b50b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4112,8 +4112,8 @@ dependencies = [ [[package]] name = "hotshot" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "async-broadcast", @@ -4161,7 +4161,7 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "async-trait", "clap", @@ -4180,7 +4180,7 @@ dependencies = [ [[package]] name = "hotshot-builder-core" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#784fe95fa235ee8404fd10c1359b7cde0ef5a0ba" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=hotshot/rc-0.5.79#8953206c7d6b4f21c3536c3b2615d7ea5223f735" dependencies = [ "anyhow", "async-broadcast", @@ -4237,7 +4237,7 @@ dependencies = [ [[package]] name = "hotshot-events-service" version = "0.1.49" -source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?branch=sishan/trait_builder_transaction#085b911bd7611021c44f0a314ce6b636b0547439" +source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?branch=hotshot/rc-0.5.79#2cdc6bf36bccecd5574ee193f3408705f051ef45" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -4262,8 +4262,8 @@ dependencies = [ [[package]] name = "hotshot-example-types" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "async-broadcast", @@ -4296,8 +4296,8 @@ dependencies = [ [[package]] name = "hotshot-fakeapi" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4316,8 +4316,8 @@ dependencies = [ [[package]] name = "hotshot-macros" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "derive_builder", "proc-macro2", @@ -4327,8 +4327,8 @@ dependencies = [ [[package]] name = "hotshot-orchestrator" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4357,7 +4357,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" version = "0.1.62" -source = "git+https://github.com/EspressoSystems/hotshot-query-service?branch=sishan/trait_builder_transaction#0ccd2ff2c5b8c5c68586e43d8275090a0b6d68bf" +source = "git+https://github.com/EspressoSystems/hotshot-query-service?branch=hotshot/rc-0.5.79#ed3b3026b65a2d1566cc0ae3f5c3bf21f9bc9ba9" dependencies = [ "anyhow", "ark-serialize", @@ -4409,8 +4409,8 @@ dependencies = [ [[package]] name = "hotshot-stake-table" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "ark-bn254", "ark-ed-on-bn254", @@ -4471,8 +4471,8 @@ dependencies = [ [[package]] name = "hotshot-task" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "async-broadcast", @@ -4487,8 +4487,8 @@ dependencies = [ [[package]] name = "hotshot-task-impls" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "async-broadcast", @@ -4525,8 +4525,8 @@ dependencies = [ [[package]] name = "hotshot-testing" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "async-broadcast", @@ -4572,7 +4572,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "ark-bn254", @@ -5833,8 +5833,8 @@ dependencies = [ [[package]] name = "libp2p-networking" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "anyhow", "async-compatibility-layer", @@ -6223,7 +6223,7 @@ dependencies = [ [[package]] name = "marketplace-builder-core" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#784fe95fa235ee8404fd10c1359b7cde0ef5a0ba" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=hotshot/rc-0.5.79#8953206c7d6b4f21c3536c3b2615d7ea5223f735" dependencies = [ "anyhow", "async-broadcast", @@ -6265,7 +6265,7 @@ dependencies = [ [[package]] name = "marketplace-builder-shared" version = "0.1.51" -source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=sishan/trait_builder_transaction#784fe95fa235ee8404fd10c1359b7cde0ef5a0ba" +source = "git+https://github.com/EspressoSystems/marketplace-builder-core?branch=hotshot/rc-0.5.79#8953206c7d6b4f21c3536c3b2615d7ea5223f735" dependencies = [ "anyhow", "async-broadcast", @@ -10742,8 +10742,8 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "utils" -version = "0.5.78" -source = "git+https://github.com/EspressoSystems/hotshot?branch=sishan/trait_builder_transaction#10983f5596f2c6149d31d748f103134539329024" +version = "0.5.79" +source = "git+https://github.com/EspressoSystems/hotshot?branch=bump/rc-0.5.79#b704eb86fffd00e29361906d2315a001e2275af9" dependencies = [ "tracing", ] diff --git a/Cargo.toml b/Cargo.toml index 25a029d564..d289faa182 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,24 +57,24 @@ dyn-clone = "1.0" ethers = { version = "2.0", features = ["solc"] } futures = "0.3" -hotshot = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } +hotshot = { git = "https://github.com/EspressoSystems/hotshot", branch = "bump/rc-0.5.79" } # Hotshot imports -hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "sishan/trait_builder_transaction" } -hotshot-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "sishan/trait_builder_transaction" } -marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "sishan/trait_builder_transaction" } -marketplace-builder-shared = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "sishan/trait_builder_transaction" } -hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", branch = "sishan/trait_builder_transaction" } -hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } -hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", branch = "sishan/trait_builder_transaction" } -hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } +hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", branch = "bump/rc-0.5.79" } +hotshot-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "hotshot/rc-0.5.79" } +marketplace-builder-core = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "hotshot/rc-0.5.79" } +marketplace-builder-shared = { git = "https://github.com/EspressoSystems/marketplace-builder-core", branch = "hotshot/rc-0.5.79" } +hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", branch = "hotshot/rc-0.5.79" } +hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", branch = "bump/rc-0.5.79" } +hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", branch = "hotshot/rc-0.5.79" } +hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", branch = "bump/rc-0.5.79" } hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" } -hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } -hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } -hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } -libp2p-networking = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } +hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", branch = "bump/rc-0.5.79" } +hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", branch = "bump/rc-0.5.79" } +hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "bump/rc-0.5.79" } +libp2p-networking = { git = "https://github.com/EspressoSystems/hotshot", branch = "bump/rc-0.5.79" } hotshot-contract-adapter = { version = "0.1.0", path = "contracts/rust/adapter" } # Temporary, used to pull in the mock auction results provider -hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "sishan/trait_builder_transaction" } +hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", branch = "bump/rc-0.5.79" } # Push CDN imports cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", features = [