From 36af853034eafcc0948c9c953c57d451876f02ab Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 9 Nov 2023 08:53:39 -0500 Subject: [PATCH 1/8] add interface --- feemarket/feemarket.go | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 feemarket/feemarket.go diff --git a/feemarket/feemarket.go b/feemarket/feemarket.go new file mode 100644 index 0000000..c5a0e6f --- /dev/null +++ b/feemarket/feemarket.go @@ -0,0 +1,64 @@ +package feemarket + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type ( + // FeeMarket defines the expected interface each fee market plugin must + // implement to be utilized by the fee market module. + FeeMarket interface { + // ------------------- 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. + UpdateHandler func(ctx sdk.Context) error +) From f0fa6b1e1bef919fc963ab2d497f5642d70fd997 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 9 Nov 2023 09:24:50 -0500 Subject: [PATCH 2/8] mock --- feemarket/plugins/README.md | 6 ++ feemarket/plugins/mock/ante.go | 1 + feemarket/plugins/mock/feemarket.go | 75 +++++++++++++++++++++ tests/simapp/feemarketd/main.go | 1 + tests/simapp/feemarketd/testappd/root.go | 1 + tests/simapp/feemarketd/testappd/testnet.go | 1 + 6 files changed, 85 insertions(+) create mode 100644 feemarket/plugins/README.md create mode 100644 feemarket/plugins/mock/ante.go create mode 100644 feemarket/plugins/mock/feemarket.go diff --git a/feemarket/plugins/README.md b/feemarket/plugins/README.md new file mode 100644 index 0000000..144f82b --- /dev/null +++ b/feemarket/plugins/README.md @@ -0,0 +1,6 @@ +# FeeMarket Plugins + +This directory contains implementations of the `FeeMarket` interface to be plugged into the `x/feemarket` module. + +Current implementations include: + - [Mock:](./mock/feemarket.go) fee market that can be used for basic testing. DO NOT use in production. \ No newline at end of file diff --git a/feemarket/plugins/mock/ante.go b/feemarket/plugins/mock/ante.go new file mode 100644 index 0000000..f33e02b --- /dev/null +++ b/feemarket/plugins/mock/ante.go @@ -0,0 +1 @@ +package mock diff --git a/feemarket/plugins/mock/feemarket.go b/feemarket/plugins/mock/feemarket.go new file mode 100644 index 0000000..d867377 --- /dev/null +++ b/feemarket/plugins/mock/feemarket.go @@ -0,0 +1,75 @@ +package mock + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/skip-mev/feemarket/feemarket" +) + +var _ feemarket.FeeMarket = FeeMarket{} + +// FeeMarket is a simple mock fee market implmentation that should only be used for testing. +type FeeMarket struct{} + +// Init which initializes the fee market (in InitGenesis) +func (fm FeeMarket) Init(ctx 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(ctx sdk.Context) feemarket.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(ctx sdk.Context) map[string]feemarket.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(ctx sdk.Context, tx 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(ctx sdk.Context) map[string]string { + return nil +} + +// GetID returns the identifier of the fee market +func (fm FeeMarket) GetID() string { + return "mock" +} + +// FeeAnteHandler will be called in the module AnteHandler. +// Performs no actions. +func (fm FeeMarket) FeeAnteHandler( + ctx sdk.Context, + tx sdk.Tx, + simulate bool, + next sdk.AnteHandler, +) sdk.AnteHandler { + return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + return ctx, nil + } +} + +// FeePostHandler will be called in the module PostHandler +// if PostHandlers are implemented. Performs no actions. +func (fm FeeMarket) FeePostHandler( + ctx sdk.Context, + tx sdk.Tx, + simulate, + success bool, + next sdk.PostHandler, +) sdk.PostHandler { + return func(ctx sdk.Context, tx sdk.Tx, simulate, success bool) (newCtx sdk.Context, err error) { + return ctx, nil + } +} diff --git a/tests/simapp/feemarketd/main.go b/tests/simapp/feemarketd/main.go index e73c607..8036ee7 100644 --- a/tests/simapp/feemarketd/main.go +++ b/tests/simapp/feemarketd/main.go @@ -5,6 +5,7 @@ import ( "cosmossdk.io/log" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" + "github.com/skip-mev/feemarket/tests/simapp" cmd "github.com/skip-mev/feemarket/tests/simapp/feemarketd/testappd" ) diff --git a/tests/simapp/feemarketd/testappd/root.go b/tests/simapp/feemarketd/testappd/root.go index 42b368b..5e56cb6 100644 --- a/tests/simapp/feemarketd/testappd/root.go +++ b/tests/simapp/feemarketd/testappd/root.go @@ -16,6 +16,7 @@ import ( "cosmossdk.io/depinject" "cosmossdk.io/log" confixcmd "cosmossdk.io/tools/confix/cmd" + "github.com/skip-mev/feemarket/tests/simapp" "github.com/cosmos/cosmos-sdk/client" diff --git a/tests/simapp/feemarketd/testappd/testnet.go b/tests/simapp/feemarketd/testappd/testnet.go index 88391b6..5b1dbc7 100644 --- a/tests/simapp/feemarketd/testappd/testnet.go +++ b/tests/simapp/feemarketd/testappd/testnet.go @@ -33,6 +33,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/skip-mev/feemarket/tests/simapp" ) From dbc62d611846c38287852bead2ebf504eaa73bbb Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 9 Nov 2023 10:07:05 -0500 Subject: [PATCH 3/8] md --- feemarket/plugins/README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/feemarket/plugins/README.md b/feemarket/plugins/README.md index 144f82b..0e9c284 100644 --- a/feemarket/plugins/README.md +++ b/feemarket/plugins/README.md @@ -1,6 +1,9 @@ # FeeMarket Plugins -This directory contains implementations of the `FeeMarket` interface to be plugged into the `x/feemarket` module. +This directory contains implementations of the `FeeMarket` interface to be +plugged into the `x/feemarket` module. Current implementations include: - - [Mock:](./mock/feemarket.go) fee market that can be used for basic testing. DO NOT use in production. \ No newline at end of file + + - [Mock:](./mock/feemarket.go) fee market that can be used for basic testing. + DO NOT use in production. \ No newline at end of file From 2bb20f726295339d4c19057914a315d29fef6892 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 9 Nov 2023 10:10:17 -0500 Subject: [PATCH 4/8] md --- feemarket/plugins/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/feemarket/plugins/README.md b/feemarket/plugins/README.md index 0e9c284..8cc754a 100644 --- a/feemarket/plugins/README.md +++ b/feemarket/plugins/README.md @@ -1,9 +1,9 @@ # FeeMarket Plugins -This directory contains implementations of the `FeeMarket` interface to be +This directory contains implementations of the `FeeMarket` interface to be plugged into the `x/feemarket` module. Current implementations include: - - [Mock:](./mock/feemarket.go) fee market that can be used for basic testing. - DO NOT use in production. \ No newline at end of file + - [Mock:](./mock/feemarket.go) fee market that can be used for basic testing. + DO NOT use in production. From f0a006cbd97fd806eafa58c51e6df64e5be2a5d9 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 9 Nov 2023 10:11:20 -0500 Subject: [PATCH 5/8] md --- feemarket/plugins/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/feemarket/plugins/README.md b/feemarket/plugins/README.md index 8cc754a..dd33ebc 100644 --- a/feemarket/plugins/README.md +++ b/feemarket/plugins/README.md @@ -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. - DO NOT use in production. +- [Mock:](./mock/feemarket.go) fee market that can be used for basic testing. +DO NOT use in production. From c84c9a767b14aa01ac1e0943cbcbef227bb78556 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 9 Nov 2023 10:21:26 -0500 Subject: [PATCH 6/8] lint fix --- feemarket/plugins/mock/feemarket.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/feemarket/plugins/mock/feemarket.go b/feemarket/plugins/mock/feemarket.go index d867377..b4cf141 100644 --- a/feemarket/plugins/mock/feemarket.go +++ b/feemarket/plugins/mock/feemarket.go @@ -12,33 +12,33 @@ var _ feemarket.FeeMarket = FeeMarket{} type FeeMarket struct{} // Init which initializes the fee market (in InitGenesis) -func (fm FeeMarket) Init(ctx sdk.Context) error { +func (fm FeeMarket) 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(ctx sdk.Context) feemarket.UpdateHandler { +func (fm FeeMarket) EndBlockUpdateHandler(_ sdk.Context) feemarket.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(ctx sdk.Context) map[string]feemarket.UpdateHandler { +func (fm FeeMarket) EpochUpdateHandler(_ sdk.Context) map[string]feemarket.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(ctx sdk.Context, tx sdk.Tx) sdk.Coins { +func (fm FeeMarket) 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(ctx sdk.Context) map[string]string { +func (fm FeeMarket) GetFeeMarketInfo(_ sdk.Context) map[string]string { return nil } @@ -50,26 +50,26 @@ func (fm FeeMarket) GetID() string { // FeeAnteHandler will be called in the module AnteHandler. // Performs no actions. func (fm FeeMarket) FeeAnteHandler( - ctx sdk.Context, - tx sdk.Tx, - simulate bool, + _ sdk.Context, + _ sdk.Tx, + _ bool, next sdk.AnteHandler, ) sdk.AnteHandler { return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { - return ctx, nil + return next(ctx, tx, simulate) } } // FeePostHandler will be called in the module PostHandler // if PostHandlers are implemented. Performs no actions. func (fm FeeMarket) FeePostHandler( - ctx sdk.Context, - tx sdk.Tx, - simulate, - success bool, + _ sdk.Context, + _ sdk.Tx, + _, + _ bool, next sdk.PostHandler, ) sdk.PostHandler { return func(ctx sdk.Context, tx sdk.Tx, simulate, success bool) (newCtx sdk.Context, err error) { - return ctx, nil + return next(ctx, tx, simulate, success) } } From 7ce863c71b3779aed4d1eba88f53558edea127b4 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 9 Nov 2023 11:43:37 -0500 Subject: [PATCH 7/8] move files --- feemarket/feemarket.go | 64 ----------------- feemarket/plugins/README.md | 9 --- feemarket/plugins/mock/ante.go | 1 - x/feemarket/plugins/README.md | 0 .../feemarket}/plugins/mock/feemarket.go | 28 ++++---- x/feemarket/types/feemarket.go | 70 +++++++++++++++++++ 6 files changed, 86 insertions(+), 86 deletions(-) delete mode 100644 feemarket/feemarket.go delete mode 100644 feemarket/plugins/README.md delete mode 100644 feemarket/plugins/mock/ante.go create mode 100644 x/feemarket/plugins/README.md rename {feemarket => x/feemarket}/plugins/mock/feemarket.go (67%) create mode 100644 x/feemarket/types/feemarket.go diff --git a/feemarket/feemarket.go b/feemarket/feemarket.go deleted file mode 100644 index c5a0e6f..0000000 --- a/feemarket/feemarket.go +++ /dev/null @@ -1,64 +0,0 @@ -package feemarket - -import sdk "github.com/cosmos/cosmos-sdk/types" - -type ( - // FeeMarket defines the expected interface each fee market plugin must - // implement to be utilized by the fee market module. - FeeMarket interface { - // ------------------- 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. - UpdateHandler func(ctx sdk.Context) error -) diff --git a/feemarket/plugins/README.md b/feemarket/plugins/README.md deleted file mode 100644 index dd33ebc..0000000 --- a/feemarket/plugins/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# FeeMarket Plugins - -This directory contains implementations of the `FeeMarket` interface to be -plugged into the `x/feemarket` module. - -Current implementations include: - -- [Mock:](./mock/feemarket.go) fee market that can be used for basic testing. -DO NOT use in production. diff --git a/feemarket/plugins/mock/ante.go b/feemarket/plugins/mock/ante.go deleted file mode 100644 index f33e02b..0000000 --- a/feemarket/plugins/mock/ante.go +++ /dev/null @@ -1 +0,0 @@ -package mock diff --git a/x/feemarket/plugins/README.md b/x/feemarket/plugins/README.md new file mode 100644 index 0000000..e69de29 diff --git a/feemarket/plugins/mock/feemarket.go b/x/feemarket/plugins/mock/feemarket.go similarity index 67% rename from feemarket/plugins/mock/feemarket.go rename to x/feemarket/plugins/mock/feemarket.go index b4cf141..8e8b30b 100644 --- a/feemarket/plugins/mock/feemarket.go +++ b/x/feemarket/plugins/mock/feemarket.go @@ -3,53 +3,57 @@ 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{} +type MockFeeMarket struct{} //nolint + +// 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 +66,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, _, diff --git a/x/feemarket/types/feemarket.go b/x/feemarket/types/feemarket.go new file mode 100644 index 0000000..f538aaa --- /dev/null +++ b/x/feemarket/types/feemarket.go @@ -0,0 +1,70 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// FeeMarketImplementation represents the interface of various FeeMarket types implemented +// by other modules or packages. +type FeeMarketImplementation interface { + // proto.Message TODO: add + + // 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 From ee0b83f9c56174a5dd41048b4d83655070e38a48 Mon Sep 17 00:00:00 2001 From: aljo242 Date: Thu, 9 Nov 2023 13:50:18 -0500 Subject: [PATCH 8/8] nit fix --- x/feemarket/plugins/mock/feemarket.go | 30 +++++++++++++++------------ x/feemarket/types/feemarket.go | 18 ++++++++-------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/x/feemarket/plugins/mock/feemarket.go b/x/feemarket/plugins/mock/feemarket.go index 8e8b30b..bf161e4 100644 --- a/x/feemarket/plugins/mock/feemarket.go +++ b/x/feemarket/plugins/mock/feemarket.go @@ -1,6 +1,8 @@ package mock import ( + "encoding/json" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/skip-mev/feemarket/x/feemarket/types" @@ -20,23 +22,25 @@ 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 *MockFeeMarket) EndBlockUpdateHandler(_ sdk.Context) types.UpdateHandler { - return nil +// Export which exports the fee market (in ExportGenesis) +func (fm *MockFeeMarket) Export(_ sdk.Context) (json.RawMessage, error) { + return nil, 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 *MockFeeMarket) EpochUpdateHandler(_ sdk.Context) map[string]types.UpdateHandler { - return nil +// BeginBlockUpdateHandler allows the fee market to be updated +// after every block. This will be added to the BeginBlock chain. +func (fm *MockFeeMarket) BeginBlockUpdateHandler(_ sdk.Context) types.UpdateHandler { + return func(ctx sdk.Context) error { + return nil + } } -// GetMinGasPrice retrieves the minimum gas price(s) needed -// to be included in the block for the given transaction -func (fm *MockFeeMarket) GetMinGasPrice(_ sdk.Context, _ sdk.Tx) sdk.Coins { - return sdk.NewCoins() +// EndBlockUpdateHandler allows the fee market to be updated +// after every block. This will be added to the EndBlock chain. +func (fm *MockFeeMarket) EndBlockUpdateHandler(_ sdk.Context) types.UpdateHandler { + return func(ctx sdk.Context) error { + return nil + } } // GetFeeMarketInfo retrieves the fee market's information about diff --git a/x/feemarket/types/feemarket.go b/x/feemarket/types/feemarket.go index f538aaa..3876870 100644 --- a/x/feemarket/types/feemarket.go +++ b/x/feemarket/types/feemarket.go @@ -1,6 +1,8 @@ package types import ( + "encoding/json" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -18,21 +20,19 @@ type FeeMarketImplementation interface { // Init which initializes the fee market (in InitGenesis) Init(ctx sdk.Context) error + // Export which exports the fee market (in ExportGenesis) + Export(ctx sdk.Context) (json.RawMessage, error) + + // BeginBlockUpdateHandler allows the fee market to be updated + // after every block. This will be added to the BeginBlock chain. + BeginBlockUpdateHandler(ctx sdk.Context) UpdateHandler + // 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.).