-
Notifications
You must be signed in to change notification settings - Fork 115
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
[DO NOT MERGE, PREVIEW ONLY] Merge feature/cosmwasm
into main
#2074
base: main
Are you sure you want to change the base?
Conversation
…1499) * Add initial test contract with dydx messages. * Add custom querier support for OracleQuery (#974) * cleanup + remove unnecessary files * cherrypick 8e3f5b2, modified versions * Add Rust library for Dydx Query (#979) * update cargo.toml and Cargo.lock --------- Co-authored-by: Vincent Chau <99756290+vincentwschau@users.noreply.github.com>
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
feature/cosmwasm
into main
feature/cosmwasm
into main
b4828e1
to
e3331b3
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.
Not a full review, just some comments I had while looking at the code
// AllCapabilities returns all capabilities available with the current wasmvm | ||
// See https://github.com/CosmWasm/cosmwasm/blob/main/docs/CAPABILITIES-BUILT-IN.md | ||
supportedFeatures := "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_4,dydx" | ||
|
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'd recommend using something like strings.Join(append(AllCapabilities(),"dydx"), ",")
. That way you don't need to manually update the capabilities when you upgrade x/wasm.
@@ -1476,6 +1557,10 @@ func New( | |||
|
|||
// initialize BaseApp | |||
app.SetInitChainer(app.InitChainer) | |||
// wasmd also comes with 2 custom ante handlers: | |||
// - CountTXDecorator adds the TX position in the block into the context and passes it to the contracts |
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.
You need this if you want contracts to get access to env.transaction
. Otherwise they get None
there.
@@ -1476,6 +1557,10 @@ func New( | |||
|
|||
// initialize BaseApp | |||
app.SetInitChainer(app.InitChainer) | |||
// wasmd also comes with 2 custom ante handlers: | |||
// - CountTXDecorator adds the TX position in the block into the context and passes it to the contracts | |||
// - LimitSimulationGasDecorator prevents an "infinite gas" query |
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's probably less important for permissioned chains, but still good to have in case someone finds a way to cause an infinite loop in a contract call.
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.
Added some comments
@@ -12,6 +14,7 @@ ARG GOLANG_1_22_ALPINE_DIGEST="cdc86d9f363e8786845bea2040312b4efa321b828acdeb26f | |||
FROM golang@sha256:${GOLANG_1_22_ALPINE_DIGEST} as builder | |||
ARG VERSION | |||
ARG COMMIT | |||
ARG WASMVM_VERSION=v1.5.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.
It would be great to use wasmvm v1.5.5 because it includes some security fixes.
if !isSingleWasmEx { | ||
return next(ctx, tx, simulate) | ||
} |
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.
Do you actually mean to skip this ante handler if there are multiple wasm exec in the same tx?
To my understanding you probably want to discard the tx, in that case you should just return an error
@@ -396,6 +404,9 @@ func (h *lockingAnteHandler) otherMsgAnteHandle(ctx sdk.Context, tx sdk.Tx, simu | |||
defer h.globalLock.Unlock() | |||
} | |||
|
|||
if ctx, err = h.executeCosmWasm.AnteHandle(ctx, tx, simulate, noOpAnteHandle); 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.
you should also add wasmd ante handlers :
CountTXDecorator
is useful because it provides position data to the contract via Env . The motivation is to add a unique ID to the contract environment to distinguish between multiple executions within the same block but in different tx versus a reentrant call within the same msg or tx.LimitSimulationGasDecorator
limits the maximum gas available in simulations, preventing the "infinite gas" issues.
So to avoid well known issues and keep the full compatibility both ante handlers should be provided.
@@ -35,6 +36,9 @@ var ( | |||
govtypes.ModuleName: {authtypes.Burner}, | |||
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, | |||
icatypes.ModuleName: nil, | |||
// https://github.com/CosmWasm/wasmvm/blob/1c3fdc2a4402e527617ec72fe53f114b24899a01/types/msg.go#L116-L121 | |||
// required to burn given coins from the contract's account. | |||
wasmtypes.ModuleName: {authtypes.Burner}, |
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.
👍
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 reviewed the Rust bits and they look fine save for nitpicks.
// implement custom query | ||
impl CustomQuery for DydxQueryWrapper {} | ||
|
||
/// SeiQuery is defines available query datas |
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.
/// SeiQuery is defines available query datas | |
/// SeiQuery defines available query datas |
pub fn new(i: BigInt) -> Self { | ||
Self { i } | ||
} | ||
pub fn to_big_int(&self) -> &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.
pub fn to_big_int(&self) -> &BigInt { | |
pub fn as_big_int(&self) -> &BigInt { |
This is more idiomatic for reference conversions. See example
use dydx_cosmwasm::{DydxQuerier, DydxQueryWrapper, SubaccountId}; | ||
use dydx_cosmwasm::DydxQuery; | ||
|
||
// version info for migration info |
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.
// version info for migration info | |
// version info for migration |
} | ||
|
||
#[cfg_attr(not(feature = "library"), entry_point)] | ||
pub fn query(deps: Deps<DydxQueryWrapper>, _env: Env, msg: DydxQuery) -> StdResult<Binary> { |
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 this contract meant as an example for contract devs to use as a reference? I worry accepting the DydxQuery
type from the bindings lib would be confusing to them. It's more typical for a contract to define its own QueryMsg
.
Changelist
[Describe or list the changes made in this PR]
Test Plan
[Describe how this PR was tested (if applicable)]
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.