Skip to content

Commit

Permalink
Merge branch 'feat/v2.10/feemarket' of https://github.com/terra-money…
Browse files Browse the repository at this point in the history
…/core into feat/v2.10/feemarket
  • Loading branch information
emidev98 committed Feb 29, 2024
2 parents 3694ea0 + 2a8cc5a commit 41eaa7b
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 34 deletions.
4 changes: 4 additions & 0 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
feemarketante.NewFeeMarketCheckDecorator( // fee market check replaces fee deduct decorator
options.FeeMarketKeeper,
options.AccountKeeper,
options.BankKeeper,
options.FeegrantKeeper,
options.TxFeeChecker,
), // fees are deducted in the fee market deduct post handler
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,6 @@ replace (
github.com/cosmos/ibc-go/v7 => github.com/terra-money/ibc-go/v7 v7.3.1-terra.0
github.com/cosmos/ledger-cosmos-go => github.com/terra-money/ledger-terra-go v0.11.2
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/skip-mev/feemarket => github.com/terra-money/feemarket v0.0.0-20240206032516-4ee63309c483
github.com/skip-mev/feemarket => github.com/terra-money/feemarket v0.0.0-20240215105105-dc75f934f9ba
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1136,8 +1136,8 @@ github.com/terra-money/alliance v0.3.4 h1:rBEKw8o9mN8AL6yCS2+Pb8DIi82an2HUnfdUtq
github.com/terra-money/alliance v0.3.4/go.mod h1:HDiUexeXRUkLkLRw5jLQcHuVt1Sx43HfyVl0kfwW3JM=
github.com/terra-money/cosmos-sdk v0.47.6-terra.0 h1:BrK2cq8W5HsMT5siVdJCFDx1vcEMm+BGN5713FEm84g=
github.com/terra-money/cosmos-sdk v0.47.6-terra.0/go.mod h1:xTc1chW8HyUWCfrgGbjS5jNu9RzlPVrBNfbL9RmZUio=
github.com/terra-money/feemarket v0.0.0-20240206032516-4ee63309c483 h1:gyk2P3ArL1owdohKMC/zYY8h1TU3AQ/EMejOR6Okhcg=
github.com/terra-money/feemarket v0.0.0-20240206032516-4ee63309c483/go.mod h1:Gl4UMT4EKGUj/qq9fn4JtH8tsDDjVzzN/2VMK55SXdo=
github.com/terra-money/feemarket v0.0.0-20240215105105-dc75f934f9ba h1:bZhxyABS7PcsvSZx58Vv/IdaC0c/2RsdSX+3sgFbkPk=
github.com/terra-money/feemarket v0.0.0-20240215105105-dc75f934f9ba/go.mod h1:Gl4UMT4EKGUj/qq9fn4JtH8tsDDjVzzN/2VMK55SXdo=
github.com/terra-money/ibc-go/v7 v7.3.1-terra.0 h1:CF+iicqyI4BJsW2zjUrUrTxRRrPWFZC30VqvlRyVl28=
github.com/terra-money/ibc-go/v7 v7.3.1-terra.0/go.mod h1:wvx4pPBofe5ZdMNV3OFRxSI4auEP5Qfqf8JXLLNV04g=
github.com/terra-money/ledger-terra-go v0.11.2 h1:BVXZl+OhJOri6vFNjjVaTabRLApw9MuG7mxWL4V718c=
Expand Down
44 changes: 15 additions & 29 deletions integration-tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"typescript": "^5.2.2"
},
"dependencies": {
"@terra-money/feather.js": "2.1.0-beta.1",
"@terra-money/feather.js": "2.1.0-beta.2",
"moment": "^2.29.4"
}
}
180 changes: 179 additions & 1 deletion integration-tests/src/modules/feemarket/feemarket.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Coins, Fee, MnemonicKey, MsgSend, MsgSubmitProposal, MsgVote } from "@terra-money/feather.js";
import { VoteOption } from "@terra-money/terra.proto/cosmos/gov/v1beta1/gov";
import { blockInclusion, getLCDClient, getMnemonics, votingPeriod } from "../../helpers";
import { FeemarketParams, MsgFeeDenomParam, MsgParams } from "@terra-money/feather.js/dist/core/feemarket";
import { FeemarketParams, MsgFeeDenomParam, MsgRemoveFeeDenomParam, MsgParams } from "@terra-money/feather.js/dist/core/feemarket";


describe("Feemarket Module (https://github.com/terra-money/feemarket/tree/v0.0.1-alpha.2-terra.0) ", () => {
Expand Down Expand Up @@ -205,6 +205,184 @@ describe("Feemarket Module (https://github.com/terra-money/feemarket/tree/v0.0.1
}
});

