-
Notifications
You must be signed in to change notification settings - Fork 153
feat(mempool): Optimistic Proposals #930
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
base: feat/krakatoa
Are you sure you want to change the base?
Conversation
mempool/proposal_builder.go
Outdated
| latestProposal: &abci.ResponsePrepareProposal{}, | ||
| done: make(chan struct{}), | ||
| } | ||
| go pb.loop() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
551c3ee to
928c11c
Compare
mempool/proposal_builder.go
Outdated
| go func() { | ||
| start := time.Now() | ||
| defer func() { telemetry.MeasureSince(start, proposalCreationDurationKey) }() | ||
|
|
||
| // We create a per goroutine instance of the ProposalHandler | ||
| // since it the internal txSelector is not thread safe. | ||
| abciProposalHandler := baseapp.NewDefaultProposalHandler(pb.evmMempool, pb.txVerifier) | ||
| abciProposalHandler.SetSignerExtractionAdapter( | ||
| NewEthSignerExtractionAdapter( | ||
| sdkmempool.NewDefaultSignerExtractionAdapter(), | ||
| ), | ||
| ) | ||
| abciProposalHandler.SetTxSelector(NewNoCopyProposalTxSelector()) | ||
|
|
||
| // TODO: there is an issue that must be solved here. | ||
| // CometBFT typically supplies this value in the | ||
| // PrepareProposalRequest, it uses the MaxBlockBytes as | ||
| // used here, and then subtracts away the space that it | ||
| // knows will be used for storing encoding info, header | ||
| // info, validator commits, and evidence. We do not have | ||
| // access to that info at this point. | ||
| // | ||
| // One possible solution would be to introduce a new ABCI | ||
| // method for CometBFT to inform the application of the | ||
| // smaller MaxTxBytes immediately after Commit is | ||
| // processed, which is when we need to start building | ||
| // proposals. | ||
| const blockOverheadBytes = 2000 // 2000 will suffice for comets overhead assuming 5 vals and no evidence | ||
| maxTxBytes := pb.app.GetConsensusParams(proposalContext).Block.MaxBytes - blockOverheadBytes | ||
|
|
||
| req := &abci.RequestPrepareProposal{ | ||
| MaxTxBytes: maxTxBytes, | ||
| Height: proposalContext.BlockHeight(), | ||
| } | ||
|
|
||
| // TODO: there is a lot of state setup done in baseapp that happens | ||
| // before the PrepareProposalHandler is called. I don't think this | ||
| // is actually required here, but this should be investigated more. | ||
| resp, err := abciProposalHandler.PrepareProposalHandler()(proposalContext, req) | ||
| if err != nil { | ||
| pb.logger.Error("failed to prepare proposal", "height", req.Height, "err", err) | ||
| resp = &abci.ResponsePrepareProposal{} | ||
| } | ||
| pb.setLatestProposal(proposalContext.BlockHeight(), time.Since(start), resp) | ||
| pb.logger.Debug("created a new proposal", "for_height", proposalContext.BlockHeight()) | ||
|
|
||
| inflightProposals-- | ||
| telemetry.SetGauge(float32(inflightProposals), inflightProposalsKey) | ||
| }() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
mempool/proposal_builder.go
Outdated
| telemetry.SetGauge(float32(inflightProposals), inflightProposalsKey) | ||
|
|
||
| go func() { | ||
| start := time.Now() |
Check warning
Code scanning / CodeQL
Calling the system time Warning
…s at that height have been created
3605d35 to
f0a0784
Compare
mempool/proposal_builder.go
Outdated
| } | ||
|
|
||
| func (pb *ProposalBuilder) waitForProposalCreation() { | ||
| defer func(t0 time.Time) { telemetry.MeasureSince(t0, prepareProposalWaitDuration) }(time.Now()) |
Check warning
Code scanning / CodeQL
Calling the system time Warning
…ith abci methods, lives on evmd app
… proposal handler
4f5580e to
31a1834
Compare
Description
Kicks off proposal creation immediately after commit, so that hopefully when we go to propose, a proposal has already been created and we can return instantly.
This is having some (likely) locking issues where the prepare_proposal abci time is low, but from CometBFT's point of view, it is taking > the Commit step's duration. Same with process proposal, which typically is around 50ms for a 50mil max gas block, but here it is around 200ms for some unknown reason.
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
mainbranch