-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feat/start height #8
Conversation
WalkthroughThis update significantly enhances the system's robustness and adaptability through improved context management, error handling, and configuration flexibility. By integrating Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Broadcaster
participant Node
participant Context
User->>Broadcaster: Initiate transaction
Broadcaster->>Context: Create context
Context-->>Broadcaster: Return context
Broadcaster->>Node: Process new block with context
Node-->>Broadcaster: Handle event with context
Broadcaster-->>User: Transaction completed
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Do we also have feature to prevent feeding old oracle prices??
like when the op bot started in past start block (not latest block), then we have to wait until we are reaching to latest l1 height before feeding oracle price to l2.
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
Files selected for processing (48)
- README.md (1 hunks)
- bot/types/bot.go (1 hunks)
- cmd/opinitd/reset.go (1 hunks)
- cmd/opinitd/start.go (2 hunks)
- executor/README.md (2 hunks)
- executor/batch/batch.go (4 hunks)
- executor/batch/handler.go (9 hunks)
- executor/batch/status.go (1 hunks)
- executor/batch/utils.go (1 hunks)
- executor/celestia/celestia.go (2 hunks)
- executor/celestia/handler.go (1 hunks)
- executor/celestia/status.go (1 hunks)
- executor/child/child.go (6 hunks)
- executor/child/deposit.go (2 hunks)
- executor/child/handler.go (2 hunks)
- executor/child/msgs.go (1 hunks)
- executor/child/oracle.go (3 hunks)
- executor/child/query.go (4 hunks)
- executor/child/status.go (1 hunks)
- executor/child/withdraw.go (6 hunks)
- executor/executor.go (7 hunks)
- executor/host/batch.go (2 hunks)
- executor/host/deposit.go (2 hunks)
- executor/host/handler.go (4 hunks)
- executor/host/host.go (3 hunks)
- executor/host/msgs.go (1 hunks)
- executor/host/query.go (3 hunks)
- executor/host/status.go (1 hunks)
- executor/host/withdraw.go (4 hunks)
- executor/status.go (1 hunks)
- executor/types/batch.go (2 hunks)
- executor/types/config.go (6 hunks)
- go.mod (1 hunks)
- keys/codec.go (1 hunks)
- keys/keyring.go (1 hunks)
- merkle/merkle.go (1 hunks)
- node/broadcaster/broadcaster.go (3 hunks)
- node/broadcaster/process.go (6 hunks)
- node/broadcaster/tx.go (3 hunks)
- node/broadcaster/types/config.go (3 hunks)
- node/broadcaster/types/db.go (3 hunks)
- node/db.go (1 hunks)
- node/node.go (4 hunks)
- node/process.go (14 hunks)
- node/rpcclient/client.go (2 hunks)
- node/types/handler.go (3 hunks)
- node/types/status.go (1 hunks)
- types/context.go (1 hunks)
Files skipped from review due to trivial changes (6)
- README.md
- executor/batch/utils.go
- executor/child/msgs.go
- executor/host/status.go
- keys/codec.go
- keys/keyring.go
Files skipped from review as they are similar to previous changes (31)
- bot/types/bot.go
- cmd/opinitd/reset.go
- executor/batch/handler.go
- executor/batch/status.go
- executor/celestia/handler.go
- executor/celestia/status.go
- executor/child/deposit.go
- executor/child/handler.go
- executor/child/oracle.go
- executor/child/status.go
- executor/child/withdraw.go
- executor/host/batch.go
- executor/host/deposit.go
- executor/host/msgs.go
- executor/host/query.go
- executor/host/withdraw.go
- executor/status.go
- executor/types/batch.go
- go.mod
- merkle/merkle.go
- node/broadcaster/broadcaster.go
- node/broadcaster/process.go
- node/broadcaster/tx.go
- node/broadcaster/types/config.go
- node/broadcaster/types/db.go
- node/db.go
- node/node.go
- node/process.go
- node/rpcclient/client.go
- node/types/status.go
- types/context.go
Additional context used
golangci-lint
executor/child/query.go
24-24: copylocks: QueryBridgeInfo passes lock by value: github.com/initia-labs/opinit-bots-go/executor/child.Child contains sync.Once contains sync/atomic.Uint32 contains sync/atomic.noCopy
(govet)
Markdownlint
executor/README.md
76-76: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
228-228: Column: 1
Hard tabs(MD010, no-hard-tabs)
229-229: Column: 1
Hard tabs(MD010, no-hard-tabs)
230-230: Column: 1
Hard tabs(MD010, no-hard-tabs)
231-231: Column: 1
Hard tabs(MD010, no-hard-tabs)
232-232: Column: 1
Hard tabs(MD010, no-hard-tabs)
Additional comments not posted (35)
node/types/handler.go (5)
18-18
: Contextual enhancement approved forEventHandlerFn
.The addition of
context.Context
improves the function's ability to handle context-related operations.
27-27
: Contextual enhancement approved forTxHandlerFn
.The inclusion of
context.Context
is a beneficial change for managing context in concurrent operations.
35-35
: Contextual enhancement approved forBeginBlockHandlerFn
.Adding
context.Context
enhances the function's ability to manage context effectively.
43-43
: Contextual enhancement approved forEndBlockHandlerFn
.The addition of
context.Context
is a positive change for context management.
50-50
: Contextual enhancement approved forRawBlockHandlerFn
.Including
context.Context
improves the function's context management capabilities.cmd/opinitd/start.go (2)
19-20
: Addition offlagPollingInterval
approved.The new constant enhances the configurability of the command by allowing users to specify the polling interval.
47-58
: Enhancements instartCmd
function approved.The use of an error group and retrieval of the polling interval improve the command's robustness and configurability.
Ensure that
WithErrGrp
andWithPollingInterval
are correctly implemented and used throughout the codebase.Verification successful
Verify consistent usage of
WithErrGrp
andWithPollingInterval
across the codebase.Both functions are implemented in
types/context.go
and used incmd/opinitd/start.go
. Ensure they are used consistently and appropriately in other parts of the codebase if applicable.
WithErrGrp
is implemented intypes/context.go
and used incmd/opinitd/start.go
.WithPollingInterval
is implemented intypes/context.go
and used incmd/opinitd/start.go
.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the implementation and usage of `WithErrGrp` and `WithPollingInterval`. # Test: Search for the implementation and usage of `WithErrGrp`. rg --type go 'WithErrGrp' # Test: Search for the implementation and usage of `WithPollingInterval`. rg --type go 'WithPollingInterval'Length of output: 392
executor/host/handler.go (3)
Line range hint
15-19
:
Contextual enhancement approved forbeginBlockHandler
.The addition of
context.Context
prepares the function for improved context management.
Line range hint
24-64
:
Contextual enhancement approved forendBlockHandler
.Including
context.Context
enhances the function's capability for context-aware operations.
Line range hint
65-74
:
Contextual enhancement approved fortxHandler
.The addition of
context.Context
aligns with best practices for managing context in asynchronous operations.executor/child/query.go (3)
Line range hint
24-31
:
Ensure proper context usage inQueryBridgeInfo
.The addition of
context.Context
improves the function's ability to handle cancellation and timeouts. Ensure that the context is correctly propagated in all call sites.Tools
golangci-lint
24-24: copylocks: QueryBridgeInfo passes lock by value: github.com/initia-labs/opinit-bots-go/executor/child.Child contains sync.Once contains sync/atomic.Uint32 contains sync/atomic.noCopy
(govet)
Line range hint
36-43
:
Ensure proper context usage inQueryNextL1Sequence
.The context parameter enhances the function's cancellation and timeout capabilities. Verify that all invocations of this method correctly pass the context.
Line range hint
48-55
:
Ensure proper context usage inQueryNextL2Sequence
.The context parameter, along with the height, supports better management of long-running operations. Confirm that all call sites handle the context appropriately.
executor/batch/batch.go (3)
26-26
: Ensure context propagation inQueryBatchInfos
.The
hostNode
interface method now takes acontext.Context
, allowing for better cancellation and timeout handling. Ensure that implementations of this interface correctly utilize the context.
Line range hint
110-147
:
Verify context and startHeight handling inBatchSubmitter.Initialize
.The addition of
context.Context
andstartHeight
parameters improves initialization flexibility. Ensure that all calls to this method correctly provide these parameters.
133-137
: Review file handling logic.The conditional logic for setting file flags based on node initialization state is clear and improves flexibility. Ensure that this logic aligns with your intended file handling strategy.
executor/celestia/celestia.go (1)
97-101
: Improve error handling inCelestia.Initialize
.The addition of node initialization with error handling ensures that subsequent operations only proceed if the node is successfully initialized. This change enhances robustness.
executor/host/host.go (2)
29-29
: Enhancement: Added context toQueryNextL1Sequence
.The addition of
context.Context
to theQueryNextL1Sequence
method improves the interface's ability to handle cancellations and timeouts.
118-127
: Improvement: Context and start height added toInitialize
.The
Initialize
method now supports context management and allows specifying a starting height, enhancing flexibility and control.Ensure that all calls to
Initialize
are updated to use the new signature.Verification successful
Let's refine the search to capture all instances of
Initialize
calls and ensure they match the new signature.
Update Confirmed:
Host.Initialize
uses new signature inexecutor/executor.go
.The
Initialize
method inexecutor/host/host.go
is correctly called with the new signature inexecutor/executor.go
. Ensure that all other instances across the codebase are similarly updated.
executor/executor.go
:ex.host.Initialize(ctx, hostStartHeight, ex.child, ex.batch, int64(bridgeInfo.BridgeId))
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `Host.Initialize` use the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'Initialize(context.Context, uint64, childNode, batchNode, int64)'Length of output: 86
Script:
#!/bin/bash # Description: Search for all calls to `Initialize` in the codebase to verify they match the new signature. # Test: Search for the function usage with a broader pattern to capture all calls. rg --type go 'Initialize\(' -A 3Length of output: 2759
executor/child/child.go (3)
33-34
: Enhancement: Added context toQueryLastOutput
andQueryOutput
.The addition of
context.Context
to these methods improves their ability to handle cancellations and timeouts.
56-57
: Enhancement: AddedinitializeTree
andinitializeTreeFn
toChild
.These fields improve the initialization logic and state management of the
Child
struct.
124-138
: Improvement: Enhanced initialization inChild.Initialize
.The method now supports additional parameters for improved configurability and sets up an initialization function.
Ensure that all calls to
Initialize
are updated to use the new signature.Verification successful
Verification Complete:
Child.Initialize
Signature Updated CorrectlyThe
Child.Initialize
method is called with the correct new signature in the codebase, ensuring proper initialization with the additional parameters.
executor/executor.go
: Correct usage ofChild.Initialize
with the new parameters.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all calls to `Child.Initialize` use the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type go -A 5 $'Initialize(uint64, uint64, hostNode, opchildtypes.BridgeInfo)'Length of output: 83
Script:
#!/bin/bash # Description: Verify all calls to `Child.Initialize` use the new signature. # Test: Search for the function usage with a more flexible pattern. rg --type go 'Initialize\(' -A 5Length of output: 3483
executor/types/config.go (5)
11-18
: Enhancement: IntroducedNodeConfig
type.The
NodeConfig
type consolidates node-specific settings, improving configuration management and maintainability.
20-30
: Enhancement: Added validation forNodeConfig
.The
Validate
method ensures essential fields are populated, enhancing robustness and preventing misconfiguration.
40-45
: Refactor: UpdatedConfig
to useNodeConfig
.The
Config
structure now includesNodeConfig
instances for L1, L2, and DA nodes, simplifying configuration management.
84-109
: Improvement: UpdatedDefaultConfig
to useNodeConfig
.The function now initializes
L1Node
,L2Node
, andDANode
withNodeConfig
, providing default values for each node type.
134-144
: Enhancement: AddedNodeConfig
validation inConfig.Validate
.The method now ensures that all
NodeConfig
instances are validated, enhancing robustness and preventing misconfiguration.executor/executor.go (5)
49-64
: Configuration access improvements are approved.The changes enhance clarity by using nested configuration properties. This is consistent with the new configuration structure.
76-119
: Error handling improvements are approved.Replacing panics with error returns enhances robustness. The encapsulation of start height logic into
getStartHeights
improves readability.
Line range hint
122-137
:
Concurrency management is well-implemented.The use of
types.ErrGrp
for managing concurrent operations is appropriate and ensures clean shutdowns.
Line range hint
166-201
:
DA node creation logic is sound.The method correctly handles different chain types and initializes DA nodes with appropriate error handling.
203-236
: Start heights retrieval logic is well-structured.The method encapsulates start height logic effectively, enhancing readability and maintainability.
executor/README.md (3)
19-69
: Configuration restructuring is well-executed.The use of nested objects improves clarity and maintainability. New parameters like
gas_adjustment
andtx_timeout
enhance transaction control.
73-135
: Start height configuration examples are clear and informative.The examples effectively demonstrate how different configurations affect start heights, providing valuable guidance.
Tools
Markdownlint
76-76: null
Fenced code blocks should have a language specified(MD040, fenced-code-language)
Line range hint
136-232
:
Comprehensive documentation enhances understanding.The detailed explanations and code snippets improve understanding of the Executor's operations, covering handler rules, deposit, withdrawal, oracle, and batch processes.
Tools
Markdownlint
228-228: Column: 1
Hard tabs(MD010, no-hard-tabs)
229-229: Column: 1
Hard tabs(MD010, no-hard-tabs)
230-230: Column: 1
Hard tabs(MD010, no-hard-tabs)
231-231: Column: 1
Hard tabs(MD010, no-hard-tabs)
232-232: Column: 1
Hard tabs(MD010, no-hard-tabs)
It only sends when the current block is equal to the latest height, but basically the user has to look at the oracle height and decide whether to use the price or not. Also, if it submits a price for an older height than the one already submitted, the simulation will fail with the old height, and this error will be ignored and the Tx will not be submitted. |
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.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
README.md (1)
67-70
: LGTM! Consider adding more context for clarity.The new section for querying the bot's status is a valuable addition. It might be helpful to provide a brief explanation of what users can expect from the status endpoint, such as the type of information returned or any prerequisites needed to access it.
### Query status + This command retrieves the current operational status of the bot. Ensure the bot is running and accessible at the specified address. ```bash curl localhost:3000/status</blockquote></details> </blockquote></details> <details> <summary>Review details</summary> **Configuration used: CodeRabbit UI** **Review profile: CHILL** <details> <summary>Commits</summary> Files that changed from the base of the PR and between 0e2e4b769c6d108d9a4d7c8ded4c329631a4c087 and 6de57c889b065dff106e4dac90465a23daec3a2d. </details> <details> <summary>Files selected for processing (3)</summary> * README.md (2 hunks) * executor/child/child.go (6 hunks) * node/broadcaster/process.go (6 hunks) </details> <details> <summary>Files skipped from review as they are similar to previous changes (2)</summary> * executor/child/child.go * node/broadcaster/process.go </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Added a config to start from a specific height. If you enter l2 height, it starts from the l2 block number +1 of the last output smaller than that.
A batch can also start from a specific height or from an initialized l2 height.
Summary by CodeRabbit
New Features
curl
.Bug Fixes
Documentation
Refactor
Chores
github.com/initia-labs/OPinit
dependency fromv0.4.1
tov0.4.2
.