aergo_bridge_operator
¶
-
class
aergo_bridge_operator.validator_server.
ValidatorService
(config_file_path: str, aergo1: str, aergo2: str, privkey_name: str = None, privkey_pwd: str = None, validator_index: int = 0, anchoring_on: bool = False, auto_update: bool = False, oracle_update: bool = False)¶ Validates anchors for the bridge proposer
-
GetAnchorSignature
(anchor, context)¶ Verifies the anchors are valid and signes them aergo1 and aergo2 must be trusted.
-
GetOracleSignature
(oracle_msg, context)¶ Get signature to update bridge oracle
-
GetTAnchorSignature
(tempo_msg, context)¶ Get a vote(signature) from the validator to update the t_anchor setting in the Aergo bridge contract
-
GetTFinalSignature
(tempo_msg, context)¶ Get a vote(signature) from the validator to update the t_final setting in the Aergo bridge contract
-
GetValidatorsSignature
(val_msg, context)¶ Get signature to update validators of anchors
-
get_oracle
(hera: aergo.herapy.aergo.Aergo, aergo_from: str, aergo_to: str, oracle_to: str, id_to: str, bridge_to: str, oracle_msg)¶ Get a vote(signature) from the validator to update the oracle controlling the bridge contract
-
is_valid_anchor
(anchor, aergo_from: aergo.herapy.aergo.Aergo, bridge_from: str, aergo_to: aergo.herapy.aergo.Aergo, bridge_to: str, oracle_to: str) → Optional[str]¶ An anchor is valid if : 1- it’s height is finalized 2- it’s root for that height is correct. 3- it’s nonce is correct 4- it’s height is higher than previous anchored height + t_anchor
-
-
class
aergo_bridge_operator.proposer_client.
BridgeProposerClient
(config_file_path: str, aergo_mainnet: str, aergo_sidechain: str, privkey_name: str = None, privkey_pwd: str = None, anchoring_on: bool = False, auto_update: bool = False, oracle_update: bool = False)¶ The BridgeProposerClient starts proposers on both sides of the bridge
-
class
aergo_bridge_operator.proposer_client.
ProposerClient
(config_file_path: str, aergo_from: str, aergo_to: str, is_from_mainnet: bool, privkey_name: str = None, privkey_pwd: str = None, anchoring_on: bool = False, auto_update: bool = False, oracle_update: bool = False)¶ The proposer client periodically (every t_anchor) broadcasts the finalized trie state root (after lib) of the bridge contract on the other side of the bridge after validation by the Validator servers. It first checks the last merged height and waits until now > lib + t_anchor is reached, then merges the current finalised block (lib). Start again after waiting t_anchor.
- Note on config_data:
- config_data is used to store current validators and their ip when the proposer starts. (change validators after the proposer has started)
- After starting, when users change the config.json, the proposer will attempt to gather signatures to reflect the changes.
- t_anchor value is always taken from the bridge contract
- validators are taken from the config_data because ip information is not stored on chain
- when a validator set update succeeds, self.config_data is updated
- if another proposer updates to a new set of validators and the proposer doesnt know about it, proposer must be restarted with the new current validator set to create new connections to them.
-
extract_signatures
(approvals: List[Any]) → Tuple[List[str], List[int]]¶ Convert signatures to hex string and keep 2/3 of them.
-
get_anchor_signatures
(root: str, merge_height: int, nonce: int) → Tuple[List[str], List[int]]¶ Query all validators and gather 2/3 of their signatures.
-
get_new_oracle_signatures
(oracle)¶ Request approvals of validators for the new oracle.
-
get_new_validators_signatures
(validators)¶ Request approvals of validators for the new validator set.
-
get_signature_worker
(rpc_service: str, request, h: bytes, index: int) → Optional[Any]¶ Get a validator’s (index) signature and verify it
-
get_tempo_signatures
(tempo, rpc_service, tempo_id)¶ Request approvals of validators for the new t_anchor or t_final.
-
monitor_settings
()¶ Check if a modification of bridge settings is requested by seeing if the config file has been changed and try to update the bridge contract (gather 2/3 validators signatures).
-
monitor_settings_and_sleep
(sleeping_time)¶ While sleeping, periodicaly check changes to the config file and update settings if necessary. If another proposer updated settings it doesnt matter, validators will just not give signatures.
-
new_anchor
(root: str, next_anchor_height: int, validator_indexes: List[int], sigs: List[str]) → None¶ Anchor a new root on chain
-
run
() → None¶ Gathers signatures from validators, verifies them, and if 2/3 majority is acquired, set the new anchored root in bridge_to.
-
set_oracle
(new_oracle, validator_indexes, sigs)¶ Update oracle on chain
-
set_tempo
(t_anchor, validator_indexes, sigs, contract_function) → bool¶ Update t_anchor or t_final on chain
-
set_validators
(new_validators, validator_indexes, sigs)¶ Update validators on chain
-
update_oracle
(oracle)¶ Try to update the oracle periode registered in the bridge contract.
-
update_t_anchor
(t_anchor)¶ Try to update the anchoring periode registered in the bridge contract.
-
update_t_final
(t_final)¶ Try to update the anchoring periode registered in the bridge contract.
-
update_validator_connections
()¶ Update connections to validators after a successful update of bridge validators with the validators in the config file.
-
update_validators
(new_validators)¶ Try to update the validator set with the one in the config file.
-
wait_next_anchor
(merged_height: int) → int¶ Wait until t_anchor has passed after merged height. Return the next finalized block after t_anchor to be the next anchor
-
exception
aergo_bridge_operator.proposer_client.
ValidatorMajorityError
¶