-
Notifications
You must be signed in to change notification settings - Fork 69
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
Implement BidTx #1633
Conversation
sequencer/src/auction.rs
Outdated
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, | ||
} |
There was a problem hiding this comment.
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)
sequencer/src/auction.rs
Outdated
/// from this sequencer if they win the auction | ||
url: Url, | ||
/// The slot this bid is for | ||
slot: Slot, |
There was a problem hiding this comment.
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
sequencer/src/auction.rs
Outdated
bid_amount: FeeAmount, | ||
// TODO What is the correct type? What do we use this for? | ||
/// The public key of this sequencer | ||
public_key: SequencerKey, |
There was a problem hiding this comment.
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
sequencer/src/auction.rs
Outdated
let key = FeeAccount::test_key_pair(); | ||
let nsid = NamespaceId::from(999); | ||
Self { | ||
url: Url::from_str("htts://sequencer:3939/request_budle").unwrap(), |
There was a problem hiding this comment.
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>.
sequencer/src/auction.rs
Outdated
if get_phase() != AuctionPhaseKind::Bid { | ||
return Err(( | ||
ExecutionError::InvalidPhase, | ||
FullNetworkTx::Bid(self.clone()), | ||
)); | ||
} |
There was a problem hiding this comment.
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
sequencer/src/auction.rs
Outdated
.map_err(|e| (e, FullNetworkTx::Bid(self.clone())))?; | ||
|
||
// TODO do we still do this in JIT auction? | ||
// store_in_marketplace_state(); |
There was a problem hiding this comment.
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.
sequencer/src/auction.rs
Outdated
// TODO I'm not sure how phases will work in JIT | ||
pub fn get_phase() -> AuctionPhaseKind { | ||
AuctionPhaseKind::Bid | ||
} | ||
|
There was a problem hiding this comment.
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
sequencer/src/header.rs
Outdated
// /// 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>, |
There was a problem hiding this comment.
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.
sequencer/src/state.rs
Outdated
// TODO | ||
// /// Map of Marketplace Results. | ||
// slot_map: HashMap<Slot, MarketplaceResults>, |
There was a problem hiding this comment.
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.
FullNetworkTx for MVP-0 Auctions * we are currently only concerned with `BidTx` * there is some very basic coverage of essential functionality
cleanup
build a `BidTx` with `signed`
`BidTx` as a varian of `FullNetworkTx`. Includes some tests. Closes #1633
`BidTx` as a varian of `FullNetworkTx`. Includes some tests. Closes #1633
Closing superseded by #1696 |
`BidTx` as a varian of `FullNetworkTx`. Includes some tests. Closes #1633
This PR:
This PR itroduces
FullNetworkTx
by way of a single enum variant,BidTx
. To meet upcoming goals we only needBidTx
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
inheader.rs
has been given some useful methods (mocks for now) and validation logic instate.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 ofBidTx
.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
.