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

feature: adding agglayer-prover #313

Merged
merged 6 commits into from
Oct 24, 2024
Merged
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
108 changes: 84 additions & 24 deletions agglayer.star
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,72 @@ def run(plan, args):
agglayer_config_artifact = create_agglayer_config_artifact(
plan, args, contract_setup_addresses, db_configs
)

agglayer_prover_config_artifact = create_agglayer_prover_config_artifact(plan, args)
agglayer_keystore_artifact = plan.store_service_files(
name="agglayer-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/agglayer.keystore",
)

prover = plan.add_service(
name="agglayer-prover",
config=create_agglayer_prover_config(args, agglayer_prover_config_artifact),
description="AggLayer Prover",
)

plan.add_service(
name="agglayer",
config=ServiceConfig(
image=args["agglayer_image"],
ports={
"agglayer": PortSpec(
args["agglayer_port"], application_protocol="http"
),
"prometheus": PortSpec(
args["prometheus_port"], application_protocol="http"
),
},
files={
"/etc/zkevm": Directory(
artifact_names=[
agglayer_config_artifact,
agglayer_keystore_artifact,
]
),
},
entrypoint=[
"/usr/local/bin/agglayer",
],
cmd=["run", "--cfg", "/etc/zkevm/agglayer-config.toml"],
config=create_agglayer_config(
args, agglayer_config_artifact, agglayer_keystore_artifact
),
description="AggLayer",
)


def create_agglayer_prover_config(args, agglayer_prover_config_artifact):
return ServiceConfig(
image=args["agglayer_image"],
ports={
"api": PortSpec(args["agglayer_prover_port"], application_protocol="grpc"),
"prometheus": PortSpec(
args["agglayer_prover_metrics_port"], application_protocol="http"
),
},
files={
"/etc/zkevm": Directory(
artifact_names=[
agglayer_prover_config_artifact,
]
),
},
entrypoint=[
"/usr/local/bin/agglayer",
],
cmd=["prover", "--cfg", "/etc/zkevm/agglayer-prover-config.toml"],
)


def create_agglayer_config(args, agglayer_config_artifact, agglayer_keystore_artifact):
return ServiceConfig(
image=args["agglayer_image"],
ports={
"agglayer": PortSpec(args["agglayer_port"], application_protocol="http"),
"prometheus": PortSpec(
args["agglayer_metrics_port"], application_protocol="http"
),
},
files={
"/etc/zkevm": Directory(
artifact_names=[
agglayer_config_artifact,
agglayer_keystore_artifact,
]
),
},
entrypoint=[
"/usr/local/bin/agglayer",
],
cmd=["run", "--cfg", "/etc/zkevm/agglayer-config.toml"],
)


Expand All @@ -60,6 +94,7 @@ def create_agglayer_config_artifact(plan, args, contract_setup_addresses, db_con
"global_log_level": args["global_log_level"],
"l1_chain_id": args["l1_chain_id"],
"l1_rpc_url": args["l1_rpc_url"],
"l1_ws_url": args["l1_ws_url"],
"zkevm_l2_keystore_password": args["zkevm_l2_keystore_password"],
"zkevm_l2_proofsigner_address": args[
"zkevm_l2_proofsigner_address"
Expand All @@ -68,11 +103,36 @@ def create_agglayer_config_artifact(plan, args, contract_setup_addresses, db_con
# ports
"zkevm_rpc_http_port": args["zkevm_rpc_http_port"],
"agglayer_port": args["agglayer_port"],
"prometheus_port": args["prometheus_port"],
"agglayer_prover_entrypoint": "http://agglayer-prover:{}".format(
args["agglayer_prover_port"]
),
"prometheus_port": args["agglayer_metrics_port"],
"l2_rpc_name": args["l2_rpc_name"],
}
| contract_setup_addresses
| db_configs,
)
},
)


def create_agglayer_prover_config_artifact(plan, args):
agglayer_prover_config_template = read_file(
src="./templates/bridge-infra/agglayer-prover-config.toml"
)
return plan.render_templates(
name="agglayer-prover-config-artifact",
config={
"agglayer-prover-config.toml": struct(
template=agglayer_prover_config_template,
# TODO: Organize those args.
data={
"deployment_suffix": args["deployment_suffix"],
"global_log_level": args["global_log_level"],
# ports
"agglayer_prover_port": args["agglayer_prover_port"],
"prometheus_port": args["agglayer_prover_metrics_port"],
},
)
},
)
8 changes: 4 additions & 4 deletions docs/attach-multiple-cdks.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
By default, the Agglayer service will be deployed with the above deployment instructions. To create a devnet with multiple rollups attached to the agglayer:

```bash
kurtosis run --enclave cdk-v1 --args-file agglayer-attach-cdk-params.yml .
kurtosis run --enclave=cdk --args-file=./.github/tests/attach-second-cdk.yml --show-enclave-inspect=false .
```

The above command will use `agglayer-attach-cdk-params.yml` as the input params which have a few tweaked parameters to attach to the existing Agglayer service.
The above command will use `attach-second-cdk.yml` as the input params which have a few tweaked parameters to attach to the existing Agglayer service.
After running the above additional deployment command, the `agglayer-config.toml` needs to be edited to settle the signed transactions from the rollups.

