@agoric/cosmos 0.35.0-u11.0 → 0.35.0-u12.0
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.
- package/CHANGELOG.md +28 -0
- package/Makefile +7 -1
- package/app/app.go +14 -98
- package/git-revision.txt +1 -1
- package/go.mod +3 -3
- package/go.sum +4 -4
- package/package.json +2 -2
- package/x/vibc/ibc.go +1 -2
- package/x/vibc/keeper/keeper.go +1 -15
- package/x/vibc/types/expected_keepers.go +2 -1
- package/x/vstorage/keeper/querier.go +31 -11
- package/x/vstorage/types/path_keys.go +22 -10
- package/x/vstorage/types/path_keys_test.go +84 -18
- package/app/const.go +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.35.0-u12.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/cosmos@0.35.0-u11wf.0...@agoric/cosmos@0.35.0-u12.0) (2023-11-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **vstorage:** Enforce path validation
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **cosmos:** Lower `BlockParams.MaxBytes` to 5MB ([84908e5](https://github.com/Agoric/agoric-sdk/commit/84908e5a5a181e3f64da0e298d0105fedb97570a))
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **vibc:** accommodate ibc-go v3 breaking changes ([f582901](https://github.com/Agoric/agoric-sdk/commit/f582901fb3835d95d493c777aac6a63fc3ee4681))
|
|
20
|
+
* **vibc:** put extraneous `CounterpartyChannelID` in `Counterparty` struct ([9469971](https://github.com/Agoric/agoric-sdk/commit/946997192cec0ed6b07fdaa18d8f380f460ab004))
|
|
21
|
+
* **vstorage:** Enforce path validation ([d8db331](https://github.com/Agoric/agoric-sdk/commit/d8db3310fb21a8546388694752889f3563733010)), closes [#8337](https://github.com/Agoric/agoric-sdk/issues/8337)
|
|
22
|
+
* **cosmos:** Update cosmos-sdk with fix for state-sync restore of large payloads ([e04b398](https://github.com/Agoric/agoric-sdk/commit/e04b398bf16d884fa4708c16d4c03b39cc4e0f1b)), closes [#8325](https://github.com/Agoric/agoric-sdk/issues/8325)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## [0.35.0-u11wf.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/cosmos@0.35.0-u11.0...@agoric/cosmos@0.35.0-u11wf.0) (2023-09-23)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @agoric/cosmos
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
## [0.35.0-u11.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/cosmos@0.34.1...@agoric/cosmos@0.35.0-u11.0) (2023-08-24)
|
|
7
35
|
|
|
8
36
|
|
package/Makefile
CHANGED
|
@@ -32,13 +32,18 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(VersionName) \
|
|
|
32
32
|
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
|
|
33
33
|
|
|
34
34
|
gcflags =
|
|
35
|
+
shared_ldflags = $(ldflags)
|
|
35
36
|
|
|
36
37
|
ifneq ($(GO_DEBUG),)
|
|
37
38
|
ldflags += -compressdwarf=false
|
|
38
39
|
gcflags += -N -l
|
|
40
|
+
else ifeq ($(shell uname -s 2>/dev/null),Darwin)
|
|
41
|
+
# Darwin's latest ld crashes with https://github.com/Agoric/agoric-sdk/issues/8367
|
|
42
|
+
shared_ldflags += -w
|
|
39
43
|
endif
|
|
40
44
|
|
|
41
45
|
BUILD_FLAGS := -tags "$(build_tags)" -gcflags '$(gcflags)' -ldflags '$(ldflags)'
|
|
46
|
+
SHARED_BUILD_FLAGS := -tags "$(build_tags)" -gcflags '$(gcflags)' -ldflags '$(shared_ldflags)'
|
|
42
47
|
|
|
43
48
|
all: compile-chain
|
|
44
49
|
|
|
@@ -69,7 +74,8 @@ compile-gyp:
|
|
|
69
74
|
rm -f binding.gyp
|
|
70
75
|
|
|
71
76
|
compile-libdaemon: go-mod-cache
|
|
72
|
-
go build -v $(MOD_READONLY) $(
|
|
77
|
+
go build -v $(MOD_READONLY) $(SHARED_BUILD_FLAGS) -buildmode=c-shared \
|
|
78
|
+
-o build/libagcosmosdaemon.so ./cmd/libdaemon/main.go
|
|
73
79
|
|
|
74
80
|
go-mod-cache: go.sum
|
|
75
81
|
@echo "--> Download go modules to local cache"
|
package/app/app.go
CHANGED
|
@@ -103,6 +103,7 @@ import (
|
|
|
103
103
|
"github.com/tendermint/tendermint/libs/log"
|
|
104
104
|
tmos "github.com/tendermint/tendermint/libs/os"
|
|
105
105
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
106
|
+
tmtypes "github.com/tendermint/tendermint/types"
|
|
106
107
|
dbm "github.com/tendermint/tm-db"
|
|
107
108
|
|
|
108
109
|
gaiaappparams "github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
|
|
@@ -790,13 +791,18 @@ func NewAgoricApp(
|
|
|
790
791
|
app.SetBeginBlocker(app.BeginBlocker)
|
|
791
792
|
app.SetEndBlocker(app.EndBlocker)
|
|
792
793
|
|
|
794
|
+
const (
|
|
795
|
+
upgradeName = "agoric-upgrade-12"
|
|
796
|
+
upgradeNameTest = "agorictest-upgrade-12"
|
|
797
|
+
)
|
|
798
|
+
|
|
793
799
|
app.UpgradeKeeper.SetUpgradeHandler(
|
|
794
800
|
upgradeName,
|
|
795
|
-
|
|
801
|
+
upgrade12Handler(app, upgradeName),
|
|
796
802
|
)
|
|
797
803
|
app.UpgradeKeeper.SetUpgradeHandler(
|
|
798
804
|
upgradeNameTest,
|
|
799
|
-
|
|
805
|
+
upgrade12Handler(app, upgradeNameTest),
|
|
800
806
|
)
|
|
801
807
|
|
|
802
808
|
if loadLatest {
|
|
@@ -819,107 +825,17 @@ func NewAgoricApp(
|
|
|
819
825
|
return app
|
|
820
826
|
}
|
|
821
827
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
func (eventHandler swingStoreMigrationEventHandler) OnExportStarted(height uint64, retrieveSwingStoreExport func() error) error {
|
|
827
|
-
return retrieveSwingStoreExport()
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
func (eventHandler swingStoreMigrationEventHandler) OnExportRetrieved(provider swingsetkeeper.SwingStoreExportProvider) (err error) {
|
|
831
|
-
exportDataReader, err := provider.GetExportDataReader()
|
|
832
|
-
if err != nil {
|
|
833
|
-
return err
|
|
834
|
-
}
|
|
835
|
-
defer exportDataReader.Close()
|
|
836
|
-
|
|
837
|
-
var hasExportData bool
|
|
838
|
-
|
|
839
|
-
for {
|
|
840
|
-
entry, err := exportDataReader.Read()
|
|
841
|
-
if err == io.EOF {
|
|
842
|
-
break
|
|
843
|
-
} else if err != nil {
|
|
844
|
-
return err
|
|
845
|
-
}
|
|
846
|
-
hasExportData = true
|
|
847
|
-
if !entry.HasValue() {
|
|
848
|
-
return fmt.Errorf("no value for export data key %s", entry.Key())
|
|
849
|
-
}
|
|
850
|
-
eventHandler.swingStore.Set([]byte(entry.Key()), []byte(entry.StringValue()))
|
|
851
|
-
}
|
|
852
|
-
if !hasExportData {
|
|
853
|
-
return fmt.Errorf("export data had no entries")
|
|
854
|
-
}
|
|
855
|
-
return nil
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
// upgrade11Handler performs standard upgrade actions plus custom actions for upgrade-11.
|
|
859
|
-
func upgrade11Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
|
|
828
|
+
// upgrade12Handler performs standard upgrade actions plus custom actions for upgrade-12.
|
|
829
|
+
func upgrade12Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
|
|
860
830
|
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
|
|
861
831
|
app.CheckControllerInited(false)
|
|
862
832
|
// Record the plan to send to SwingSet
|
|
863
833
|
app.upgradePlan = &plan
|
|
864
834
|
|
|
865
|
-
//
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
// We are at the begining of the upgrade block, so all stores are commited
|
|
870
|
-
// as of the end of the previous block
|
|
871
|
-
savedBlockHeight := uint64(ctx.BlockHeight() - 1)
|
|
872
|
-
|
|
873
|
-
// First, repair swing-store metadata in case this node was previously
|
|
874
|
-
// initialized from a state-sync snapshot. This is done with a check on the
|
|
875
|
-
// block height to catch early any hangover related mismatch.
|
|
876
|
-
// Only entries related to missing historical metadata are imported, but we
|
|
877
|
-
// don't know what these look like here, so we provide it all.
|
|
878
|
-
getSwingStoreExportDataFromVstorage := func() (reader agorictypes.KVEntryReader, err error) {
|
|
879
|
-
return agorictypes.NewVstorageDataEntriesReader(
|
|
880
|
-
app.VstorageKeeper.ExportStorageFromPrefix(ctx, swingsetkeeper.StoragePathSwingStore),
|
|
881
|
-
), nil
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
// We're not restoring any artifact to swing-store, nor have any to provide
|
|
885
|
-
readNoArtifact := func() (artifact swingsettypes.SwingStoreArtifact, err error) {
|
|
886
|
-
return artifact, io.EOF
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
err := app.SwingStoreExportsHandler.RestoreExport(
|
|
890
|
-
swingsetkeeper.SwingStoreExportProvider{
|
|
891
|
-
BlockHeight: savedBlockHeight,
|
|
892
|
-
GetExportDataReader: getSwingStoreExportDataFromVstorage,
|
|
893
|
-
ReadNextArtifact: readNoArtifact,
|
|
894
|
-
},
|
|
895
|
-
swingsetkeeper.SwingStoreRestoreOptions{
|
|
896
|
-
ArtifactMode: swingsetkeeper.SwingStoreArtifactModeNone,
|
|
897
|
-
ExportDataMode: swingsetkeeper.SwingStoreExportDataModeRepairMetadata,
|
|
898
|
-
},
|
|
899
|
-
)
|
|
900
|
-
if err != nil {
|
|
901
|
-
return nil, err
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
// Then migrate the swing-store shadow copy:
|
|
905
|
-
// 1. Remove the swing-store "export data" shadow-copy entries from vstorage.
|
|
906
|
-
// 2. Export swing-store "export-data" (as of the previous block) through a
|
|
907
|
-
// handler that writes every entry into the swingset module's new Store.
|
|
908
|
-
app.VstorageKeeper.RemoveEntriesWithPrefix(ctx, swingsetkeeper.StoragePathSwingStore)
|
|
909
|
-
err = app.SwingStoreExportsHandler.InitiateExport(
|
|
910
|
-
savedBlockHeight,
|
|
911
|
-
swingStoreMigrationEventHandler{swingStore: app.SwingSetKeeper.GetSwingStore(ctx)},
|
|
912
|
-
swingsetkeeper.SwingStoreExportOptions{
|
|
913
|
-
ArtifactMode: swingsetkeeper.SwingStoreArtifactModeNone,
|
|
914
|
-
ExportDataMode: swingsetkeeper.SwingStoreExportDataModeAll,
|
|
915
|
-
},
|
|
916
|
-
)
|
|
917
|
-
if err == nil {
|
|
918
|
-
err = swingsetkeeper.WaitUntilSwingStoreExportDone()
|
|
919
|
-
}
|
|
920
|
-
if err != nil {
|
|
921
|
-
return nil, err
|
|
922
|
-
}
|
|
835
|
+
// Reflect default BlockParams.MaxBytes change to current params
|
|
836
|
+
cp := app.BaseApp.GetConsensusParams(ctx)
|
|
837
|
+
cp.Block.MaxBytes = tmtypes.DefaultBlockParams().MaxBytes
|
|
838
|
+
app.BaseApp.StoreConsensusParams(ctx, cp)
|
|
923
839
|
|
|
924
840
|
// Always run module migrations
|
|
925
841
|
mvm, err := app.mm.RunMigrations(ctx, app.configurator, fromVm)
|
package/git-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
ee5a5fdad
|
package/go.mod
CHANGED
|
@@ -15,6 +15,7 @@ require (
|
|
|
15
15
|
github.com/rakyll/statik v0.1.7
|
|
16
16
|
github.com/spf13/cast v1.5.0
|
|
17
17
|
github.com/spf13/cobra v1.6.0
|
|
18
|
+
github.com/spf13/viper v1.13.0
|
|
18
19
|
github.com/stretchr/testify v1.8.0
|
|
19
20
|
github.com/tendermint/tendermint v0.34.23
|
|
20
21
|
github.com/tendermint/tm-db v0.6.7
|
|
@@ -105,7 +106,6 @@ require (
|
|
|
105
106
|
github.com/spf13/afero v1.8.2 // indirect
|
|
106
107
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
|
107
108
|
github.com/spf13/pflag v1.0.5 // indirect
|
|
108
|
-
github.com/spf13/viper v1.13.0 // indirect
|
|
109
109
|
github.com/subosito/gotenv v1.4.1 // indirect
|
|
110
110
|
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
|
|
111
111
|
github.com/tendermint/btcd v0.1.1 // indirect
|
|
@@ -142,10 +142,10 @@ replace google.golang.org/grpc => google.golang.org/grpc v1.33.2
|
|
|
142
142
|
|
|
143
143
|
// At least until post-v0.34.14 is released with
|
|
144
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.
|
|
145
|
+
replace github.com/tendermint/tendermint => github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.4
|
|
146
146
|
|
|
147
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.
|
|
148
|
+
replace github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.4
|
|
149
149
|
|
|
150
150
|
replace github.com/cosmos/gaia/v7 => github.com/Agoric/ag0/v7 v7.0.2-alpha.agoric.1
|
|
151
151
|
|
package/go.sum
CHANGED
|
@@ -80,12 +80,12 @@ github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:
|
|
|
80
80
|
github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
|
|
81
81
|
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
|
|
82
82
|
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
|
83
|
-
github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.
|
|
84
|
-
github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.
|
|
83
|
+
github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.4 h1:OU1rRq0qS+5KNe7eF7ceXPpHeXWj+JSbUpHgiQTml2E=
|
|
84
|
+
github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.4/go.mod h1:fdXvzy+wmYB+W+N139yb0+szbT7zAGgUjmxm5DBrjto=
|
|
85
85
|
github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1 h1:2jvHI/2d+psWAZy6FQ0vXJCHUtfU3ZbbW+pQFL04arQ=
|
|
86
86
|
github.com/agoric-labs/cosmos-sdk/ics23/go v0.8.0-alpha.agoric.1/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
|
|
87
|
-
github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.
|
|
88
|
-
github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.
|
|
87
|
+
github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.4 h1:NWqGDUk5UkkXxsEVRtCWFpMeuCtu2MyRtC0Cib7sKH8=
|
|
88
|
+
github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.4/go.mod h1:rXVrl4OYzmIa1I91av3iLv2HS0fGSiucyW9J4aMTpKI=
|
|
89
89
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
|
90
90
|
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
|
91
91
|
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.35.0-
|
|
3
|
+
"version": "0.35.0-u12.0",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "ee5a5fdad9187a6b1b7b26b772b6564c0db3062e"
|
|
39
39
|
}
|
package/x/vibc/ibc.go
CHANGED
|
@@ -228,7 +228,6 @@ type channelOpenAckEvent struct {
|
|
|
228
228
|
Event string `json:"event"` // channelOpenAck
|
|
229
229
|
PortID string `json:"portID"`
|
|
230
230
|
ChannelID string `json:"channelID"`
|
|
231
|
-
CounterpartyChannelID string `json:"counterpartyChannelID"`
|
|
232
231
|
CounterpartyVersion string `json:"counterpartyVersion"`
|
|
233
232
|
Counterparty channeltypes.Counterparty `json:"counterparty"`
|
|
234
233
|
ConnectionHops []string `json:"connectionHops"`
|
|
@@ -247,12 +246,12 @@ func (im IBCModule) OnChanOpenAck(
|
|
|
247
246
|
// returns an empty channel object that we can still use without crashing.
|
|
248
247
|
channel, _ := im.keeper.GetChannel(ctx, portID, channelID)
|
|
249
248
|
|
|
249
|
+
channel.Counterparty.ChannelId = counterpartyChannelID
|
|
250
250
|
event := channelOpenAckEvent{
|
|
251
251
|
Type: "IBC_EVENT",
|
|
252
252
|
Event: "channelOpenAck",
|
|
253
253
|
PortID: portID,
|
|
254
254
|
ChannelID: channelID,
|
|
255
|
-
CounterpartyChannelID: counterpartyChannelID,
|
|
256
255
|
CounterpartyVersion: counterpartyVersion,
|
|
257
256
|
Counterparty: channel.Counterparty,
|
|
258
257
|
ConnectionHops: channel.ConnectionHops,
|
package/x/vibc/keeper/keeper.go
CHANGED
|
@@ -92,13 +92,7 @@ func (k Keeper) ChanOpenInit(ctx sdk.Context, order channeltypes.Order, connecti
|
|
|
92
92
|
return err
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
ctx.EventManager().EmitEvents(sdk.Events{
|
|
97
|
-
sdk.NewEvent(
|
|
98
|
-
sdk.EventTypeMessage,
|
|
99
|
-
sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory),
|
|
100
|
-
),
|
|
101
|
-
})
|
|
95
|
+
k.channelKeeper.WriteOpenInitChannel(ctx, portID, channelID, order, connectionHops, counterparty, version)
|
|
102
96
|
return nil
|
|
103
97
|
}
|
|
104
98
|
|
|
@@ -157,14 +151,6 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error {
|
|
|
157
151
|
if err != nil {
|
|
158
152
|
return err
|
|
159
153
|
}
|
|
160
|
-
|
|
161
|
-
// We need to emit a channel event to notify the relayer.
|
|
162
|
-
ctx.EventManager().EmitEvents(sdk.Events{
|
|
163
|
-
sdk.NewEvent(
|
|
164
|
-
sdk.EventTypeMessage,
|
|
165
|
-
sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory),
|
|
166
|
-
),
|
|
167
|
-
})
|
|
168
154
|
return nil
|
|
169
155
|
}
|
|
170
156
|
|
|
@@ -16,7 +16,8 @@ type ChannelKeeper interface {
|
|
|
16
16
|
WriteAcknowledgement(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error
|
|
17
17
|
ChanOpenInit(ctx sdk.Context, order channel.Order, connectionHops []string, portID string,
|
|
18
18
|
portCap *capability.Capability, counterparty channel.Counterparty, version string) (string, *capability.Capability, error)
|
|
19
|
-
|
|
19
|
+
WriteOpenInitChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
|
|
20
|
+
connectionHops []string, counterparty channel.Counterparty, version string)
|
|
20
21
|
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
|
|
21
22
|
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
|
|
22
23
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
package keeper
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
"strings"
|
|
5
|
-
|
|
6
4
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
7
5
|
|
|
8
6
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
@@ -18,14 +16,36 @@ const (
|
|
|
18
16
|
QueryChildren = "children"
|
|
19
17
|
)
|
|
20
18
|
|
|
21
|
-
//
|
|
19
|
+
// getVstorageEntryPath validates that a request URL path represents a valid
|
|
20
|
+
// entry path with no extra data, and returns the path of that vstorage entry.
|
|
21
|
+
func getVstorageEntryPath(urlPathSegments []string) (string, error) {
|
|
22
|
+
if len(urlPathSegments) != 1 || types.ValidatePath(urlPathSegments[0]) != nil {
|
|
23
|
+
return "", sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid vstorage entry path")
|
|
24
|
+
}
|
|
25
|
+
return urlPathSegments[0], nil
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// NewQuerier returns the function for handling queries routed to this module.
|
|
29
|
+
// It performs its own routing based on the first slash-separated URL path
|
|
30
|
+
// segment (e.g., URL path `/data/foo.bar` is a request for the value associated
|
|
31
|
+
// with vstorage path "foo.bar", and `/children/foo.bar` is a request for the
|
|
32
|
+
// child path segments immediately underneath vstorage path "foo.bar" which may
|
|
33
|
+
// be used to extend it to a vstorage path such as "foo.bar.baz").
|
|
22
34
|
func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
|
23
|
-
return func(ctx sdk.Context,
|
|
24
|
-
switch
|
|
35
|
+
return func(ctx sdk.Context, urlPathSegments []string, req abci.RequestQuery) (res []byte, err error) {
|
|
36
|
+
switch urlPathSegments[0] {
|
|
25
37
|
case QueryData:
|
|
26
|
-
|
|
38
|
+
entryPath, entryPathErr := getVstorageEntryPath(urlPathSegments[1:])
|
|
39
|
+
if entryPathErr != nil {
|
|
40
|
+
return nil, entryPathErr
|
|
41
|
+
}
|
|
42
|
+
return queryData(ctx, entryPath, req, keeper, legacyQuerierCdc)
|
|
27
43
|
case QueryChildren:
|
|
28
|
-
|
|
44
|
+
entryPath, entryPathErr := getVstorageEntryPath(urlPathSegments[1:])
|
|
45
|
+
if entryPathErr != nil {
|
|
46
|
+
return nil, entryPathErr
|
|
47
|
+
}
|
|
48
|
+
return queryChildren(ctx, entryPath, req, keeper, legacyQuerierCdc)
|
|
29
49
|
default:
|
|
30
50
|
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown vstorage query endpoint")
|
|
31
51
|
}
|
|
@@ -36,12 +56,12 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
|
|
|
36
56
|
func queryData(ctx sdk.Context, path string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) (res []byte, err error) {
|
|
37
57
|
entry := keeper.GetEntry(ctx, path)
|
|
38
58
|
if !entry.HasValue() {
|
|
39
|
-
return nil, sdkerrors.Wrap(sdkerrors.
|
|
59
|
+
return nil, sdkerrors.Wrap(sdkerrors.ErrNotFound, "no data for vstorage path")
|
|
40
60
|
}
|
|
41
61
|
|
|
42
|
-
bz,
|
|
43
|
-
if
|
|
44
|
-
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal,
|
|
62
|
+
bz, marshalErr := codec.MarshalJSONIndent(legacyQuerierCdc, types.Data{Value: entry.StringValue()})
|
|
63
|
+
if marshalErr != nil {
|
|
64
|
+
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, marshalErr.Error())
|
|
45
65
|
}
|
|
46
66
|
|
|
47
67
|
return bz, nil
|
|
@@ -7,9 +7,17 @@ import (
|
|
|
7
7
|
"strings"
|
|
8
8
|
)
|
|
9
9
|
|
|
10
|
-
// - A "path" is a sequence of zero or more dot-separated nonempty
|
|
11
|
-
//
|
|
12
|
-
//
|
|
10
|
+
// - A "path" is a sequence of zero or more dot-separated nonempty segments
|
|
11
|
+
// using a restricted alphabet of ASCII alphanumerics plus underscore and dash,
|
|
12
|
+
// consistent with packages/internal/src/lib-chainStorage.js but not currently
|
|
13
|
+
// enforcing a length restriction on path segments.
|
|
14
|
+
// So `""`, `"foo"`, and `"foo.bar__baz.qux--quux"` are paths but `"."`,
|
|
15
|
+
// `"foo/bar"`, `"fo\to"`, and `"foö"` are not.
|
|
16
|
+
// This alphabet might be expanded in the future, but such expansion SHOULD NOT
|
|
17
|
+
// include control characters (including those that are not ASCII, such as
|
|
18
|
+
// U+202E RIGHT-TO-LEFT OVERRIDE), slash `/` (which separates ABCI request path
|
|
19
|
+
// segments in e.g. `custom/vstorage/data/foo`), or backslash `\` (which should
|
|
20
|
+
// be reserved for adding escape sequences).
|
|
13
21
|
//
|
|
14
22
|
// - An encoded key for a path is the path prefixed with its length (in ASCII
|
|
15
23
|
// digits), separated by nul, followed by the path with dots replaced with nul.
|
|
@@ -42,22 +50,26 @@ func EncodedKeyToPath(key []byte) string {
|
|
|
42
50
|
return string(pathBytes)
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
var
|
|
53
|
+
var pathSegmentPattern = `[a-zA-Z0-9_-]+`
|
|
54
|
+
var pathSeparatorPattern = `\` + PathSeparator
|
|
55
|
+
var pathPattern = fmt.Sprintf(`^$|^%[1]s(%[2]s%[1]s)*$`, pathSegmentPattern, pathSeparatorPattern)
|
|
56
|
+
var pathMatcher = regexp.MustCompile(pathPattern)
|
|
46
57
|
|
|
47
58
|
func ValidatePath(path string) error {
|
|
48
|
-
if
|
|
49
|
-
return
|
|
50
|
-
}
|
|
51
|
-
if strings.Contains(path, PathSeparator+PathSeparator) {
|
|
52
|
-
return fmt.Errorf("path %q contains doubled separators", path)
|
|
59
|
+
if pathMatcher.MatchString(path) {
|
|
60
|
+
return nil
|
|
53
61
|
}
|
|
62
|
+
// Rescan the string to give a useful error message.
|
|
54
63
|
if strings.HasPrefix(path, PathSeparator) {
|
|
55
64
|
return fmt.Errorf("path %q starts with separator", path)
|
|
56
65
|
}
|
|
57
66
|
if strings.HasSuffix(path, PathSeparator) {
|
|
58
67
|
return fmt.Errorf("path %q ends with separator", path)
|
|
59
68
|
}
|
|
60
|
-
|
|
69
|
+
if strings.Contains(path, PathSeparator+PathSeparator) {
|
|
70
|
+
return fmt.Errorf("path %q contains doubled separators", path)
|
|
71
|
+
}
|
|
72
|
+
return fmt.Errorf("path %q contains invalid characters", path)
|
|
61
73
|
}
|
|
62
74
|
|
|
63
75
|
// PathToEncodedKey converts a path to a byte slice key
|
|
@@ -2,40 +2,106 @@ package types
|
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
4
|
"bytes"
|
|
5
|
+
"fmt"
|
|
6
|
+
"strings"
|
|
5
7
|
"testing"
|
|
6
8
|
)
|
|
7
9
|
|
|
8
10
|
func Test_Key_Encoding(t *testing.T) {
|
|
9
11
|
tests := []struct {
|
|
10
|
-
name
|
|
11
|
-
|
|
12
|
-
key
|
|
12
|
+
name string
|
|
13
|
+
path string
|
|
14
|
+
key []byte
|
|
15
|
+
errContains string
|
|
13
16
|
}{
|
|
14
17
|
{
|
|
15
|
-
name:
|
|
16
|
-
|
|
17
|
-
key:
|
|
18
|
+
name: "empty path",
|
|
19
|
+
path: "",
|
|
20
|
+
key: []byte("0\x00"),
|
|
18
21
|
},
|
|
19
22
|
{
|
|
20
|
-
name:
|
|
21
|
-
|
|
22
|
-
key:
|
|
23
|
+
name: "single-segment path",
|
|
24
|
+
path: "some",
|
|
25
|
+
key: []byte("1\x00some"),
|
|
23
26
|
},
|
|
24
27
|
{
|
|
25
|
-
name:
|
|
26
|
-
|
|
27
|
-
key:
|
|
28
|
+
name: "multi-segment path",
|
|
29
|
+
path: "some.child.grandchild",
|
|
30
|
+
key: []byte("3\x00some\x00child\x00grandchild"),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "non-letters",
|
|
34
|
+
path: "-_0_-",
|
|
35
|
+
key: []byte("1\x00-_0_-"),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "lone dot",
|
|
39
|
+
path: ".",
|
|
40
|
+
errContains: "starts with separator",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "starts with dot",
|
|
44
|
+
path: ".foo",
|
|
45
|
+
errContains: "starts with separator",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "ends with dot",
|
|
49
|
+
path: "foo.",
|
|
50
|
+
errContains: "ends with separator",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "empty path segment",
|
|
54
|
+
path: "foo..bar",
|
|
55
|
+
errContains: "doubled separators",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "invalid path character U+0000 NUL",
|
|
59
|
+
path: "foo\x00bar",
|
|
60
|
+
errContains: "invalid character",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "invalid path character U+002F SOLIDUS",
|
|
64
|
+
path: "foo/bar",
|
|
65
|
+
errContains: "invalid character",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "invalid path character U+005C REVERSE SOLIDUS",
|
|
69
|
+
path: "foo\\bar",
|
|
70
|
+
errContains: "invalid character",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "invalid path character U+007C VERTICAL LINE",
|
|
74
|
+
path: "foo|bar",
|
|
75
|
+
errContains: "invalid character",
|
|
28
76
|
},
|
|
29
77
|
}
|
|
30
78
|
|
|
31
79
|
for _, tt := range tests {
|
|
80
|
+
if tt.key != nil {
|
|
81
|
+
t.Run(tt.name, func(t *testing.T) {
|
|
82
|
+
if key := PathToEncodedKey(tt.path); !bytes.Equal(key, tt.key) {
|
|
83
|
+
t.Errorf("pathToKey(%q) = []byte(%q), want []byte(%q)", tt.path, key, tt.key)
|
|
84
|
+
}
|
|
85
|
+
if path := EncodedKeyToPath(tt.key); path != tt.path {
|
|
86
|
+
t.Errorf("keyToPath([]byte(%q)) = %q, want %q", tt.key, path, tt.path)
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
expect := tt.errContains
|
|
32
92
|
t.Run(tt.name, func(t *testing.T) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
93
|
+
var key []byte
|
|
94
|
+
defer func() {
|
|
95
|
+
if err := recover(); err != nil {
|
|
96
|
+
errStr := fmt.Sprintf("%v", err)
|
|
97
|
+
if !strings.Contains(errStr, expect) {
|
|
98
|
+
t.Errorf("pathToKey(%q) = error %q, want error %v", tt.path, errStr, expect)
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
t.Errorf("pathToKey(%q) = []byte(%q), want error %v", tt.path, key, expect)
|
|
102
|
+
}
|
|
103
|
+
}()
|
|
104
|
+
key = PathToEncodedKey(tt.path)
|
|
39
105
|
})
|
|
40
106
|
}
|
|
41
107
|
}
|