Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fmt
Browse files Browse the repository at this point in the history
aljo242 committed Nov 9, 2023
1 parent ff86779 commit 7c5d658
Showing 16 changed files with 2,556 additions and 90 deletions.
64 changes: 0 additions & 64 deletions feemarket/feemarket.go

This file was deleted.

17 changes: 17 additions & 0 deletions proto/feemarket/feemarket/v1/feemarket.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
syntax = "proto3";
package feemarket.feemarket.v1;

option go_package = "github.com/skip-mev/feemarket/x/feemarket/types";

import "google/protobuf/any.proto";
import "cosmos_proto/cosmos.proto";

// FeeMarket is the fee market implementation to be used by the x/feemarket
// module.
message FeeMarket {
// Implementation is a byte array that must implement
// x/feemarket/types/FeeMarketImplementation
bytes implementation = 1
[ (cosmos_proto.accepts_interface) =
"feemarket.feemarket.v1.FeeMarketImplementation" ];
}
10 changes: 5 additions & 5 deletions proto/feemarket/feemarket/v1/genesis.proto
Original file line number Diff line number Diff line change
@@ -5,15 +5,15 @@ option go_package = "github.com/skip-mev/feemarket/x/feemarket/types";

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "feemarket/feemarket/v1/genesis.proto";

import "feemarket/feemarket/v1/feemarket.proto";

// GenesisState defines the feemarket module's genesis state.
message GenesisState {
// Plugin is the FeeMarket implementation plugged into the feemarket module.
FeeMarket plugin = 1 [ (gogoproto.nullable) = false ];

// Params are the parameters for the feemarket module.
Params params = 3 [
(gogoproto.nullable) = false
];
Params params = 2 [ (gogoproto.nullable) = false ];
}

// Params defines the parameters for the feemarket module.
15 changes: 15 additions & 0 deletions proto/feemarket/feemarket/v1/mock.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";
package feemarket.feemarket.v1;

option go_package = "github.com/skip-mev/feemarket/x/feemarket/plugins/mock";

import "cosmos_proto/cosmos.proto";

// MockFeeMarket is a message that contains the information about a mock fee
// market implementation.
//
// NOTE: This is an example of a mock fee market. It is not used in production.
message MockFeeMarket {
option (cosmos_proto.implements_interface) =
"feemarket.feemarket.v1.FeeMarketImplementation";
}
7 changes: 2 additions & 5 deletions proto/feemarket/feemarket/v1/query.proto
Original file line number Diff line number Diff line change
@@ -7,13 +7,12 @@ import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "feemarket/feemarket/v1/genesis.proto";


// Query Service for the feemarket module.
service Query {
// Params returns the current feemarket module parameters.
rpc Params(ParamsRequest) returns (ParamsResponse) {
option (google.api.http) = {
get: "/feemarket/feemarket/v1/params"
get : "/feemarket/feemarket/v1/params"
};
};
}
@@ -22,6 +21,4 @@ service Query {
message ParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message ParamsResponse {
Params params = 1 [(gogoproto.nullable) = false];
}
message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; }
8 changes: 5 additions & 3 deletions proto/feemarket/feemarket/v1/tx.proto
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@ import "gogoproto/gogo.proto";

option go_package = "github.com/skip-mev/feemarket/x/feemarket/types";

// Message service defines the types of messages supported by the feemarket module.
// Message service defines the types of messages supported by the feemarket
// module.
service Msg {
option (cosmos.msg.v1.service) = true;

@@ -22,8 +23,9 @@ message MsgParams {
option (cosmos.msg.v1.signer) = "from_address";

// Params defines the new parameters for the feemarket module.
Params params = 1 [(gogoproto.nullable) = false];
// Authority defines the authority that is updating the feemarket module parameters.
Params params = 1 [ (gogoproto.nullable) = false ];
// Authority defines the authority that is updating the feemarket module
// parameters.
string authority = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
}

Original file line number Diff line number Diff line change
@@ -5,5 +5,5 @@ plugged into the `x/feemarket` module.

Current implementations include:

- [Mock:](./mock/feemarket.go) fee market that can be used for basic testing.
- [Mock:](mock/feemarket.go) fee market that can be used for basic testing.
DO NOT use in production.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -3,53 +3,55 @@ package mock
import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/skip-mev/feemarket/feemarket"
"github.com/skip-mev/feemarket/x/feemarket/types"
)

var _ feemarket.FeeMarket = FeeMarket{}
var _ types.FeeMarketImplementation = &MockFeeMarket{}

// FeeMarket is a simple mock fee market implmentation that should only be used for testing.
type FeeMarket struct{}
// ValidateBasic is a no-op.
func (fm *MockFeeMarket) ValidateBasic() error {
return nil
}

