-
Notifications
You must be signed in to change notification settings - Fork 103
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(x/ecocredit): add buy/sell expiration #671
Changes from 7 commits
8a1bfd2
29b561a
e0e40ec
59e5c97
0d578f7
6b97ceb
3b602ac
9fa1b45
bbfd904
4a04cba
3781a67
7d18334
239923f
8cf6281
54776f9
c29ab33
f67cde6
071c3bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,7 +406,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest | |
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC) | ||
app.mm.SetOrderBeginBlockers( | ||
upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, | ||
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, | ||
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, /* ecocredit.ModuleName, */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is ecocredit commented out due to errors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct, not sure how to resolve at the moment: #671 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's leave it for a next task. |
||
) | ||
app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName) | ||
// NOTE: The genutils module must occur after staking so that pools are | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ syntax = "proto3"; | |
|
||
package regen.ecocredit.v1alpha2; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
option go_package = "github.com/regen-network/regen-ledger/x/ecocredit"; | ||
|
||
|
@@ -147,6 +149,10 @@ message EventSell { | |
// buyer to disable auto-retirement in their buy order enabling them to | ||
// resell the credits to another buyer. | ||
bool disable_auto_retire = 5; | ||
|
||
// expiration is the optional timestamp when the sell order expires. When the | ||
ryanchristo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// expiration time is reached, the sell order is removed from state. | ||
google.protobuf.Timestamp expiration = 6 [ (gogoproto.stdtime) = true ]; | ||
} | ||
|
||
// EventUpdateSellOrder is an event emitted when a sell order is updated. | ||
|
@@ -170,6 +176,10 @@ message EventUpdateSellOrder { | |
|
||
// disable_auto_retire updates the disable_auto_retire field in the sell order. | ||
bool disable_auto_retire = 6; | ||
|
||
// new_expiration is the optional timestamp when the sell order expires. When the | ||
// expiration time is reached, the sell order is removed from state. | ||
google.protobuf.Timestamp new_expiration = 7 [ (gogoproto.stdtime) = true ]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really want to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, we don't do that in general. The other parts were not yet released. Let's chat about naming in the discord or standup. |
||
} | ||
|
||
// EventBuyOrderCreated is an event emitted when a buy order is created. | ||
|
@@ -202,6 +212,10 @@ message EventBuyOrderCreated { | |
// disable_partial_fill disables the default behavior of partially filling | ||
// buy orders if the requested quantity is not available. | ||
bool disable_partial_fill = 6; | ||
|
||
// expiration is the optional timestamp when the buy order expires. When the | ||
// expiration time is reached, the buy order is removed from state. | ||
google.protobuf.Timestamp expiration = 7 [ (gogoproto.stdtime) = true ]; | ||
} | ||
|
||
// EventBuyOrderFilled is an event emitted when a buy order is filled. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package ecocredit | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
) | ||
|
||
// BeginBlocker checks if there are any expired sell or buy orders and removes them from state. | ||
func BeginBlocker(ctx sdk.Context, k Keeper, req abci.RequestBeginBlock) { | ||
ryanchristo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
defer telemetry.ModuleMeasureSince(ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
|
||
if err := k.PruneOrders(ctx); err != nil { | ||
panic(err) | ||
ryanchristo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any ideas why adding this would cause the tests to hang?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It times out after 10 minutes with the following error:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm wondering if this has anything to do with the ecocredit module not fulfilling the interface that actually contains the BeginBlock signature.
might need to : add this to the ecocredit/module/module.go file
var _ module.AppModule = Module{}
and implement the methods it says its missing. maybe that would work?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be best to break this out into a separate issue. The ecocredit module does not implement the
AppModule
interface and in attempting to do so there are some conflicts with theRegisterServices
method which uses a differentConfigurator
. Opened #689.