```bash
# Shell into the Agglayer service
kurtosis service shell cdk-v1 agglayer
kurtosis service shell cdk agglayer

# Edit the agglayer-config.toml file
vim /etc/zkevm/agglayer-config.toml
Expand All @@ -30,7 +30,7 @@ The `agglayer-config.toml` file should be changed as follows:
# Sequencer address for first rollup
1 = "0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed"
# Sequencer address for second rollup
2 = "0xF4ee37aAc3ccd6B71A4a795700b065d2CA479581"
2 = "0xA670342930242407b9984e467353044f8472055e"
```

Then restart the Agglayer service
Expand Down
5 changes: 4 additions & 1 deletion input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ DEFAULT_DEPLOYMENT_STAGES = {
}

DEFAULT_IMAGES = {
"agglayer_image": "ghcr.io/agglayer/agglayer-rs:pr-96", # https://github.com/agglayer/agglayer/pkgs/container/agglayer-rs
"agglayer_image": "ghcr.io/agglayer/agglayer:feature-storage-adding-epoch-packing", # https://github.com/agglayer/agglayer/pkgs/container/agglayer-rs
"cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.1.0", # https://hub.docker.com/r/hermeznetwork/cdk-erigon/tags
"cdk_node_image": "ghcr.io/0xpolygon/cdk:0.3.0", # https://github.com/0xpolygon/cdk/pkgs/container/cdk
"cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags
Expand All @@ -43,6 +43,9 @@ DEFAULT_IMAGES = {

DEFAULT_PORTS = {
"agglayer_port": 4444,
"agglayer_prover_port": 4445,
"agglayer_metrics_port": 9092,
"agglayer_prover_metrics_port": 9093,
"prometheus_port": 9091,
"zkevm_aggregator_port": 50081,
"zkevm_bridge_grpc_port": 9090,
Expand Down
83 changes: 54 additions & 29 deletions templates/bridge-infra/agglayer-config.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,62 @@
[FullNodeRPCs]
prover-entrypoint = "{{.agglayer_prover_entrypoint}}"

[full-node-rpcs]
# TODO switch this to permissionless
1 = "http://{{.l2_rpc_name}}{{.deployment_suffix}}:{{.zkevm_rpc_http_port}}"

[ProofSigners]
[proof-signers]
1 = "{{.zkevm_l2_sequencer_address}}"

[RPC]
Host = "0.0.0.0"
Port = {{.agglayer_port}}
ReadTimeout = "60s"
WriteTimeout = "60s"
MaxRequestsPerIPAndSecond = 5000

[Log]
Environment = "production" # "production" or "development"
Level = "{{.global_log_level}}"
Outputs = ["stderr"]

[EthTxManager]
FrequencyToMonitorTxs = "1s"
WaitTxToBeMined = "2m"
ForcedGas = 0
GasPriceMarginFactor = 1
MaxGasPriceLimit = 0
PrivateKeys = [
{Path = "/etc/zkevm/agglayer.keystore", Password = "{{.zkevm_l2_keystore_password}}"},
[rpc]
port = {{.agglayer_port}}
host = "0.0.0.0"
request-timeout = 180

[outbound.rpc.settle]
max-retries = 3
retry-interval = 7
confirmations = 1
settlement-timeout = 1200

[log]
level = "{{.global_log_level}}"
outputs = ["stderr"]
format = "pretty"

[auth.local]
private-keys = [
{ path = "/etc/zkevm/agglayer.keystore", password = "{{.zkevm_l2_keystore_password}}" },
]
KMSKeyName = "" # Disable for local

[L1]
ChainID = {{.l1_chain_id}}
NodeURL = "{{.l1_rpc_url}}"
RollupManagerContract = "{{.zkevm_rollup_manager_address}}"
[l1]
chain-id = {{.l1_chain_id}}
node-url = "{{.l1_rpc_url}}"
ws-node-url = "{{.l1_ws_url}}"
rollup-manager-contract = "{{.zkevm_rollup_manager_address}}"
rpc-timeout = 45

[l2]
rpc-timeout = 45

[telemetry]
prometheus-addr = "0.0.0.0:{{.prometheus_port}}"

[rate-limiting]
send-tx = "unlimited"

[rate-limiting.network]

[epoch.block-clock]
epoch-duration = 15
genesis-block = 0

[shutdown]
runtime-timeout = 5

[certificate-orchestrator]
input-backpressure-buffer-size = 1000

[certificate-orchestrator.prover.sp1-local]

[Telemetry]
PrometheusAddr = "0.0.0.0:{{.prometheus_port}}"
[storage]
db-path = "/etc/zkevm/storage"
21 changes: 21 additions & 0 deletions templates/bridge-infra/agglayer-prover-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
grpc-endpoint = "0.0.0.0:{{ .agglayer_prover_port }}"
max-concurrency-limit = 100
max-request-duration = 300
max-buffered-queries = 100

[log]
environment = "production" # "production" or "development"
level = "{{.global_log_level}}"
outputs = ["stderr"]
format = "json"

[telemetry]
prometheus-addr = "0.0.0.0:{{.prometheus_port}}"

[cpu-prover]
max-concurrency-limit = 100
proving-timeout = 300

[network-prover]
enabled = false
proving-timeout = 300
Loading