Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to hotshot rc-0.5.67 / marketplace #1784

Merged
merged 32 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7d813b0
update header::new
tbro Jul 24, 2024
e5507e3
Update to hotshot rc-0.5.66
tbro Jul 25, 2024
ee3aa28
update query-service
tbro Jul 26, 2024
f04b89f
Cargo.lock
tbro Jul 26, 2024
ff07652
cargo fmt
tbro Jul 26, 2024
ab55cf1
fix test
tbro Jul 26, 2024
89dc892
BlockMerkleTree should take Header enum
tbro Jul 26, 2024
2e1e213
bump some versions
tbro Jul 26, 2024
17ed30f
compilage
tbro Jul 26, 2024
23c2769
clippy
tbro Jul 26, 2024
0906697
lint
imabdulbasit Jul 25, 2024
8a2d6c2
lint tests
tbro Jul 26, 2024
c90c91e
fix pre-commit errors
tbro Jul 26, 2024
cafa8c9
Bump deps
QuentinI Jul 26, 2024
1a8f66e
fix charge_tx test
tbro Jul 29, 2024
faf9631
revert 1a8f66ec4aa0f0887327965aba110b83ac0d10f7
tbro Jul 29, 2024
30ebfc1
disable tx charge test for now
tbro Jul 29, 2024
85b8834
update reference headers for v3
tbro Jul 29, 2024
4e3b484
add `validate_builder_fee` test
tbro Jul 30, 2024
e7cf690
Merge remote-tracking branch 'origin/main' into tb/marketplace/update…
tbro Jul 30, 2024
908981a
remove duplicate lint thing
tbro Jul 30, 2024
def8b8b
conflict
tbro Jul 30, 2024
8205703
cargo sort
tbro Jul 30, 2024
bf97214
conflict
tbro Jul 30, 2024
6756e31
explicity test marketplace function
tbro Jul 30, 2024
c4a9a8e
Accept any signature verification that succeeds
tbro Jul 30, 2024
08e79cc
typo
tbro Jul 30, 2024
d4af112
Copy reference test changes from #1792
tbro Jul 30, 2024
f88f66a
revert unversioned data files
tbro Jul 30, 2024
212d82c
larger default max_block_size
tbro Jul 30, 2024
2622660
fix the lint thing again
tbro Jul 30, 2024
cd69ecc
fix typo
tbro Jul 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
339 changes: 286 additions & 53 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ dotenvy = "0.15"
ethers = { version = "2.0", features = ["solc"] }
futures = "0.3"

hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.64" }
hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.66" }
# Hotshot imports
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.64" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "rc-0.1.36" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "rc-0.1.35" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.64" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "rc-0.1.46" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.64" }
hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "rc-0.5.66" }
hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "rc-0.1.35" }
hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "rc-0.1.34" }
hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.66" }
hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "rc-0.1.48" }
hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.66" }
hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.64" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.64" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.64" }
hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.66" }
hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.66" }
hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.66" }
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 = "rc-0.5.64" }
hotshot-example-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "rc-0.5.66" }

# Push CDN imports
cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", features = [
Expand Down
2 changes: 2 additions & 0 deletions types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ tracing = { workspace = true }
trait-set = { workspace = true }
url = { workspace = true }
vbs = { workspace = true }
surf-disco = { workspace = true }
tide-disco = { workspace = true }
5 changes: 4 additions & 1 deletion types/src/v0/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use committable::Commitment;
use serde::{Deserialize, Serialize};
use vbs::version::Version;

use crate::{v0_1, v0_2, v0_3, ChainConfig};
use crate::{
v0_1::{self, ChainConfig},
v0_2, v0_3,
};

