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

feat: tax2gas #500

Merged
merged 77 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
419ce91
Add tax2gas module and move all handle fees logic to tax2gas module
phamminh0811 Jun 24, 2024
7500c39
lint
phamminh0811 Jun 24, 2024
1599911
proto lint
phamminh0811 Jun 24, 2024
8fe545d
revert change in protocgen
phamminh0811 Jun 24, 2024
c40fa96
add tax2gas module and implementation
expertdicer Jul 8, 2024
22a7186
remove redundant files
expertdicer Jul 8, 2024
ef4264f
remove wasm file
expertdicer Jul 8, 2024
226de57
remove wasm file
expertdicer Jul 8, 2024
a2ae5c9
change proto
expertdicer Jul 8, 2024
4cd85c9
v8_1 upgrade handler
expertdicer Jul 8, 2024
cce285f
rename var and add comment
expertdicer Jul 9, 2024
af547c2
remove redundant check
expertdicer Jul 9, 2024
1203f0f
add comment and rename var
expertdicer Jul 9, 2024
b272150
correctly set ctx.Value
expertdicer Jul 9, 2024
c131733
remove tax2gas subspace and add authority
expertdicer Jul 11, 2024
bb99053
register msg service
expertdicer Jul 11, 2024
92ef82c
add msg update params
expertdicer Jul 11, 2024
c016cc6
register codec and unit tests
expertdicer Jul 11, 2024
e6d8242
proto update
expertdicer Jul 11, 2024
023cdfe
refactor tax2gas querier
expertdicer Jul 11, 2024
2fc2c60
refactor structure
expertdicer Jul 15, 2024
2d94166
adding unit tests
expertdicer Jul 16, 2024
a16d4df
deduct from tx origin
expertdicer Jul 16, 2024
ed0ad82
Allow to paid by multiple fees denom
phamminh0811 Jul 16, 2024
d57e4ce
consume tax gas in wasm plugin
expertdicer Jul 16, 2024
3c9b03a
Compute feeRequired base on gasPrice and gasRemaining
phamminh0811 Jul 16, 2024
0b55dd8
Handle fee grant in post handle
phamminh0811 Jul 17, 2024
ee60e0c
Handle fee grant in post handle
phamminh0811 Jul 17, 2024
9131a18
Add test scenario to tax2gas
phamminh0811 Jul 17, 2024
f615e83
Merge branch 'minh/tax2gas' of github-expertdicer:classic-terra/core …
expertdicer Jul 17, 2024
d83b8b3
add simulate condition
expertdicer Jul 17, 2024
052f7fb
update tests and checkTxFee
expertdicer Jul 17, 2024
e2b6dc1
lint
phamminh0811 Jul 17, 2024
2f779bf
lint
phamminh0811 Jul 17, 2024
8ecad7e
fix interchain test
phamminh0811 Jul 17, 2024
b7aa915
update tests and minor fix
expertdicer Jul 17, 2024
d66c1f4
Merge branch 'minh/tax2gas' of github-expertdicer:classic-terra/core …
expertdicer Jul 17, 2024
3e816ea
Move burn tax process to post handler
phamminh0811 Jul 18, 2024
af2336c
add bypass msg types and max gas, unit tests
expertdicer Jul 18, 2024
3f22cf0
Merge branch 'minh/tax2gas' of github-expertdicer:classic-terra/core …
expertdicer Jul 18, 2024
75bd097
update tests
expertdicer Jul 18, 2024
693a641
Merge branch 'main' into minh/tax2gas
expertdicer Jul 22, 2024
fb0344f
update post handler
expertdicer Jul 22, 2024
3deac13
Use taxGasMeter in sdk to handle tax2Gas logic (#499)
phamminh0811 Jul 23, 2024
56ea70b
fix e2e test
phamminh0811 Jul 23, 2024
1327e9d
fix test
expertdicer Jul 24, 2024
644d5f4
Merge branch 'minh/tax2gas' of github-expertdicer:classic-terra/core …
expertdicer Jul 24, 2024
29ac9ad
Add e2e tests to cover test scenario in tax2gas
phamminh0811 Jul 25, 2024
c98c617
lint
phamminh0811 Jul 25, 2024
4523ec5
fix ante test
phamminh0811 Jul 26, 2024
87437f1
lint
phamminh0811 Jul 26, 2024
9be68ba
fix e2e-test
phamminh0811 Jul 26, 2024
dd5eda3
fix tax2gas keeper test
phamminh0811 Jul 26, 2024
c21b748
fix msg server test
phamminh0811 Jul 26, 2024
d3f4005
fix sim test
expertdicer Jul 26, 2024
c1d0a11
lint
expertdicer Jul 26, 2024
da4d9d5
Add test for fee tax non value token denom
phamminh0811 Jul 27, 2024
240caaa
lint
phamminh0811 Jul 27, 2024
997910f
Change taxGas to sdkmath.Int
phamminh0811 Jul 27, 2024
1cb33dd
Fix tax exemption test
phamminh0811 Jul 29, 2024
b4e3896
Make gas auto work
phamminh0811 Jul 29, 2024
a2d402b
Move taxRate to tax2gas module params
phamminh0811 Jul 30, 2024
a1a12ac
Add upgrade handler
phamminh0811 Jul 30, 2024
56f61a5
fix exemption test
phamminh0811 Jul 30, 2024
c34c82d
combine all computeTax to one
phamminh0811 Jul 30, 2024
eb0097d
rename v8_2 to v9
phamminh0811 Jul 30, 2024
e355e02
lint
phamminh0811 Jul 30, 2024
d4eb832
Use more precise way to estimate gas and change e2e test for using ga…
phamminh0811 Jul 30, 2024
b4b813f
Deduct all fees and handle tx priority
phamminh0811 Aug 1, 2024
5abf3a9
lint
phamminh0811 Aug 1, 2024
7dcbf74
merge main
phamminh0811 Aug 1, 2024
bac6f8b
doc
phamminh0811 Aug 1, 2024
3c86903
fix wasmbinding test
phamminh0811 Aug 1, 2024
5f4d877
consume taxgas only on simulate
phamminh0811 Aug 1, 2024
b3d175d
revert logic to deduct correct amount needed for gas and tax
phamminh0811 Aug 1, 2024
eed10ea
lint
phamminh0811 Aug 1, 2024
e584267
final version of Tax2Gas
phamminh0811 Aug 2, 2024
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
9 changes: 8 additions & 1 deletion app/upgrades/v9/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ func CreateV9UpgradeHandler(
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// set default oracle split
keepers.TreasuryKeeper.SetTaxRate(ctx, sdk.ZeroDec())
keepers.Tax2gasKeeper.SetParams(ctx, tax2gastypes.DefaultParams())

tax2gasParams := tax2gastypes.DefaultParams()
phamminh0811 marked this conversation as resolved.
Show resolved Hide resolved
tax2gasParams.GasPrices = sdk.NewDecCoins(
sdk.NewDecCoinFromDec("uluna", sdk.NewDecWithPrec(28325, 3)),
sdk.NewDecCoinFromDec("uusd", sdk.NewDecWithPrec(75, 2)),
)
tax2gasParams.MaxTotalBypassMinFeeMsgGasUsage = 200000
keepers.Tax2gasKeeper.SetParams(ctx, tax2gasParams)
return mm.RunMigrations(ctx, cfg, fromVM)
}
}
8 changes: 4 additions & 4 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ func (s *IntegrationTestSuite) TestFeeTaxGrant() {

s.Require().Equal(balanceTest1, transferCoin1)
s.Require().Equal(newValidatorBalance, validatorBalance.Add(transferCoin1))
// addr2 lost 10uluna to pay for grant msg's gas, 100000000 * TaxRate + 1uluna to pay for bank send msg's tx fees,
s.Require().Equal(balanceTest2.Amount, transferAmount1.Sub(initialization.TaxRate.MulInt(transferAmount1).TruncateInt()).SubRaw(4))
// addr2 lost 2uluna to pay for grant msg's gas, 100000000 * TaxRate + 2uluna to pay for bank send msg's tx fees,
s.Require().Equal(balanceTest2.Amount, transferAmount1.Sub(initialization.TaxRate.MulInt(transferAmount1).TruncateInt()).SubRaw(12))

// Test 3: try bank send with no grant
transferAmount2 := sdkmath.NewInt(200000000)
Expand Down Expand Up @@ -292,7 +292,7 @@ func (s *IntegrationTestSuite) TestFeeTaxGrant() {
initialization.TaxRate.MulInt(transferAmount2). // tax amount in the form of terra denom
Mul(initialization.UsdGasPrice.Quo(initialization.TerraGasPrice)). // convert terra denom to usd denom base on gas price
TruncateInt(),
).SubRaw(5), // addr2 lost 2uusd to pay for revoke msg's gas, 2uusd to pay for grant msg's gas, 1uusd to pay for band send msg's gas
).SubRaw(21), // addr2 lost 10uusd to pay for revoke msg's gas, 10uusd to pay for grant msg's gas, 1uusd to pay for band send msg's gas
)
}

