From af93defe9a58ea9303bb8b754a881a229d5d6546 Mon Sep 17 00:00:00 2001 From: Dima Kniazev Date: Tue, 16 Jan 2024 17:20:18 -0800 Subject: [PATCH] [LocalNet] Add sequencer block persistence (#277) * add localnet persistance * bump local-celestia-devnet * rollback celestia container * change messages --- .github/label-actions.yml | 6 +++--- Tiltfile | 9 +++++++-- cmd/signals/on_exit.go | 3 ++- docs/static/openapi.yml | 10 ++++++++++ localnet/kubernetes/sequencer-volume.yaml | 10 ++++++++++ localnet/kubernetes/values-sequencer.yaml | 2 ++ 6 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 localnet/kubernetes/sequencer-volume.yaml create mode 100644 localnet/kubernetes/values-sequencer.yaml diff --git a/.github/label-actions.yml b/.github/label-actions.yml index 8618e0d5a..4d4451c4f 100644 --- a/.github/label-actions.yml +++ b/.github/label-actions.yml @@ -1,7 +1,7 @@ -# When `devnet-test-e2e` is added, also assign `devnet` to the PR. +# When `devnet-test-e2e` is added, also assign `devnet` and `push-image` to the PR. devnet-test-e2e: prs: - comment: The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks. + comment: The CI will now also run the e2e tests on devnet, which increases the time it takes to complete all CI checks. If you just created a pull request, you might need to push another commit to produce a container image DevNet can utilize to spin up infrastructure. You can use `make trigger_ci` to push an empty commit. label: - devnet - push-image @@ -27,7 +27,7 @@ devnet: # Let the developer know that they need to push another commit after attaching the label to PR. push-image: prs: - comment: The image is going to be pushed after the next commit. If you want to run an e2e test, it is necessary to push another commit. You can use `make trigger_ci` to push an empty commit. + comment: The image is going to be pushed after the next commit. You can use `make trigger_ci` to push an empty commit. If you also want to run an E2E test, please add `devnet-test-e2e` label. # When `push-image` is removed, also delete `devnet` from the PR. -push-image: diff --git a/Tiltfile b/Tiltfile index ec07451c3..6102c2222 100644 --- a/Tiltfile +++ b/Tiltfile @@ -7,6 +7,7 @@ hot_reload_dirs = ["app", "cmd", "tools", "x", "pkg"] # Create a localnet config file from defaults, and if a default configuration doesn't exist, populate it with default values localnet_config_path = "localnet_config.yaml" localnet_config_defaults = { + "sequencer": {"cleanupBeforeEachStart": True}, "relayminers": {"count": 1}, "gateways": {"count": 1}, "appgateservers": {"count": 1}, @@ -109,14 +110,18 @@ WORKDIR / # Run celestia and anvil nodes k8s_yaml( - ["localnet/kubernetes/celestia-rollkit.yaml", "localnet/kubernetes/anvil.yaml"] + ["localnet/kubernetes/celestia-rollkit.yaml", "localnet/kubernetes/anvil.yaml", "localnet/kubernetes/sequencer-volume.yaml"] ) # Run pocket-specific nodes (sequencer, relayminers, etc...) helm_resource( "sequencer", chart_prefix + "poktroll-sequencer", - flags=["--values=./localnet/kubernetes/values-common.yaml"], + flags=[ + "--values=./localnet/kubernetes/values-common.yaml", + "--values=./localnet/kubernetes/values-sequencer.yaml", + "--set=persistence.cleanupBeforeEachStart=" + str(localnet_config["sequencer"]["cleanupBeforeEachStart"]), + ], image_deps=["poktrolld"], image_keys=[("image.repository", "image.tag")], ) diff --git a/cmd/signals/on_exit.go b/cmd/signals/on_exit.go index 1106cce96..e2ff9a8cb 100644 --- a/cmd/signals/on_exit.go +++ b/cmd/signals/on_exit.go @@ -3,6 +3,7 @@ package signals import ( "os" "os/signal" + "syscall" ) // GoOnExitSignal calls the given callback when the process receives an interrupt @@ -12,7 +13,7 @@ func GoOnExitSignal(onInterrupt func()) { // Set up sigCh to receive when this process receives an interrupt or // kill signal. sigCh := make(chan os.Signal, 1) - signal.Notify(sigCh, os.Interrupt, os.Kill) + signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM) // Block until we receive an interrupt or kill signal (OS-agnostic) <-sigCh diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 83bbefe5f..dee3a5d07 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -47279,12 +47279,14 @@ paths: - GRPC - WEBSOCKET - JSON_RPC + - REST default: UNKNOWN_RPC description: |- - UNKNOWN_RPC: Undefined RPC type - GRPC: gRPC - WEBSOCKET: WebSocket - JSON_RPC: JSON-RPC + - REST: REST configs: type: array items: @@ -77805,12 +77807,14 @@ definitions: - GRPC - WEBSOCKET - JSON_RPC + - REST default: UNKNOWN_RPC description: |- - UNKNOWN_RPC: Undefined RPC type - GRPC: gRPC - WEBSOCKET: WebSocket - JSON_RPC: JSON-RPC + - REST: REST configs: type: array items: @@ -78057,12 +78061,14 @@ definitions: - GRPC - WEBSOCKET - JSON_RPC + - REST default: UNKNOWN_RPC description: |- - UNKNOWN_RPC: Undefined RPC type - GRPC: gRPC - WEBSOCKET: WebSocket - JSON_RPC: JSON-RPC + - REST: REST configs: type: array items: @@ -78209,6 +78215,7 @@ definitions: - GRPC: gRPC - WEBSOCKET: WebSocket - JSON_RPC: JSON-RPC + - REST: REST title: Enum to define RPC types pocket.shared.Supplier: type: object @@ -78277,6 +78284,7 @@ definitions: - GRPC: gRPC - WEBSOCKET: WebSocket - JSON_RPC: JSON-RPC + - REST: REST configs: type: array items: @@ -78335,6 +78343,7 @@ definitions: - GRPC: gRPC - WEBSOCKET: WebSocket - JSON_RPC: JSON-RPC + - REST: REST configs: type: array items: @@ -78407,6 +78416,7 @@ definitions: - GRPC: gRPC - WEBSOCKET: WebSocket - JSON_RPC: JSON-RPC + - REST: REST configs: type: array items: diff --git a/localnet/kubernetes/sequencer-volume.yaml b/localnet/kubernetes/sequencer-volume.yaml new file mode 100644 index 000000000..21ff34773 --- /dev/null +++ b/localnet/kubernetes/sequencer-volume.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: "sequencer-data-volume" +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi \ No newline at end of file diff --git a/localnet/kubernetes/values-sequencer.yaml b/localnet/kubernetes/values-sequencer.yaml new file mode 100644 index 000000000..6caef084d --- /dev/null +++ b/localnet/kubernetes/values-sequencer.yaml @@ -0,0 +1,2 @@ +persistence: + existingClaim: "sequencer-data-volume"