// Init which initializes the fee market (in InitGenesis)
func (fm FeeMarket) Init(_ sdk.Context) error {
func (fm *MockFeeMarket) Init(_ sdk.Context) error {
return nil
}

// EndBlockUpdateHandler allows the fee market to be updated
// after every block. This will be added to the EndBlock chain.
func (fm FeeMarket) EndBlockUpdateHandler(_ sdk.Context) feemarket.UpdateHandler {
func (fm *MockFeeMarket) EndBlockUpdateHandler(_ sdk.Context) types.UpdateHandler {
return nil
}

// EpochUpdateHandler allows the fee market to be updated
// after every given epoch identifier. This maps the epoch
// identifier to the UpdateHandler that should be executed.
func (fm FeeMarket) EpochUpdateHandler(_ sdk.Context) map[string]feemarket.UpdateHandler {
func (fm *MockFeeMarket) EpochUpdateHandler(_ sdk.Context) map[string]types.UpdateHandler {
return nil
}

// GetMinGasPrice retrieves the minimum gas price(s) needed
// to be included in the block for the given transaction
func (fm FeeMarket) GetMinGasPrice(_ sdk.Context, _ sdk.Tx) sdk.Coins {
func (fm *MockFeeMarket) GetMinGasPrice(_ sdk.Context, _ sdk.Tx) sdk.Coins {
return sdk.NewCoins()
}

// GetFeeMarketInfo retrieves the fee market's information about
// how to pay for a transaction (min gas price, min tip,
// where the fees are being distributed, etc.).
func (fm FeeMarket) GetFeeMarketInfo(_ sdk.Context) map[string]string {
func (fm *MockFeeMarket) GetFeeMarketInfo(_ sdk.Context) map[string]string {
return nil
}

// GetID returns the identifier of the fee market
func (fm FeeMarket) GetID() string {
func (fm *MockFeeMarket) GetID() string {
return "mock"
}

// FeeAnteHandler will be called in the module AnteHandler.
// Performs no actions.
func (fm FeeMarket) FeeAnteHandler(
func (fm *MockFeeMarket) FeeAnteHandler(
_ sdk.Context,
_ sdk.Tx,
_ bool,
@@ -62,7 +64,7 @@ func (fm FeeMarket) FeeAnteHandler(

// FeePostHandler will be called in the module PostHandler
// if PostHandlers are implemented. Performs no actions.
func (fm FeeMarket) FeePostHandler(
func (fm *MockFeeMarket) FeePostHandler(
_ sdk.Context,
_ sdk.Tx,
_,
272 changes: 272 additions & 0 deletions x/feemarket/plugins/mock/mock.pb.go
71 changes: 71 additions & 0 deletions x/feemarket/types/feemarket.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"
)

// FeeMarketImplementation represents the interface of various FeeMarket types implemented
// by other modules or packages.
type FeeMarketImplementation interface {
proto.Message

// ValidateBasic does a simple validation check that
// doesn't require access to any other information.
ValidateBasic() error

// ------------------- Fee Market Parameters ------------------- //

// Init which initializes the fee market (in InitGenesis)
Init(ctx sdk.Context) error

// EndBlockUpdateHandler allows the fee market to be updated
// after every block. This will be added to the EndBlock chain.
EndBlockUpdateHandler(ctx sdk.Context) UpdateHandler

// EpochUpdateHandler allows the fee market to be updated
// after every given epoch identifier. This maps the epoch
// identifier to the UpdateHandler that should be executed.
EpochUpdateHandler(ctx sdk.Context) map[string]UpdateHandler

// ------------------- Fee Market Queries ------------------- //

// GetMinGasPrice retrieves the minimum gas price(s) needed
// to be included in the block for the given transaction
GetMinGasPrice(ctx sdk.Context, tx sdk.Tx) sdk.Coins

// GetFeeMarketInfo retrieves the fee market's information about
// how to pay for a transaction (min gas price, min tip,
// where the fees are being distributed, etc.).
GetFeeMarketInfo(ctx sdk.Context) map[string]string

// GetID returns the identifier of the fee market
GetID() string

// ------------------- Fee Market Extraction ------------------- //

// FeeAnteHandler will be called in the module AnteHandler,
// this is where the fee market would extract and distribute
// fees from a given transaction
FeeAnteHandler(
ctx sdk.Context,
tx sdk.Tx,
simulate bool,
next sdk.AnteHandler,
) sdk.AnteHandler

// FeePostHandler will be called in the module PostHandler
// if PostHandlers are implemented. This is another place
// the fee market might refund users
FeePostHandler(
ctx sdk.Context,
tx sdk.Tx,
simulate,
success bool,
next sdk.PostHandler,
) sdk.PostHandler
}

// UpdateHandler is responsible for updating the parameters of the
// fee market plugin. Fees can optionally also be extracted here.
type UpdateHandler func(ctx sdk.Context) error
327 changes: 327 additions & 0 deletions x/feemarket/types/feemarket.pb.go
545 changes: 545 additions & 0 deletions x/feemarket/types/genesis.pb.go

Large diffs are not rendered by default.

536 changes: 536 additions & 0 deletions x/feemarket/types/query.pb.go

Large diffs are not rendered by default.

153 changes: 153 additions & 0 deletions x/feemarket/types/query.pb.gw.go
593 changes: 593 additions & 0 deletions x/feemarket/types/tx.pb.go

Large diffs are not rendered by default.

0 comments on commit 7c5d658

Please sign in to comment.