Skip to content

Commit

Permalink
Merge pull request #1004 from Agoric/mfig/dibc-outbound
Browse files Browse the repository at this point in the history
Accomodate relayers that start channels themselves
  • Loading branch information
michaelfig authored Apr 30, 2020
2 parents ec705b4 + 69ee801 commit fa18bd0
Show file tree
Hide file tree
Showing 22 changed files with 700 additions and 202 deletions.
13 changes: 10 additions & 3 deletions packages/cosmic-swingset/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@ NAME := $(shell sed -ne 's/.*"name": "\([^"]*\)".*/\1/p' package.json)
VERSION := $(shell sed -ne 's/.*"version": "\([^"]*\)".*/\1/p' package.json)
COMMIT := $(shell git log -1 --format='%H' || cat lib/git-revision.txt)

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(NAME) \
ldflags = \
-X github.com/cosmos/cosmos-sdk/version.Name=$(NAME) \
-X github.com/cosmos/cosmos-sdk/version.ServerName=ag-chain-cosmos \
-X github.com/cosmos/cosmos-sdk/version.ClientName=ag-cosmos-helper \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags)"
gcflags =

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
ifneq ($(GO_DEBUG),)
ldflags += -compressdwarf=false
gcflags += -N -l
endif

BUILD_FLAGS := -tags "$(build_tags)" -gcflags '$(gcflags)' -ldflags '$(ldflags)'

include Makefile.ledger
all: build-cosmos install
Expand Down Expand Up @@ -149,7 +156,7 @@ node-compile-gyp:
# Only run from the package.json build:gyp script.
compile-gyp:
cp binding.gyp.in binding.gyp
node-gyp configure build || { status=$$?; rm -f binding.gyp; exit $$status; }
node-gyp configure build $(GYP_DEBUG) || { status=$$?; rm -f binding.gyp; exit $$status; }
rm -f binding.gyp

install: go.sum
Expand Down
11 changes: 5 additions & 6 deletions packages/cosmic-swingset/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func NewAgoricApp(
auth.StoreKey, bank.StoreKey, staking.StoreKey,
mint.StoreKey, distr.StoreKey, slashing.StoreKey,
gov.StoreKey, params.StoreKey, ibc.StoreKey, upgrade.StoreKey,
evidence.StoreKey, transfer.StoreKey, capability.StoreKey, swingset.StoreKey,
evidence.StoreKey, transfer.StoreKey, swingset.StoreKey, capability.StoreKey,
)
tKeys := sdk.NewTransientStoreKeys(params.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capability.MemStoreKey)
Expand Down Expand Up @@ -291,7 +291,7 @@ func NewAgoricApp(
// This function is tricky to get right, so we inject it ourselves.
app.swingSetKeeper.CallToController = func(ctx sdk.Context, str string) (string, error) {
defer swingset.SetControllerContext(ctx)()
defer swingset.SetControllerKeeper(app.swingSetKeeper)()
defer swingset.SetControllerKeeper(&app.swingSetKeeper)()
return sendToController(true, str)
}

Expand Down Expand Up @@ -329,11 +329,11 @@ func NewAgoricApp(
distr.NewAppModule(appCodec, app.distrKeeper, app.accountKeeper, app.bankKeeper, app.stakingKeeper),
staking.NewAppModule(appCodec, app.stakingKeeper, app.accountKeeper, app.bankKeeper),
upgrade.NewAppModule(app.upgradeKeeper),
evidence.NewAppModule(app.evidenceKeeper),
evidence.NewAppModule(appCodec, app.evidenceKeeper),
ibc.NewAppModule(app.ibcKeeper),
params.NewAppModule(app.paramsKeeper),
transferModule,
swingsetModule,
transferModule,
)

// During begin block slashing happens after distr.BeginBlocker so that
Expand All @@ -353,8 +353,7 @@ func NewAgoricApp(
app.mm.SetOrderInitGenesis(
capability.ModuleName, auth.ModuleName, distr.ModuleName, staking.ModuleName, bank.ModuleName,
slashing.ModuleName, gov.ModuleName, mint.ModuleName, crisis.ModuleName,
ibc.ModuleName, genutil.ModuleName, evidence.ModuleName, transfer.ModuleName,
swingset.ModuleName,
ibc.ModuleName, genutil.ModuleName, evidence.ModuleName, swingset.ModuleName, transfer.ModuleName,
)

app.mm.RegisterInvariants(&app.crisisKeeper)
Expand Down
19 changes: 16 additions & 3 deletions packages/cosmic-swingset/bin/ag-nchainz
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
set -e
progname=$(basename -- "$0")

trap 'kill $(jobs -p) 2>/dev/null' EXIT

BASE_PORT=8000
NUM_SOLOS=1

Expand Down Expand Up @@ -59,11 +61,16 @@ testnet)
ag-solo 1000uag
done
# $thisdir/../../deployment/set-json.js $n0d/config/genesis.json --agoric-genesis-overrides
for node in `ls -d $chainid/n[1-9]* 2>/dev/null`; do
for node in `ls -d $chainid/n[1-9]* 2>/dev/null || true`; do
cp $n0d/config/genesis.json $node/$DAEMON/config/genesis.json
done
exit 0
;;
start-daemon)
if [[ $1 == '--debug' ]]; then
debug=yes
shift
fi
BASEDIR=$1
shift
ba=$($CLI --home "$BASEDIR/n0/$CLI" keys show n0 --keyring-backend=test | jq -r .address)
Expand All @@ -72,7 +79,12 @@ start-daemon)
ba="$ba $(cat $solo/ag-cosmos-helper-address)"
done
echo "Starting BOOT_ADDRESS=$ba $DAEMON ${1+"$@"}"
DEBUG=agoric ROLE=two_chain BOOT_ADDRESS=$ba $DAEMON ${1+"$@"}
if [[ $debug == yes ]]; then
DEBUG=agoric ROLE=two_chain BOOT_ADDRESS=$ba node --inspect-brk $(which $DAEMON) ${1+"$@"}
else
DEBUG=agoric ROLE=two_chain BOOT_ADDRESS=$ba $DAEMON ${1+"$@"}
fi
exit 0
;;

