Skip to content

Comments

Bwilson/proxyd fix headers process response#1698

Closed
optimisticben wants to merge 2 commits intodevelopfrom
bwilson/proxyd-fix-headers-process-response
Closed

Bwilson/proxyd fix headers process response#1698
optimisticben wants to merge 2 commits intodevelopfrom
bwilson/proxyd-fix-headers-process-response

Conversation

@optimisticben
Copy link
Contributor

Description
Should have been 2 PRs, my bad.

Fix:
We're striping all headers from client requests, this is probably a good thing!
Geth requires the Content-type header is present though (infra providers seem to let this slide, lol)

// Required when connecting directly to geth
	httpReq.Header.Add("Content-type", "application/json")

Added:
Process RPC responses and create metrics based on errors.

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2021

🦋 Changeset detected

Latest commit: dbbb36e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eth-optimism/proxyd Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov-commenter
Copy link

codecov-commenter commented Nov 4, 2021

Codecov Report

Merging #1698 (dbbb36e) into develop (c057424) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1698   +/-   ##
========================================
  Coverage    76.52%   76.52%           
========================================
  Files           82       82           
  Lines         3041     3041           
  Branches       466      466           
========================================
  Hits          2327     2327           
  Misses         714      714           
Flag Coverage Δ
batch-submitter 61.74% <ø> (ø)
contracts 86.05% <ø> (ø)
core-utils 63.27% <ø> (ø)
data-transport-layer 37.86% <ø> (ø)
message-relayer 83.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c057424...dbbb36e. Read the comment docs.

if err != nil {
return nil, wrapErr(err, "error unmarshaling response from forward")
}
go processReponse(responseBody)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should process the response on the existing goroutine - the overhead of spawning the new goroutine is likely higher the overhead of processing the response itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My concern was slowing down the request response to the client.

The processing is pretty light right now, but I could imagine it getting heavier.

Premature optimization 😅


return resB, nil
}
func processReponse(response RPCResponse) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

*RPCResponse to avoid copying the struct.

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 did a copy on purpose because of the go routine. Does that matter, or nah?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nah. You can safely pass around pointers without race conditions as long as you don't modify the data the pointer points to without a mutex.

noneTooLowRegex := regexp.MustCompile(`nonce too low`)
gasPriceTooHighRegex := regexp.MustCompile(`gas price too high`)
gasPriceTooLowRegex := regexp.MustCompile(`gas price too low`)
invalidParametersRegex := regexp.MustCompile(`invalid parameters`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will recompile the regexes on every request. Instead, create these regexes as variables at the top of the file.

That said - if all we're doing is a substring match, then strings.Contains will likely be more efficient.

i int64
}

type RPCResponse struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this struct already exists - see RPCRes.

@mslipper
Copy link
Collaborator

mslipper commented Nov 4, 2021

I recommend we merge #1679 followed by this PR. The metrics collected are different there, and we'll need to wire up the new error metrics defined here with the WS handler as well.

@tynes
Copy link
Contributor

tynes commented Nov 4, 2021

I recommend we merge #1679 followed by this PR. The metrics collected are different there, and we'll need to wire up the new error metrics defined here with the WS handler as well.

#1679 has been merged, this PR can be rebased on top of that

@mslipper mslipper closed this Nov 5, 2021
@optimisticben optimisticben deleted the bwilson/proxyd-fix-headers-process-response branch December 1, 2021 17:27
theochap pushed a commit that referenced this pull request Dec 10, 2025
## Overview

Adds a path for finalizing L2 blocks, based off of the L1 block they
were derived from. To accomplish this:
1. The derivation pipeline now attaches the L1 block that the L2 block
was derived from, within `OpAttributesWithParent`.
2. The DA watcher actor now watches a stream of finalized L1 blocks,
polled every 1m.
3. The engine actor now holds onto a map of `l1_block_number =>
highest_l2_block_in_epoch`, saturated when it receives attributes from
the derivation actor.
- When a new finalized L1 block is observed by the engine actor, it will
find the highest L2 block whose batch data is contained within the
finalized L1 chain, and finalize it (if it knows of any.)

This approach is different than suggested by the tickets, but results in
a more slim outcome that takes advantage of existing actors.

### Periphery changes

- Some refactoring of the `OpAttributesWithParent` type.
- The sync start algorithm now stops safe block traversal at the
finalized head, to ensure it never assigns a safe block past it.
- The `L1WatcherRpc` now uses a custom `BlockStream`, since alloy's
`watch_blocks` stream doesn't dedup nor allow for observing anything
other than head block updates.

### Result

Finalized blocks are correctly streaming in 😄 

<img width="1228" alt="Screenshot 2025-05-24 at 5 09 01 PM"
src="https://github.com/user-attachments/assets/609184a5-35b8-4b04-a124-eeece8ef53e4"
/>

### Meta

closes #1693 
closes #1694 
closes #1695 
closes #1696 
closes #1698
theochap pushed a commit that referenced this pull request Jan 14, 2026
## Overview

Adds a path for finalizing L2 blocks, based off of the L1 block they
were derived from. To accomplish this:
1. The derivation pipeline now attaches the L1 block that the L2 block
was derived from, within `OpAttributesWithParent`.
2. The DA watcher actor now watches a stream of finalized L1 blocks,
polled every 1m.
3. The engine actor now holds onto a map of `l1_block_number =>
highest_l2_block_in_epoch`, saturated when it receives attributes from
the derivation actor.
- When a new finalized L1 block is observed by the engine actor, it will
find the highest L2 block whose batch data is contained within the
finalized L1 chain, and finalize it (if it knows of any.)

This approach is different than suggested by the tickets, but results in
a more slim outcome that takes advantage of existing actors.

### Periphery changes

- Some refactoring of the `OpAttributesWithParent` type.
- The sync start algorithm now stops safe block traversal at the
finalized head, to ensure it never assigns a safe block past it.
- The `L1WatcherRpc` now uses a custom `BlockStream`, since alloy's
`watch_blocks` stream doesn't dedup nor allow for observing anything
other than head block updates.

### Result

Finalized blocks are correctly streaming in 😄 

<img width="1228" alt="Screenshot 2025-05-24 at 5 09 01 PM"
src="https://github.com/user-attachments/assets/609184a5-35b8-4b04-a124-eeece8ef53e4"
/>

### Meta

closes #1693 
closes #1694 
closes #1695 
closes #1696 
closes #1698
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants