Skip to content

Commit

Permalink
feat(gasless): add gasless module (#427)
Browse files Browse the repository at this point in the history
Co-authored-by: rockstarRhino <“[email protected]”>
Co-authored-by: hunter1269 <[email protected]>
Co-authored-by: Hunter 1269 <[email protected]>
  • Loading branch information
4 people authored Jun 5, 2024
1 parent bccd5b9 commit 7b38c5a
Show file tree
Hide file tree
Showing 58 changed files with 17,752 additions and 7 deletions.
12 changes: 9 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ go 1.22.2
require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
github.com/CosmWasm/wasmd v0.33.0
github.com/cometbft/cometbft v0.37.2
github.com/cosmos/cosmos-sdk v0.46.16
github.com/cosmos/gogoproto v1.4.11
github.com/cosmos/ibc-go/v6 v6.2.1
github.com/dymensionxyz/dymint v1.1.3-rc04
github.com/gogo/protobuf v1.3.3
Expand All @@ -21,8 +23,10 @@ require (
github.com/stretchr/testify v1.8.4
github.com/tendermint/tendermint v0.34.29
github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe
google.golang.org/grpc v1.61.0
google.golang.org/protobuf v1.32.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v2 v2.4.0
)
Expand All @@ -38,6 +42,7 @@ require (
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/CosmWasm/wasmvm v1.2.3 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/Workiva/go-datastructures v1.0.53 // indirect
Expand Down Expand Up @@ -74,7 +79,6 @@ require (
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gogoproto v1.4.11 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.6 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect
Expand All @@ -91,6 +95,7 @@ require (
github.com/dgraph-io/badger/v3 v3.2103.3 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
Expand Down Expand Up @@ -119,6 +124,7 @@ require (
github.com/google/btree v1.1.2 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect
Expand Down Expand Up @@ -207,6 +213,7 @@ require (
github.com/multiformats/go-multistream v0.5.0 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onsi/ginkgo/v2 v2.15.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
Expand Down Expand Up @@ -256,7 +263,6 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
golang.org/x/mod v0.15.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
Expand All @@ -271,7 +277,6 @@ require (
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -281,6 +286,7 @@ require (
)

replace (
github.com/CosmWasm/wasmd => github.com/decentrio/wasmd v0.33.0-sdk46.2
github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/availproject/go-substrate-rpc-client/v4 v4.0.12-avail-1.4.0-rc1-5e286e3
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/evmos/evmos/v12 => github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.3
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM=
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
github.com/CosmWasm/wasmvm v1.2.3 h1:OKYlobwmVGbl0eSn0mXoAAjE5hIuXnQCLPjbNd91sVY=
github.com/CosmWasm/wasmvm v1.2.3/go.mod h1:vW/E3h8j9xBQs9bCoijDuawKo9kCtxOaS8N8J7KFtkc=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
Expand Down Expand Up @@ -453,6 +455,8 @@ github.com/cosmos/iavl v0.19.6 h1:XY78yEeNPrEYyNCKlqr9chrwoeSDJ0bV2VjocTk//OU=
github.com/cosmos/iavl v0.19.6/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-go/v6 v6.2.1 h1:NiaDXTRhKwf3n9kELD4VRIe5zby1yk1jBvaz9tXTQ6k=
github.com/cosmos/ibc-go/v6 v6.2.1/go.mod h1:XLsARy4Y7+GtAqzMcxNdlQf6lx+ti1e8KcMGv5NIK7A=
github.com/cosmos/interchain-accounts v0.4.3 h1:WedxEa/Hj/2GY7AF6CafkEPJ/Z9rhl3rT1mRwNHsdts=
github.com/cosmos/interchain-accounts v0.4.3/go.mod h1:qibHB6y/R2YsuuZdamI2BcIUBPMyhyELDWAr8Nk8x4g=
github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw=
github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
Expand All @@ -473,6 +477,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU=
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U=
github.com/decentrio/wasmd v0.33.0-sdk46.2 h1:cUgYN8crDXiQiKLBYfGR5IXg77Z/QrvZBoU9Fg/1ACo=
github.com/decentrio/wasmd v0.33.0-sdk46.2/go.mod h1:mPBiB+54La70eS2HHzvK2Vn7Frgf7rjnxDo70oopw+w=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
Expand Down Expand Up @@ -509,6 +515,8 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/cli v24.0.2+incompatible h1:QdqR7znue1mtkXIJ+ruQMGQhpw2JzMJLRXp6zpzF6tM=
github.com/docker/cli v24.0.2+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
Expand Down
92 changes: 92 additions & 0 deletions proto/gasless/v1beta1/gasless.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
syntax = "proto3";
package rollapp.gasless.v1beta1;

import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/gasless/types";
option (gogoproto.goproto_getters_all) = false;

// UsageIdentifierToGasTankIds maps all the gas tank ids with the usage identifier
// results in faster query of gas tanks based on usage identifier
message UsageIdentifierToGasTankIds {
// usage identifier defines the unique identifier for a tx
string usage_identifier = 1;

// all the associated gas tank ids for the usage identifier
repeated uint64 gas_tank_ids = 2;
}

// GasTank defines the store for all the configurations of a set by a gas provider
message GasTank {
// id defines the id of gas tank
uint64 id = 1;

// provider defines the creator/owner of the gas tank
string provider = 2;

// reserve defines the reserve address of the gas tank where deposited funds are stored
string reserve = 3;

// status of the gas tank if it is active or not
bool is_active = 4;

// max_fee_usage_per_consumer defines the gas consumption limit which consumer is allowed, beyod this limit gas tank will not sponsor the tx
string max_fee_usage_per_consumer = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];

// max_fee_usage_per_tx defines the maximum limit for the fee ased by the tx, beyond this gastank cannot sponsor the tx
string max_fee_usage_per_tx = 6 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];

// usage_identifiers defines the unique list of MessageTypes,ContractAddress or any valid usage identifier which are whitelisted by gas tank.
repeated string usage_identifiers = 7;

// fee_denom defines the supported fee denom by gas tank.
string fee_denom = 8;
}

// GasConsumer > ConsumptionDetail > Usage > Detail stores the consumption activity of the consumer
message Detail {
// timestamp defines the timestamp at which the fee was consumed
google.protobuf.Timestamp timestamp = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];

// gas_consumed defines the amount of fee consumed by the tx
string gas_consumed = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];
}

// GasConsumer > ConsumptionDetail > Usage defines the independent usage of gas by the individual usage identifier
message Usage {
// usage identifier defines the gas consumption/usage identifier of the tx, this identifier is responsible for consuming gas
string usage_identifier = 1;

// details defines the list of usage details by the usage identifier along with fee amount and timestamp
repeated Detail details = 2;
}

// GasConsumer > ConsumptionDetail defines the usage statistics of the consumer within each gas tank
message ConsumptionDetail {
// gas_tank_id defines the if of the gas tank
uint64 gas_tank_id = 1;

// is_blocked defines if the consumer is blocked or not by the gas tank
bool is_blocked = 2;

// total_fee_consumption_allowed defines the maximum fee consumption allowed by the gas tank to the consumer
string total_fee_consumption_allowed = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];

// total_fees_consumed defines the total fee consumed so far by the consumer in this gas tank
string total_fees_consumed = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false];

// usage defines the usage of gas within this gas tank
repeated Usage usage = 5;
}

// GasConsumer stores the consumer address and all the gas consumption activities within the gas tank
message GasConsumer {
// bech32 encoded address of the consumer
string consumer = 1;

// consumtion statistics of the consumer
repeated ConsumptionDetail consumptions = 2;
}


27 changes: 27 additions & 0 deletions proto/gasless/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";
package rollapp.gasless.v1beta1;

import "gogoproto/gogo.proto";
import "gasless/v1beta1/params.proto";
import "gasless/v1beta1/gasless.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/gasless/types";
option (gogoproto.goproto_getters_all) = false;

// GenesisState defines the gasless module's genesis state.
message GenesisState {
// parms defines the parameters of the gasess module
Params params = 1 [(gogoproto.nullable) = false];

// usage_identifier_to_gastank_ids defines maps of all the gas tank ids with the usage identifier
repeated UsageIdentifierToGasTankIds usage_identifier_to_gastank_ids = 2 [(gogoproto.nullable) = false];

// last_gas_tank_id defines most recent gas tank id within the key store
uint64 last_gas_tank_id = 3;

// gas_tanks defines all available gas tanks
repeated GasTank gas_tanks = 4 [(gogoproto.nullable) = false];

// gas_consumers defines all available gas consumer
repeated GasConsumer gas_consumers = 5 [(gogoproto.nullable) = false];
}
8 changes: 8 additions & 0 deletions proto/gasless/v1beta1/gov.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";
package rollapp.gasless.v1beta1;

import "gogoproto/gogo.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/gasless/types";
option (gogoproto.equal_all) = false;
option (gogoproto.goproto_getters_all) = false;
15 changes: 15 additions & 0 deletions proto/gasless/v1beta1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";
package rollapp.gasless.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/dymensionxyz/dymension-rdk/x/gasless/types";
option (gogoproto.goproto_getters_all) = false;

// Params defines the parameters for the module.
message Params {
// minimum_gas_deposit defines the minimum coins required while creating gas tank
repeated cosmos.base.v1beta1.Coin minimum_gas_deposit = 2
[(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false];
}
Loading

0 comments on commit 7b38c5a

Please sign in to comment.