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

Implement BidTx #1633

Closed
wants to merge 27 commits into from
Closed

Implement BidTx #1633

wants to merge 27 commits into from

Conversation

tbro
Copy link
Contributor

@tbro tbro commented Jun 20, 2024

This PR:

This PR itroduces FullNetworkTx by way of a single enum variant, BidTx. To meet upcoming goals we only need BidTx but having it nested in long term structure may be helpful. There is a tiny bit of test coverage to ensure a moderate degree of santity.

This is a DRAFT and exists for collaboration and to gather feedback.

Key places to review:

Most of the juicy bits are in auction.rs. Header in header.rs has been given some useful methods (mocks for now) and validation logic in state.rs has been updated to execute the transaction. None of the logic is complete or refined, but it more or less covers the breadth of requirements for the first iteration of BidTx.

How to test this PR:

Tests are currently testing, you can run cargo test if you like.

Things tested

There is currently a test for verifying signature of a mock BidTx.

sequencer/src/auction.rs Outdated Show resolved Hide resolved
sequencer/src/auction.rs Outdated Show resolved Hide resolved
Comment on lines 20 to 71
struct SequencerKey;

// for MVP-0(-1) (JIT)
// Sum of all sequencing fee match current check
// builder signature no longer includes payload
// new fee info flag (fee or bid)

pub struct MarketplaceResults {
/// Slot these results are for
slot: Slot,
/// Bids that did not win, initially all bids are added to this,
/// and then the winning bids are removed
pending_bids: Vec<BidTx>,
/// Map of winning sequencer public keys to the bundle of namespaces they bid for
winner_map: HashMap<SequencerKey, HashSet<NamespaceId>>,
/// Whether refunds have been processed for this slot
refunds_processed: bool,
}

// - needs to be configured in genesis block
// - needs to be updatable
/// Configuration for the auction system
struct AuctionConfig {
bid_phase_num_views: NonZeroU64,
auction_phase_num_views: NonZeroU64,
sequencing_phase_num_views: NonZeroU64,
}

/// Uniquely identifies an auction for sequencing rights of namespaces in the network
#[derive(Clone, Copy)]
struct AuctionId(u64);

/// Uniquely identifies one auction phase for a specific auction
#[derive(Clone, Copy)]
struct AuctionPhaseId(AuctionId, AuctionPhaseKind);

/// Describes one auction phase for a specific auction
#[derive(Clone, Copy)]
struct AuctionPhase {
id: AuctionPhaseId,
kind: AuctionPhaseKind,
start: ViewNumber,
end: ViewNumber,
}

/// Describes the 3 kinds of phases an active auction can be in
#[derive(Clone, Copy, Eq, PartialEq)]
enum AuctionPhaseKind {
Bid,
Assign,
Sequence,
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can remove all this for now (but let's keep in on a branch for later when we need it)

/// from this sequencer if they win the auction
url: Url,
/// The slot this bid is for
slot: Slot,
Copy link
Member

Choose a reason for hiding this comment

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

Let's change this to be of ViewNumber type. The JIT auction won't have a concept of slots. See here for reference: https://www.notion.so/espressosys/Yet-Another-Marketplace-Spec-WIP-c09873314c8241e4b4e6463594d44bb6?pvs=4#7a316e557df44de7a834f82182d2b7fc

bid_amount: FeeAmount,
// TODO What is the correct type? What do we use this for?
/// The public key of this sequencer
public_key: SequencerKey,
Copy link
Member

Choose a reason for hiding this comment

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

This should be the public key of the builder, which I think is BuilderSignatureKey type

let key = FeeAccount::test_key_pair();
let nsid = NamespaceId::from(999);
Self {
url: Url::from_str("htts://sequencer:3939/request_budle").unwrap(),
Copy link
Member

Choose a reason for hiding this comment

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

This URL will be just the base URL of the builder's API: https://<builder_url>.

Comment on lines 212 to 217
if get_phase() != AuctionPhaseKind::Bid {
return Err((
ExecutionError::InvalidPhase,
FullNetworkTx::Bid(self.clone()),
));
}
Copy link
Member

Choose a reason for hiding this comment

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

We can remove this for the JIT auction

.map_err(|e| (e, FullNetworkTx::Bid(self.clone())))?;

// TODO do we still do this in JIT auction?
// store_in_marketplace_state();
Copy link
Member

Choose a reason for hiding this comment

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

No, we don't need to store any state for the JIT auction.

// TODO I'm not sure how phases will work in JIT
pub fn get_phase() -> AuctionPhaseKind {
AuctionPhaseKind::Bid
}

Copy link
Member

Choose a reason for hiding this comment

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

There are no phases in the JIT auction

Comment on lines 102 to 105
// /// refund flag set at the beginning of new slots
// /// In extreme cases, more than one slot may need to be refunded,
// /// hence this data structure
// pub refund_bids: HashSet<Slot>,
Copy link
Member

Choose a reason for hiding this comment

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

We can delete this for now.

Comment on lines 85 to 87
// TODO
// /// Map of Marketplace Results.
// slot_map: HashMap<Slot, MarketplaceResults>,
Copy link
Member

Choose a reason for hiding this comment

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

The JIT auction no longer has the marketplace results struct, so we can delete this.

@tbro tbro requested a review from elliedavidson July 2, 2024 18:32
sequencer/src/auction.rs Outdated Show resolved Hide resolved
tbro added a commit that referenced this pull request Jul 11, 2024
`BidTx` as a varian of `FullNetworkTx`. Includes some tests.

Closes #1633
@tbro tbro mentioned this pull request Jul 11, 2024
tbro added a commit that referenced this pull request Jul 11, 2024
`BidTx` as a varian of `FullNetworkTx`. Includes some tests.

Closes #1633
@tbro
Copy link
Contributor Author

tbro commented Jul 11, 2024

Closing superseded by #1696

@tbro tbro closed this Jul 11, 2024
tbro added a commit that referenced this pull request Jul 17, 2024
`BidTx` as a varian of `FullNetworkTx`. Includes some tests.

Closes #1633
@Ancient123 Ancient123 deleted the tb/full_network_tx branch August 29, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants