-
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
Conversation
@@ -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 comment
The 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.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #300 +/- ##
==========================================
+ Coverage 56.74% 56.82% +0.07%
==========================================
Files 227 227
Lines 10756 10761 +5
==========================================
+ Hits 6104 6115 +11
+ Misses 4139 4134 -5
+ Partials 513 512 -1 ☔ View full report in Codecov by Sentry. |
} | ||
|
||
if mode := ctx.ExecMode(); mode == sdk.ExecModePrepareProposal || mode == sdk.ExecModeProcessProposal { | ||
removed, err := s.oracleKeeper.GetNumRemovedCurrencyPairs(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.
removed, err := s.oracleKeeper.GetNumRemovedCurrencyPairs(ctx) | |
removed, err := s.oracleKeeper.GetNumRemovedCurrencyPairsInBlock(ctx) |
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:
- Get the # of cps in state before the block was executed (+ all cps added in the last block executed)
- Get the current # of cps in state
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
@@ -113,10 +113,19 @@ func NewKeeper( | |||
|
|||
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
goated
if !k.HasCurrencyPair(ctx, cp) { | ||
return types.NewCurrencyPairNotExistError(cp) | ||
} | ||
|
||
if err := k.currencyPairs.Remove(ctx, cp.String()); err != nil { |
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 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?
So in this case, we're leaving |
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.
left comment
The main one in my mind is that we are doing significantly less state reads this way. O(1) v O(n) |
@nivasan1 we originally had alignment that we would check only the size, you proposed the other idea but we decided to go with the simpler approach. I suggest we leave this as is and ask ottersec to take a deeper dive into this. More likely than not I can see the possibility of us moving into checking the IDs. |
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.
Approving for now but @davidterpay can you create an issue to clean this up / rename functions / doc this?
9f9f72b
to
eb68c2c
Compare
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.
lgtm
Let's walk through a few scenarios:
Example 1
Example 2
Example 3