Skip to content

GasTracker split#202

Merged
edjroz merged 28 commits into
mainfrom
split_gastracker
Aug 9, 2022
Merged

GasTracker split#202
edjroz merged 28 commits into
mainfrom
split_gastracker

Conversation

@iTiky

@iTiky iTiky commented Jul 27, 2022

Copy link
Copy Markdown
Contributor

No description provided.

@iTiky iTiky requested review from ParthDesai, edjroz and fdymylja July 27, 2022 15:18

// Params implements the types.QueryServer interface.
func (s *QueryServer) Params(c context.Context, request *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
if request == nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we can avoid checking for this as the gRPC stub should handle this seamlessly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is done in the Cosmos SDK so I did the same 🤷‍♂️

@fdymylja fdymylja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed tracking part, LGTM.

@iTiky iTiky force-pushed the split_gastracker branch from 3701dbf to 464fb1c Compare July 30, 2022 22:10
…imited (LT 1.0) as 1.0 triggers an error on x/mint BeginBlocker
@iTiky iTiky force-pushed the split_gastracker branch from 783fe56 to a3da7bf Compare July 31, 2022 11:52
Comment thread app/ante.go Outdated
Comment thread proto/archway/rewards/v1beta1/genesis.proto Outdated

@fdymylja fdymylja left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rewards protos ACK.

Comment thread x/rewards/ante/fee_deduction.go Outdated
if err := dfd.bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), authTypes.FeeCollectorName, fees); err != nil {
return sdkErrors.Wrapf(sdkErrors.ErrInsufficientFunds, err.Error())
}
return nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need to be conscious about this approach for tracking pruning, because tracking can have records of this TX whilst rewards does not.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also side note, we're fetching the Dec twice here, for performance we could just fetch the tx fee rebate ratio here, and apply the isZero() logic here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dec usage fixed. As for pruning. If there were no TxRebate rewards a corresponding rewards tracking entry is not created and this is handled by the x/rewards distribution logic.

Comment thread x/rewards/keeper/genesis.go
Comment thread x/rewards/mintbankkeeper/keeper.go Outdated
iTiky and others added 7 commits August 1, 2022 13:48
…; Ante handlers reordered; ContractMetadata has ContractAddress in it.

Tests fixes
x/rewards, x/tracking: state tests added.
E2E tests: Sudo test enabled (after the wasmd upgrade), Stargate query test disabled (removed by the wasmvm developers).
Comment thread x/rewards/ante/fee_deduction.go Outdated
}

// Check that only one coin has been minted
if len(dappRewards) != 1 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are we making an assumption here that only one coin can be minted?

I understand current version of cosmos sdk only support one coin for inflation, but that could change in future. Besides, if we go by that then input will always contain one coin anyway. So there is no point in this check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@fdymylja Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copied from your code so need yours feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This mocks the behaviour of the current minting module in the SDK, once we upgrade to a different SDK version if there are changes in the minting module we can change this.

Comment thread x/rewards/types/params.go
@iTiky iTiky force-pushed the split_gastracker branch from f862f9c to 63dbcd3 Compare August 3, 2022 14:12
Comment thread x/rewards/client/cli/query.go Outdated
Comment thread x/rewards/client/cli/tx.go Outdated
// estimateBlockRewards update block distribution state with tracked rewards calculating reward shares per contract.
// Func iterates over all tracked transactions and estimates inflation (on block level) and fee rebate (merging
// tokens for each transaction contract has operation at) rewards for each contract.
func (k Keeper) estimateBlockRewards(ctx sdk.Context, blockDistrState *blockRewardsDistributionState) *blockRewardsDistributionState {

@edjroz edjroz Aug 3, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm a bit concerened on GC overhead of passing a pointer, golang pointers are a bit quirky since it passes pointers to heap which takes longer to clean than stack values, the GC cycle is probably longer than block times so it would accumulate over time.
Once that is done the GC has to dereference which is a costly implementation in itself.

This might be over panicking however, in case performance analysis is neccesary in the future we can always make a escape analysis build with go build -gcflags="-m"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right about pointers in general. Goway is to be as immutable as possible. But here, since we are not "escaping" (not in terms of the compiler) the DistributeRewards func, this is kind of OK. But if that really bothers you, I can pass an object and return an updated one. BTW maps in the State object are "heaped" (probably 🤷‍♂️).

@edjroz edjroz Aug 3, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's not get ahead of ourselves here, If we switch to rewards distribution using a smart contract then this change would be moot. I'll just keep a mental note on it as we observe further growth.

P.D: yeah maps are notoriously bad in golang for memory growth more on this golang issue

Co-authored-by: Eduardo Díaz <edjroz@users.noreply.github.com>
@edjroz edjroz marked this pull request as ready for review August 9, 2022 14:02
@codecov

codecov Bot commented Aug 9, 2022

Copy link
Copy Markdown

Codecov Report

Merging #202 (b1fc078) into main (f9fcee9) will increase coverage by 6.77%.
The diff coverage is 71.67%.

@@            Coverage Diff             @@
##             main     #202      +/-   ##
==========================================
+ Coverage   56.68%   63.45%   +6.77%     
==========================================
  Files          20       47      +27     
  Lines        1302     1929     +627     
==========================================
+ Hits          738     1224     +486     
- Misses        527      664     +137     
- Partials       37       41       +4     
Impacted Files Coverage Δ
app/test_access.go 0.00% <ø> (ø)
pkg/cli_args.go 0.00% <0.00%> (ø)
pkg/cli_flags.go 0.00% <0.00%> (ø)
pkg/coin.go 0.00% <0.00%> (ø)
pkg/dec.go 0.00% <0.00%> (ø)
x/rewards/types/events.go 0.00% <0.00%> (ø)
x/tracking/types/query.go 0.00% <0.00%> (ø)
x/rewards/keeper/grpc_query.go 3.77% <3.77%> (ø)
x/rewards/keeper/msg_server.go 14.28% <14.28%> (ø)
x/rewards/types/msg.go 21.73% <21.73%> (ø)
... and 47 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants