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 BlockSpaceAllocator state machine #778

Conversation

sug0
Copy link
Collaborator

@sug0 sug0 commented Nov 14, 2022

Separated from #774

Allocate space for the different TxBin instances depending on the current phase of a type-level state machine. This will be useful to allow, e.g. decrypted txs to use as much space as needed, or to disallow including user encrypted txs in blocks when space is a critical resource needed for protocol level txs.

Unit tests will be added in a new PR, to simplify the review process.

This was referenced Nov 14, 2022
@sug0 sug0 force-pushed the tiago/ethbridge/impl-tx-bins-state-machine branch from be62303 to 17c7c78 Compare November 14, 2022 16:41
@sug0 sug0 marked this pull request as draft November 21, 2022 13:07
@sug0 sug0 marked this pull request as ready for review November 21, 2022 13:41
@sug0 sug0 marked this pull request as draft November 22, 2022 09:24
Copy link
Contributor

@james-chf james-chf left a comment

Choose a reason for hiding this comment

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

The PRs are in draft

Comment on lines +33 to +51
// TODO: what if a tx has a size greater than the threshold for
// its bin? how do we handle this? if we keep it in the mempool
// forever, it'll be a DoS vec, as we can make nodes run out of
// memory! maybe we should allow block decisions for txs that are
// too big to fit in their respective bin? in these special block
// decisions, we would only decide proposals with "large" txs??
//
// MAYBE: in the state machine impl, reset to beginning state, and
// and alloc space for large tx right at the start. the problem with
// this is that then we may not have enough space for decrypted txs

// TODO: panic if we don't have enough space reserved for a
// decrypted tx; in theory, we should always have enough space
// reserved for decrypted txs, given the invariants of the state
// machine

// TODO: refactor our measure of space to also reflect gas costs.
// the total gas of all chosen txs cannot exceed the configured max
// gas per block, otherwise a proposal will be rejected!
Copy link
Contributor

Choose a reason for hiding this comment

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

these could have GH issues

@sug0
Copy link
Collaborator Author

sug0 commented Nov 22, 2022

The PRs are in draft

@james-chf yeah I set them all to draft PRs, since the top priority right now is getting rid of digests. then these PRs will be based on those changes

@sug0 sug0 requested a review from james-chf November 25, 2022 15:43
@sug0 sug0 marked this pull request as ready for review November 25, 2022 15:43
Copy link
Contributor

@james-chf james-chf left a comment

Choose a reason for hiding this comment

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

will look at #774 to see how this PR is used

@sug0 sug0 marked this pull request as draft November 28, 2022 15:21
@sug0 sug0 requested a review from james-chf November 28, 2022 16:16
@sug0 sug0 marked this pull request as ready for review November 28, 2022 16:16
///
/// Signal the caller if the tx is larger than its max
/// allotted bin space.
fn try_dump(&mut self, tx: &[u8]) -> Result<(), AllocFailure> {
Copy link
Member

Choose a reason for hiding this comment

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

Could rename this error as Constipation. 💩

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

legit lol'd at this

@sug0 sug0 marked this pull request as draft November 29, 2022 10:40
@sug0 sug0 marked this pull request as ready for review November 29, 2022 11:07
@sug0 sug0 requested a review from batconjurer November 29, 2022 11:07
@sug0 sug0 merged commit 2a162d5 into tiago/ethbridge/optimize-block-proposal Dec 2, 2022
@sug0 sug0 deleted the tiago/ethbridge/impl-tx-bins-state-machine branch December 2, 2022 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants