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: Add gas calculator for all the messages of storage module #102

Merged
merged 3 commits into from
Feb 9, 2023
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
75 changes: 43 additions & 32 deletions proto/cosmos/gashub/v1alpha1/gashub.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,48 @@ message Params {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;

uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"];
uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"];
uint64 msg_grant_fixed_gas = 3 [(gogoproto.customname) = "MsgGrantFixedGas"];
uint64 msg_grant_per_item_gas = 4 [(gogoproto.customname) = "MsgGrantPerItemGas"];
uint64 msg_revoke_gas = 5 [(gogoproto.customname) = "MsgRevokeGas"];
uint64 msg_exec_gas = 6 [(gogoproto.customname) = "MsgExecGas"];
uint64 msg_send_gas = 7 [(gogoproto.customname) = "MsgSendGas"];
uint64 msg_multi_send_fixed_gas = 8 [(gogoproto.customname) = "MsgMultiSendFixedGas"];
uint64 msg_multi_send_per_item_gas = 9 [(gogoproto.customname) = "MsgMultiSendPerItemGas"];
uint64 msg_withdraw_delegator_reward_gas = 10 [(gogoproto.customname) = "MsgWithdrawDelegatorRewardGas"];
uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"];
uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"];
uint64 msg_grant_fixed_gas = 3 [(gogoproto.customname) = "MsgGrantFixedGas"];
uint64 msg_grant_per_item_gas = 4 [(gogoproto.customname) = "MsgGrantPerItemGas"];
uint64 msg_revoke_gas = 5 [(gogoproto.customname) = "MsgRevokeGas"];
uint64 msg_exec_gas = 6 [(gogoproto.customname) = "MsgExecGas"];
uint64 msg_send_gas = 7 [(gogoproto.customname) = "MsgSendGas"];
uint64 msg_multi_send_fixed_gas = 8 [(gogoproto.customname) = "MsgMultiSendFixedGas"];
uint64 msg_multi_send_per_item_gas = 9 [(gogoproto.customname) = "MsgMultiSendPerItemGas"];
uint64 msg_withdraw_delegator_reward_gas = 10 [(gogoproto.customname) = "MsgWithdrawDelegatorRewardGas"];
uint64 msg_withdraw_validator_commission_gas = 11 [(gogoproto.customname) = "MsgWithdrawValidatorCommissionGas"];
uint64 msg_set_withdraw_address_gas = 12 [(gogoproto.customname) = "MsgSetWithdrawAddressGas"];
uint64 msg_fund_community_pool_gas = 13 [(gogoproto.customname) = "MsgFundCommunityPoolGas"];
uint64 msg_grant_allowance_fixed_gas = 14 [(gogoproto.customname) = "MsgGrantAllowanceFixedGas"];
uint64 msg_grant_allowance_per_item_gas = 15 [(gogoproto.customname) = "MsgGrantAllowancePerItemGas"];
uint64 msg_revoke_allowance_gas = 16 [(gogoproto.customname) = "MsgRevokeAllowanceGas"];
uint64 msg_submit_proposal_gas = 17 [(gogoproto.customname) = "MsgSubmitProposalGas"];
uint64 msg_vote_gas = 18 [(gogoproto.customname) = "MsgVoteGas"];
uint64 msg_vote_weighted_gas = 19 [(gogoproto.customname) = "MsgVoteWeightedGas"];
uint64 msg_deposit_gas = 20 [(gogoproto.customname) = "MsgDepositGas"];
uint64 msg_unjail_gas = 21 [(gogoproto.customname) = "MsgUnjailGas"];
uint64 msg_impeach_gas = 22 [(gogoproto.customname) = "MsgImpeachGas"];
uint64 msg_edit_validator_gas = 23 [(gogoproto.customname) = "MsgEditValidatorGas"];
uint64 msg_delegate_gas = 24 [(gogoproto.customname) = "MsgDelegateGas"];
uint64 msg_undelegate_gas = 25 [(gogoproto.customname) = "MsgUndelegateGas"];
uint64 msg_begin_redelegate_gas = 26 [(gogoproto.customname) = "MsgBeginRedelegateGas"];
uint64 msg_cancel_unbonding_delegation_gas = 27 [(gogoproto.customname) = "MsgCancelUnbondingDelegationGas"];
uint64 msg_create_validator_gas = 28 [(gogoproto.customname) = "MsgCreateValidatorGas"];
uint64 msg_claim_gas = 29 [(gogoproto.customname) = "MsgClaimGas"];
uint64 msg_transfer_out_gas = 30 [(gogoproto.customname) = "MsgTransferOutGas"];
uint64 msg_create_storage_provider_gas = 31 [(gogoproto.customname) = "MsgCreateStorageProviderGas"];
uint64 msg_edit_storage_provider_gas = 32 [(gogoproto.customname) = "MsgEditStorageProviderGas"];
uint64 msg_sp_deposit_gas = 33 [(gogoproto.customname) = "MsgSpDepositGas"];
uint64 msg_set_withdraw_address_gas = 12 [(gogoproto.customname) = "MsgSetWithdrawAddressGas"];
uint64 msg_fund_community_pool_gas = 13 [(gogoproto.customname) = "MsgFundCommunityPoolGas"];
uint64 msg_grant_allowance_fixed_gas = 14 [(gogoproto.customname) = "MsgGrantAllowanceFixedGas"];
uint64 msg_grant_allowance_per_item_gas = 15 [(gogoproto.customname) = "MsgGrantAllowancePerItemGas"];
uint64 msg_revoke_allowance_gas = 16 [(gogoproto.customname) = "MsgRevokeAllowanceGas"];
uint64 msg_submit_proposal_gas = 17 [(gogoproto.customname) = "MsgSubmitProposalGas"];
uint64 msg_vote_gas = 18 [(gogoproto.customname) = "MsgVoteGas"];
uint64 msg_vote_weighted_gas = 19 [(gogoproto.customname) = "MsgVoteWeightedGas"];
uint64 msg_deposit_gas = 20 [(gogoproto.customname) = "MsgDepositGas"];
uint64 msg_unjail_gas = 21 [(gogoproto.customname) = "MsgUnjailGas"];
uint64 msg_impeach_gas = 22 [(gogoproto.customname) = "MsgImpeachGas"];
uint64 msg_edit_validator_gas = 23 [(gogoproto.customname) = "MsgEditValidatorGas"];
uint64 msg_delegate_gas = 24 [(gogoproto.customname) = "MsgDelegateGas"];
uint64 msg_undelegate_gas = 25 [(gogoproto.customname) = "MsgUndelegateGas"];
uint64 msg_begin_redelegate_gas = 26 [(gogoproto.customname) = "MsgBeginRedelegateGas"];
uint64 msg_cancel_unbonding_delegation_gas = 27 [(gogoproto.customname) = "MsgCancelUnbondingDelegationGas"];
uint64 msg_create_validator_gas = 28 [(gogoproto.customname) = "MsgCreateValidatorGas"];
uint64 msg_claim_gas = 29 [(gogoproto.customname) = "MsgClaimGas"];
uint64 msg_transfer_out_gas = 30 [(gogoproto.customname) = "MsgTransferOutGas"];
uint64 msg_create_storage_provider_gas = 31 [(gogoproto.customname) = "MsgCreateStorageProviderGas"];
uint64 msg_edit_storage_provider_gas = 32 [(gogoproto.customname) = "MsgEditStorageProviderGas"];
uint64 msg_sp_deposit_gas = 33 [(gogoproto.customname) = "MsgSpDepositGas"];
uint64 msg_storage_create_bucket_gas = 34 [(gogoproto.customname) = "MsgStorageCreateBucket"];
uint64 msg_storage_delete_bucket_gas = 35 [(gogoproto.customname) = "MsgStorageDeleteBucket"];
uint64 msg_storage_create_object_gas = 36 [(gogoproto.customname) = "MsgStorageCreateObject"];
uint64 msg_storage_delete_object_gas = 37 [(gogoproto.customname) = "MsgStorageDeleteObject"];
uint64 msg_storage_seal_object_gas = 38 [(gogoproto.customname) = "MsgStorageSealObject"];
uint64 msg_storage_copy_object_gas = 39 [(gogoproto.customname) = "MsgStorageCopyObject"];
uint64 msg_storage_reject_seal_object_gas = 40 [(gogoproto.customname) = "MsgStorageRejectSealObject"];
uint64 msg_storage_create_group_gas = 41 [(gogoproto.customname) = "MsgStorageCreateGroup"];
uint64 msg_storage_delete_group_gas = 42 [(gogoproto.customname) = "MsgStorageDeleteGroup"];
uint64 msg_storage_leave_group_gas = 43 [(gogoproto.customname) = "MsgStorageLeaveGroup"];
uint64 msg_storage_update_group_member_gas = 44 [(gogoproto.customname) = "MsgStorageUpdateGroupMember"];
}
3 changes: 2 additions & 1 deletion x/gashub/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func RandomizedGenState(simState *module.SimulationState) {

params := types.NewParams(maxTxSize, minGasPerByte, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas,
msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas,
msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas)
msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas,
msgGas, msgGas, msgGas, msgGas, msgGas, msgGas)

