Skip to content

Commit

Permalink
Merge pull request #126 from wonkr/ethereum-redesign
Browse files Browse the repository at this point in the history
Ethereum Service meta data label update
  • Loading branch information
wonkr authored Feb 21, 2023
2 parents faff837 + c3282a4 commit 775ee8c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions seedemu/services/EthereumService/EthereumServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from .EthTemplates import EthServerFileTemplates, GethCommandTemplates
from .EthTemplates.LighthouseCommandTemplates import *

ETH_LABEL_META = 'ethereum.{key}'

class EthereumServer(Server):
"""!
@brief The Ethereum Server
Expand Down Expand Up @@ -38,7 +40,9 @@ class EthereumServer(Server):
_miner_thread: int
_coinbase: str

_geth_start_command:str
_geth_start_command: str

_role: list

def __init__(self, id: int, blockchain:Blockchain):
"""!
Expand Down Expand Up @@ -75,6 +79,8 @@ def __init__(self, id: int, blockchain:Blockchain):
self._miner_thread = 1
self._coinbase = ""
self._geth_start_command = ""

self._role = []


def _generateGethStartCommand(self):
Expand Down Expand Up @@ -111,10 +117,14 @@ def install(self, node: Node, eth: EthereumService):
"""

node.appendClassName('EthereumService')
node.setLabel('node_id', self.getId())
node.setLabel('consensus', self._consensus_mechanism.value)
node.setLabel('blockchain', self._blockchain.getChainName())
node.setLabel('chain_id', self._blockchain.getChainId())
node.setLabel(ETH_LABEL_META.format(key='node_id'), self.getId())
node.setLabel(ETH_LABEL_META.format(key='consensus'), self._consensus_mechanism.value)
node.setLabel(ETH_LABEL_META.format(key='chain_name'), self._blockchain.getChainName())
node.setLabel(ETH_LABEL_META.format(key='chain_id'), self._blockchain.getChainId())

if self.isBootNode(): self._role.append("bootnode")
if self.isStartMiner(): self._role.append("miner")
node.setLabel(ETH_LABEL_META.format(key='role'), json.dumps(self._role).replace("\"", "\\\""))

ifaces = node.getInterfaces()
assert len(ifaces) > 0, 'EthereumServer::install: node as{}/{} has no interfaces'.format(node.getAsn(), node.getName())
Expand Down Expand Up @@ -586,6 +596,11 @@ def install(self, node: Node, eth: EthereumService):
beacon_setup_node.install(node, self._blockchain)
return

if self.__is_beacon_validator_at_genesis:
self._role.append("validator_at_genesis")
if self.__is_beacon_validator_at_running:
self._role.append("validator_at_running")

super().install(node,eth)
self.__install_beacon(node, eth)

Expand Down

0 comments on commit 775ee8c

Please sign in to comment.