/// Each variant represents a specific minor version header.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
Expand Down
85 changes: 73 additions & 12 deletions types/src/v0/impls/auction.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
use super::state::ValidatedState;
use crate::{
eth_signature_key::{EthKeyPair, SigningError},
v0_1::ValidatedState,
v0_3::{BidTx, BidTxBody, FullNetworkTx},
v0_3::{BidTx, BidTxBody, FullNetworkTx, SolverAuctionResults},
FeeAccount, FeeAmount, FeeError, FeeInfo, NamespaceId,
};
use async_trait::async_trait;
use committable::{Commitment, Committable};
use ethers::types::Signature;
use hotshot_types::{
data::ViewNumber,
traits::{
auction_results_provider::HasUrls, node_implementation::ConsensusTime,
auction_results_provider::{AuctionResultsProvider, HasUrls},
node_implementation::{ConsensusTime, NodeType},
signature_key::BuilderSignatureKey,
},
};
use std::str::FromStr;
use thiserror::Error;
use tide_disco::error::ServerError;
use url::Url;
use vbs::version::StaticVersion;

pub fn mock_full_network_txs(key: Option<EthKeyPair>) -> Vec<FullNetworkTx> {
// if no key is supplied, use `test_key_pair`. Since default `BidTxBody` is
// signed with `test_key_pair`, it will verify successfully
let key = key.unwrap_or_else(FeeAccount::test_key_pair);
vec![FullNetworkTx::Bid(BidTx::mock(key))]
}

