Skip to content

Commit

Permalink
uint64
Browse files Browse the repository at this point in the history
  • Loading branch information
mj850 committed Dec 12, 2024
1 parent b0118d1 commit e891b96
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion proto/confidentialtransfers/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ option go_package = "github.com/sei-protocol/sei-chain/x/confidentialtransfers/t
// Params defines the parameters for the confidential tokens module.
message Params {
bool enable_ct_module = 1;
uint32 range_proof_gas_cost = 2;
uint64 range_proof_gas_cost = 2;
}
6 changes: 3 additions & 3 deletions x/confidentialtransfers/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type Keeper interface {
SetParams(ctx sdk.Context, params types.Params)

IsCtModuleEnabled(ctx sdk.Context) bool
GetRangeProofGasCost(ctx sdk.Context) uint32
GetRangeProofGasCost(ctx sdk.Context) uint64

BankKeeper() types.BankKeeper

Expand Down Expand Up @@ -186,8 +186,8 @@ func (k BaseKeeper) IsCtModuleEnabled(ctx sdk.Context) bool {
}

// GetRangeProofGasCost retrieves the value of the RangeProofGasCost param from the parameter store
func (k BaseKeeper) GetRangeProofGasCost(ctx sdk.Context) uint32 {
var rangeProofGas uint32
func (k BaseKeeper) GetRangeProofGasCost(ctx sdk.Context) uint64 {
var rangeProofGas uint64
k.paramSpace.Get(ctx, types.KeyRangeProofGas, &rangeProofGas)
return rangeProofGas
}
Expand Down
4 changes: 2 additions & 2 deletions x/confidentialtransfers/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (m msgServer) Withdraw(goCtx context.Context, req *types.MsgWithdraw) (*typ
// Consume additional gas as range proofs are computationally expensive.
cost := m.Keeper.GetRangeProofGasCost(ctx)
if cost > 0 {
ctx.GasMeter().ConsumeGas(uint64(cost), "range proof verification")
ctx.GasMeter().ConsumeGas(cost, "range proof verification")
}

verified, _ := zkproofs.VerifyRangeProof(instruction.Proofs.RemainingBalanceRangeProof, instruction.RemainingBalanceCommitment, 128, m.CachedRangeVerifierFactory)
Expand Down Expand Up @@ -443,7 +443,7 @@ func (m msgServer) Transfer(goCtx context.Context, req *types.MsgTransfer) (*typ
}

// Validate proofs
rangeProofGasCost := uint64(m.Keeper.GetRangeProofGasCost(ctx))
rangeProofGasCost := m.Keeper.GetRangeProofGasCost(ctx)

// Consume additional gas as range proofs are computationally expensive.
if rangeProofGasCost > 0 {
Expand Down
4 changes: 2 additions & 2 deletions x/confidentialtransfers/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
const DefaultEnableCtModule = true

// DefaultRangeProofGasCost is the default value for RangeProofGasCost param.
const DefaultRangeProofGasCost = uint32(1000000)
const DefaultRangeProofGasCost = uint64(1000000)

// ParamKeyTable ParamTable for confidential transfers module.
func ParamKeyTable() paramtypes.KeyTable {
Expand Down Expand Up @@ -57,7 +57,7 @@ func validateEnableCtModule(i interface{}) error {

// Validator for the parameter.
func validateRangeProofGasCost(i interface{}) error {
_, ok := i.(uint32)
_, ok := i.(uint64)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
Expand Down
14 changes: 7 additions & 7 deletions x/confidentialtransfers/types/params.pb.go

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

2 changes: 1 addition & 1 deletion x/confidentialtransfers/types/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestDefaultParams(t *testing.T) {
func TestParams_Validate(t *testing.T) {
type fields struct {
EnableCtModule bool
RangeProofGasCost uint32
RangeProofGasCost uint64
}
tests := []struct {
name string
Expand Down

0 comments on commit e891b96

Please sign in to comment.