Skip to content
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

op-node: Persist synchroniser state #6105

Merged
merged 11 commits into from
Jun 27, 2023
Merged

Conversation

ajsutton
Copy link
Contributor

Description

Adds a --rpc.admin-state CLI option to specify a file to persist config changes made via the RPC Admin APIs to. Currently that's just whether the sequencer is started or stopped.

  • The file is only created when the first change is made via RPC
  • If the file doesn't exist, the other CLI args determine if the sequencer starts or not (--sequencer.stopped in particular)
  • If the file does exist and is valid, the persisted value overrides the --sequencer.stopped option
  • If the file exists and is invalid, op-node will refuse to start
  • If writing the file fails, the admin API call will report an error and the sequencer state will be unchanged

The state is persisted as a JSON file so that we can extend it with additional options in the future if need be. The code for persistence has been kept simple and takes advantage of there only being one value currently - it can be refactored to be more complex and merge multiple values in the future if needed.

The file is written with maximal safety - updates are first written to a temp file, fsync'd and then renamed into place.

Tests

Unit tests added around the persistence code. Manual testing for the actual CLI interactions. Will investigate cli tests or e2e tests for this in a follow up PR.

Metadata

@changeset-bot
Copy link

changeset-bot bot commented Jun 22, 2023

⚠️ No Changeset found

Latest commit: 189ae1e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@netlify
Copy link

netlify bot commented Jun 22, 2023

Deploy Preview for opstack-docs ready!

Name Link
🔨 Latest commit 189ae1e
🔍 Latest deploy log https://app.netlify.com/sites/opstack-docs/deploys/649b0a6af640450008c5060c
😎 Deploy Preview https://deploy-preview-6105--opstack-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov
Copy link

codecov bot commented Jun 22, 2023

Codecov Report

Merging #6105 (4163278) into develop (4d7798f) will increase coverage by 0.29%.
The diff coverage is 31.29%.

❗ Current head 4163278 differs from pull request most recent head 189ae1e. Consider uploading reports for the commit 189ae1e to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #6105      +/-   ##
===========================================
+ Coverage    44.48%   44.78%   +0.29%     
===========================================
  Files          443      307     -136     
  Lines        29058    23540    -5518     
  Branches       691        0     -691     
===========================================
- Hits         12926    10542    -2384     
+ Misses       15084    12019    -3065     
+ Partials      1048      979      -69     
Flag Coverage Δ
bedrock-go-tests 44.78% <31.29%> (+1.12%) ⬆️
cannon-go-tests ?
common-ts-tests ?
contracts-bedrock-tests ?
core-utils-tests ?
fault-detector-tests ?
sdk-tests ?

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

Impacted Files Coverage Δ
op-node/flags/flags.go 62.50% <ø> (ø)
op-node/node/config.go 0.00% <0.00%> (ø)
op-node/node/node.go 0.64% <0.00%> (ø)
op-node/rollup/driver/driver.go 0.00% <0.00%> (ø)
op-node/rollup/driver/state.go 0.00% <0.00%> (ø)
op-node/service.go 9.09% <0.00%> (-0.84%) ⬇️
op-node/sources/rollupclient.go 0.00% <0.00%> (ø)
op-node/node/config_persistence.go 55.40% <55.40%> (ø)

... and 148 files with indirect coverage changes

@mergify
Copy link
Contributor

mergify bot commented Jun 22, 2023

Hey @ajsutton! This PR has merge conflicts. Please fix them before continuing review.

@mergify mergify bot added the conflict label Jun 22, 2023
@ajsutton ajsutton force-pushed the aj/persist-synchronizer-state branch from 7fe2f49 to 4352684 Compare June 22, 2023 02:52
@mergify mergify bot removed the conflict label Jun 22, 2023
@ajsutton ajsutton marked this pull request as ready for review June 22, 2023 03:18
op-node/node/config_persistence.go Outdated Show resolved Hide resolved
op-node/node/config_persistence.go Show resolved Hide resolved
op-node/rollup/driver/state.go Show resolved Hide resolved
op-node/rollup/driver/state.go Outdated Show resolved Hide resolved
op-node/flags/flags.go Outdated Show resolved Hide resolved
op-node/service.go Outdated Show resolved Hide resolved
op-node/node/config_persistence.go Outdated Show resolved Hide resolved
@ajsutton
Copy link
Contributor Author

ajsutton commented Jun 23, 2023

@protolambda I've added some e2e tests in here. I was going to do it as a follow up but in implementing them I discovered that having the loading of persisted config mixed in with CLI option parsing made it impossible to test since the e2e tests don't do the CLI parsing. So I've moved it to a method on Config. Happy to accept suggestions for better approaches...

op-node/node/config_persistence.go Show resolved Hide resolved
op-node/node/config_persistence.go Show resolved Hide resolved
op-node/node/config_persistence.go Outdated Show resolved Hide resolved
op-node/node/config_persistence.go Show resolved Hide resolved
op-node/flags/flags.go Outdated Show resolved Hide resolved
@ajsutton ajsutton force-pushed the aj/persist-synchronizer-state branch from 6610be1 to 4163278 Compare June 25, 2023 22:04
@mergify
Copy link
Contributor

mergify bot commented Jun 27, 2023

This PR has been added to the merge queue, and will be merged soon.

@mergify
Copy link
Contributor

mergify bot commented Jun 27, 2023

This PR is next in line to be merged, and will be merged as soon as checks pass.

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Jun 27, 2023

This PR is next in line to be merged, and will be merged as soon as checks pass.

@OptimismBot OptimismBot merged commit fe51934 into develop Jun 27, 2023
71 of 73 checks passed
@OptimismBot OptimismBot deleted the aj/persist-synchronizer-state branch June 27, 2023 16:26
@mergify mergify bot removed the on-merge-train label Jun 27, 2023
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.

None yet

4 participants