impl FullNetworkTx {
/// Proxy for `execute` method of each transaction variant.
Expand Down Expand Up @@ -93,11 +104,20 @@ impl BidTxBody {
pub fn amount(&self) -> FeeAmount {
self.bid_amount
}
/// get the view number
pub fn view(&self) -> ViewNumber {
self.view
}
/// Instantiate a `BidTxBody` containing the values of `self`
/// with a new `url` field.
pub fn with_url(self, url: Url) -> Self {
Self { url, ..self }
}

/// Get the cloned `url` field.
fn url(&self) -> Url {
self.url.clone()
}
}

impl Default for BidTxBody {
Expand Down Expand Up @@ -169,8 +189,7 @@ impl BidTx {
return Err(ExecutionError::UnresolvableChainConfig);
};

// TODO change to `bid_recipient` when this logic is finally enabled
let recipient = chain_config.fee_recipient;
let recipient = chain_config.bid_recipient.unwrap();
// Charge the bid amount
state
.charge_fee(FeeInfo::new(self.account(), self.amount()), recipient)
Expand Down Expand Up @@ -213,19 +232,61 @@ impl BidTx {
pub fn account(&self) -> FeeAccount {
self.body.account
}
/// get the view number
pub fn view(&self) -> ViewNumber {
self.body.view
}
/// Get the `url` field from the body.
fn url(&self) -> Url {
self.body.url()
}
}

impl HasUrls for BidTx {
/// Get the `url` field from the body.
fn urls(&self) -> Vec<Url> {
self.body.urls()
impl SolverAuctionResults {
pub fn winning_bids(&self) -> &[BidTx] {
&self.winning_bids
}
pub fn reserve_bids(&self) -> &[(NamespaceId, Url)] {
&self.reserve_bids
}
pub fn genesis() -> Self {
Self {
view_number: ViewNumber::genesis(),
winning_bids: vec![],
reserve_bids: vec![],
}
}
}

impl HasUrls for BidTxBody {
/// Get the cloned `url` field.
impl HasUrls for SolverAuctionResults {
fn urls(&self) -> Vec<Url> {
vec![self.url.clone()]
self.winning_bids()
.iter()
.map(|bid| bid.url())
.chain(self.reserve_bids().iter().map(|bid| bid.1.clone()))
.collect()
}
}

const SOLVER_URL: &str = "https://solver:1234";
Copy link
Contributor

Choose a reason for hiding this comment

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

this should come from env var?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes but it doesn't matter yet.

type Ver = StaticVersion<0, 3>;
type SurfClient<Ver> = surf_disco::Client<ServerError, Ver>;

#[async_trait]
impl<TYPES: NodeType> AuctionResultsProvider<TYPES> for SolverAuctionResults {
type AuctionResult = SolverAuctionResults;

/// Fetch the auction results.
async fn fetch_auction_result(
&self,
view_number: TYPES::Time,
) -> anyhow::Result<Self::AuctionResult> {
let resp = SurfClient::<Ver>::new(Url::from_str(SOLVER_URL).unwrap())
.get::<SolverAuctionResults>(&format!("/v0/api/auction_results/{}", *view_number))
.send()
.await
.unwrap();
Ok(resp)
}
}

Expand Down
13 changes: 9 additions & 4 deletions types/src/v0/impls/block/full_payload/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ use jf_vid::VidScheme;
use sha2::Digest;

use crate::{
ChainConfig, Index, Iter, NamespaceId, NodeState, NsIndex, NsPayload, NsPayloadBuilder,
NsPayloadRange, NsTable, NsTableBuilder, Payload, PayloadByteLen, SeqTypes, Transaction,
TxProof, ValidatedState,
v0::impls::{NodeState, ValidatedState},
v0_1::ChainConfig,
Index, Iter, NamespaceId, NsIndex, NsPayload, NsPayloadBuilder, NsPayloadRange, NsTable,
NsTableBuilder, Payload, PayloadByteLen, SeqTypes, Transaction, TxProof,
};

impl Payload {
Expand Down Expand Up @@ -146,7 +147,11 @@ impl BlockPayload<SeqTypes> for Payload {
}
};

Self::from_transactions_sync(transactions, chain_config, instance_state)
Self::from_transactions_sync(
transactions,
ChainConfig::from(chain_config),
instance_state,
)
}

// TODO avoid cloning the entire payload here?
Expand Down
72 changes: 5 additions & 67 deletions types/src/v0/impls/chain_config.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use std::str::FromStr;

use bytesize::ByteSize;
use committable::{Commitment, Committable};
use committable::Commitment;
use derive_more::From;
use ethers::types::U256;
use itertools::Either;
use sequencer_utils::{
impl_serde_from_string_or_integer, impl_to_fixed_bytes, ser::FromStringOrInteger,
};
use snafu::Snafu;
use std::str::FromStr;

use crate::{BlockSize, ChainConfig, ChainId, ResolvableChainConfig};
use crate::{BlockSize, ChainId};

impl_serde_from_string_or_integer!(ChainId);
impl_to_fixed_bytes!(ChainId, U256);
Expand Down Expand Up @@ -77,69 +76,6 @@ impl FromStringOrInteger for BlockSize {
}
}

impl Default for ChainConfig {
fn default() -> Self {
Self {
chain_id: U256::from(35353).into(), // arbitrarily chosen chain ID
max_block_size: 30720.into(),
base_fee: 0.into(),
fee_contract: None,
fee_recipient: Default::default(),
}
}
}

impl Committable for ChainConfig {
fn tag() -> String {
"CHAIN_CONFIG".to_string()
}

fn commit(&self) -> Commitment<Self> {
let comm = committable::RawCommitmentBuilder::new(&Self::tag())
.fixed_size_field("chain_id", &self.chain_id.to_fixed_bytes())
.u64_field("max_block_size", *self.max_block_size)
.fixed_size_field("base_fee", &self.base_fee.to_fixed_bytes())
.fixed_size_field("fee_recipient", &self.fee_recipient.to_fixed_bytes());
let comm = if let Some(addr) = self.fee_contract {
comm.u64_field("fee_contract", 1).fixed_size_bytes(&addr.0)
} else {
comm.u64_field("fee_contract", 0)
};
comm.finalize()
}
}

impl ResolvableChainConfig {
pub fn commit(&self) -> Commitment<ChainConfig> {
match self.chain_config {
Either::Left(config) => config.commit(),
Either::Right(commitment) => commitment,
}
}
pub fn resolve(self) -> Option<ChainConfig> {
match self.chain_config {
Either::Left(config) => Some(config),
Either::Right(_) => None,
}
}
}

impl From<Commitment<ChainConfig>> for ResolvableChainConfig {
fn from(value: Commitment<ChainConfig>) -> Self {
Self {
chain_config: Either::Right(value),
}
}
}

impl From<ChainConfig> for ResolvableChainConfig {
fn from(value: ChainConfig) -> Self {
Self {
chain_config: Either::Left(value),
}
}
}

#[derive(Clone, Debug, From, Snafu)]
pub struct ParseSizeError {
msg: String,
Expand All @@ -151,6 +87,8 @@ pub fn parse_size(s: &str) -> Result<u64, ParseSizeError> {

#[cfg(test)]
mod tests {
use crate::v0_3::{ChainConfig, ResolvableChainConfig};

use super::*;

#[test]
Expand Down
Loading
Loading