Skip to content

Commit

Permalink
Merge branch 'master' into 2018-store-no-empty-data-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
warner authored Mar 11, 2021
2 parents 9b448e6 + 92b63b6 commit 83286e3
Show file tree
Hide file tree
Showing 27 changed files with 543 additions and 123 deletions.
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.15
require (
github.com/btcsuite/btcd v0.21.0-beta
github.com/btcsuite/btcutil v1.0.2
github.com/cosmos/cosmos-sdk v0.41.1
github.com/cosmos/cosmos-sdk v0.42.0
github.com/ethereum/go-ethereum v1.9.22
github.com/gogo/protobuf v1.3.3
github.com/gorilla/mux v1.8.0
Expand All @@ -14,7 +14,7 @@ require (
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.3.1
github.com/spf13/cobra v1.1.1
github.com/tendermint/tendermint v0.34.4
github.com/tendermint/tendermint v0.34.8
github.com/tendermint/tm-db v0.6.4
google.golang.org/genproto v0.0.0-20210114201628-6edceaf6022f
google.golang.org/grpc v1.35.0
Expand All @@ -24,9 +24,11 @@ require (
replace github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4
replace google.golang.org/grpc => google.golang.org/grpc v1.33.2

// At least until tendermint v0.34.4 is released.
// replace github.com/tendermint/tendermint => github.com/agoric-labs/tendermint v0.33.1-dev2.0.20210126214117-87803b32fbb4
// At least until post-v0.34.8 is released with
// https://github.com/tendermint/tendermint/pull/6204.
replace github.com/tendermint/tendermint => github.com/agoric-labs/tendermint v0.33.1-dev2.0.20210310191408-9156bacf449c

// At least until https://github.com/cosmos/cosmos-sdk/issues/8478 is solved and
// released.
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ github.com/agoric-labs/tendermint v0.33.1-dev2.0.20210122151802-a81eb67c924d h1:
github.com/agoric-labs/tendermint v0.33.1-dev2.0.20210122151802-a81eb67c924d/go.mod h1:FxbRbTEQsxz1LUmY4cVFFcjcdNT6VwVm7Ajw5HQmf04=
github.com/agoric-labs/tendermint v0.33.1-dev2.0.20210126214117-87803b32fbb4 h1:oHNB57wl8KSb6oo1w32FW19PdB5uFfPjfnFYX6/pbn8=
github.com/agoric-labs/tendermint v0.33.1-dev2.0.20210126214117-87803b32fbb4/go.mod h1:h57vnXeOlrdvvNFCqPBSaOrpOivl+2swWEtlUAqStYE=
github.com/agoric-labs/tendermint v0.33.1-dev2.0.20210310191408-9156bacf449c h1:Mib4I7yaBDNA/xpadU6WH0mqporvACuQ5LSNuachIgo=
github.com/agoric-labs/tendermint v0.33.1-dev2.0.20210310191408-9156bacf449c/go.mod h1:JVuu3V1ZexOaZG8VJMRl8lnfrGw6hEB2TVnoUwKRbss=
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 @@ -157,6 +159,8 @@ github.com/cosmos/cosmos-sdk v0.40.1 h1:gjrtV3MQj/CMeyXN4+sosHMG6Xwa2uH6HITSjSNL
github.com/cosmos/cosmos-sdk v0.40.1/go.mod h1:vlgqdPpUGSxgqSbZea6fjszoLkPKwCuiqSBySLlv4ro=
github.com/cosmos/cosmos-sdk v0.41.1 h1:QatVRc8EaEObHtOFDNYHoF6di/jvSFVkXBK3I3SQ+/4=
github.com/cosmos/cosmos-sdk v0.41.1/go.mod h1:mCaJm2k+fqY7+qwvwd7WDHZZFG3avW4+I6c4lizAkIY=
github.com/cosmos/cosmos-sdk v0.42.0 h1:oQ+rUTYZ5gUq8/YEW83NosCJ3+41iA/3/wZ3pfEIYH8=
github.com/cosmos/cosmos-sdk v0.42.0/go.mod h1:xiLp1G8mumj82S5KLJGCAyeAlD+7VNomg/aRSJV12yk=
github.com/cosmos/go-bip39 v0.0.0-20180618194314-52158e4697b8/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
Expand Down Expand Up @@ -707,6 +711,8 @@ github.com/tendermint/tendermint v0.34.3 h1:9yEsf3WO5VAwPVwrmM+RffDMiijmNfWaBwNt
github.com/tendermint/tendermint v0.34.3/go.mod h1:h57vnXeOlrdvvNFCqPBSaOrpOivl+2swWEtlUAqStYE=
github.com/tendermint/tendermint v0.34.4 h1:E7qkvFGx27d8ugVLiAY2iWP6DL5cep3l/mpTaWKHyBA=
github.com/tendermint/tendermint v0.34.4/go.mod h1:JVuu3V1ZexOaZG8VJMRl8lnfrGw6hEB2TVnoUwKRbss=
github.com/tendermint/tendermint v0.34.8 h1:PMWgUx47FrNTsfhxCWzoiIlVAC1SE9+WBlnsF9oQW0I=
github.com/tendermint/tendermint v0.34.8/go.mod h1:JVuu3V1ZexOaZG8VJMRl8lnfrGw6hEB2TVnoUwKRbss=
github.com/tendermint/tm-db v0.4.1/go.mod h1:JsJ6qzYkCGiGwm5GHl/H5GLI9XLb6qZX7PRe425dHAY=
github.com/tendermint/tm-db v0.5.0/go.mod h1:lSq7q5WRR/njf1LnhiZ/lIJHk2S8Y1Zyq5oP/3o9C2U=
github.com/tendermint/tm-db v0.6.1/go.mod h1:m3x9kRP4UFd7JODJL0yBAZqE7wTw+S37uAE90cTx7OA=
Expand Down Expand Up @@ -985,6 +991,7 @@ google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM
google.golang.org/grpc v1.33.0 h1:IBKSUNL2uBS2DkJBncPP+TwT0sp9tgA8A75NjHt6umg=
google.golang.org/grpc v1.33.0/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/grpc v1.35.0 h1:TwIQcH3es+MojMVojxxfQ3l3OF2KzlRxML2xZq0kRo8=
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
Expand Down
18 changes: 1 addition & 17 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}

// module accounts that are allowed to receive tokens
allowedReceivingModAcc = map[string]bool{
distrtypes.ModuleName: true,
}
)

var (
Expand Down Expand Up @@ -275,7 +270,7 @@ func NewAgoricApp(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms,
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(),
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(),
)
stakingKeeper := stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
Expand Down Expand Up @@ -580,17 +575,6 @@ func (app *GaiaApp) ModuleAccountAddrs() map[string]bool {
return modAccAddrs
}

// BlockedAddrs returns all the app's module account addresses that are not
// allowed to receive external tokens.
func (app *GaiaApp) BlockedAddrs() map[string]bool {
blockedAddrs := make(map[string]bool)
for acc := range maccPerms {
blockedAddrs[authtypes.NewModuleAddress(acc).String()] = !allowedReceivingModAcc[acc]
}

return blockedAddrs
}

// LegacyAmino returns GaiaApp's amino codec.
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
Expand Down
4 changes: 2 additions & 2 deletions golang/cosmos/daemon/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@ func createSimappAndExport(
encCfg.Marshaler = codec.NewProtoCodec(encCfg.InterfaceRegistry)
var gaiaApp *gaia.GaiaApp
if height != -1 {
gaiaApp = gaia.NewGaiaApp(logger, db, traceStore, false, map[int64]bool{}, "", uint(1), encCfg, appOpts)
gaiaApp = gaia.NewGaiaApp(logger, db, traceStore, false, map[int64]bool{}, "", cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts)

if err := gaiaApp.LoadHeight(height); err != nil {
return servertypes.ExportedApp{}, err
}
} else {
gaiaApp = gaia.NewGaiaApp(logger, db, traceStore, true, map[int64]bool{}, "", uint(1), encCfg, appOpts)
gaiaApp = gaia.NewGaiaApp(logger, db, traceStore, true, map[int64]bool{}, "", cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts)
}

return gaiaApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs)
Expand Down
23 changes: 12 additions & 11 deletions packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
makeEchoConnectionHandler,
} from '@agoric/swingset-vat/src/vats/network';
import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';

// this will return { undefined } until `ag-solo set-gci-ingress`
// has been run to update gci.js
Expand All @@ -24,7 +25,7 @@ const PROVISIONER_INDEX = 1;

function makeVattpFrom(vats) {
const { vattp, comms } = vats;
return harden({
return Far('vattp', {
makeNetworkHost(allegedName, console = undefined) {
return E(vattp).makeNetworkHost(allegedName, comms, console);
},
Expand Down Expand Up @@ -205,7 +206,7 @@ export function buildRootObject(vatPowers, vatParameters) {
}),
);

return harden({
return Far('chainBundler', {
async createUserBundle(_nickname, powerFlags = []) {
// Bind to some fresh ports (unspecified name) on the IBC implementation
// and provide them for the user to have.
Expand Down Expand Up @@ -238,12 +239,12 @@ export function buildRootObject(vatPowers, vatParameters) {
pursePetname: issuerNameToRecord.get(issuerName).pursePetname,
}));

const faucet = {
const faucet = Far('faucet', {
// A method to reap the spoils of our on-chain provisioning.
async tapFaucet() {
return paymentInfo;
},
};
});

const bundle = harden({
...additionalPowers,
Expand Down Expand Up @@ -275,7 +276,7 @@ export function buildRootObject(vatPowers, vatParameters) {
);
if (bridgeMgr) {
// We have access to the bridge, and therefore IBC.
const callbacks = harden({
const callbacks = Far('callbacks', {
downcall(method, obj) {
return bridgeMgr.toBridge('dibc', {
...obj,
Expand Down Expand Up @@ -304,7 +305,7 @@ export function buildRootObject(vatPowers, vatParameters) {
// Add an echo listener on our ibc-port network.
const port = await E(vats.network).bind('/ibc-port/echo');
E(port).addListener(
harden({
Far('listener', {
async onAccept(_port, _localAddr, _remoteAddr, _listenHandler) {
return harden(makeEchoConnectionHandler());
},
Expand All @@ -314,7 +315,7 @@ export function buildRootObject(vatPowers, vatParameters) {

if (bridgeMgr) {
// Register a provisioning handler over the bridge.
const handler = harden({
const handler = Far('provisioningHandler', {
async fromBridge(_srcID, obj) {
switch (obj.type) {
case 'PLEASE_PROVISION': {
Expand Down Expand Up @@ -355,7 +356,7 @@ export function buildRootObject(vatPowers, vatParameters) {
}

// This will allow dApp developers to register in their api/deploy.js
const httpRegCallback = {
const httpRegCallback = Far('httpRegCallback', {
doneLoading(subsystems) {
return E(vats.http).doneLoading(subsystems);
},
Expand All @@ -378,7 +379,7 @@ export function buildRootObject(vatPowers, vatParameters) {
E(vats.http).setWallet(wallet),
]);
},
};
});

return allComparable(
harden({
Expand All @@ -395,7 +396,7 @@ export function buildRootObject(vatPowers, vatParameters) {
);
}

return harden({
return Far('root', {
async bootstrap(vats, devices) {
const bridgeManager =
devices.bridge && makeBridgeManager(E, D, devices.bridge);
Expand Down Expand Up @@ -494,7 +495,7 @@ export function buildRootObject(vatPowers, vatParameters) {
// Allow some hardcoded client address connections into the chain.
// This is necessary for fake-chain, which does not have Cosmos SDK
// transactions to provision its client.
const demoProvider = harden({
const demoProvider = Far('demoProvider', {
// build a chain-side bundle for a client.
async getDemoBundle(nickname) {
if (giveMeAllTheAgoricPowers) {
Expand Down
5 changes: 3 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import makeStore from '@agoric/store';
import '@agoric/store/exported';
import { assert, details as X } from '@agoric/assert';
import { Far } from '@agoric/marshal';

/**
* @template T
Expand Down Expand Up @@ -53,7 +54,7 @@ export function makeBridgeManager(E, D, bridgeDevice) {
// No return value.
}

const bridgeHandler = harden({ inbound: bridgeInbound });
const bridgeHandler = Far('bridgeHandler', { inbound: bridgeInbound });

function callOutbound(dstID, obj) {
assert(bridgeDevice, X`bridge device not yet connected`);
Expand All @@ -70,7 +71,7 @@ export function makeBridgeManager(E, D, bridgeDevice) {
// We now manage the device.
D(bridgeDevice).registerInboundHandler(bridgeHandler);

return harden({
return Far('bridgeManager', {
toBridge(dstID, obj) {
return callOutbound(dstID, obj);
},
Expand Down
3 changes: 2 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// in its own makeHardener, etc.
import { makeCapTP } from '@agoric/captp/lib/captp';
import { E } from '@agoric/eventual-send';
import { Data } from '@agoric/marshal';

export const getCapTPHandler = (
send,
Expand All @@ -11,7 +12,7 @@ export const getCapTPHandler = (
const chans = new Map();
const doFallback = async (method, ...args) => {
if (!fallback) {
return {};
return Data({});
}
return E(fallback)[method](...args);
};
Expand Down
7 changes: 4 additions & 3 deletions packages/cosmic-swingset/lib/ag-solo/vats/ibc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import makeStore from '@agoric/store';
import { makePromiseKit } from '@agoric/promise-kit';
import { assert, details as X } from '@agoric/assert';
import { Far } from '@agoric/marshal';

import '@agoric/store/exported';
import '@agoric/swingset-vat/src/vats/network/types';
Expand Down Expand Up @@ -176,7 +177,7 @@ export function makeIBCProtocolHandler(E, rawCallIBCDevice) {
onReceive = withChannelReceiveQueue(onReceive);
}

return harden({
return Far('IBCConnectionHandler', {
async onOpen(conn, localAddr, remoteAddr, _handler) {
console.debug(
'onOpen Remote IBC Connection',
Expand Down Expand Up @@ -244,7 +245,7 @@ export function makeIBCProtocolHandler(E, rawCallIBCDevice) {
/**
* @type {ProtocolHandler}
*/
const protocol = harden({
const protocol = Far('ProtocolHandler', {
async onCreate(impl, _protocolHandler) {
console.debug('IBC onCreate');
protocolImpl = impl;
Expand Down Expand Up @@ -378,7 +379,7 @@ EOF
},
});

return harden({
return Far('IBCProtocolHandler', {
...protocol,
async fromBridge(srcID, obj) {
console.info('IBC fromBridge', srcID, obj);
Expand Down
3 changes: 2 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/lib-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { generateSparseInts } from '@agoric/sparse-ints';
import { assert, details as X, q } from '@agoric/assert';
import { Far } from '@agoric/marshal';
import makeStore from '@agoric/store';
import { models as crcmodels } from 'polycrc';

Expand Down Expand Up @@ -40,7 +41,7 @@ function makeBoard(seed = 0) {
const sparseInts = generateSparseInts(seed);

/** @type {Board} */
const board = harden({
const board = Far('Board', {
// Add if not already present
getId: value => {
if (!valToId.has(value)) {
Expand Down
3 changes: 2 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/vat-board.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Far } from '@agoric/marshal';
import { makeBoard } from './lib-board';

export function buildRootObject(_vatPowers) {
const board = makeBoard();
return harden({ getBoard: () => board });
return Far('board', { getBoard: () => board });
}
5 changes: 3 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-host.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright (C) 2018 Agoric, under Apache License 2.0

import { Far } from '@agoric/marshal';
import { makeContractHost } from '@agoric/spawner';

export function buildRootObject(vatPowers) {
return harden({
return Far('root', {
makeHost() {
return harden(makeContractHost(vatPowers));
return makeContractHost(vatPowers);
},
});
}
9 changes: 5 additions & 4 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { makeNotifierKit } from '@agoric/notifier';
import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { assert, details as X } from '@agoric/assert';
import { getReplHandler } from './repl';
import { getCapTPHandler } from './captp';
Expand Down Expand Up @@ -71,15 +72,15 @@ export function buildRootObject(vatPowers) {
urlToHandler.set(url, commandHandler);
}

return harden({
return Far('root', {
setCommandDevice(d) {
commandDevice = d;

const replHandler = getReplHandler(replObjects, send, vatPowers);
registerURLHandler(replHandler, '/private/repl');

// Assign the captp handler.
const captpHandler = harden({
const captpHandler = Far('captpHandler', {
getBootstrap(_otherSide, _meta) {
// Harden only our exported objects, and fetch them afresh each time.
return harden(exportedToCapTP);
Expand Down Expand Up @@ -113,7 +114,7 @@ export function buildRootObject(vatPowers) {
...decentralObjects, // TODO: Remove; replaced by .agoric
...privateObjects, // TODO: Remove; replaced by .local
...handyObjects,
agoric: { ...decentralObjects },
agoric: { ...decentralObjects }, // TODO: maybe needs Data()???
local: { ...privateObjects },
};

Expand Down Expand Up @@ -161,7 +162,7 @@ export function buildRootObject(vatPowers) {
try {
let channelHandle = channelIdToHandle.get(rawChannelID);
if (dispatcher === 'onOpen') {
channelHandle = harden({});
channelHandle = Far('channelHandle');
channelIdToHandle.set(rawChannelID, channelHandle);
channelHandleToId.set(channelHandle, rawChannelID);
} else if (dispatcher === 'onClose') {
Expand Down
Loading

0 comments on commit 83286e3

Please sign in to comment.