Skip to content

Commit

Permalink
feat: integrate aggoracle
Browse files Browse the repository at this point in the history
Signed-off-by: Ji Hwan <[email protected]>
  • Loading branch information
jhkimqd committed Jan 8, 2025
1 parent c97d876 commit 673914d
Show file tree
Hide file tree
Showing 5 changed files with 180 additions and 2 deletions.
37 changes: 37 additions & 0 deletions cdk_central_environment.star
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ zkevm_node_package = import_module("./lib/zkevm_node.star")
zkevm_prover_package = import_module("./lib/zkevm_prover.star")
zkevm_sequence_sender_package = import_module("./lib/zkevm_sequence_sender.star")
cdk_node_package = import_module("./lib/cdk_node.star")
cdk_aggoracle_package = import_module("./lib/cdk_aggoracle.star")
databases = import_module("./databases.star")


Expand Down Expand Up @@ -131,6 +132,36 @@ def run(plan, args, contract_setup_addresses):
description="Starting the cdk node components",
)

# Create the cdk aggoracle config.
aggoracle_config_template = read_file(
src="./templates/trusted-node/cdk-node-config.toml"
)
aggoracle_config_artifact = plan.render_templates(
name="cdk-aggoracle-config-artifact",
config={
"config.toml": struct(
template=aggoracle_config_template,
data=args
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(
args
),
}
| db_configs
| contract_setup_addresses,
)
},
)

# Start the aggoracle components.
cdk_aggoracle_configs = cdk_aggoracle_package.create_cdk_aggoracle_service_config(
args, aggoracle_config_artifact, genesis_artifact, keystore_artifacts
)

plan.add_services(
configs=cdk_aggoracle_configs,
description="Starting the cdk aggoracle components",
)

def get_keystores_artifacts(plan, args):
sequencer_keystore_artifact = plan.store_service_files(
Expand Down Expand Up @@ -158,12 +189,18 @@ def get_keystores_artifacts(plan, args):
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/claimsponsor.keystore",
)
aggoracle_keystore_artifact = plan.store_service_files(
name="aggoracle-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/aggoracle.keystore",
)
return struct(
sequencer=sequencer_keystore_artifact,
aggregator=aggregator_keystore_artifact,
proofsigner=proofsigner_keystore_artifact,
dac=dac_keystore_artifact,
claimsponsor=claimsponsor_keystore_artifact,
aggoracle=aggoracle_keystore_artifact,
)


Expand Down
8 changes: 6 additions & 2 deletions input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ DEFAULT_DEPLOYMENT_STAGES = {
# TODO: Remove this parameter to incorporate cdk-erigon inside the central environment.
"deploy_cdk_erigon_node": True,
# Deploy Optimism rollup.
"deploy_optimism_rollup": False,
"deploy_optimism_rollup": True,
# Deploy contracts on L2 (as well as fund accounts).
"deploy_l2_contracts": False,
}