gashubGenesis := types.NewGenesisState(params)

Expand Down
51 changes: 51 additions & 0 deletions x/gashub/types/gas_calculator.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,55 @@ func init() {
fixedGas := params.GetMsgSpDepositGas()
return FixedGasCalculator(fixedGas)
})

RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgCreateBucket", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageCreateBucket()
return FixedGasCalculator(fixedGas)
})

RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgDeleteBucket", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageDeleteBucket()
return FixedGasCalculator(fixedGas)
})

RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgCreateObject", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageCreateObject()
return FixedGasCalculator(fixedGas)
})

RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgDeleteObject", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageDeleteObject()
return FixedGasCalculator(fixedGas)
})
RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgSealObject", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageSealObject()
return FixedGasCalculator(fixedGas)
})
RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgCopyObject", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageCopyObject()
return FixedGasCalculator(fixedGas)
})
RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgRejectSealObject", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageRejectSealObject()
return FixedGasCalculator(fixedGas)
})

RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgCreateGroup", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageCreateGroup()
return FixedGasCalculator(fixedGas)
})

RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgDeleteGroup", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageDeleteGroup()
return FixedGasCalculator(fixedGas)
})

RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgLeaveGroup", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageLeaveGroup()
return FixedGasCalculator(fixedGas)
})
RegisterCalculatorGen("/bnbchain.greenfield.storage.MsgUpdateGroupMember", func(params Params) GasCalculator {
fixedGas := params.GetMsgStorageUpdateGroupMember()
return FixedGasCalculator(fixedGas)
})
}
Loading