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

Idan/main/add sequencer deployment tools #1856

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions config/sequencer/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"chain_id": "0x5",
"eth_fee_token_address": "0x6",
"strk_fee_token_address": "0x7",
"components.batcher.execution_mode": "Disabled",
"components.batcher.local_server_config.#is_none": true,
"components.consensus_manager.execution_mode": "Disabled",
"components.gateway.execution_mode": "Disabled",
"components.http_server.execution_mode": "Disabled",
"components.mempool.execution_mode": "Disabled",
"components.mempool_p2p.execution_mode": "Disabled",
"components.consensus_manager.local_server_config.#is_none": true,
"components.gateway.local_server_config.#is_none": true,
"components.http_server.local_server_config.#is_none": true,
"components.mempool.local_server_config.#is_none": true,
"components.mempool_p2p.local_server_config.#is_none": true,
"components.http_server.remote_server_config.#is_none": true
}
31 changes: 31 additions & 0 deletions deployments/images/sequencer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# syntax = devthefuture/dockerfile-x

INCLUDE deployments/images/base/Dockerfile


# Compile the sequencer_node crate in release mode, ensuring dependencies are locked.
FROM base AS builder
COPY . .
RUN cargo build --release --package starknet_sequencer_node

FROM base AS sequencer

ENV ID=1000
WORKDIR /app
COPY --from=builder /target/release/starknet_sequencer_node /app/target/release/starknet_sequencer_node
COPY config/ config/

# Create a new user "sequencer".
RUN set -ex; \
addgroup --gid ${ID} sequencer; \
adduser --ingroup $(getent group ${ID} | cut -d: -f1) --uid ${ID} --gecos "" --disabled-password --home /app sequencer; \
chown -R sequencer:sequencer /app

# Expose RPC and monitoring ports.
EXPOSE 8080 8081 8082

# Switch to the new user.
USER ${ID}

# Set the entrypoint to use tini to manage the process.
ENTRYPOINT ["tini", "--", "/app/target/release/starknet_sequencer_node"]
3 changes: 2 additions & 1 deletion deployments/sequencer/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ verify_ssl = true
[dev-packages]

[packages]
cdk8s = "~=2.66.2"
constructs = "~=10.2.70"
jsonschema = "~=4.23.0"
mypy = "*"
cdk8s = "*"

[requires]
python_version = "3.10"
65 changes: 60 additions & 5 deletions deployments/sequencer/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 7 additions & 16 deletions deployments/sequencer/config/sequencer.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
from typing import Dict, Any
import os
import json
import jsonschema

ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../')
CONFIG_DIR = os.path.join(ROOT_DIR, 'config/papyrus/')


class Config():
def __init__(self, schema: Dict[Any, Any], config: Dict[Any, Any]):
self.schema = schema
self.config = config
from services.objects import Config

def get(self):
return self.config

def validate(self):
pass
ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../')
CONFIG_DIR = os.path.join(ROOT_DIR, 'config/papyrus/')


class SequencerDevConfig(Config):
def __init__(self):
def __init__(self, mount_path: str):
super().__init__(
schema=json.loads(open(os.path.join(CONFIG_DIR, 'default_config.json'), 'r').read()),
config=json.loads(open(os.path.join(CONFIG_DIR, 'presets', 'sepolia_testnet.json'), 'r').read())
)
config=json.loads(open(os.path.join(CONFIG_DIR, 'presets', 'sepolia_testnet.json'), 'r').read()),
mount_path = mount_path
)

def validate(self):
jsonschema.validate(self.config, schema=self.schema)
93 changes: 65 additions & 28 deletions deployments/sequencer/main.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,98 @@
#!/usr/bin/env python3

from constructs import Construct
from cdk8s import App, Chart
from typing import Dict, Any
from services.service import Service
import dataclasses

from constructs import Construct # type: ignore
from cdk8s import App, Chart, YamlOutputType # type: ignore
from typing import Dict, Any, Optional

from services.service import Service
from config.sequencer import Config, SequencerDevConfig
from services.objects import *
from services import defaults


@dataclasses.dataclass
class SystemStructure:
topology: str = "mesh"
replicas: str = "2"
size: str = "small"
config: Config = SequencerDevConfig()
config: Optional[Config] = None

def __post_init__(self):
self.config.validate()


class SequencerSystem(Chart):
class SequencerNode(Chart):
def __init__(
self,
scope: Construct,
name: str,
namespace: str,
system_structure: Dict[str, Dict[str, Any]],
namespace: str
):
super().__init__(
scope, name, disable_resource_name_hashes=True, namespace=namespace
)
self.mempool = Service(
self.service = Service(
self,
"mempool",
image="paulbouwer/hello-kubernetes:1.7",
replicas=2,
config=system_structure.config.get(),
)
self.batcher = Service(self, "batcher", image="ghost", container_port=2368)
self.sequencer_node = Service(
self,
"sequencer",
image="",
container_port=8082,
startup_probe_path="/monitoring/nodeVersion",
readiness_probe_path="/monitoring/ready",
liveness_probe_path="/monitoring/alive"
"sequencer-node",
image="us.gcr.io/starkware-dev/sequencer-node-test:0.0.1-dev.1",
args=defaults.sequencer.args,
port_mappings=defaults.sequencer.port_mappings,
service_type=defaults.sequencer.service_type,
replicas=defaults.sequencer.replicas,
config=defaults.sequencer.config,
health_check=defaults.sequencer.health_check,
pvc=defaults.sequencer.pvc,
ingress=defaults.sequencer.ingress
)


app = App()
a = SequencerSystem(
# class SequencerSystem(Chart):
# def __init__(
# self,
# scope: Construct,
# name: str,
# namespace: str,
# system_structure: Dict[str, Dict[str, Any]],
# ):
# super().__init__(
# scope, name, disable_resource_name_hashes=True, namespace=namespace
# )
# self.mempool = Service(
# self,
# "mempool",
# image="paulbouwer/hello-kubernetes:1.7",
# replicas=2,
# config=system_structure.config,
# health_check=defaults.health_check
# )
# self.batcher = Service(
# self,
# "batcher",
# image="ghost",
# port_mappings=[
# PortMapping(name="http", port=80, container_port=2368)
# ],
# health_check=defaults.health_check
# )


app = App(
yaml_output_type=YamlOutputType.FOLDER_PER_CHART_FILE_PER_RESOURCE
)

sequencer_node = SequencerNode(
scope=app,
name="sequencer-system",
namespace="test-namespace",
system_structure=SystemStructure(),
name="sequencer-node",
namespace="sequencer-node-test"
)

# a = SequencerSystem(
# scope=app,
# name="sequencer-system",
# namespace="test-namespace",
# system_structure=SystemStructure(config=SequencerDevConfig(mount_path="/app/config")),
# )

app.synth()
Loading
Loading