start-solos)
Expand Down Expand Up @@ -100,8 +112,9 @@ start-solos)
) >>nchainz/logs/$log 2>&1 &
done
sleep 2
echo "Waiting for all solos (Hit Control-C to exit)..."
echo "Waiting for all ${1+"$@ "}solos (Hit Control-C to exit)..."
wait
exit 0
;;
*)
echo 1>&2 "$progname: unrecognized command \`$COMMAND'"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package main

// #cgo CPPFLAGS: -I/usr/local/include/node
// #cgo LDFLAGS: -L/usr/local/lib
import "C"

import "github.com/Agoric/agoric-sdk/packages/cosmic-swingset/lib/daemon"

func main() {
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
github.com/99designs/keyring v1.1.4 // indirect
github.com/Agoric/agoric-sdk v0.0.0-00010101000000-000000000000 // indirect
github.com/bartekn/go-bip39 v0.0.0-20171116152956-a05967ea095d // indirect
github.com/cosmos/cosmos-sdk v0.34.4-0.20200422222342-f6e9ee762358
github.com/gibson042/canonicaljson-go v1.0.3 // indirect
github.com/cosmos/cosmos-sdk v0.34.4-0.20200423194215-1cd1d088df05
github.com/gibson042/canonicaljson-go v1.0.3 // indirect
github.com/golang/mock v1.4.3 // indirect
github.com/gorilla/handlers v1.4.2 // indirect
github.com/gorilla/mux v1.7.4
Expand Down
9 changes: 9 additions & 0 deletions packages/cosmic-swingset/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN
github.com/99designs/keyring v1.1.3/go.mod h1:657DQuMrBZRtuL/voxVyiyb6zpMehlm5vLB9Qwrv904=
github.com/99designs/keyring v1.1.4 h1:x0g0zQ9bQKgNsLo0XSXAy1H8Q1RG/td+5OXJt+Ci8b8=
github.com/99designs/keyring v1.1.4/go.mod h1:657DQuMrBZRtuL/voxVyiyb6zpMehlm5vLB9Qwrv904=
github.com/99designs/keyring v1.1.5 h1:wLv7QyzYpFIyMSwOADq1CLTF9KbjbBfcnfmOGJ64aO4=
github.com/99designs/keyring v1.1.5/go.mod h1:7hsVvt2qXgtadGevGJ4ujg+u8m6SpJ5TpHqTozIPqf0=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/ChainSafe/go-schnorrkel v0.0.0-20200102211924-4bcbc698314f h1:4O1om+UVU+Hfcihr1timk8YNXHxzZWgCo7ofnrZRApw=
Expand All @@ -21,6 +23,9 @@ github.com/Workiva/go-datastructures v1.0.52 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9
github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA=
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.34.4-0.20200428210309-3cf84258cc12 h1:xnDgoo7cqnbvMFXp7QYrNwYPpAe0wtBuVSkG40PHb1U=
github.com/agoric-labs/cosmos-sdk v0.34.4-0.20200428210309-3cf84258cc12/go.mod h1:tvCen72hkJxkYT1/CsOaKHjZ4PouX4Isp4w9aRL2K4c=
github.com/agoric-labs/cosmos-sdk v0.37.0 h1:y9OTnnORhLHPnfxLIaK4Pv/7Z7KcpnbTxpE5xxWlUUY=
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 Expand Up @@ -87,6 +92,8 @@ github.com/cosmos/cosmos-sdk v0.34.4-0.20200417201027-11528d39594c h1:Yd7DVqfImC
github.com/cosmos/cosmos-sdk v0.34.4-0.20200417201027-11528d39594c/go.mod h1:jngw1LJfwEAU+xc/tZwUGIXBAJHapckYGtXycsq8D+U=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200422222342-f6e9ee762358 h1:ZsII2yECeLh2jWqFz3bK8JInzzlHPhgB0ob2c9XMyz4=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200422222342-f6e9ee762358/go.mod h1:Kcgs8c2WWtO2Q+KmDogvGRw+sdEqpvHYXFhj/QiAoOg=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200423194215-1cd1d088df05 h1:jaV9iTBaiYmNAMaDEhvWukIQWQ/NfBoHbgSqPgdKFmM=
github.com/cosmos/cosmos-sdk v0.34.4-0.20200423194215-1cd1d088df05/go.mod h1:Kcgs8c2WWtO2Q+KmDogvGRw+sdEqpvHYXFhj/QiAoOg=
github.com/cosmos/cosmos-sdk v0.38.3 h1:qIBTiw+2T9POaSUJ5rvbBbXeq8C8btBlJxnSegPBd3Y=
github.com/cosmos/cosmos-sdk v0.38.3/go.mod h1:rzWOofbKfRt3wxiylmYWEFHnxxGj0coyqgWl2I9obAw=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
Expand Down Expand Up @@ -313,6 +320,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJ
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs=
github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
Expand Down
14 changes: 13 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/fake-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,19 @@ export async function connectToFakeChain(basedir, GCI, role, delay, inbound) {
console.error('received', dstID, obj);
return 'IBC and bridge device not used on fake-chain';
}
const s = await launch(stateDBdir, mailboxStorage, doOutboundBridge, vatsdir, argv);
function flushChainSends(replay) {
if (replay) {
throw Error(`Replay not implemented`);
}
}
const s = await launch(
stateDBdir,
mailboxStorage,
doOutboundBridge,
flushChainSends,
vatsdir,
argv,
);

const blockManager = makeBlockManager(s);
const { savedHeight, savedActions } = s;
Expand Down
7 changes: 5 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ export function makeBridgeManager(E, D, bridgeDevice) {
if (!bridgeDevice) {
throw Error(`bridge device not yet connected`);
}
const retval = D(bridgeDevice).callOutbound(dstID, obj);
const retobj = D(bridgeDevice).callOutbound(dstID, obj);
// note: *we* get this return value synchronously, but any callers (in
// separate vats) only get a Promise, and will receive the value in some
// future turn
return retval;
if (retobj && retobj.error) {
throw Error(retobj.error);
}
return retobj;
}

// We now manage the device.
Expand Down
Loading

0 comments on commit fa18bd0

Please sign in to comment.