Skip to content
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

rebase/cherry-pick commits for upgrade 12 #8510

Merged
merged 47 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
f582901
fix(vibc): accommodate ibc-go v3 breaking changes
michaelfig Aug 1, 2023
1ca6e84
docs(SwingSet): remove mention of obsolete "need prompt ACK" for IBC …
michaelfig Aug 2, 2023
9469971
fix(vibc): put extraneous `CounterpartyChannelID` in `Counterparty` s…
michaelfig Aug 2, 2023
90b1a06
feat: port bash tests to javascript
iomekam Aug 17, 2023
a1b3b66
Merge pull request #8127 from Agoric/mfig-vibc-write-open-init
michaelfig Aug 5, 2023
c01198b
chore(deployment): add test of core proposal execution
mhofman Aug 31, 2023
9d7e8ac
test: separate upgrade-12
iomekam Aug 31, 2023
fcee255
Merge pull request #8145 from Agoric/execa-proto
iomekam Aug 17, 2023
d8db331
fix(vstorage)!: Enforce path validation
gibson042 Sep 18, 2023
b366faa
chore(deployment): shortcut to run upgrade test non-interactive
mhofman Aug 31, 2023
c88f00b
Merge pull request #8254 from Agoric/ta/upgrade-12
mergify[bot] Aug 31, 2023
645f1e3
chore(vstorage): Improve path/key testing
gibson042 Sep 18, 2023
0a3ac9a
test: move ag11 and ag12 to JS
iomekam Sep 7, 2023
1b7e73f
Partial merge pull request #8287 from Agoric/mhofman/8279-atomic-swin…
mergify[bot] Sep 1, 2023
d71458e
ci: build upgrade image from agoric-3-proposals
turadg Nov 4, 2023
29bc2c6
test: remove tmux from upgrade-tests
turadg Sep 25, 2023
2b04694
refactor(vstorage): Improve custom query handling
gibson042 Sep 18, 2023
a852db9
Merge pull request #8237 from Agoric/agoric-upgrade-11-js
mergify[bot] Sep 8, 2023
7d1aa4e
ci: remove ag0 considerations
turadg Nov 4, 2023
8d738c6
fix(swing-store): ensure crank savepoint is wrapped in transaction
mhofman Oct 4, 2023
b217c44
feat(Docker): make shell
turadg Sep 27, 2023
cfe4793
Merge pull request #8348 from Agoric/gibson-8337-vstorage-path-valida…
mergify[bot] Sep 19, 2023
cf2da61
ci: always USE_JS for chain upgrade test
turadg Nov 4, 2023
c27a586
test: add test of savepoints, including no automatic transactions
warner Oct 4, 2023
49752fe
Merge pull request #8393 from Agoric/drop-tmux
mergify[bot] Sep 27, 2023
6f3eecf
ci: voteLatestProposalAndWait poll patiently
dckc Nov 4, 2023
4ef1cde
chore(cosmos): update tendermint to v0.34.23-alpha.agoric.4
mhofman Nov 6, 2023
6e859d3
Merge pull request #8429 from Agoric/mhofman/8423-crank-ensure-transa…
mergify[bot] Oct 4, 2023
14fa701
test: fix upgrade-12 expected vault count
turadg Nov 4, 2023
5286c6d
chore(cosmos): reflect new default max block size in upgrade
mhofman Nov 2, 2023
06302a2
feat(cosmic-swingset): add begin block check and transaction (#8432)
mhofman Oct 12, 2023
7f188b3
ci: skip TAP timing collection for docker-build-sdk
turadg Nov 4, 2023
c2a75a2
chore: add upgrade test of max block size
mhofman Nov 1, 2023
46b09de
SECURITY.md updates and ownership (#8455)
raphdev Nov 2, 2023
5285da8
ci: Zoe test failing for now
turadg Nov 6, 2023
84908e5
Merge pull request #8484 from Agoric/mhofman/max-block-size
mergify[bot] Nov 6, 2023
6219230
ci: disable upgrade-12 actions that aren't working
turadg Nov 7, 2023
e04b398
chore(cosmos): update cosmos-sdk (#8507)
mhofman Nov 8, 2023
a36ae56
Merge pull request #8476 from Agoric/8443-drop-upgrade-tests
mhofman Nov 8, 2023
3350bdc
ci(install-deps): work around Ansible Launchpad PPA breakage
michaelfig Nov 9, 2023
3b97178
chore(deployment): test upgrade-12 does not have core proposal
mhofman Nov 8, 2023
3b3ccd4
Merge pull request #8515 from Agoric/mfig-install-ansible-workaround
mergify[bot] Nov 9, 2023
11637d2
chore: change branch name used for creating releases (#8375)
mhofman Nov 9, 2023
35aef87
feat(swing-store): faster import of swing-store
mhofman Nov 9, 2023
03f642d
feat(swing-store): prevent SwingSet usage of imported swing-store
mhofman Nov 10, 2023
06edaa4
Merge pull request #8522 from Agoric/mhofman/import-swing-store-fast
mergify[bot] Nov 10, 2023
664f59f
fix: hard code working agoric-3-proposals image
mhofman Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,13 @@ module.exports = {
project: false,
},
},
{
files: ['packages/**/upgrade-test-scripts/**/*.*js'],
rules: {
// NOTE: This rule is enabled for the repository in general. We turn it
// off for test code for now.
'@jessie.js/safe-await-separator': 'off',
},
},
],
};
4 changes: 3 additions & 1 deletion .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,9 @@ jobs:

- uses: actions/checkout@v3
- name: docker build (sdk)
run: cd packages/deployment && ./scripts/test-docker-build.sh | $TEST_COLLECT
# run: cd packages/deployment && ./scripts/test-docker-build.sh | $TEST_COLLECT
# XXX skip TAP test output and collection for now; it hides the output from the logs
run: cd packages/deployment && make docker-build-sdk
- name: docker build upgrade test
run: cd packages/deployment/upgrade-test && docker build --build-arg BOOTSTRAP_MODE=${{ matrix.bootstrap-version }} --build-arg DEST_IMAGE=ghcr.io/agoric/agoric-sdk:latest -t docker-upgrade-test:latest -f Dockerfile upgrade-test-scripts
- name: docker run upgrade final stage
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SECURITY.md @Agoric/security
2 changes: 1 addition & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ in this branch. The release tags will be human-meaningful, the release branch ne
```sh
# Create a release branch.
now=`date -u +%Y%m%dT%H%M%S`
git checkout -b release-$now
git checkout -b prepare-release-$now
```

- [ ] Do a `yarn install` to generate tooling needed for the release.
Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Supported Versions

The current `master` and `release-pismo` branches are supported with security updates.
The current `master` and only the latest `agoric-upgrade-*` tagged release and pre-release are supported with security updates.

## Coordinated Vulnerability Disclosure

Expand Down
112 changes: 14 additions & 98 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import (
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

gaiaappparams "github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
Expand Down Expand Up @@ -790,13 +791,18 @@ func NewAgoricApp(
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)

const (
upgradeName = "agoric-upgrade-12"
upgradeNameTest = "agorictest-upgrade-12"
)

app.UpgradeKeeper.SetUpgradeHandler(
upgradeName,
upgrade11Handler(app, upgradeName),
upgrade12Handler(app, upgradeName),
)
app.UpgradeKeeper.SetUpgradeHandler(
upgradeNameTest,
upgrade11Handler(app, upgradeNameTest),
upgrade12Handler(app, upgradeNameTest),
)

if loadLatest {
Expand All @@ -819,107 +825,17 @@ func NewAgoricApp(
return app
}

type swingStoreMigrationEventHandler struct {
swingStore sdk.KVStore
}

func (eventHandler swingStoreMigrationEventHandler) OnExportStarted(height uint64, retrieveSwingStoreExport func() error) error {
return retrieveSwingStoreExport()
}

func (eventHandler swingStoreMigrationEventHandler) OnExportRetrieved(provider swingsetkeeper.SwingStoreExportProvider) (err error) {
exportDataReader, err := provider.GetExportDataReader()
if err != nil {
return err
}
defer exportDataReader.Close()

var hasExportData bool

for {
entry, err := exportDataReader.Read()
if err == io.EOF {
break
} else if err != nil {
return err
}
hasExportData = true
if !entry.HasValue() {
return fmt.Errorf("no value for export data key %s", entry.Key())
}
eventHandler.swingStore.Set([]byte(entry.Key()), []byte(entry.StringValue()))
}
if !hasExportData {
return fmt.Errorf("export data had no entries")
}
return nil
}

// upgrade11Handler performs standard upgrade actions plus custom actions for upgrade-11.
func upgrade11Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
// upgrade12Handler performs standard upgrade actions plus custom actions for upgrade-12.
func upgrade12Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
app.CheckControllerInited(false)
// Record the plan to send to SwingSet
app.upgradePlan = &plan

// Perform swing-store migrations. We do this in the app upgrade handler
// since it involves multiple modules (x/vstorage and x/swingset) which
// don't strictly have a version change on their own.

// We are at the begining of the upgrade block, so all stores are commited
// as of the end of the previous block
savedBlockHeight := uint64(ctx.BlockHeight() - 1)

// First, repair swing-store metadata in case this node was previously
// initialized from a state-sync snapshot. This is done with a check on the
// block height to catch early any hangover related mismatch.
// Only entries related to missing historical metadata are imported, but we
// don't know what these look like here, so we provide it all.
getSwingStoreExportDataFromVstorage := func() (reader agorictypes.KVEntryReader, err error) {
return agorictypes.NewVstorageDataEntriesReader(
app.VstorageKeeper.ExportStorageFromPrefix(ctx, swingsetkeeper.StoragePathSwingStore),
), nil
}

// We're not restoring any artifact to swing-store, nor have any to provide
readNoArtifact := func() (artifact swingsettypes.SwingStoreArtifact, err error) {
return artifact, io.EOF
}

err := app.SwingStoreExportsHandler.RestoreExport(
swingsetkeeper.SwingStoreExportProvider{
BlockHeight: savedBlockHeight,
GetExportDataReader: getSwingStoreExportDataFromVstorage,
ReadNextArtifact: readNoArtifact,
},
swingsetkeeper.SwingStoreRestoreOptions{
ArtifactMode: swingsetkeeper.SwingStoreArtifactModeNone,
ExportDataMode: swingsetkeeper.SwingStoreExportDataModeRepairMetadata,
},
)
if err != nil {
return nil, err
}

// Then migrate the swing-store shadow copy:
// 1. Remove the swing-store "export data" shadow-copy entries from vstorage.
// 2. Export swing-store "export-data" (as of the previous block) through a
// handler that writes every entry into the swingset module's new Store.
app.VstorageKeeper.RemoveEntriesWithPrefix(ctx, swingsetkeeper.StoragePathSwingStore)
err = app.SwingStoreExportsHandler.InitiateExport(
savedBlockHeight,
swingStoreMigrationEventHandler{swingStore: app.SwingSetKeeper.GetSwingStore(ctx)},
swingsetkeeper.SwingStoreExportOptions{
ArtifactMode: swingsetkeeper.SwingStoreArtifactModeNone,
ExportDataMode: swingsetkeeper.SwingStoreExportDataModeAll,
},
)
if err == nil {
err = swingsetkeeper.WaitUntilSwingStoreExportDone()
}
if err != nil {
return nil, err
}
// Reflect default BlockParams.MaxBytes change to current params
cp := app.BaseApp.GetConsensusParams(ctx)
cp.Block.MaxBytes = tmtypes.DefaultBlockParams().MaxBytes
app.BaseApp.StoreConsensusParams(ctx, cp)

// Always run module migrations
mvm, err := app.mm.RunMigrations(ctx, app.configurator, fromVm)
Expand Down
6 changes: 0 additions & 6 deletions golang/cosmos/app/const.go

This file was deleted.

6 changes: 3 additions & 3 deletions golang/cosmos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.6.0
github.com/spf13/viper v1.13.0
github.com/stretchr/testify v1.8.0
github.com/tendermint/tendermint v0.34.23
github.com/tendermint/tm-db v0.6.7
Expand Down Expand Up @@ -105,7 +106,6 @@ require (
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.13.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tendermint/btcd v0.1.1 // indirect
Expand Down Expand Up @@ -142,10 +142,10 @@ replace google.golang.org/grpc => google.golang.org/grpc v1.33.2

// At least until post-v0.34.14 is released with
// https://github.com/tendermint/tendermint/issue/6899 resolved.
replace github.com/tendermint/tendermint => github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.3
replace github.com/tendermint/tendermint => github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.4

// We need a fork of cosmos-sdk until all of the differences are merged.
replace github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.3
replace github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.4

replace github.com/cosmos/gaia/v7 => github.com/Agoric/ag0/v7 v7.0.2-alpha.agoric.1

Expand Down
8 changes: 4 additions & 4 deletions golang/cosmos/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:
github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.3 h1:CMWOJYFHoRpKnNt2l90e5tEMy9phxkDEjQKfsCUHtgU=
github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.3/go.mod h1:fdXvzy+wmYB+W+N139yb0+szbT7zAGgUjmxm5DBrjto=
github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.4 h1:OU1rRq0qS+5KNe7eF7ceXPpHeXWj+JSbUpHgiQTml2E=
github.com/agoric-labs/cosmos-sdk v0.45.11-alpha.agoric.4/go.mod h1:fdXvzy+wmYB+W+N139yb0+szbT7zAGgUjmxm5DBrjto=
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/agoric-labs/tendermint v0.34.23-alpha.agoric.3 h1:aq6F1r3RQkKUYNeMNjRxgGn3dayvKnDK/R6gQF0WoFs=
github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.3/go.mod h1:rXVrl4OYzmIa1I91av3iLv2HS0fGSiucyW9J4aMTpKI=
github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.4 h1:NWqGDUk5UkkXxsEVRtCWFpMeuCtu2MyRtC0Cib7sKH8=
github.com/agoric-labs/tendermint v0.34.23-alpha.agoric.4/go.mod h1:rXVrl4OYzmIa1I91av3iLv2HS0fGSiucyW9J4aMTpKI=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
Expand Down
3 changes: 1 addition & 2 deletions golang/cosmos/x/vibc/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ type channelOpenAckEvent struct {
Event string `json:"event"` // channelOpenAck
PortID string `json:"portID"`
ChannelID string `json:"channelID"`
CounterpartyChannelID string `json:"counterpartyChannelID"`
CounterpartyVersion string `json:"counterpartyVersion"`
Counterparty channeltypes.Counterparty `json:"counterparty"`
ConnectionHops []string `json:"connectionHops"`
Expand All @@ -247,12 +246,12 @@ func (im IBCModule) OnChanOpenAck(
// returns an empty channel object that we can still use without crashing.
channel, _ := im.keeper.GetChannel(ctx, portID, channelID)

channel.Counterparty.ChannelId = counterpartyChannelID
event := channelOpenAckEvent{
Type: "IBC_EVENT",
Event: "channelOpenAck",
PortID: portID,
ChannelID: channelID,
CounterpartyChannelID: counterpartyChannelID,
CounterpartyVersion: counterpartyVersion,
Counterparty: channel.Counterparty,
ConnectionHops: channel.ConnectionHops,
Expand Down
16 changes: 1 addition & 15 deletions golang/cosmos/x/vibc/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,7 @@ func (k Keeper) ChanOpenInit(ctx sdk.Context, order channeltypes.Order, connecti
return err
}

// We need to emit a channel event to notify the relayer.
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory),
),
})
k.channelKeeper.WriteOpenInitChannel(ctx, portID, channelID, order, connectionHops, counterparty, version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michaelfig please verify that this is good to include.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please! This is a critical platform fix whose absence would prevent the use of dIBC in JS contracts.

return nil
}

Expand Down Expand Up @@ -157,14 +151,6 @@ func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error {
if err != nil {
return err
}

// We need to emit a channel event to notify the relayer.
ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, channeltypes.AttributeValueCategory),
),
})
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion golang/cosmos/x/vibc/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ type ChannelKeeper interface {
WriteAcknowledgement(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error
ChanOpenInit(ctx sdk.Context, order channel.Order, connectionHops []string, portID string,
portCap *capability.Capability, counterparty channel.Counterparty, version string) (string, *capability.Capability, error)

WriteOpenInitChannel(ctx sdk.Context, portID, channelID string, order channel.Order,
connectionHops []string, counterparty channel.Counterparty, version string)
ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capability.Capability) error
TimeoutExecuted(ctx sdk.Context, channelCap *capability.Capability, packet ibcexported.PacketI) error
}
Expand Down
42 changes: 31 additions & 11 deletions golang/cosmos/x/vstorage/keeper/querier.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"strings"

