-
Notifications
You must be signed in to change notification settings - Fork 1
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
middleware base #129
base: dev
Are you sure you want to change the base?
middleware base #129
Conversation
… pool helper method
I think the pretty name of the valence type should be an alias that we manage for convenience, but by default these types should be content addressed somehow. This allows anyone to add new valence types and external types to the registry and mapping them, but prevents squatting something like So I'm an external developer I add the following to the registry:
The concatenation of these two content addresses And then as a convenience, a multi-sig we own can create human readable aliases for a unique After which developers can use something like What's here is already a substantial addition, so we may want to address this is a separate PR. |
we should probably rename icq-querier to neutron-icq-querier to avoid future conflicts |
prost = { version = "0.13.3", default-features = false, features = [ "prost-derive" ] } | ||
prost-types = { version = "0.13.3", default-features = false } |
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.
nit: maybe add the default-features flag in the contract?
@@ -0,0 +1 @@ | |||
# ICQ-querier library |
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.
prob worth adding something here
_info: MessageInfo, | ||
_msg: InstantiateMsg, | ||
) -> Result<Response<NeutronMsg>, LibraryError> { | ||
Ok(Response::default()) |
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.
set contract version here?
keys: vec![query_kv_key], | ||
transactions_filter: String::new(), | ||
connection_id, | ||
update_period: 5, |
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.
should update_period be hardcoded?
let mut resp = vec![]; | ||
for entry in ASSOCIATED_QUERY_IDS.range(deps.storage, None, None, Order::Ascending) { | ||
resp.push(entry?); | ||
} | ||
to_json_binary(&resp) |
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.
nit: can just do
.filter_map(Result::ok)
.map(|(_, entry)| entry)
.collect()
for these queries
@@ -0,0 +1,3 @@ | |||
[alias] | |||
wasm = "build --release --lib --target wasm32-unknown-unknown" | |||
schema = "run --bin schema" |
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 you create the schemas for both contracts? This way linter won't complain when we merge into main
prost = { workspace = true } | ||
prost-types = { workspace = true } |
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.
would add the default-features = false here like for serde-json-wasm (linked to prev comment)
osmosis-std = "0.26.0" | ||
osmosis-std-derive = "0.26.0" |
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.
nit: we have these in workspace
nit2: indent.
_info: MessageInfo, | ||
_msg: InstantiateMsg, | ||
) -> Result<Response, MiddlewareError> { | ||
Ok(Response::default()) |
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.
same as other contract. Add versioning for migration.
/* | ||
OSMOSIS POOL | ||
|
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.
leftover?
closes #126 , #120
introduces a base implementation of Valence Types to be used in programs.
new additions:
contracts/middleware/broker
- type registry gateway meant to enable runtime upgrades to type registriescontracts/middleware/type-registries
- actual type registries where developers can add new types to be used in valencecontracts/libraries/icq-querier
- icq querier library which uses the broker for getting theKVKey
needed for registering an ICQuerypackages/middleware-utils
- utils used to define the common api for middleware systemlocal-interchaintest/examples/middleware_icq_test
- e2e test showcasing the middleware usage to icq an osmosis gamm pool, parse it into a valence xyk type, and get its pricewhile some parts are still a little rough around the edges, I think it makes sense to put this pr up now to get some feedback around some key logic in this flow.
Broker
I expect the same broker to be used for any and all type registries or other types of plugins we may want to enable, as long as they comply with the expected interface.
Brokers wrap around the type registry api and relay the requests to the specified (or default=latest) version of the type registry. New type registries can be added to brokers during runtime to enable new types/functionality without requiring any upgrades from programs relying on a given broker.
Type Registries
This is where I spent the most time. In particular,
contracts/middleware/type-registries/osmosis/osmo-26-0-0/src/definitions
.In
mod.rs
, we have aregister_types!
macro call. Currently it looks like this:Under the hood the macro generates a query handler that is used in the type registry contract:
My thinking here was to minimize the lines of code needed to have a unified interface.
It can be seen as a map which maps the external type url (designator) to a set of functionality (plugins) we wish to enable for that type.
Zooming in on the gamm pool entry, we are basically saying:
Valence Types are defined in utils packages and are out of developer (who are implementing the type registry) control.
Currently the set of enabled types is:
Adapter is the only thing the developer needs to write, see example at
contracts/middleware/type-registries/osmosis/osmo-26-0-0/src/definitions/gamm_pool
.Currently it feels like most (if not all) of those macro fields can be seen as optional. No type being registered should be expected to implement every adapter possible.
For example, we could introduce an
evm_adapter
field which could be used to specify the type/struct/function that knows how to do evm serde. It would only be useful for a small subset of all types we may be dealing with.One thing to note here is that in order to maintain the unified api, these macros will embed every possible adapter for every type registry. Meaning, if we tried to call some evm_serde method on a type that does not have that adapter implemented, it would return an error along the lines of "evm adapter is not implemented for this type".