-
Notifications
You must be signed in to change notification settings - Fork 233
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(cosmos): ensure simulated transactions can't trigger SwingSet #3740
Conversation
9ccd635
to
c8eb958
Compare
The former pattern of `vm.IsSimulation` was too brittle to handle our migration to the GRPC-based transaction handlers. Instead, intercept the actual invocation of CallToController and prevent it from running anything in SwingSet if in simulation mode. Also, make sure our InfiniteGasMeter is only assigned once, so that if we ever do Cosmos-level metering of SwingSet downcalls, there is only one place to adjust.
c8eb958
to
997329a
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.
Wild.
I browsed the changes. If it's important to have this approved soon: Which are the key parts and which are just knock-on effects?
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.
Thanks for testing it.
fix(cosmos): ensure simulated transactions can't trigger SwingSet
@@ -23,7 +23,7 @@ func NewStorageHandler(keeper Keeper) storageHandler { | |||
return storageHandler{keeper: keeper} | |||
} | |||
|
|||
func (sh storageHandler) Receive(ctx *vm.ControllerContext, str string) (ret string, err error) { | |||
func (sh storageHandler) Receive(cctx *vm.ControllerContext, str string) (ret string, err error) { |
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've been using ctlCtx
, e.g. in vbank_test.go
, so we should use one of the two names consistently (I don't care which). Might save some clutter below by extracting ctx := ctlCtx.Context
at the top.
callToController := func(ctx sdk.Context, str, simReturn string) (string, error) { | ||
if vm.IsSimulation(ctx) { | ||
// Just return the simReturn, since the message is being simulated. | ||
return simReturn, 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.
It sure looks like simReturn
is always the empty string. If so, you can avoid the extra arg to callToController
and avoid a lot of changes.
Closes #3739
The former pattern of
vm.IsSimulation
was too brittle to handleour migration to the GRPC-based transaction handlers. Instead,
intercept the actual invocation of CallToController and prevent
it from running anything in SwingSet if in simulation mode.
Also, make sure our InfiniteGasMeter is only assigned once, so
that if we ever do Cosmos-level metering of SwingSet downcalls,
there is only one place to adjust.