test('Must send a proposal to add fee denom for stake and validate it has been added correctly', async () => {
try {
// Create an state update proposal sign and submit on chain-1
let tx = await val1Wallet.createAndSignTx({
msgs: [new MsgSubmitProposal(
[new MsgFeeDenomParam(
'stake',
'1550000000000000',
'terra10d07y265gmmuvt4z0w9aw880jnsr700juxf95n',
)],
Coins.fromString("1000000000uluna"),
val1WalletAddress,
"metadata",
"title",
"summary"
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
let result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await blockInclusion();

// Check that the proposal was created successfully
let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any;
expect(txResult.code).toBe(0);

// Get the proposal id and validate exists
const proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]);
expect(proposalId).toBeDefined();

// Vote for the proposal
tx = await val1Wallet.createAndSignTx({
msgs: [new MsgVote(
proposalId,
val1WalletAddress,
VoteOption.VOTE_OPTION_YES
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await votingPeriod();

// Validate the tx vote was casted successflully
txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1")
expect(txResult.code).toBe(0);

// Query the feemarket state for uluna and validate the new values
const res = (await LCD.chain1.feemarket.feeDenomParam("test-1", "stake"))[0];
expect(res.feeDenom).toEqual("stake");
expect(res.baseFee.toNumber()).toBeGreaterThanOrEqual(0.00155);
expect(res.minBaseFee.toString()).toStrictEqual("0.00155");
}
catch (e: any) {
console.log(e)
expect(e).toBeUndefined();
}
});

test('Must send a proposal to remove fee denom for stake and validate it has been removed correctly', async () => {
try {
// Create an state update proposal sign and submit on chain-1
let tx = await val1Wallet.createAndSignTx({
msgs: [new MsgSubmitProposal(
[new MsgRemoveFeeDenomParam(
'stake',
'terra10d07y265gmmuvt4z0w9aw880jnsr700juxf95n',
)],
Coins.fromString("1000000000uluna"),
val1WalletAddress,
"metadata",
"title",
"summary"
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
let result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await blockInclusion();

// Check that the proposal was created successfully
let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any;
expect(txResult.code).toBe(0);

// Get the proposal id and validate exists
const proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]);
expect(proposalId).toBeDefined();

// Vote for the proposal
tx = await val1Wallet.createAndSignTx({
msgs: [new MsgVote(
proposalId,
val1WalletAddress,
VoteOption.VOTE_OPTION_YES
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await votingPeriod();

// Validate the tx vote was casted successflully
txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1")
expect(txResult.code).toBe(0);

// Query the feemarket state for uluna and validate the new values
try {
await LCD.chain1.feemarket.feeDenomParam("test-1", "stake");
} catch(e: any) {
expect(e.message).toBe("Request failed with status code 500");
return;
}
throw new Error('No error was thrown when trying to query the removed fee denom.')
}
catch (e: any) {
console.log(e)
expect(e.message).toBeUndefined();
}
});

test('Must send a proposal to remove default fee denom uluna and validate it will not be removed after execution', async () => {
try {
// Create an state update proposal sign and submit on chain-1
let tx = await val1Wallet.createAndSignTx({
msgs: [new MsgSubmitProposal(
[new MsgRemoveFeeDenomParam(
'uluna',
'terra10d07y265gmmuvt4z0w9aw880jnsr700juxf95n',
)],
Coins.fromString("1000000000uluna"),
val1WalletAddress,
"metadata",
"title",
"summary"
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
let result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await blockInclusion();

// Check that the proposal was created successfully
let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any;
expect(txResult.code).toBe(0);

// Get the proposal id and validate exists
const proposalId = Number(txResult.logs[0].eventsByType.submit_proposal.proposal_id[0]);
expect(proposalId).toBeDefined();

// Vote for the proposal
tx = await val1Wallet.createAndSignTx({
msgs: [new MsgVote(
proposalId,
val1WalletAddress,
VoteOption.VOTE_OPTION_YES
)],
chainID: "test-1",
fee: new Fee(200000, Coins.fromString("1000000uluna"))
});
result = await LCD.chain1.tx.broadcastSync(tx, "test-1");
await votingPeriod();

// Validate the tx vote was casted successflully
txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1")
expect(txResult.code).toBe(0);

// Query the feemarket state for uluna and validate the new values
const res = (await LCD.chain1.feemarket.feeDenomParam("test-1", "uluna"))[0];
expect(res.feeDenom).toEqual("uluna");
expect(res.baseFee.toNumber()).toBeGreaterThanOrEqual(0.00155);
expect(res.minBaseFee.toString()).toStrictEqual("0.00155");
}
catch (e: any) {
console.log(e)
expect(e.message).toBeUndefined();
}
});

test('Must modify the fees back to the default values', async () => {
try {
// Create a FeemarketParams proposal change and
Expand Down

0 comments on commit 41eaa7b

Please sign in to comment.