@agoric/cosmos 0.34.1-dev-69236fd.0 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,219 +0,0 @@
1
- package ante
2
-
3
- import (
4
- "context"
5
- "fmt"
6
- "reflect"
7
- "testing"
8
-
9
- swingtypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
10
- "github.com/cosmos/cosmos-sdk/codec/types"
11
- sdk "github.com/cosmos/cosmos-sdk/types"
12
- "github.com/cosmos/cosmos-sdk/types/tx"
13
- banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
14
- "github.com/gogo/protobuf/proto"
15
- )
16
-
17
- func TestInboundAnteHandle(t *testing.T) {
18
- for _, tt := range []struct {
19
- name string
20
- checkTx bool
21
- tx sdk.Tx
22
- simulate bool
23
- inboundQueueLength int32
24
- inboundQueueLengthErr error
25
- inboundLimit int32
26
- mempoolLimit int32
27
- errMsg string
28
- isHighPriorityOwner bool
29
- }{
30
- {
31
- name: "empty-empty",
32
- tx: makeTestTx(),
33
- },
34
- {
35
- name: "reject-on-zero-allowed",
36
- tx: makeTestTx(&swingtypes.MsgDeliverInbound{}),
37
- errMsg: ErrInboundQueueFull.Error(),
38
- },
39
- {
40
- name: "has-room",
41
- tx: makeTestTx(&swingtypes.MsgInstallBundle{}),
42
- inboundLimit: 10,
43
- inboundQueueLength: 8,
44
- },
45
- {
46
- name: "at-limit",
47
- tx: makeTestTx(&swingtypes.MsgInstallBundle{}),
48
- inboundLimit: 10,
49
- inboundQueueLength: 9,
50
- },
51
- {
52
- name: "no-room",
53
- tx: makeTestTx(&swingtypes.MsgProvision{}),
54
- inboundLimit: 10,
55
- inboundQueueLength: 10,
56
- errMsg: ErrInboundQueueFull.Error(),
57
- },
58
- {
59
- name: "state-lookup-error",
60
- tx: makeTestTx(&swingtypes.MsgWalletAction{}, &swingtypes.MsgWalletSpendAction{}),
61
- inboundLimit: 10,
62
- inboundQueueLengthErr: fmt.Errorf("sunspots"),
63
- errMsg: "sunspots",
64
- },
65
- {
66
- name: "allow-non-swingset-msgs",
67
- tx: makeTestTx(&banktypes.MsgSend{}, &banktypes.MsgSend{}),
68
- inboundLimit: 1,
69
- },
70
- {
71
- name: "lazy-queue-length-lookup",
72
- tx: makeTestTx(&banktypes.MsgSend{}, &banktypes.MsgSend{}),
73
- inboundLimit: 1,
74
- inboundQueueLengthErr: fmt.Errorf("sunspots"),
75
- },
76
- {
77
- name: "checktx",
78
- checkTx: true,
79
- tx: makeTestTx(&swingtypes.MsgDeliverInbound{}),
80
- inboundLimit: 10,
81
- mempoolLimit: 5,
82
- inboundQueueLength: 7,
83
- errMsg: ErrInboundQueueFull.Error(),
84
- },
85
- {
86
- name: "empty-queue-allowed",
87
- tx: makeTestTx(&swingtypes.MsgInstallBundle{}),
88
- inboundLimit: -1,
89
- errMsg: ErrInboundQueueFull.Error(),
90
- },
91
- {
92
- name: "already-full",
93
- tx: makeTestTx(&swingtypes.MsgProvision{}),
94
- inboundLimit: 10,
95
- inboundQueueLength: 10,
96
- errMsg: ErrInboundQueueFull.Error(),
97
- },
98
- {
99
- name: "max-per-tx",
100
- tx: makeTestTx(&swingtypes.MsgWalletAction{}, &swingtypes.MsgWalletSpendAction{}),
101
- inboundLimit: 10,
102
- inboundQueueLength: 5,
103
- errMsg: ErrInboundQueueFull.Error(),
104
- },
105
- {
106
- name: "priority-limit-bypass",
107
- tx: makeTestTx(&swingtypes.MsgWalletSpendAction{}),
108
- isHighPriorityOwner: true,
109
- },
110
- {
111
- name: "priority-multi-bypass",
112
- tx: makeTestTx(&swingtypes.MsgWalletSpendAction{}, &swingtypes.MsgWalletSpendAction{}),
113
- isHighPriorityOwner: true,
114
- },
115
- {
116
- name: "mixed-priority-limit-first-fail",
117
- tx: makeTestTx(&swingtypes.MsgWalletSpendAction{}, &swingtypes.MsgProvision{}),
118
- isHighPriorityOwner: true,
119
- inboundLimit: 1,
120
- errMsg: ErrInboundQueueFull.Error(),
121
- },
122
- {
123
- name: "mixed-priority-limit-last-succeed",
124
- tx: makeTestTx(&swingtypes.MsgProvision{}, &swingtypes.MsgWalletSpendAction{}),
125
- isHighPriorityOwner: true,
126
- inboundLimit: 1,
127
- },
128
- } {
129
- t.Run(tt.name, func(t *testing.T) {
130
- ctx := sdk.Context{}.WithContext(context.Background()).WithIsCheckTx(tt.checkTx)
131
- emptyQueueAllowed := false
132
- if tt.inboundLimit == -1 {
133
- emptyQueueAllowed = true
134
- }
135
- mock := mockSwingsetKeeper{
136
- inboundQueueLength: tt.inboundQueueLength,
137
- inboundQueueLengthErr: tt.inboundQueueLengthErr,
138
- inboundLimit: tt.inboundLimit,
139
- mempoolLimit: tt.mempoolLimit,
140
- emptyQueueAllowed: emptyQueueAllowed,
141
- isHighPriorityOwner: tt.isHighPriorityOwner,
142
- }
143
- decorator := NewInboundDecorator(mock)
144
- newCtx, err := decorator.AnteHandle(ctx, tt.tx, tt.simulate, nilAnteHandler)
145
- if !reflect.DeepEqual(newCtx, ctx) {
146
- t.Errorf("want ctx %v, got %v", ctx, newCtx)
147
- }
148
- if err != nil {
149
- if tt.errMsg == "" {
150
- t.Errorf("want no error, got %s", err.Error())
151
- } else if err.Error() != tt.errMsg {
152
- t.Errorf("want error %s, got %s", tt.errMsg, err.Error())
153
- }
154
- } else if tt.errMsg != "" {
155
- t.Errorf("want error %s, got none", tt.errMsg)
156
- }
157
- })
158
- }
159
- }
160
-
161
- func makeTestTx(msgs ...proto.Message) sdk.Tx {
162
- wrappedMsgs := make([]*types.Any, len(msgs))
163
- for i, m := range msgs {
164
- any, err := types.NewAnyWithValue(m)
165
- if err != nil {
166
- panic(err)
167
- }
168
- wrappedMsgs[i] = any
169
- }
170
- return &tx.Tx{
171
- Body: &tx.TxBody{
172
- Messages: wrappedMsgs,
173
- },
174
- }
175
- }
176
-
177
- func nilAnteHandler(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) {
178
- return ctx, nil
179
- }
180
-
181
- type mockSwingsetKeeper struct {
182
- inboundQueueLength int32
183
- inboundQueueLengthErr error
184
- inboundLimit int32
185
- mempoolLimit int32
186
- emptyQueueAllowed bool
187
- isHighPriorityOwner bool
188
- }
189
-
190
- var _ SwingsetKeeper = mockSwingsetKeeper{}
191
- var _ swingtypes.SwingSetKeeper = mockSwingsetKeeper{}
192
-
193
- func (msk mockSwingsetKeeper) InboundQueueLength(ctx sdk.Context) (int32, error) {
194
- return msk.inboundQueueLength, msk.inboundQueueLengthErr
195
- }
196
-
197
- func (msk mockSwingsetKeeper) GetState(ctx sdk.Context) swingtypes.State {
198
- if msk.emptyQueueAllowed {
199
- return swingtypes.State{}
200
- }
201
- return swingtypes.State{
202
- QueueAllowed: []swingtypes.QueueSize{
203
- swingtypes.NewQueueSize(swingtypes.QueueInbound, msk.inboundLimit),
204
- swingtypes.NewQueueSize(swingtypes.QueueInboundMempool, msk.mempoolLimit),
205
- },
206
- }
207
- }
208
-
209
- func (msk mockSwingsetKeeper) IsHighPriorityAddress(ctx sdk.Context, addr sdk.AccAddress) (bool, error) {
210
- return msk.isHighPriorityOwner, nil
211
- }
212
-
213
- func (msk mockSwingsetKeeper) GetBeansPerUnit(ctx sdk.Context) map[string]sdk.Uint {
214
- return nil
215
- }
216
-
217
- func (msk mockSwingsetKeeper) ChargeBeans(ctx sdk.Context, addr sdk.AccAddress, beans sdk.Uint) error {
218
- return fmt.Errorf("not implemented")
219
- }
@@ -1,64 +0,0 @@
1
- package ante
2
-
3
- import (
4
- "github.com/armon/go-metrics"
5
-
6
- "github.com/cosmos/cosmos-sdk/telemetry"
7
- sdk "github.com/cosmos/cosmos-sdk/types"
8
- sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
9
-
10
- "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
11
- )
12
-
13
- // TODO: We don't have a more appropriate error type for this.
14
- var ErrAdmissionRefused = sdkerrors.ErrMempoolIsFull
15
-
16
- // AdmissionDecorator will ask the Controller (such as SwingSet) if it is
17
- // temporarily rejecting inbound messages. If CheckAdmissibility passes for all
18
- // messages, decorator calls next AnteHandler in chain.
19
- type AdmissionDecorator struct {
20
- data interface{}
21
- }
22
-
23
- func NewAdmissionDecorator(data interface{}) AdmissionDecorator {
24
- return AdmissionDecorator{data: data}
25
- }
26
-
27
- // AnteHandle calls CheckAdmissibility for all messages that implement the
28
- // vm.ControllerAdmissionMsg interface. If it returns an error, refuse the
29
- // entire transaction.
30
- func (ad AdmissionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
31
- msgs := tx.GetMsgs()
32
- errors := make([]error, 0, len(msgs))
33
-
34
- // Ask the controller if we are rejecting messages.
35
- for _, msg := range tx.GetMsgs() {
36
- if camsg, ok := msg.(vm.ControllerAdmissionMsg); ok {
37
- if err := camsg.CheckAdmissibility(ctx, ad.data); err != nil {
38
- // Only let admission errors interrupt the transaction if we're not
39
- // simulating, otherwise our gas estimation will be too low.
40
- if !simulate {
41
- errors = append(errors, err)
42
- defer func(msg sdk.Msg) {
43
- telemetry.IncrCounterWithLabels(
44
- []string{"tx", "ante", "admission_refused"},
45
- 1,
46
- []metrics.Label{
47
- telemetry.NewLabel("msg", sdk.MsgTypeURL(msg)),
48
- },
49
- )
50
- }(msg)
51
- }
52
- }
53
- }
54
- }
55
-
56
- numErrors := len(errors)
57
- if numErrors > 0 {
58
- // Add to instrumentation.
59
-
60
- return ctx, sdkerrors.Wrapf(ErrAdmissionRefused, "controller refused message admission: %s", errors[0].Error())
61
- }
62
-
63
- return next(ctx, tx, simulate)
64
- }
package/buf.work.yaml DELETED
@@ -1,4 +0,0 @@
1
- version: v1
2
- directories:
3
- - proto
4
- - third_party/proto
package/git-revision.txt DELETED
@@ -1 +0,0 @@
1
- 69236fd
package/go.mod DELETED
@@ -1,155 +0,0 @@
1
- module github.com/Agoric/agoric-sdk/golang/cosmos
2
-
3
- go 1.20
4
-
5
- require (
6
- github.com/armon/go-metrics v0.4.0
7
- github.com/cosmos/cosmos-sdk v0.45.11
8
- github.com/cosmos/gaia/v7 v7.0.0-00010101000000-000000000000
9
- github.com/cosmos/ibc-go/v3 v3.4.0
10
- github.com/gogo/protobuf v1.3.3
11
- github.com/golang/protobuf v1.5.2
12
- github.com/gorilla/mux v1.8.0
13
- github.com/grpc-ecosystem/grpc-gateway v1.16.0
14
- github.com/pkg/errors v0.9.1
15
- github.com/rakyll/statik v0.1.7
16
- github.com/spf13/cast v1.5.0
17
- github.com/spf13/cobra v1.6.0
18
- github.com/stretchr/testify v1.8.0
19
- github.com/tendermint/tendermint v0.34.23
20
- github.com/tendermint/tm-db v0.6.7
21
- google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a
22
- google.golang.org/grpc v1.50.1
23
- gopkg.in/yaml.v2 v2.4.0
24
- )
25
-
26
- require (
27
- filippo.io/edwards25519 v1.0.0-beta.2 // indirect
28
- github.com/99designs/keyring v1.1.6 // indirect
29
- github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
30
- github.com/DataDog/zstd v1.4.5 // indirect
31
- github.com/Workiva/go-datastructures v1.0.53 // indirect
32
- github.com/beorn7/perks v1.0.1 // indirect
33
- github.com/bgentry/speakeasy v0.1.0 // indirect
34
- github.com/btcsuite/btcd v0.22.1 // indirect
35
- github.com/cespare/xxhash v1.1.0 // indirect
36
- github.com/cespare/xxhash/v2 v2.1.2 // indirect
37
- github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
38
- github.com/confio/ics23/go v0.7.0 // indirect
39
- github.com/cosmos/btcutil v1.0.4 // indirect
40
- github.com/cosmos/go-bip39 v1.0.0 // indirect
41
- github.com/cosmos/gorocksdb v1.2.0 // indirect
42
- github.com/cosmos/iavl v0.19.4 // indirect
43
- github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
44
- github.com/cosmos/ledger-go v0.9.2 // indirect
45
- github.com/creachadair/taskgroup v0.3.2 // indirect
46
- github.com/danieljoos/wincred v1.1.0 // indirect
47
- github.com/davecgh/go-spew v1.1.1 // indirect
48
- github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
49
- github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
50
- github.com/dgraph-io/ristretto v0.0.3 // indirect
51
- github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
52
- github.com/dustin/go-humanize v1.0.0 // indirect
53
- github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
54
- github.com/felixge/httpsnoop v1.0.2 // indirect
55
- github.com/fsnotify/fsnotify v1.5.4 // indirect
56
- github.com/ghodss/yaml v1.0.0 // indirect
57
- github.com/go-kit/kit v0.12.0 // indirect
58
- github.com/go-kit/log v0.2.1 // indirect
59
- github.com/go-logfmt/logfmt v0.5.1 // indirect
60
- github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
61
- github.com/gogo/gateway v1.1.0 // indirect
62
- github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
63
- github.com/golang/snappy v0.0.4 // indirect
64
- github.com/google/btree v1.0.1 // indirect
65
- github.com/google/gofuzz v1.2.0 // indirect
66
- github.com/google/orderedcode v0.0.1 // indirect
67
- github.com/gorilla/handlers v1.5.1 // indirect
68
- github.com/gorilla/websocket v1.5.0 // indirect
69
- github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
70
- github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
71
- github.com/gtank/merlin v0.1.1 // indirect
72
- github.com/gtank/ristretto255 v0.1.2 // indirect
73
- github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
74
- github.com/hashicorp/golang-lru v0.5.4 // indirect
75
- github.com/hashicorp/hcl v1.0.0 // indirect
76
- github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect
77
- github.com/improbable-eng/grpc-web v0.14.1 // indirect
78
- github.com/inconshreveable/mousetrap v1.0.1 // indirect
79
- github.com/jmhodges/levigo v1.0.0 // indirect
80
- github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
81
- github.com/klauspost/compress v1.15.11 // indirect
82
- github.com/lib/pq v1.10.6 // indirect
83
- github.com/libp2p/go-buffer-pool v0.1.0 // indirect
84
- github.com/magiconair/properties v1.8.6 // indirect
85
- github.com/mattn/go-colorable v0.1.13 // indirect
86
- github.com/mattn/go-isatty v0.0.16 // indirect
87
- github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
88
- github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
89
- github.com/minio/highwayhash v1.0.2 // indirect
90
- github.com/mitchellh/mapstructure v1.5.0 // indirect
91
- github.com/mtibben/percent v0.2.1 // indirect
92
- github.com/pelletier/go-toml v1.9.5 // indirect
93
- github.com/pelletier/go-toml/v2 v2.0.5 // indirect
94
- github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
95
- github.com/pmezard/go-difflib v1.0.0 // indirect
96
- github.com/prometheus/client_golang v1.12.2 // indirect
97
- github.com/prometheus/client_model v0.2.0 // indirect
98
- github.com/prometheus/common v0.34.0 // indirect
99
- github.com/prometheus/procfs v0.8.0 // indirect
100
- github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
101
- github.com/regen-network/cosmos-proto v0.3.1 // indirect
102
- github.com/rs/cors v1.8.2 // indirect
103
- github.com/rs/zerolog v1.27.0 // indirect
104
- github.com/sasha-s/go-deadlock v0.3.1 // indirect
105
- github.com/spf13/afero v1.8.2 // indirect
106
- github.com/spf13/jwalterweatherman v1.1.0 // indirect
107
- github.com/spf13/pflag v1.0.5 // indirect
108
- github.com/spf13/viper v1.13.0 // indirect
109
- github.com/subosito/gotenv v1.4.1 // indirect
110
- github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
111
- github.com/tendermint/btcd v0.1.1 // indirect
112
- github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
113
- github.com/tendermint/go-amino v0.16.0 // indirect
114
- github.com/zondax/hid v0.9.0 // indirect
115
- go.etcd.io/bbolt v1.3.6 // indirect
116
- golang.org/x/crypto v0.1.0 // indirect
117
- golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
118
- golang.org/x/net v0.7.0 // indirect
119
- golang.org/x/sys v0.5.0 // indirect
120
- golang.org/x/term v0.5.0 // indirect
121
- golang.org/x/text v0.7.0 // indirect
122
- google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
123
- gopkg.in/ini.v1 v1.67.0 // indirect
124
- gopkg.in/yaml.v3 v3.0.1 // indirect
125
- nhooyr.io/websocket v1.8.6 // indirect
126
- )
127
-
128
- // Silence a warning on MacOS
129
- replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
130
-
131
- // At least until post-v0.9.0 is released with
132
- // https://github.com/Zondax/hid/issues/4 resolved.
133
- replace github.com/zondax/hid => github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266
134
-
135
- replace github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
136
-
137
- replace github.com/confio/ics23/go => github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1
138
-
139
- replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
140
-
141
- replace google.golang.org/grpc => google.golang.org/grpc v1.33.2
142
-
143
- // At least until post-v0.34.14 is released with
144
- // https://github.com/tendermint/tendermint/issue/6899 resolved.
145
- replace github.com/tendermint/tendermint => github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.3
146
-
147
- // We need a fork of cosmos-sdk until all of the differences are merged.
148
- replace github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.2
149
-
150
- replace github.com/cosmos/gaia/v7 => github.com/Agoric/ag0/v7 v7.0.2-alpha.agoric.1
151
-
152
- // For testing against a local cosmos-sdk or tendermint
153
- // replace github.com/cosmos/cosmos-sdk => ../../../forks/cosmos-sdk
154
-
155
- // replace github.com/tendermint/tendermint => ../../../forks/tendermint