DEFAULT_IMAGES = {
"agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.23", # https://github.com/agglayer/agglayer/tags
"cdk_aggoracle_image": "arnaubennassar/cdk:12b8e2c", # https://github.com/0xpolygon/cdk/pkgs/container/cdk
"cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.60.2", # https://hub.docker.com/r/hermeznetwork/cdk-erigon/tags
"cdk_node_image": "ghcr.io/0xpolygon/cdk:0.5.0-beta10", # 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 Down Expand Up @@ -110,7 +111,7 @@ DEFAULT_STATIC_PORTS = {

# Addresses and private keys of the different components.
# They have been generated using the following command:
# polycli wallet inspect --mnemonic 'lab code glass agree maid neutral vessel horror deny frequent favorite soft gate galaxy proof vintage once figure diary virtual scissors marble shrug drop' --addresses 11 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner,l1testing,claimsponsor",roles,",")} {print "# " roles[NR] "\n\"zkevm_l2_" roles[NR] "_address\": \"" $1 "\","; print "\"zkevm_l2_" roles[NR] "_private_key\": \"0x" $2 "\",\n"}'
# polycli wallet inspect --mnemonic 'lab code glass agree maid neutral vessel horror deny frequent favorite soft gate galaxy proof vintage once figure diary virtual scissors marble shrug drop' --addresses 12 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner,l1testing,claimsponsor,aggoracle",roles,",")} {print "# " roles[NR] "\n\"zkevm_l2_" roles[NR] "_address\": \"" $1 "\","; print "\"zkevm_l2_" roles[NR] "_private_key\": \"0x" $2 "\",\n"}'
DEFAULT_ACCOUNTS = {
# sequencer
"zkevm_l2_sequencer_address": "0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed",
Expand Down Expand Up @@ -145,6 +146,9 @@ DEFAULT_ACCOUNTS = {
# claimsponsor
"zkevm_l2_claimsponsor_address": "0x0b68058E5b2592b1f472AdFe106305295A332A7C",
"zkevm_l2_claimsponsor_private_key": "0x6d1d3ef5765cf34176d42276edd7a479ed5dc8dbf35182dfdb12e8aafe0a4919",
# aggoracle
"zkevm_l2_aggoracle_address": "0xc653eCD4AC5153a3700Fb13442Bcf00A691cca16",
"zkevm_l2_aggoracle_private_key": "0xa574853f4757bfdcbb59b03635324463750b27e16df897f3d00dc6bef2997ae0",
}

DEFAULT_L1_ARGS = {
Expand Down
60 changes: 60 additions & 0 deletions lib/cdk_aggoracle.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
ports_package = import_module("../src/package_io/ports.star")


def create_cdk_aggoracle_service_config(
args,
config_artifact,
genesis_artifact,
keystore_artifact,
):
cdk_aggoracle_name = "cdk-aggoracle" + args["deployment_suffix"]
(ports, public_ports) = get_cdk_aggoracle_ports(args)
service_command = get_cdk_aggoracle_cmd(args)
cdk_aggoracle_service_config = ServiceConfig(
image=args["cdk_node_image"],
ports=ports,
public_ports=public_ports,
files={
"/app": Directory(
artifact_names=[
config_artifact,
genesis_artifact,
keystore_artifact.claimsponsor,
keystore_artifact.aggoracle,
],
),
"/data": Directory(
artifact_names=[],
),
},
entrypoint=["sh", "-c"],
cmd=service_command,
)

return {cdk_aggoracle_name: cdk_aggoracle_service_config}


def get_cdk_aggoracle_ports(args):

# FEP requires the aggregator
ports = {
"rpc": PortSpec(
args["zkevm_cdk_node_port"],
application_protocol="http",
wait=None,
),
}

public_ports = ports_package.get_public_ports(ports, "cdk_node_start_port", args)
return (ports, public_ports)


def get_cdk_aggoracle_cmd(args):
service_command = [
"sleep 20 && cdk-node run "
+ "--cfg=/app/config.toml "
+ "--custom-network-file=/app/genesis.json "
+ "--components=aggoracle,rpc"
]

return service_command
1 change: 1 addition & 0 deletions templates/contract-deploy/create-keystores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ create_geth_keystore "agglayer.keystore" "{{.zkevm_l2_agglayer_private_ke
create_geth_keystore "dac.keystore" "{{.zkevm_l2_dac_private_key}}" "{{.zkevm_l2_keystore_password}}"
create_geth_keystore "proofsigner.keystore" "{{.zkevm_l2_proofsigner_private_key}}" "{{.zkevm_l2_keystore_password}}"
create_geth_keystore "claimsponsor.keystore" "{{.zkevm_l2_claimsponsor_private_key}}" "{{.zkevm_l2_keystore_password}}"
create_geth_keystore "aggoracle.keystore" "{{.zkevm_l2_aggoracle_private_key}}" "{{.zkevm_l2_keystore_password}}"
76 changes: 76 additions & 0 deletions templates/trusted-node/cdk-node-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,82 @@ Outputs = ["stderr"]
[RPC]
Port = {{.zkevm_cdk_node_port}}


[AggOracle]
TargetChainType="EVM"
URLRPCL1="http://el-1-geth-lighthouse:8545"
BlockFinality="FinalizedBlock"
WaitPeriodNextGER="1s"
[AggOracle.EVMSender]
GlobalExitRootL2="{{.zkevm_global_exit_root_l2_address}}"
URLRPCL2="http://cdk-erigon-rpc-001:8123" # This can be replaced with desired L2 e.g. OP Geth RPC
ChainIDL2=2151908
GasOffset=0
WaitPeriodMonitorTx="1s"
SenderAddr="{{.zkevm_l2_aggoracle_address}}"
[AggOracle.EVMSender.EthTxManager]
FrequencyToMonitorTxs = "1s"
WaitTxToBeMined = "1s"
GetReceiptMaxTime = "1s"
GetReceiptWaitInterval = "1s"
PrivateKeys = [
{Path = "/app/aggoracle.keystore", Password = "{{.zkevm_l2_keystore_password}}"},
]
ForcedGas = 0
GasPriceMarginFactor = 1
MaxGasPriceLimit = 0
PersistenceFilename = "/tmp/ethtxmanager-sequencesender.json"
ReadPendingL1Txs = false
SafeStatusL1NumberOfBlocks = 5
FinalizedStatusL1NumberOfBlocks = 10
[AggOracle.EVMSender.EthTxManager.Etherman]
URL = "http://cdk-erigon-rpc-001:8123" # This can be replaced with desired L2 e.g. OP Geth RPC
MultiGasProvider = false
L1ChainID = 2151908
HTTPHeaders = []

[ClaimSponsor]
DBPath = "/tmp/claimsponsor"
Enabled = true
SenderAddr = "{{.zkevm_l2_claimsponsor_address}}"
BridgeAddrL2 = "{{.zkevm_bridge_l2_address}}"
MaxGas = 200000
RetryAfterErrorPeriod = "1s"
MaxRetryAttemptsAfterError = -1
WaitTxToBeMinedPeriod = "3s"
WaitOnEmptyQueue = "3s"
GasOffset = 0
[ClaimSponsor.EthTxManager]
FrequencyToMonitorTxs = "1s"
WaitTxToBeMined = "2s"
GetReceiptMaxTime = "250ms"
GetReceiptWaitInterval = "1s"
PrivateKeys = [
{Path = "/app/claimsponsor.keystore", Password = "{{.zkevm_l2_keystore_password}}"},
]
ForcedGas = 0
GasPriceMarginFactor = 1
MaxGasPriceLimit = 0
PersistenceFilename = "/tmp/ethtxmanager-claimsponsor.json"
ReadPendingL1Txs = false
SafeStatusL1NumberOfBlocks = 5
FinalizedStatusL1NumberOfBlocks = 10
[ClaimSponsor.EthTxManager.Etherman]
URL = "http://cdk-erigon-rpc-001:8123" # This can be replaced with desired L2 e.g. OP Geth RPC
MultiGasProvider = false
L1ChainID = 2151908
HTTPHeaders = []

[LastGERSync]
DBPath = "/tmp/lastgersync"
BlockFinality = "LatestBlock"
InitialBlockNum = 0
GlobalExitRootL2Addr = "{{.zkevm_global_exit_root_l2_address}}"
RetryAfterErrorPeriod = "1s"
MaxRetryAttemptsAfterError = -1
WaitForNewBlocksPeriod = "1s"
DownloadBufferSize = 100

[AggSender]
CertificateSendInterval = "1m"
CheckSettledInterval = "5s"
Expand Down

0 comments on commit 673914d

Please sign in to comment.