Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Conversation

@Wazzymandias
Copy link
Contributor

@Wazzymandias Wazzymandias commented May 9, 2023

📝 Summary

  • Fix rate limit bug that allowed more builder submissions than desired
  • Expose FLASHBOTS_BUILDER_RATE_LIMIT_DURATION and FLASHBOTS_BUILDER_BURST_LIMIT environment variables
  • Update builder submission logic such that submissions are sent near end of slot

🧪 Testing

  • Testing was done with test builder deployed on production mainnet

Without builder submission change

image

With builder submission change

image

TL;DR

  • Prior to change, builder submissions happened roughly between ~t-11 to ~t+3 where t is the time of slot s
  • After change, builder submissions happen roughly between ~t-4 to ~t+3, which is desired

📚 References

Untitled


… limit, update submit logic such that submissions happen near end of slot
@Wazzymandias Wazzymandias changed the title Wasif/build 295 submission rate [build-295] Improve Builder submission rate May 9, 2023
@Wazzymandias Wazzymandias marked this pull request as ready for review May 22, 2023 18:39
@Wazzymandias Wazzymandias requested a review from dvush May 22, 2023 19:00
args.limiter = rate.NewLimiter(rate.Every(RateLimitIntervalDefault), RateLimitBurstDefault)
}

if args.builderBlockResubmitInterval == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if this shouldn't be the caller's responsibility (same for the above)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if this shouldn't be the caller's responsibility (same for the above)

I have it in both places. In general I agree with you re: caller's responsibility. However I would want to return an error for invalid inputs but the function signature would need to be updated. I didn't want to do that work in this PR - happy to discuss

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd make it the responsibility of the caller still, since you don't really validate the value

Copy link
Contributor Author

@Wazzymandias Wazzymandias May 25, 2023

Choose a reason for hiding this comment

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

I'd make it the responsibility of the caller still, since you don't really validate the value

For now what's wrong with having it in both places? I'm worried that without the defensive check in the receiver, we can easily have a resubmit interval of 0. A resubmit interval of 0 could cause some very strange and difficult to debug behavior since we're using it for retry loop. My preference would rather be to refactor the function signature in the future such that a 0 value returns an error.

@Wazzymandias Wazzymandias requested a review from Ruteri May 25, 2023 00:16
args.limiter = rate.NewLimiter(rate.Every(RateLimitIntervalDefault), RateLimitBurstDefault)
}

if args.builderBlockResubmitInterval == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd make it the responsibility of the caller still, since you don't really validate the value

if parentBlock == nil {
log.Warn("Block hash not found in blocktree", "head block hash", attrs.HeadHash)
return errors.New("parent block not found in blocktree")
return fmt.Errorf("parent block hash not found in block tree given head block hash %s", attrs.HeadHash)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is HeadHash a string? Same for vd.Pubkey couple lines above

// Avoid submitting early into a given slot. For example if slots have 12 second interval, submissions should
// not begin until 8 seconds into the slot.
slotTime := time.Unix(int64(attrs.Timestamp), 0).UTC()
submitTime := slotTime.Add(-SubmissionDelaySecondsDefault)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I find this a bit strange
I'm not sure if the semantics work out, since we don't actually know what's the submit time - here it's defined as slot time - submission delay, which could use a different name. Maybe slot sumission start time? Also the time is not really a delay, it's actually the other way around - its something like a ramp up time
I'd also add a sanity check for attrs.Timestamp < SubmissionDelaySecondsDefault.

waitUntilSubmitTime = func(waitUntil time.Time) (ok bool) {
now := time.Now().UTC()
if waitUntil.UTC().Before(now) {
waitUntil = now
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't this just be return true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not necessarily i think - in the time the function is invoked i want to make sure the context hasn't been cancelled

@Wazzymandias Wazzymandias merged commit 66893df into main May 26, 2023
@Wazzymandias Wazzymandias deleted the wasif/build-295-submission-rate branch May 26, 2023 20:12
avalonche pushed a commit that referenced this pull request Jul 6, 2023
- Prior to change, builder submissions happened roughly between ~t-11 to ~t+3 where t is the time of slot s
- After change, builder submissions happen roughly between ~t-4 to ~t+3, which is desired

* Add bug fix for rate limit

* Expose environment variables that adjust builder rate limit and burst limit, update submit logic such that submissions happen near end of slot

* Update submit loop function

* Update conditional in resubmit loop

* Update rate limit variable name

* Create constant for default burst on builder rate limit

* Use CLI flags instead of bespoke environment variables for builder rate limit settings

* Fix typo

* Update logs for more data analysis

* Expose builder block resubmit interval as CLI flag and environment variable

* Update variable name for default builder block resubmit interval

* Fix wait time when timestamp is not passed in to address failures in unit tests

* Update README

* Update comments

* Fix when error log occurs

* Update log

* Update check

* Update go mod
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants