-
Notifications
You must be signed in to change notification settings - Fork 60
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
fix: ABCI Removal Fix of Currency Pairs #300
Changes from all commits
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 |
---|---|---|
|
@@ -120,11 +120,3 @@ func (s *DeltaCurrencyPairStrategy) getOnChainPrice(ctx sdk.Context, cp slinkyty | |
s.cache[cp] = currentPrice | ||
return currentPrice, nil | ||
} | ||
|
||
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 inherit the default one so we don't need this since the check is the same. |
||
// GetMaxNumCP returns the number of pairs that the VEs should include. This method returns an error if the size cannot | ||
// be queried from the x/oracle state. | ||
func (s *DeltaCurrencyPairStrategy) GetMaxNumCP( | ||
ctx sdk.Context, | ||
) (uint64, error) { | ||
return s.oracleKeeper.GetPrevBlockCPCounter(ctx) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,10 +113,19 @@ | |
|
||
// RemoveCurrencyPair removes a given CurrencyPair from state, i.e. removes its nonce + QuotePrice from the module's store. | ||
func (k *Keeper) RemoveCurrencyPair(ctx sdk.Context, cp slinkytypes.CurrencyPair) error { | ||
// check if the currency pair exists. | ||
if !k.HasCurrencyPair(ctx, cp) { | ||
return types.NewCurrencyPairNotExistError(cp) | ||
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. goated |
||
} | ||
|
||
if err := k.currencyPairs.Remove(ctx, cp.String()); err != nil { | ||
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. this is just for knowledge sake - if this does not return an error if the key does not exist, what are the cases where this does error? |
||
return err | ||
} | ||
return k.incrementRemovedCPCounter(ctx) | ||
if err := k.incrementRemovedCPCounter(ctx); err != nil { | ||
return err | ||
} | ||
|
||
return k.decrementCPCounter(ctx) | ||
} | ||
|
||
// HasCurrencyPair returns true if a given CurrencyPair is stored in state, false otherwise. | ||
|
@@ -334,8 +343,8 @@ | |
return k.numRemoves.Set(ctx, val) | ||
} | ||
|
||
// GetRemovedCPCounter gets the counter of removed currency pairs. | ||
func (k *Keeper) GetRemovedCPCounter(ctx sdk.Context) (uint64, error) { | ||
// GetNumRemovedCurrencyPairs gets the counter of removed currency pairs in the previous block. | ||
func (k *Keeper) GetNumRemovedCurrencyPairs(ctx sdk.Context) (uint64, error) { | ||
return k.numRemoves.Get(ctx) | ||
} | ||
|
||
|
@@ -350,7 +359,18 @@ | |
return k.numCPs.Set(ctx, val) | ||
} | ||
|
||
// GetPrevBlockCPCounter gets the counter of currency pairs in the previous block. | ||
func (k *Keeper) GetPrevBlockCPCounter(ctx sdk.Context) (uint64, error) { | ||
// DecrementCPCounter decrements the counter of currency pairs. | ||
func (k *Keeper) decrementCPCounter(ctx sdk.Context) error { | ||
val, err := k.numCPs.Get(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
val-- | ||
return k.numCPs.Set(ctx, val) | ||
} | ||
|
||
// GetNumCurrencyPairs returns the number of currency pairs currently in state. | ||
func (k *Keeper) GetNumCurrencyPairs(ctx sdk.Context) (uint64, error) { | ||
return k.numCPs.Get(ctx) | ||
} |
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 let's be as pedantic as possible here since this is tricky enough to reason about
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.
Instead of implicitly casing on the exec-mode, I'd ideally like to expose to the caller whether they want the value of cps in state before the block was executed (specifically in
Prepare
/Process
), or whether they want the # of cps in state (Verify
)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.
This function has two diff behaviors AFAICT:
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.
that would a breaking change with the current dYdX integration so im in favor of keeping it as is.
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.
This alr is a breaking change, no? Only the
GetPrevBlockCPCounter
is implemented in dydx