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

Problem: no doc for feemarket param gov proposal #1344

Merged
merged 1 commit into from
Mar 12, 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
10 changes: 9 additions & 1 deletion integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ def gov_propose_v0_7(self, proposer, kind, proposal, **kwargs):

def gov_propose_legacy(self, proposer, kind, proposal, **kwargs):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
kwargs.setdefault("gas", 300000)
if kind == "software-upgrade":
return json.loads(
self.raw(
Expand Down Expand Up @@ -782,7 +783,9 @@ def gov_vote(self, voter, proposal_id, option, **kwargs):
)
)

def gov_deposit(self, depositor, proposal_id, amount):
def gov_deposit(self, depositor, proposal_id, amount, **kwargs):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
kwargs.setdefault("gas", 300000)
return json.loads(
self.raw(
"tx",
Expand All @@ -796,6 +799,7 @@ def gov_deposit(self, depositor, proposal_id, amount):
node=self.node_rpc,
keyring_backend="test",
chain_id=self.chain_id,
**kwargs,
)
)

Expand Down Expand Up @@ -1452,3 +1456,7 @@ def changeset_ingest_versiondb_sst(self, versiondb_dir, sst_dir, **kwargs):
"--move-files",
**kwargs,
).decode()

def query_feemarket_params(self, **kwargs):
res = self.raw("q", "feemarket", "params", home=self.data_dir, **kwargs)
return json.loads(res)
28 changes: 28 additions & 0 deletions integration_tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from decimal import Decimal
from pathlib import Path

import pytest
Expand All @@ -16,6 +17,7 @@
KEYS,
Greeter,
RevertTestContract,
approve_proposal,
build_batch_tx,
contract_address,
contract_path,
Expand Down Expand Up @@ -732,3 +734,29 @@ def test_replay_protection(cronos):
match=r"only replay-protected \(EIP-155\) transactions allowed over RPC",
):
w3.eth.send_raw_transaction(HexBytes(raw))


def test_gov_min_gas_price(cronos):
cli = cronos.cosmos_cli()
orig = Decimal(cli.query_feemarket_params()["params"]["min_gas_price"])

rsp = cli.gov_propose_legacy(
"community",
"param-change",
{
"title": "Update MinGasPrice",
"description": "Update MinGasPrice",
"changes": [
{
"subspace": "feemarket",
"key": "MinGasPrice",
"value": str(orig + Decimal("0.1")),
},
],
},
)

approve_proposal(cronos, rsp)

new = Decimal(cli.query_feemarket_params()["params"]["min_gas_price"])
assert new == orig + Decimal("0.1")
39 changes: 39 additions & 0 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import time
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor, as_completed
from datetime import timedelta
from pathlib import Path

import bech32
Expand Down Expand Up @@ -524,3 +525,41 @@ def send_txs(w3, cli, to, keys, params):
sended_hash_set = send_raw_transactions(w3, raw_transactions)

return block_num_0, sended_hash_set


def find_log_event_attrs(logs, ev_type, cond=None):
for ev in logs[0]["events"]:
if ev["type"] == ev_type:
attrs = {attr["key"]: attr["value"] for attr in ev["attributes"]}
if cond is None or cond(attrs):
return attrs
return None


def get_proposal_id(rsp, msg):
def cb(attrs):
return "proposal_id" in attrs

ev = find_log_event_attrs(rsp["logs"], "submit_proposal", cb)
assert ev["proposal_messages"] == msg, rsp
return ev["proposal_id"]


def approve_proposal(n, rsp):
# get proposal_id
proposal_id = get_proposal_id(rsp, ",/cosmos.gov.v1.MsgExecLegacyContent")
cli = n.cosmos_cli()
proposal = cli.query_proposal(proposal_id)
assert proposal["status"] == "PROPOSAL_STATUS_DEPOSIT_PERIOD", proposal
rsp = cli.gov_deposit("community", proposal_id, "1basetcro")
assert rsp["code"] == 0, rsp["raw_log"]
proposal = cli.query_proposal(proposal_id)
assert proposal["status"] == "PROPOSAL_STATUS_VOTING_PERIOD", proposal
for i in range(len(n.config["validators"])):
rsp = n.cosmos_cli(i).gov_vote("validator", proposal_id, "yes")
assert rsp["code"] == 0, rsp["raw_log"]
wait_for_block_time(
cli, isoparse(proposal["voting_end_time"]) + timedelta(seconds=5)
)
proposal = cli.query_proposal(proposal_id)
assert proposal["status"] == "PROPOSAL_STATUS_PASSED", proposal
Loading