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

Fix: gov-action-loader: remove old cardano-cli dependency #1511

Merged
merged 1 commit into from
Jul 11, 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
7 changes: 0 additions & 7 deletions gov-action-loader/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
FROM python:3.10 AS builder

WORKDIR /app
# Install cardano-cli

RUN \
wget https://github.com/input-output-hk/cardano-node/releases/download/8.5.0-pre/cardano-node-8.5.0-linux.tar.gz \
&& tar -xvzf cardano-node-8.5.0-linux.tar.gz \
&& mv ./cardano-cli /usr/local/bin/cardano-cli \
&& rm -rf /code/*

COPY ./requirements.txt ./requirements.txt
RUN pip install --no-cache-dir --upgrade -r ./requirements.txt
Expand Down
6 changes: 3 additions & 3 deletions gov-action-loader/backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from app.settings import settings
from app.transaction import (get_base_proposal_for_multiple,
get_default_transaction,
get_proposal_data_from_type, get_txid_from_cli,
get_proposal_data_from_type,
main_wallet, submit_proposal_tx)

app = FastAPI()
Expand Down Expand Up @@ -106,7 +106,7 @@ async def submit_multiple_proposals(
else:
raise HTTPException(
status_code=400,
detail="No of proposals greater than 100 not supported yet.",
detail="No of proposals greater than "+str(maximum_supported_proposals)+" not supported yet.",
)


Expand Down Expand Up @@ -134,7 +134,7 @@ async def submit_single_proposal(
if kuber_response.status_code == 200:
tx = kuber_response.json()
tx["type"] = "Witnessed Tx ConwayEra"
tx_id = get_txid_from_cli(tx)
tx_id = tx['hash']
return tx | {"txId": tx_id}
else:
print(kuber_response.text)
Expand Down
49 changes: 5 additions & 44 deletions gov-action-loader/backend/app/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,38 +160,11 @@ def get_proposal_data_from_type(proposal_type, current_pParams):


def filter_updatable_paramKeys(keys):
updatable_keys = set(
[
"maxBlockSize",
"maxBBSize",
"maxTxSize",
"maxBHSize",
"keyDeposit",
"poolDeposit",
"eMax",
"nOpt",
"a0",
"rho",
"tau",
"minPoolCost",
"coinsPerUTxOByte",
"costModels",
"prices",
"maxTxExUnits",
"maxBlockExUnits",
"maxValSize",
"collateralPercentage",
"maxCollateralInputs",
"poolVotingThresholds",
"dRepVotingThresholds",
"committeeMinSize",
"committeeMaxTermLength",
"govActionLifetime",
"govActionDeposit",
"dRepDeposit",
"dRepActivity",
]
)
updatable_keys = {"maxBlockSize", "maxBBSize", "maxTxSize", "maxBHSize", "keyDeposit", "poolDeposit", "eMax",
"nOpt", "a0", "rho", "tau", "minPoolCost", "coinsPerUTxOByte", "costModels", "prices",
"maxTxExUnits", "maxBlockExUnits", "maxValSize", "collateralPercentage", "maxCollateralInputs",
"poolVotingThresholds", "dRepVotingThresholds", "committeeMinSize", "committeeMaxTermLength",
"govActionLifetime", "govActionDeposit", "dRepDeposit", "dRepActivity"}
return [x for x in keys if x in updatable_keys]


Expand Down Expand Up @@ -230,15 +203,3 @@ async def submit_proposal_tx(wallet, proposal, proposal_numbers, client):
"proposals": proposals,
}
return await submit_tx(tx, client)


def get_txid_from_cli(tx: Dict[str, Any]):
try:
with open("tx.raw", "w") as file:
json.dump(tx, file)
tx_id_command = "cardano-cli transaction txid --tx-file tx.raw"
tx_id_raw = subprocess.check_output(["bash", "-c", tx_id_command])
tx_id = tx_id_raw.decode("utf-8").strip()
return tx_id
finally:
os.remove("tx.raw")