-
Notifications
You must be signed in to change notification settings - Fork 32
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
Cache submitter gas block #1465
Conversation
WalkthroughThis update introduces caching for gas blocks in different chains to improve performance. It also refines the GitHub workflow for label management, replacing a third-party action with a built-in GitHub action for better maintainability. Changes
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Files selected for processing (3)
- ethergo/submitter/export_test.go (4 hunks)
- ethergo/submitter/submitter.go (7 hunks)
- ethergo/submitter/submitter_test.go (3 hunks)
Additional comments (Suppressed): 11
ethergo/submitter/submitter_test.go (3)
2-9: The import of
math/big
has been moved from the bottom of the import block to the top. This change is acceptable as it does not affect the functionality of the code. However, it's a good practice to group standard library imports together and separate them from third-party imports for better readability.22-25: The import of
math/big
has been removed from this block. Ensure that this does not affect any functionality in the code that relies on this package.76-107: The new
TestGetGasBlock
function tests theGetGasBlock
method's behavior in both successful and failedHeaderByNumber
RPC call scenarios, and verifies the caching behavior when the RPC call fails. This is a good addition as it covers different scenarios and ensures that the caching mechanism works as expected.ethergo/submitter/export_test.go (4)
3-9: The import of
math/big
has been removed. Ensure that this does not affect any existing functionality that relies on this package.13-16: The import of
math/big
has been removed. Ensure that this does not affect any existing functionality that relies on this package.86-93: The
GetGasBlock
function has been added to theTestTransactionSubmitter
interface. Ensure that all implementations of this interface have been updated accordingly.100-106: The
GetGasBlock
function has been implemented in thetxSubmitterImpl
struct. This function is a wrapper around thegetGasBlock
function, which is presumably a private function in the same struct.ethergo/submitter/submitter.go (4)
64-71: The addition of
gasBlockCache
to thetxSubmitterImpl
struct is a good move for performance optimization. It allows the caching of gas blocks for different chains, which can reduce the number of RPC calls when theHeaderByNumber
call fails. However, please ensure that the cache is properly managed to avoid potential memory leaks or stale data.80-93: The
NewTransactionSubmitter
function has been updated to initialize thegasBlockCache
. This is a good practice as it ensures that the cache is ready for use when the transaction submitter is created.375-382: The
getGasBlock
function now accepts achainID
parameter. This is a breaking change and all calls to this function throughout the codebase should be updated to match the new signature. Also, the error handling has been improved to return the error when the gas block retrieval fails, which prevents a potential null pointer exception.412-434: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [397-434]
The
getGasBlock
function has been updated to support the caching mechanism. If theHeaderByNumber
RPC call fails, the function will attempt to load the gas block from the cache. If the gas block is not in the cache, an error is returned. This is a good approach as it provides a fallback mechanism when the RPC call fails. However, please ensure that the cache is updated regularly to avoid serving stale data.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #1465 +/- ##
===================================================
+ Coverage 50.69210% 50.84105% +0.14894%
===================================================
Files 356 366 +10
Lines 24274 25147 +873
Branches 267 268 +1
===================================================
+ Hits 12305 12785 +480
- Misses 10775 11122 +347
- Partials 1194 1240 +46
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Files selected for processing (1)
- ethergo/submitter/submitter.go (7 hunks)
Additional comments (Suppressed): 6
ethergo/submitter/submitter.go (6)
64-71: The addition of
gasBlockCache
to thetxSubmitterImpl
struct is a good approach to mitigate the risk of a null pointer when failing to get the gas block. It's a map that stores the gas block for different chains, which can be used as a fallback when fetching the gas block from the chain fails.80-93: The
NewTransactionSubmitter
function is updated to initialize thegasBlockCache
map. This is a necessary step to ensure that the cache is ready for use when the transaction submitter is created.374-381: The
setGasPrice
function now passes thechainID
to thegetGasBlock
function. This is a change in the function signature ofgetGasBlock
, so ensure that all calls to this function throughout the codebase have been updated to match the new signature.398-402: The
getGasBlock
function signature has been updated to include thechainID
parameter. This is necessary for the function to fetch the correct gas block from the cache when theHeaderByNumber
RPC call fails.411-426: The
getGasBlock
function has been modified to retrieve the gas block from the cache if theHeaderByNumber
RPC call fails. This is a good fallback mechanism that can prevent null pointer errors when the RPC call fails. However, it's important to note that the cached gas block might not be the latest one if the cache hasn't been updated recently.428-431: The
getGasBlock
function now caches the latest gas block after successfully fetching it from the chain. This ensures that the cache is always updated with the latest gas block, which can be used as a fallback when theHeaderByNumber
RPC call fails.
…cns/sanguine into feat/submitter-gas-block
Trying to fix add-label action, as it seems the andymckay/labeler action has been deprecated for over a year: Whatever caused this was probably an issue between #1399 and now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Files ignored due to filter (10)
- agents/go.mod
- agents/go.sum
- contrib/promexporter/go.mod
- contrib/promexporter/go.sum
- ethergo/go.mod
- ethergo/go.sum
- services/cctp-relayer/go.mod
- services/cctp-relayer/go.sum
- services/omnirpc/go.mod
- services/omnirpc/go.sum
Files selected for processing (1)
- ethergo/submitter/submitter.go (7 hunks)
Additional comments (Suppressed): 6
ethergo/submitter/submitter.go (6)
4-17: The import of
github.com/puzpuzpuz/xsync/v2
is new and is used for thelastGasBlockCache
in thetxSubmitterImpl
struct. Ensure that this package is added to the project dependencies.65-72: The
lastGasBlockCache
field has been added to thetxSubmitterImpl
struct. This cache is used to store the last gas block for a given chain. This is a good addition as it can improve performance by reducing the number of RPC calls to get the gas block.81-94: The
NewTransactionSubmitter
function has been updated to initialize thelastGasBlockCache
field in thetxSubmitterImpl
struct. This is a necessary change to ensure that the cache is properly initialized when a new transaction submitter is created.376-382: The
getGasBlock
function now takes an additionalchainID
parameter. This change is necessary to support the new caching behavior. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.399-403: The
getGasBlock
function signature has been updated to include achainID
parameter. This change is necessary to support the new caching behavior. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.412-433: The
getGasBlock
function has been updated to use thelastGasBlockCache
when theHeaderByNumber
RPC call fails. This is a good change as it can improve performance by reducing the number of RPC calls. However, it's important to note that this could potentially lead to using stale gas block data if the cache is not updated frequently enough.
are agents flaking here? Or did I introduce a regression? |
Hard to say- the retry settings on the agents CI may be too lenient. Checking locally |
Description
Adds a
gasBlockCache
to submitter so that we can use a cached value in the event that theHeaderByNumber
RPC call fails.Additional context
Also fixes a bug where we fail to get the gas block properly, but continue with setting gas price and are at risk of getting nullptr.
Summary by CodeRabbit