Skip to content

Commit

Permalink
feat(ibc): clean up channel closure process (#9868)
Browse files Browse the repository at this point in the history
refs: #9857 

## Description

Add a `finalizer` Exo to the network implementation.  The finalizer contains logic to send messages expected upon disposing of a Connection or InboundAttempt.

### Security Considerations

More systematic closing of connection objects.

### Scaling Considerations

n/a

### Documentation Considerations

Should be backwards compatible.

### Testing Considerations

PR should include an upgrade test so we know it's safe to get into master

### Upgrade Considerations

It is necessary to upgrade the network and IBC vats if they have already been deployed (as they were in `agoric-upgrade-16`).
  • Loading branch information
mergify[bot] authored Aug 27, 2024
2 parents 7296b47 + 064ff1a commit d33a853
Show file tree
Hide file tree
Showing 20 changed files with 354 additions and 150 deletions.
2 changes: 1 addition & 1 deletion a3p-integration/proposals/e:upgrade-next/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ add-LEMONS/
add-OLIVES/
upgrade-bank/
upgrade-provisionPool/

upgrade-orch-core/
15 changes: 8 additions & 7 deletions a3p-integration/proposals/e:upgrade-next/initial.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ import test from 'ava';
import { getVatDetails } from '@agoric/synthetic-chain';

const vats = {
network: { incarnation: 0 },
ibc: { incarnation: 0 },
localchain: { incarnation: 0 },
network: { incarnation: 1 },
ibc: { incarnation: 1 },
localchain: { incarnation: 1 },
transfer: { incarnation: 1 },
walletFactory: { incarnation: 4 },
zoe: { incarnation: 2 },
};

test(`vat details`, async t => {
await null;
for (const [vatName, expected] of Object.entries(vats)) {
const actual = await getVatDetails(vatName);
t.like(actual, expected, `${vatName} details mismatch`);
const actual = {};
for await (const vatName of Object.keys(vats)) {
actual[vatName] = await getVatDetails(vatName);
}
t.like(actual, vats, `vat details are alike`);
});
6 changes: 4 additions & 2 deletions golang/cosmos/app/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gaia

import (

"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -37,7 +36,10 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
if isFirstTimeUpgradeOfThisVersion(app, ctx) {
// Each CoreProposalStep runs sequentially, and can be constructed from
// one or more modules executing in parallel within the step.
CoreProposalSteps = []vm.CoreProposalStep{}
CoreProposalSteps = []vm.CoreProposalStep{
// Upgrade orch-core to the latest version.
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgrade-orch-core.js"),
}
}

app.upgradeDetails = &upgradeDetails{
Expand Down
7 changes: 6 additions & 1 deletion golang/cosmos/x/vibc/types/ibc_module.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package types

import (
fmt "fmt"

sdkioerrors "cosmossdk.io/errors"
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
Expand Down Expand Up @@ -221,7 +223,10 @@ func (im IBCModule) OnChanCloseInit(
}

err := im.impl.PushAction(ctx, event)
return err
if err != nil {
return err
}
return fmt.Errorf("OnChanCloseInit can only be sent by the VM")
}

type ChannelCloseConfirmEvent struct {
Expand Down
2 changes: 1 addition & 1 deletion golang/cosmos/x/vtransfer/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewIBCMiddleware(ibcModule porttypes.IBCModule, vtransferKeeper keeper.Keep
// wrapped IBCModule. They are not performed in the context of a packet, and so
// do not need to be intercepted.

// OnChanCloseInit implements the IBCModule interface.
// OnChanOpenInit implements the IBCModule interface.
func (im IBCMiddleware) OnChanOpenInit(
ctx sdk.Context,
order channeltypes.Order,
Expand Down
4 changes: 3 additions & 1 deletion packages/boot/test/orchestration/restart-contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ test.serial('stakeAtom', async t => {
// restarting that one. For them to share bootstrap they'll each need a unique
// instance name, which will require paramatizing the the two builders scripts
// and the two core-eval functions.
test.serial('basicFlows', async t => {
//
// TODO(#9939): Flaky under Node.js until liveslots problem exposed by vows is fixed.
test.serial.skip('basicFlows', async t => {
const {
walletFactoryDriver,
buildProposal,
Expand Down
23 changes: 23 additions & 0 deletions packages/builders/scripts/vats/upgrade-orch-core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) =>
harden({
sourceSpec: '@agoric/vats/src/proposals/upgrade-orch-core-proposal.js',
getManifestCall: [
'getManifestForUpgradingOrchCore',
{
bundleRefs: {
ibc: publishRef(install('@agoric/vats/src/vat-ibc.js')),
network: publishRef(install('@agoric/vats/src/vat-network.js')),
localchain: publishRef(install('@agoric/vats/src/vat-localchain.js')),
transfer: publishRef(install('@agoric/vats/src/vat-transfer.js')),
},
},
],
});

export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('upgrade-network', defaultProposalBuilder);
};
Loading

0 comments on commit d33a853

Please sign in to comment.