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

chore: rename sidechain main cli #260

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion E2E-tests/config/substrate/ci_stack.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"cli": "export CARDANO_NODE_SOCKET_PATH=/ipc/node.socket && /tools/cardano-cli",
"ssh": "${stack_config[ssh]}"
},
"sidechain_main_cli": {
"pc_contracts_cli": {
"cli": "/tools/partner-chains-smart-contracts-6.1.0/sidechain-cli",
"ssh": "${stack_config[ssh]}"
},
Expand Down
2 changes: 1 addition & 1 deletion E2E-tests/config/substrate/devnet_stack.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"cli": "export CARDANO_NODE_SOCKET_PATH=/ipc/node.socket && /tools/cardano-cli",
"ssh": "${stack_config[ssh]}"
},
"sidechain_main_cli": {
"pc_contracts_cli": {
"cli": "/tools/partner-chains-smart-contracts-7.0.1/pc-contracts-cli",
"ssh": "${stack_config[ssh]}"
},
Expand Down
2 changes: 1 addition & 1 deletion E2E-tests/config/substrate/local_stack.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"cli": "cardano-cli",
"shell": "docker exec cardano-node-1 bash -c"
},
"sidechain_main_cli": {
"pc_contracts_cli": {
"cli": "./pc-contracts-cli",
"shell": "docker exec pc-contracts-cli bash -c"
},
Expand Down
2 changes: 1 addition & 1 deletion E2E-tests/config/substrate/staging_stack.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"cli": "export CARDANO_NODE_SOCKET_PATH=/ipc/node.socket && /tools/cardano-cli",
"ssh": "${stack_config[ssh]}"
},
"sidechain_main_cli": {
"pc_contracts_cli": {
"cli": "/tools/partner-chains-smart-contracts-7.0.1/pc-contracts-cli",
"ssh": "${stack_config[ssh]}"
},
Expand Down
6 changes: 3 additions & 3 deletions E2E-tests/docs/configure-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ As a user, you can choose where to place those services and binaries: on the tes
In case of the test runner machine (and local execution), you will need to update the binaries path in `stack_config.tools` for `<env>-stack.json` file in the `config/<blockchain>/<env>` folder:

- `cardano_cli`
- `sidechain_main_cli`
- `pc_contracts_cli`
- `generate_signatures_cli`

## Set up stack on remote host
Expand All @@ -30,7 +30,7 @@ To configure the stack, you will need to do the following:
3. Set `stack_config.ssh.host_keys_path` to the file added at step 3
4. Set `stack_config.ssh.private_key_path` to the file added at step 4
6. Set `tools.cardano_cli.cli` to the path to the cardano-cli binary. Do not forget about exposing CARDANO_NODE_SOCKET_PATH. E.g. `export CARDANO_NODE_SOCKET_PATH=/ipc/node.socket && /cardano-cli`
7. Set `tools.sidechain_main_cli` to the path to the `partner-chains-smart-contracts` binary
7. Set `tools.pc_contracts_cli` to the path to the `partner-chains-smart-contracts` binary
8. Set `tools.generate_signatures_cli` to the path to the `partner-chains-node` binary

### `<env>-stack.json` template:
Expand All @@ -52,7 +52,7 @@ To configure the stack, you will need to do the following:
"cli": <STRING>,
"ssh": "${stack_config[ssh]}"
},
"sidechain_main_cli": {
"pc_contracts_cli": {
"cli": <STRING>,
"ssh": "${stack_config[ssh]}"
},
Expand Down
4 changes: 2 additions & 2 deletions E2E-tests/docs/run-tests-on-new-env.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ E.g. for Cardano Preview it will be:
"cardano_cli": {
"cli": <STRING>, // path to cardano-cli binary
},
"sidechain_main_cli": {
"cli": <STRING> // path to sidechain-main-cli binary
"pc_contracts_cli": {
"cli": <STRING> // path to pc-contracts-cli binary
},
"generate_signatures_cli": {
"cli": <STRING> // path to partner-chains-node binary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import logging as logger


class SidechainMainCliException(Exception):
def __init__(self, message="Sidechain Main CLI error occurred", status_code=None):
class PCContractsCliException(Exception):
def __init__(self, message="PC Contracts CLI error occurred", status_code=None):
self.message = message
self.status_code = status_code
super().__init__(self.message)
Expand All @@ -31,18 +31,17 @@ def __init__(
self.sidechain_signature = sidechain_signature


class SidechainMainCli:
class PCContractsCli:
def __init__(self, config: ApiConfig, cardano_cli: CardanoCli):
sidechain_main_cli_config = config.stack_config.tools["sidechain_main_cli"]
self.cli = sidechain_main_cli_config.cli
self.generate_signatures_cli = config.stack_config.tools["generate_signatures_cli"].cli
pc_contracts_cli_config = config.stack_config.tools["pc_contracts_cli"]
self.cli = pc_contracts_cli_config.cli
self.cardano_cli = cardano_cli
self.config = config
self.run_command = RunnerFactory.get_runner(sidechain_main_cli_config.ssh, sidechain_main_cli_config.shell)
self.run_command = RunnerFactory.get_runner(pc_contracts_cli_config.ssh, pc_contracts_cli_config.shell)

def get_signatures(
self,
sidechain_registration_utxo,
partner_chain_registration_utxo,
spo_signing_key,
sidechain_signing_key,
aura_verification_key,
Expand All @@ -53,7 +52,7 @@ def get_signatures(
f"--genesis-utxo {self.config.genesis_utxo} "
f"--mainchain-signing-key {spo_signing_key} "
f"--sidechain-signing-key {sidechain_signing_key} "
f"--registration-utxo {sidechain_registration_utxo}"
f"--registration-utxo {partner_chain_registration_utxo}"
)

result = self.run_command.run(get_signatures_cmd)
Expand Down Expand Up @@ -250,15 +249,15 @@ def update_permissioned_candidates(self, governance_key, add_candidates_list, re
def handle_response(self, result):
if result.stderr and not result.stdout:
logger.error(f"Error during command: {result.stderr}")
raise SidechainMainCliException(result.stderr)
raise PCContractsCliException(result.stderr)

try:
json_part = self._get_json_string(result.stdout)
response = json.loads(json_part)
return response
except json.JSONDecodeError:
logger.error(f"Could not parse response of command: {result}")
raise SidechainMainCliException(result.stdout)
raise PCContractsCliException(result.stdout)

def _get_json_string(self, s):
start = s.find('{')
Expand Down
20 changes: 10 additions & 10 deletions E2E-tests/src/substrate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import logging as logger
from .run_command import RunnerFactory
from .cardano_cli import CardanoCli
from .sidechain_main_cli import SidechainMainCli
from .pc_contracts_cli import PCContractsCli
from .partner_chain_rpc import PartnerChainRpc, PartnerChainRpcResponse, PartnerChainRpcException, DParam
import string
import time
Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(self, config: ApiConfig, secrets, db_sync: Session):
self._substrate = None
self.run_command = RunnerFactory.get_runner(config.stack_config.ssh, config.stack_config.tools_shell)
self.cardano_cli = CardanoCli(config.main_chain, config.stack_config.tools["cardano_cli"])
self.sidechain_main_cli = SidechainMainCli(config, self.cardano_cli)
self.pc_contracts_cli = PCContractsCli(config, self.cardano_cli)
self.partner_chain_rpc = PartnerChainRpc(config.nodes_config.node.rpc_url)
self.partner_chain_epoch_calculator = PartnerChainEpochCalculator(config)
self.compact_encoder = RuntimeConfiguration().create_scale_object('Compact')
Expand Down Expand Up @@ -286,7 +286,7 @@ def _read_cardano_key_file(self, filepath):
def update_d_param(self, permissioned_candidates_count, registered_candidates_count):
signing_key = self.config.nodes_config.governance_authority.mainchain_key

result = self.sidechain_main_cli.update_d_param(
result = self.pc_contracts_cli.update_d_param(
permissioned_candidates_count,
registered_candidates_count,
signing_key,
Expand All @@ -309,15 +309,15 @@ def register_candidate(self, candidate_name):
registration_utxo = next(filter(lambda utxo: utxos_json[utxo]["value"]["lovelace"] > 2500000, utxos_json), None)
assert registration_utxo is not None, "ERROR: Could not find a well funded utxo for registration"

signatures = self.sidechain_main_cli.get_signatures(
signatures = self.pc_contracts_cli.get_signatures(
registration_utxo,
self._read_cardano_key_file(keys_files.spo_signing_key),
self._read_json_file(keys_files.partner_chain_signing_key)['skey'],
self.config.nodes_config.nodes[candidate_name].aura_public_key,
self.config.nodes_config.nodes[candidate_name].grandpa_public_key,
)

txId, next_status_epoch = self.sidechain_main_cli.register_candidate(
txId, next_status_epoch = self.pc_contracts_cli.register_candidate(
signatures,
keys_files.cardano_payment_key,
self._read_cardano_key_file(keys_files.spo_public_key),
Expand All @@ -335,7 +335,7 @@ def register_candidate(self, candidate_name):

def deregister_candidate(self, candidate_name):
keys_files = self.config.nodes_config.nodes[candidate_name].keys_files
txId, next_status_epoch = self.sidechain_main_cli.deregister_candidate(
txId, next_status_epoch = self.pc_contracts_cli.deregister_candidate(
keys_files.cardano_payment_key,
self._read_cardano_key_file(keys_files.spo_public_key),
)
Expand Down Expand Up @@ -376,7 +376,7 @@ def burn_tokens(self, recipient, amount, payment_key):
return self.burn_tokens_for_hex_address(recipient_hex, amount, payment_key)

def burn_tokens_for_hex_address(self, recipient_hex, amount, payment_key):
txHash = self.sidechain_main_cli.burn_tokens(recipient_hex, amount, payment_key)
txHash = self.pc_contracts_cli.burn_tokens(recipient_hex, amount, payment_key)
if txHash:
tx_block_no = self.get_mc_block_no_by_tx_hash(txHash)
mc_stable_block = tx_block_no + self.config.main_chain.security_param
Expand Down Expand Up @@ -451,7 +451,7 @@ def get_epoch_signatures(self, epoch) -> PartnerChainRpcResponse:
return response

def claim_tokens(self, mc_private_key_file, combined_proof, distributed_set_utxo=None) -> bool:
return self.sidechain_main_cli.claim_tokens(
return self.pc_contracts_cli.claim_tokens(
mc_private_key_file, combined_proof, distributed_set_utxo=distributed_set_utxo
)

Expand Down Expand Up @@ -603,7 +603,7 @@ def check_epoch_signatures_uploaded(self, pc_epoch=None):

def add_permissioned_candidate(self, candidate_name: str):
candidate = PermissionedCandidate(self.config.nodes_config.nodes[candidate_name])
txId, next_status_epoch = self.sidechain_main_cli.update_permissioned_candidates(
txId, next_status_epoch = self.pc_contracts_cli.update_permissioned_candidates(
self.config.nodes_config.governance_authority.mainchain_key, [candidate], []
)

Expand All @@ -618,7 +618,7 @@ def add_permissioned_candidate(self, candidate_name: str):

def remove_permissioned_candidate(self, candidate_name: str):
candidate = PermissionedCandidate(self.config.nodes_config.nodes[candidate_name])
txId, next_status_epoch = self.sidechain_main_cli.update_permissioned_candidates(
txId, next_status_epoch = self.pc_contracts_cli.update_permissioned_candidates(
self.config.nodes_config.governance_authority.mainchain_key, [], [candidate]
)

Expand Down
10 changes: 5 additions & 5 deletions E2E-tests/tests/active_flow/test_active_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from src.db.models import OutgoingTx
from sqlalchemy.orm import Session
from pytest import mark, raises
from src.sidechain_main_cli import SidechainMainCliException
from src.pc_contracts_cli import PCContractsCliException


@mark.skip_blockchain("pc_evm", reason="not implemented yet")
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_claim_transactions(
"""Test that the user can claim tokens after committee handover

* wait until the next committee handover for a partner chain epoch
* claim tokens by executing claimTokens() from sidechain-main-cli
* claim tokens by executing claimTokens() from pc-contracts-cli
"""
for db_tx in unclaimed_outgoing_txs:
logging.info(f"Checking if committee handover happened for epoch {db_tx.available_on_pc_epoch}")
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_claim_transaction_signed_by_another_recipient_should_fail(
logging.info(f"Checking if committee handover happened for epoch {db_tx.available_on_pc_epoch}")
wait_until(api.check_epoch_signatures_uploaded, db_tx.available_on_pc_epoch, timeout=config.timeouts.claim_cmd)
logging.info(f"Handover for pc epoch {db_tx.available_on_pc_epoch} has happened")
with raises(SidechainMainCliException) as excinfo:
with raises(PCContractsCliException) as excinfo:
api.claim_tokens(config.nodes_config.random_mc_account.mainchain_key, db_tx.combined_proof)
assert "ERROR-FUEL-MINTING-POLICY-04" in excinfo.value.message

Expand All @@ -368,7 +368,7 @@ def test_claim_transaction_with_invalid_key_should_fail(
logging.info(f"Checking if committee handover happened for epoch {db_tx.available_on_pc_epoch}")
wait_until(api.check_epoch_signatures_uploaded, db_tx.available_on_pc_epoch, timeout=config.timeouts.claim_cmd)
logging.info(f"Handover for pc epoch {db_tx.available_on_pc_epoch} has happened")
with raises(SidechainMainCliException) as excinfo:
with raises(PCContractsCliException) as excinfo:
api.claim_tokens(config.nodes_config.invalid_mc_skey.mainchain_key, db_tx.combined_proof)
assert "Error while decoding key" in excinfo.value.message

Expand All @@ -384,7 +384,7 @@ def test_claim_on_already_claimed_transaction_should_fail(
* claiming tokens for that transaction again should fail
"""
logging.info(f"Claiming tx that should fail: {latest_claimed_outgoing_tx}")
with raises(SidechainMainCliException) as excinfo:
with raises(PCContractsCliException) as excinfo:
api.claim_tokens(
config.nodes_config.active_transfer_account.mainchain_key,
latest_claimed_outgoing_tx.combined_proof,
Expand Down
4 changes: 2 additions & 2 deletions E2E-tests/tests/committee/test_permissioned_registrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from src.blockchain_api import BlockchainApi
from src.db.models import PermissionedCandidates
from sqlalchemy.orm import Session
from src.sidechain_main_cli import SidechainMainCliException
from src.pc_contracts_cli import PCContractsCliException
from pytest import mark


Expand All @@ -24,7 +24,7 @@ def test_add_permissioned_candidate(permissioned_candidate: PermissionedCandidat
logging.info(f"Adding permissioned candidate {permissioned_candidate.name}")
try:
result, next_status_epoch = api.add_permissioned_candidate(permissioned_candidate.name)
except SidechainMainCliException as e:
except PCContractsCliException as e:
if 'InvalidCLIParams "New candidates list is the same as the currently stored list."' in str(e):
pytest.skip("Skipping test because the candidate is already in the list")
else:
Expand Down
8 changes: 4 additions & 4 deletions E2E-tests/tests/passive_flow/test_passive_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy import Sequence
from pytest import mark
import pytest
from src.sidechain_main_cli import SidechainMainCliException
from src.pc_contracts_cli import PCContractsCliException


def get_burn_tx_from_rpc(api: BlockchainApi, tx_hash):
Expand Down Expand Up @@ -115,7 +115,7 @@ def test_burn_more_than_balance_should_fail(api: BlockchainApi, config: ApiConfi
burning_key = config.nodes_config.passive_transfer_account.mainchain_key
pc_addr = config.nodes_config.negative_test_transfer_account.partner_chain_address

with pytest.raises(SidechainMainCliException) as excinfo:
with pytest.raises(PCContractsCliException) as excinfo:
api.burn_tokens(pc_addr, amount, burning_key)
assert "BalanceInsufficientError" in excinfo.value.message

Expand All @@ -133,7 +133,7 @@ def test_burn_negative_balance_should_fail(api: BlockchainApi, config: ApiConfig
burning_key = config.nodes_config.passive_transfer_account.mainchain_key
pc_addr = config.nodes_config.negative_test_transfer_account.partner_chain_address

with pytest.raises(SidechainMainCliException) as excinfo:
with pytest.raises(PCContractsCliException) as excinfo:
api.burn_tokens(pc_addr, amount, burning_key)
assert "ExUnitsEvaluationFailed" in excinfo.value.message

Expand All @@ -150,7 +150,7 @@ def test_burn_with_invalid_key_should_fail(api: BlockchainApi, config: ApiConfig
burning_key = config.nodes_config.invalid_mc_skey.mainchain_key
pc_addr = config.nodes_config.negative_test_transfer_account.partner_chain_address

with pytest.raises(SidechainMainCliException) as excinfo:
with pytest.raises(PCContractsCliException) as excinfo:
api.burn_tokens(pc_addr, amount, burning_key)
assert "Error while decoding key" in excinfo.value.message

Expand Down
28 changes: 28 additions & 0 deletions dev/local-environment/.env.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
POSTGRES_PORT=5432
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it or add to gitignore

POSTGRES_PASSWORD=azMpOp4mTqhlKDmgCVQr
OGMIOS_PORT=1337
KUPO_PORT=1442
CPU_PARTNER_CHAINS_NODE=0.000
MEM_PARTNER_CHAINS_NODE=1000G
CPU_CARDANO=0.000
MEM_CARDANO=1000G
CPU_POSTGRES=0.000
MEM_POSTGRES=1000G
CPU_DBSYNC=0.000
MEM_DBSYNC=1000G
CPU_OGMIOS=0.000
MEM_OGMIOS=1000G
CPU_KUPO=0.000
MEM_KUPO=1000G
ARTIFACT_OVERRIDE=no
CARDANO_IMAGE=ghcr.io/intersectmbo/cardano-node:10.1.2
DBSYNC_IMAGE=ghcr.io/intersectmbo/cardano-db-sync:13.5.0.2
KUPO_IMAGE=cardanosolutions/kupo:v2.9.0
OGMIOS_IMAGE=cardanosolutions/ogmios:v6.9.0
POSTGRES_IMAGE=postgres:15.3
SIDECHAIN_MAIN_CLI_IMAGE=node:22-bookworm
TESTS_IMAGE=python:3.10-slim
PARTNER_CHAINS_NODE_IMAGE=ghcr.io/input-output-hk/partner-chains/partner-chains-node:v1.3.0
PC_CONTRACTS_CLI_ZIP_URL=https://github.com/input-output-hk/partner-chains-smart-contracts/releases/download/v7.0.1/pc-contracts-cli-v7.0.1.zip
PARTNER_CHAINS_NODE_URL=https://github.com/input-output-hk/partner-chains/releases/download/v1.3.0/partner-chains-node-v1.3.0-x86_64-linux
PARTNER_CHAINS_CLI_URL=https://github.com/input-output-hk/partner-chains/releases/download/v1.3.0/partner-chains-cli-v1.3.0-x86_64-linux
Loading
Loading