EspressoSystems / HotShot

http://hotshot.docs.espressosys.com/
101 stars 25 forks source link

[CX-Marketplace] - Update Sequencing Fees to Support Multiple Fees Per Block #3371

Open jparr721 opened 1 week ago

jparr721 commented 1 week ago

What is this task and why do we need to work on it?

Develop an updated API to handle multiple sequencing fees per block.

HotShot needs to be able to accept multiple fees for a block to allow for multiple builders to submit bundles with requisite fees as a result of the Solver’s allocation result. Because of this, we’ll need to extend the flow of the Transactions task to support in-loop web requests depending on which version of the code we’re running. The existing flow in the Transactions task is as follows:

HotShotEvent::ViewChange() => {
...
    let block = {
        if self
            .decided_upgrade_certificate
            .as_ref()
            .is_some_and(|cert| cert.upgrading_in(block_view))
        {
            None
        } else {
            self.wait_for_block().await
        }
    };

    if let Some(BuilderResponses {
        block_data,
        blocks_initial_info,
        block_header,
    }) = block
    {
        // Broadcast the block
        ...
    } else {
        // If we couldn't get a block, send an empty block
        warn!(
            "Failed to get a block for view {:?}, proposing empty block",
            view
        );
            // Construct a null block
            ...
    };
...
}

This will be one of the first blocks of versioned code that we interact with. In this, we’ll adjust the wait logic to instead query the solver service via the Sequencer by leveraging the versioning check (defined below) to execute the proper code path depending on what version of hotshot we’re interacting with.

HotShotEvent::ViewChange() => {
...
    let blocks = if self.version >= Marketplace {
            let results = self.auction_results_client.fetch_auction_result(
                block_view
            ).await?;
                        let urls = results.map(|res| res.url()).collect();
            let bundles = self.query_all_builders(urls).await?;

            // Build the block
            let bundle = PackedBundle {
                               encoded_transactions: bundles.transactions.as_bytes(),
                                pub metadata: <TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata,
                                view_number: block_view,
                                bid_fees: bundles.bid_fees.concat(),
                                sequencing_fees:  bundles.sequencing_fees.concat(),
                                vid_precompute: vid_precompute(bundles), // This method exists

                       }
    } else {
        Some(vec1![self.wait_for_block().await])
    };
...
}

What work will need to be done to complete this task?

No response

Are there any other details to include?

Confirm with @QuentinI or @nyospe about the details of computing the block fields from the bundles.

What are the acceptance criteria to close this issue?

Tests are written and pass for the various code paths.

Branch work will be merged to (if not the default branch)

No response