Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
alon-dotan-starkware committed Oct 31, 2024
1 parent 4cb5f62 commit 5894708
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 42 deletions.
3 changes: 2 additions & 1 deletion deployments/sequencer/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ verify_ssl = true
[dev-packages]

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

[requires]
python_version = "3.10"
194 changes: 165 additions & 29 deletions deployments/sequencer/Pipfile.lock

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

30 changes: 30 additions & 0 deletions deployments/sequencer/config/sequencer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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

def get(self):
return self.config

def validate(self):
pass


class SequencerDevConfig(Config):
def __init__(self):
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())
)

def validate(self):
jsonschema.validate(self.config, schema=self.schema)
32 changes: 24 additions & 8 deletions deployments/sequencer/main.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,53 @@
#!/usr/bin/env python3

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

from config.sequencer import Config, SequencerDevConfig


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

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


class SequencerSystem(Chart):
def __init__(self, scope: Construct, name: str, namespace: str, system_structure: Dict[str, Dict[str, Any]]):
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={"message": "Hello, Kubernetes!"})
breakpoint()
self.mempool = 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)

def validate(self):
pass


app_1 = App()
a = SequencerSystem(
scope=app_1,
name="sequencer-system-1",
namespace="alond",
system_structure=SystemStructure()
system_structure=SystemStructure(),
)

a.validate()
app_1.synth()
Loading

0 comments on commit 5894708

Please sign in to comment.