abci "github.com/tendermint/tendermint/abci/types"

"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -18,14 +16,36 @@ const (
QueryChildren = "children"
)

// NewQuerier is the module level router for state queries
// getVstorageEntryPath validates that a request URL path represents a valid
// entry path with no extra data, and returns the path of that vstorage entry.
func getVstorageEntryPath(urlPathSegments []string) (string, error) {
if len(urlPathSegments) != 1 || types.ValidatePath(urlPathSegments[0]) != nil {
return "", sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "invalid vstorage entry path")
}
return urlPathSegments[0], nil
}

// NewQuerier returns the function for handling queries routed to this module.
// It performs its own routing based on the first slash-separated URL path
// segment (e.g., URL path `/data/foo.bar` is a request for the value associated
// with vstorage path "foo.bar", and `/children/foo.bar` is a request for the
// child path segments immediately underneath vstorage path "foo.bar" which may
// be used to extend it to a vstorage path such as "foo.bar.baz").
func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err error) {
switch path[0] {
return func(ctx sdk.Context, urlPathSegments []string, req abci.RequestQuery) (res []byte, err error) {
switch urlPathSegments[0] {
case QueryData:
return queryData(ctx, strings.Join(path[1:], "/"), req, keeper, legacyQuerierCdc)
entryPath, entryPathErr := getVstorageEntryPath(urlPathSegments[1:])
if entryPathErr != nil {
return nil, entryPathErr
}
return queryData(ctx, entryPath, req, keeper, legacyQuerierCdc)
case QueryChildren:
return queryChildren(ctx, strings.Join(path[1:], "/"), req, keeper, legacyQuerierCdc)
entryPath, entryPathErr := getVstorageEntryPath(urlPathSegments[1:])
if entryPathErr != nil {
return nil, entryPathErr
}
return queryChildren(ctx, entryPath, req, keeper, legacyQuerierCdc)
default:
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "unknown vstorage query endpoint")
}
Expand All @@ -36,12 +56,12 @@ func NewQuerier(keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier
func queryData(ctx sdk.Context, path string, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) (res []byte, err error) {
entry := keeper.GetEntry(ctx, path)
if !entry.HasValue() {
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "could not get vstorage path")
return nil, sdkerrors.Wrap(sdkerrors.ErrNotFound, "no data for vstorage path")
}

bz, err2 := codec.MarshalJSONIndent(legacyQuerierCdc, types.Data{Value: entry.StringValue()})
if err2 != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err2.Error())
bz, marshalErr := codec.MarshalJSONIndent(legacyQuerierCdc, types.Data{Value: entry.StringValue()})
if marshalErr != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, marshalErr.Error())
}

return bz, nil
Expand Down
Loading
Loading