Expand Down Expand Up @@ -352,7 +352,7 @@ func (s *IntegrationTestSuite) TestFeeTaxNotSupport() {
transferAmount3 := sdkmath.NewInt(10000000)
transferCoin3 := sdk.NewCoin(initialization.TerraIBCDenom, transferAmount3)

nodeB.BankSend(transferCoin3.String(), test1AddrChainB, test2AddrChainB, []string{}, sdk.NewCoin(initialization.TerraDenom, sdkmath.NewInt(10)))
nodeB.BankSend(transferCoin3.String(), test1AddrChainB, test2AddrChainB, []string{}, sdk.NewCoin(initialization.TerraDenom, sdkmath.NewInt(2)))

newTerraIBCBalance, err := nodeB.QuerySpecificBalance(test1AddrChainB, initialization.TerraIBCDenom)
s.Require().NoError(err)
Expand Down
4 changes: 4 additions & 0 deletions x/tax2gas/post/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func (tgd Tax2gasPostDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate
return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "fees are not enough to pay for gas, need to cover %s gas more, which equal to %q ", gasRemaining.String(), gasRemainingFees)
}
feePayerAccount := tgd.accountKeeper.GetAccount(ctx, feePayer)

if !simulate && taxes.IsZero() {
payableFees = feeCoins
phamminh0811 marked this conversation as resolved.
Show resolved Hide resolved
}
err := tgd.bankKeeper.SendCoinsFromAccountToModule(ctx, feePayerAccount.GetAddress(), authtypes.FeeCollectorName, payableFees)
if err != nil {
return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error())
Expand Down
Loading