-
Notifications
You must be signed in to change notification settings - Fork 618
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: sidecar query server #6953
Conversation
fce5e5a
to
c576065
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.
ACK on skim, noting that I did not look at tests. Full feature will need proper review
- How to handle atomicity between ticks and pools? E.g. let's say a block is written between the time initial pools are read | ||
and the time the ticks are read. Now, we have data that is partially up-to-date. |
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.
Can/should we just operate on data from the previous block?
// NewChainInfoIngester returns a new chain information ingester. | ||
func NewChainInfoIngester(chainInfoRepo mvc.ChainInfoRepository, repositoryManager mvc.TxManager) mvc.AtomicIngester { | ||
return &chainInfoIngester{ | ||
chainInfoRepo: chainInfoRepo, | ||
repositoryManager: repositoryManager, | ||
} | ||
} |
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.
Is there a reason we don't just set the logger directly here?
func (ci *chainInfoIngester) ProcessBlock(ctx sdk.Context, tx mvc.Tx) error { | ||
height := ctx.BlockHeight() | ||
|
||
ci.logger.Info("ingesting latest blockchain height", zap.Int64("height", height)) |
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 don't think this should be an info log, we should keep info logs as bare as needed, especially for something that will happen on a per block basis.
// GetTotalValueLockedUOSMO implements domain.PoolI. | ||
func (mp *MockRoutablePool) GetTotalValueLockedUOSMO() math.Int { | ||
return mp.TotalValueLockedUSDC | ||
} | ||
|
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.
Method is UOSMO be returns USDC
newDenoms := make([]string, len(mp.Denoms)) | ||
copy(newDenoms, mp.Denoms) | ||
|
||
newTotalValueLocker := osmomath.NewIntFromBigInt(mp.TotalValueLockedUSDC.BigInt()) |
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.
Locker instead of Locked
func retrieveTakerFeeToMapIfNotExists(ctx sdk.Context, denoms []string, denomPairToTakerFeeMap domain.TakerFeeMap, poolManagerKeeper common.PoolManagerKeeper) error { | ||
for i, denomI := range denoms { | ||
for j := i + 1; j < len(denoms); j++ { | ||
if !denomPairToTakerFeeMap.Has(denomI, denoms[j]) { | ||
takerFee, err := poolManagerKeeper.GetTradingPairTakerFee(ctx, denomI, denoms[j]) | ||
if err != nil { | ||
// This error should not happen. As a result, we do not skip it | ||
return err | ||
} | ||
|
||
denomPairToTakerFeeMap.SetTakerFee(denomI, denoms[j], takerFee) | ||
} | ||
} | ||
} | ||
return 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.
Oh I see, we set it here. Can probably save on storage by making it so that if no store exists we use default rather than storing default for ever non-overriden pair.
// NewPoolsUsecase will create a new pools use case object | ||
func NewPoolsUsecase(timeout time.Duration, poolsRepository mvc.PoolsRepository, redisRepositoryManager mvc.TxManager) mvc.PoolsUsecase { | ||
return &poolsUseCase{ | ||
contextTimeout: timeout, | ||
poolsRepository: poolsRepository, | ||
redisRepositoryManager: redisRepositoryManager, | ||
} | ||
} |
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.
Is there a better name for usecase? I am still struggling to understand how usecase applies here
return nil, err | ||
} | ||
|
||
// TODO: refactor get these directl from the pools repository. |
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.
// TODO: refactor get these directl from the pools repository. | |
// TODO: refactor get these directly from the pools repository. |
// Define a regular expression pattern to match sdk.Coin where the first part is the amount and second is the denom name | ||
// Patterns tested: | ||
// 500ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2 | ||
// 100uion | ||
var coinPattern = regexp.MustCompile(`([0-9]+)(([a-z]+)(\/([A-Z0-9]+))*)`) |
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.
regex will prob need to consider multiple slash for token factory, it might already do this but I am skimming
} | ||
|
||
const ( | ||
keySeparator = "-" |
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 am skimming but is it possible for a denom to have "-" now in sdk 47 so this would maybe mess up the key
Thanks for the review. I reviewed all comments, and all are non-blocking. I will come back to addressing after the v1 release. Tracking that here: https://app.clickup.com/t/86a1j92hy |
* feat(SQS): IngestManager abstraction and wiring * comment * comment * lint * feat: sidecar query server --------- Co-authored-by: Adam Tucker <adamleetucker@outlook.com> (cherry picked from commit 4edf2cb) # Conflicts: # go.mod # go.sum
* feat(SQS): IngestManager abstraction and wiring * comment * comment * lint * feat: sidecar query server --------- Co-authored-by: Adam Tucker <adamleetucker@outlook.com> (cherry picked from commit 4edf2cb)
* feat(SQS): IngestManager abstraction and wiring * comment * comment * lint * feat: sidecar query server --------- Co-authored-by: Adam Tucker <adamleetucker@outlook.com> (cherry picked from commit 4edf2cb) Co-authored-by: Roman <roman@osmosis.team>
} | ||
|
||
// SetTokenOutDenom implements domain.RoutablePool. | ||
func (*MockRoutablePool) SetTokenOutDenom(tokenOutDenom string) { |
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.
what's the reason we're not implementing this for mock?
@@ -0,0 +1,3 @@ | |||
// Encapsulates the Model-View-Controller abstraction domain. |
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.
just curious, what was the original intention of this file:?
|
||
// AtomicIngester is an interface that defines the methods for the atomic ingester. | ||
// It processes a block by writing data into a transaction. | ||
// The caller must call Exec on the transaction to flush data to sink. |
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.
what does this mean?
MaxRoutes int | ||
MaxSplitRoutes int | ||
MaxSplitIterations int | ||
// Denominated in OSMO (not uosmo) |
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.
just curious, why do we want this in osmo not uosmo?
Debug(msg string, fields ...zap.Field) | ||
} | ||
|
||
type NoOpLogger struct{} |
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.
Why do we want no op logger?
return nil, err | ||
} | ||
|
||
core = zapcore.NewTee( |
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.
While testing, I found a bug that logger wouldnt correctly pipe it to std out besides in the ingester. Needs investigation
sqsModel := p.GetSQSPoolModel() | ||
poolDenoms := p.GetPoolDenoms() | ||
|
||
if len(poolDenoms) < 2 { |
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.
Why is this?
// updateRoutes updates the routes for all denom pairs in the taker fee map. The taker fee map value is unused. | ||
// It returns a channel that is closed when all routes are updated. | ||
// TODO: test | ||
func (pi *poolIngester) updateRoutes(ctx context.Context, tx mvc.Tx, pools []domain.PoolI, denomPairToTakerFeeMap map[domain.DenomPair]osmomath.Dec) chan domain.DenomPair { |
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.
just curious, why are we using channels here?
Closes: #XXX
What is the purpose of the change
Core implementation of the sidecar query server with the router
Separated from: #6785
SQS is not wired into the app yet. I suggest review being only cursory. Please check
go.mod
, that there is no state-machine affecting logic.Testing and Verifying
This change is a trivial rework / code cleanup without any test coverage.
Documentation and Release Note
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)