Skip to content

Commit

Permalink
Merge pull request #8902 from Agoric/mhofman/8887-fix-governance
Browse files Browse the repository at this point in the history
Handle cosmos 0.46 gov breaking changes
  • Loading branch information
mergify[bot] authored and mhofman committed Feb 18, 2024
2 parents 9c3e86f + 4cb5bc9 commit 04eae85
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion golang/cosmos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ replace (
github.com/confio/ics23/go => github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1

// We need a fork of cosmos-sdk until all of the differences are merged.
github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.1
github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2

// https://pkg.go.dev/vuln/GO-2023-2409
github.com/dvsekhvalnov/jose2go => github.com/dvsekhvalnov/jose2go v1.5.1-0.20231206184617-48ba0b76bc88
Expand Down
4 changes: 2 additions & 2 deletions golang/cosmos/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBA
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agoric-labs/cometbft v0.34.30-alpha.agoric.1 h1:tqCNL72pQXdUmBzgv1md5SN2U3K/PaYQ4qZ5pFv8v6w=
github.com/agoric-labs/cometbft v0.34.30-alpha.agoric.1/go.mod h1:myvkihZD8eg9jKE3WFaugkNoL5nvEqlP7Jbjg98pCek=
github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.1 h1:TOSWh36rYtSjbImlfGuviakCeIlX9f8OROglct35z1Y=
github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.1/go.mod h1:zUe5lsg/X7SeSO1nGkzOh9EGKO295szfrxIxYmeLYic=
github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2 h1:iHHqpYC0JzMbH4UYnQrcwVjLyHJuQphB0ogHbuLz44c=
github.com/agoric-labs/cosmos-sdk v0.46.16-alpha.agoric.2/go.mod h1:zUe5lsg/X7SeSO1nGkzOh9EGKO295szfrxIxYmeLYic=
github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1 h1:2jvHI/2d+psWAZy6FQ0vXJCHUtfU3ZbbW+pQFL04arQ=
github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
Expand Down
8 changes: 1 addition & 7 deletions golang/cosmos/x/swingset/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,7 @@ func (k Keeper) pushAction(ctx sdk.Context, inboundQueuePath string, action vm.A
}
msgIdx, msgIdxOk := ctx.Context().Value(baseapp.TxMsgIdxContextKey).(int)
if !txHashOk || !msgIdxOk {
switch action.(type) {
case *coreEvalAction:
// This is expected for CORE_EVAL since it's not in a transaction
// (deferred by governance to a BeginBlocker).
default:
stdlog.Printf("error while extracting context for action %q\n", action)
}
stdlog.Printf("error while extracting context for action %q\n", action)
}
record := inboundQueueRecord{Action: action, Context: actionContext{BlockHeight: ctx.BlockHeight(), TxHash: txHash, MsgIdx: msgIdx}}
bz, err := json.Marshal(record)
Expand Down
10 changes: 10 additions & 0 deletions golang/cosmos/x/swingset/keeper/proposal.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package keeper

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
"github.com/cosmos/cosmos-sdk/baseapp"
)

type coreEvalAction struct {
Expand All @@ -18,5 +21,12 @@ func (k Keeper) CoreEvalProposal(ctx sdk.Context, p *types.CoreEvalProposal) err
Evals: p.Evals,
}

// While the CoreEvalProposal was originally created by a transaction, by the time it
// passes by governance, we no longer have its provenance information, so we need to
// synthesize unique context information.
// We use a fixed placeholder value for the txHash context. We use `0` for the message
// index which assumes there is a single proposal per block.
ctx = ctx.WithContext(context.WithValue(ctx.Context(), baseapp.TxHashContextKey, "x/gov"))
ctx = ctx.WithContext(context.WithValue(ctx.Context(), baseapp.TxMsgIdxContextKey, 0))
return k.PushHighPriorityAction(ctx, action)
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ enactCoreEval() {
while true; do
status=$(agd query gov proposal "$propnum" --output=json | jq -r .status)
case $status in
PROPOSAL_STATUS_PASSED) break ;;
PROPOSAL_STATUS_REJECTED) return 1 ;;
*) echo "waiting for proposal $propnum to pass (current status=$status)" ;;
PROPOSAL_STATUS_PASSED)
break ;;
PROPOSAL_STATUS_REJECTED)
PROPOSAL_STATUS_FAILED)
return 1 ;;
*)
echo "waiting for proposal $propnum to pass (current status=$status)" ;;
esac
sleep 5
done
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ start-amm-etc: $(INTER_PROTO)/gov-amm-vaults-etc.js

gov-q:
$(AGCH) query gov proposals --output json | \
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]'
jq -c '.proposals[] | [if .proposal_id == null then .id else .proposal_id end,.voting_end_time,.status]'

# This probably shouldn't install, but that's what published instructions
# expect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ while [[ ${#rpcAddrs[@]} -gt 0 ]]; do
txfile="/tmp/faucet.$$.json"
trap 'rm -f "$txfile"' EXIT
echo "$body0" | jq ".body.messages += $msg1" > "$txfile"
$TX sign "$txfile" | $TX broadcast --broadcast-mode=block - | tee /dev/stderr | grep -q '^code: 0'
exit $?
if $TX sign "$txfile" | $TX broadcast --broadcast-mode=block - | tee /dev/stderr | grep -q '^code: 0'; then
status=0
else
status=$?
echo "Failed to append $msg1" 1>&2
echo "to $body0" 1>&2
fi
exit $status
;;
gift)
ADDR=$1
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ submit-proposal: $(EVALS) $(DESCRIPTION)

gov-q:
agd $(CHAIN_OPTS) query gov proposals --output json | \
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]';
jq -c '.proposals[] | [if .proposal_id == null then .id else .proposal_id end,.voting_end_time,.status]';

bank-q:
agd $(CHAIN_OPTS) query bank balances $(ADDR)

0 comments on commit 04eae85

Please sign in to comment.