Skip to content

Commit

Permalink
fix: since we don't simulate, make sure our gas estimate is good
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 26, 2020
1 parent c6bf0e2 commit a0a2df5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/agoric-cli/lib/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
'--keyring-backend=test',
'--from=provision',
'--gas=auto',
'--gas-adjustment=1.5',
'--broadcast-mode=block',
'--yes',
`--chain-id=${CHAIN_ID}`,
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ t1-provision-one-with-powers:
addr=$$(cat t1/$(BASE_PORT)/ag-cosmos-helper-address); \
$(AGCH) --home=t1/bootstrap query swingset egress $$addr --chain-id=$(CHAIN_ID) || \
$(AGCH) --home=t1/bootstrap tx swingset provision-one --keyring-backend=test --from=bootstrap \
--gas=auto --gas-adjustment=1.4 --broadcast-mode=block --yes --chain-id=$(CHAIN_ID) \
--gas=auto --broadcast-mode=block --yes --chain-id=$(CHAIN_ID) \
t1/$(BASE_PORT) $$addr agoric.vattp | tee /dev/stderr | grep -q 'code: 0'

t1-provision-one:
addr=$$(cat t1/$(BASE_PORT)/ag-cosmos-helper-address); \
$(AGCH) --home=t1/bootstrap query swingset egress $$addr --chain-id=$(CHAIN_ID) || \
$(AGCH) --home=t1/bootstrap tx swingset provision-one --keyring-backend=test --from=bootstrap \
--gas=auto --gas-adjustment=1.4 --broadcast-mode=block --yes --chain-id=$(CHAIN_ID) \
--gas=auto --broadcast-mode=block --yes --chain-id=$(CHAIN_ID) \
t1/$(BASE_PORT) $$addr | tee /dev/stderr | grep -q 'code: 0'

# Actually start the ag-solo.
Expand Down
1 change: 0 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/chain-cosmos-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ ${chainID} chain does not yet know of address ${myAddr}${adviseProvision(
'--keyring-backend=test',
`@${tmpInfo.path}`, // Deliver message over file, as it could be big.
'--gas=auto',
'--gas-adjustment=1.05',
'--from=ag-solo',
'-ojson',
'--broadcast-mode=block', // Don't return until committed.
Expand Down
3 changes: 3 additions & 0 deletions packages/cosmic-swingset/x/swingset/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func NewHandler(keeper Keeper) sdk.Handler {
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return &sdk.Result{}, nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

switch msg := msg.(type) {
Expand Down
27 changes: 27 additions & 0 deletions packages/cosmic-swingset/x/swingset/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ func (am AppModule) OnChanOpenInit(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

event := channelOpenInitEvent{
Expand Down Expand Up @@ -260,6 +263,9 @@ func (am AppModule) OnChanOpenTry(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

event := channelOpenTryEvent{
Expand Down Expand Up @@ -313,6 +319,9 @@ func (am AppModule) OnChanOpenAck(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

event := channelOpenAckEvent{
Expand Down Expand Up @@ -351,6 +360,9 @@ func (am AppModule) OnChanOpenConfirm(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

event := channelOpenConfirmEvent{
Expand Down Expand Up @@ -389,6 +401,9 @@ func (am AppModule) OnChanCloseInit(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

event := channelCloseInitEvent{
Expand Down Expand Up @@ -426,6 +441,9 @@ func (am AppModule) OnChanCloseConfirm(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

event := channelCloseConfirmEvent{
Expand Down Expand Up @@ -461,6 +479,9 @@ func (am AppModule) OnRecvPacket(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return &sdk.Result{}, nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

// Sometimes we receive duplicate packets, just with a
Expand Down Expand Up @@ -511,6 +532,9 @@ func (am AppModule) OnAcknowledgementPacket(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return &sdk.Result{}, nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

event := acknowledgementPacketEvent{
Expand Down Expand Up @@ -552,6 +576,9 @@ func (am AppModule) OnTimeoutPacket(
if committedHeight == ctx.BlockHeight() {
// We don't support simulation.
return &sdk.Result{}, nil
} else {
// The simulation was done, so now allow infinite gas.
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
}

event := timeoutPacketEvent{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
exec ag-cosmos-helper --home=$FAUCET_HOME \
tx swingset provision-one \
--node=tcp://$selected --chain-id=$chainName \
--yes --gas=auto --gas-adjustment=1.5 --broadcast-mode=block \
--yes --gas=auto --broadcast-mode=block \
--from=faucet -- "$NAME" "$ADDR"
;;
add-delegate)
Expand Down Expand Up @@ -66,7 +66,7 @@ while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
if ag-cosmos-helper --home=$FAUCET_HOME \
tx send \
--node=tcp://$selected --chain-id=$chainName \
--yes --gas=auto --gas-adjustment=1.5 --broadcast-mode=block \
--yes --gas=auto --broadcast-mode=block \
-- faucet "$ADDR" "$STAKE"; then
# Record the information before exiting.
sed -i -e "/:$NAME$/d" $thisdir/cosmos-delegates.txt
Expand Down

0 comments on commit a0a2df5

Please sign in to comment.