@agoric/cosmos 0.34.1 → 0.34.2-dev-8c14632.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/Makefile +2 -3
- package/agoric/config.go +35 -0
- package/ante/ante.go +65 -0
- package/ante/expected_keepers.go +26 -0
- package/ante/fee.go +96 -0
- package/ante/inbound.go +137 -0
- package/ante/inbound_test.go +219 -0
- package/ante/vm_admission.go +64 -0
- package/binding.gyp.in +29 -4
- package/buf.work.yaml +4 -0
- package/cmd/agd/find_binary.go +22 -7
- package/cmd/agd/main.go +2 -3
- package/git-revision.txt +1 -0
- package/go.mod +155 -0
- package/go.sum +1225 -0
- package/package.json +6 -18
- package/tools/tools.go +11 -0
- package/types/events.go +41 -0
- package/upgradegaia.sh +66 -0
- package/vm/controller.go +80 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.34.
|
|
3
|
+
"version": "0.34.2-dev-8c14632.0+8c14632",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test": "exit 0",
|
|
14
|
+
"build:all": "make",
|
|
14
15
|
"build:gyp": "make compile-gyp",
|
|
15
16
|
"build:gyp-debug": "make compile-gyp GYP_DEBUG=--debug",
|
|
16
17
|
"test:xs": "exit 0",
|
|
18
|
+
"prepack": "git rev-parse --short HEAD > git-revision.txt && rm -rf build",
|
|
19
|
+
"postpack": "git clean -f git-revision.txt",
|
|
17
20
|
"build": "exit 0",
|
|
18
21
|
"lint-fix": "yarn lint:eslint --fix",
|
|
19
22
|
"lint": "eslint '**/*.{cjs,js}'"
|
|
20
23
|
},
|
|
21
24
|
"dependencies": {
|
|
22
|
-
"bindings": "^1.2.1"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"esm": "agoric-labs/esm#Agoric-built",
|
|
25
|
+
"bindings": "^1.2.1",
|
|
26
26
|
"napi-thread-safe-callback": "0.0.6",
|
|
27
27
|
"node-addon-api": "^1.7.1"
|
|
28
28
|
},
|
|
@@ -32,20 +32,8 @@
|
|
|
32
32
|
"url": "https://github.com/Agoric/agoric-sdk/issues"
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/Agoric/agoric-sdk/tree/HEAD/golang/cosmos",
|
|
35
|
-
"files": [
|
|
36
|
-
"Makefile*",
|
|
37
|
-
"app",
|
|
38
|
-
"binding.gyp.in",
|
|
39
|
-
"cmd",
|
|
40
|
-
"daemon",
|
|
41
|
-
"proto",
|
|
42
|
-
"scripts",
|
|
43
|
-
"src",
|
|
44
|
-
"third_party",
|
|
45
|
-
"x"
|
|
46
|
-
],
|
|
47
35
|
"publishConfig": {
|
|
48
36
|
"access": "public"
|
|
49
37
|
},
|
|
50
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "8c14632298cfb982f91dc0ef271681703237a93f"
|
|
51
39
|
}
|
package/tools/tools.go
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// +build tools
|
|
2
|
+
//
|
|
3
|
+
// This file exists only to make references to tool modules we need.
|
|
4
|
+
|
|
5
|
+
package tools
|
|
6
|
+
|
|
7
|
+
import (
|
|
8
|
+
_ "github.com/golang/protobuf/protoc-gen-go"
|
|
9
|
+
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway"
|
|
10
|
+
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"
|
|
11
|
+
)
|
package/types/events.go
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package types
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
|
|
6
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
const (
|
|
10
|
+
EventTypeStateChange = "state_change"
|
|
11
|
+
|
|
12
|
+
AttributeKeyStoreName = "store"
|
|
13
|
+
AttributeKeyStoreSubkey = "key"
|
|
14
|
+
AttributeKeyAnchoredKey = "anckey"
|
|
15
|
+
AttributeKeyUnprovedValue = "value"
|
|
16
|
+
|
|
17
|
+
// We chose \1 so that it is not a valid character in a vstorage path.
|
|
18
|
+
AnchoredKeyStart = "\x01"
|
|
19
|
+
AnchoredKeyEnd = AnchoredKeyStart
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
func NewStateChangeEvent(storeName string, subkey, value []byte) sdk.Event {
|
|
23
|
+
// This is a hack to allow CONTAINS event queries to match the
|
|
24
|
+
// beginning or end of the subkey, enabling a handy OR of changes to a
|
|
25
|
+
// vstorage path's immediate children.
|
|
26
|
+
//
|
|
27
|
+
// FIXME: add string value ranges to Tendermint event queries instead.
|
|
28
|
+
anchoredKey := bytes.Join([][]byte{
|
|
29
|
+
[]byte(AnchoredKeyStart),
|
|
30
|
+
subkey,
|
|
31
|
+
[]byte(AnchoredKeyEnd),
|
|
32
|
+
}, []byte{})
|
|
33
|
+
|
|
34
|
+
return sdk.NewEvent(
|
|
35
|
+
EventTypeStateChange,
|
|
36
|
+
sdk.NewAttribute(AttributeKeyStoreName, storeName),
|
|
37
|
+
sdk.NewAttribute(AttributeKeyStoreSubkey, string(subkey)),
|
|
38
|
+
sdk.NewAttribute(AttributeKeyAnchoredKey, string(anchoredKey)),
|
|
39
|
+
sdk.NewAttribute(AttributeKeyUnprovedValue, string(value)),
|
|
40
|
+
)
|
|
41
|
+
}
|
package/upgradegaia.sh
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#! /bin/bash
|
|
2
|
+
# 3-way-merge changes from current repo to agoric-sdk/golang/cosmos
|
|
3
|
+
#
|
|
4
|
+
# Usage: ./upgradegaia.sh <FROM_BRANCH> <TO_BRANCH>
|
|
5
|
+
# Such as:
|
|
6
|
+
# cd ~/src/gaia
|
|
7
|
+
# /path/to/agoric-sdk/golang/cosmos/upgradegaia.sh release/v6.0.0-rc3 release/v6.0.0
|
|
8
|
+
set -ueo pipefail
|
|
9
|
+
|
|
10
|
+
test $# -eq 2 || {
|
|
11
|
+
echo "Usage: $0 <FROM_BRANCH> <TO_BRANCH>" 1>&2
|
|
12
|
+
exit 1
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
FROM_BRANCH="$1"
|
|
16
|
+
TO_BRANCH="$2"
|
|
17
|
+
|
|
18
|
+
thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
|
|
19
|
+
tmp="$(mktemp -dt upgradegaia.XXXXXX)"
|
|
20
|
+
|
|
21
|
+
echo "Get the Gaia files from $FROM_BRANCH and $TO_BRANCH"
|
|
22
|
+
for tag in "$FROM_BRANCH" "$TO_BRANCH"; do
|
|
23
|
+
qtag=${tag//\//_}
|
|
24
|
+
for root in Makefile app cmd/gaiad; do
|
|
25
|
+
case "$root" in
|
|
26
|
+
Makefile) echo "$root" ;;
|
|
27
|
+
*) git ls-tree --name-only --full-tree -r "$tag:$root" | sed -e "s!^!$root/!" ;;
|
|
28
|
+
esac
|
|
29
|
+
done | while read -r src; do
|
|
30
|
+
# echo "$src"
|
|
31
|
+
dst="$tmp/$qtag/$src"
|
|
32
|
+
echo "extracting $dst"
|
|
33
|
+
mkdir -p "$(dirname "$dst")"
|
|
34
|
+
git cat-file blob "$tag:$src" > "$dst"
|
|
35
|
+
done
|
|
36
|
+
done
|
|
37
|
+
|
|
38
|
+
echo "Compute 3-way diffs between Gaia and us"
|
|
39
|
+
(cd "$tmp/${FROM_BRANCH//\//_}" && find . -type f -print) | \
|
|
40
|
+
while read -r src; do
|
|
41
|
+
# echo "$src"
|
|
42
|
+
case "$src" in
|
|
43
|
+
./cmd/gaiad/*) our=${src//cmd\/gaiad/daemon} ;;
|
|
44
|
+
*) our=$src ;;
|
|
45
|
+
esac
|
|
46
|
+
|
|
47
|
+
new="$tmp/diff3/$our"
|
|
48
|
+
echo "creating $new"
|
|
49
|
+
mkdir -p "$(dirname "$new")"
|
|
50
|
+
status=0
|
|
51
|
+
diff3 -mE \
|
|
52
|
+
"$thisdir/$our" \
|
|
53
|
+
"$tmp/${FROM_BRANCH//\//_}/$src" \
|
|
54
|
+
"$tmp/${TO_BRANCH//\//_}/$src" \
|
|
55
|
+
> "$new" || status=$?
|
|
56
|
+
if [ $status -ge 2 ]; then
|
|
57
|
+
exit "$status"
|
|
58
|
+
fi
|
|
59
|
+
done
|
|
60
|
+
|
|
61
|
+
# Display some hints.
|
|
62
|
+
echo "=== Now you can run:"
|
|
63
|
+
set -x
|
|
64
|
+
: cp -a "$tmp/diff3/." "$thisdir/"
|
|
65
|
+
: git diff --stat
|
|
66
|
+
: git commit -am "Upgrade to \`$TO_BRANCH\`"
|
package/vm/controller.go
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package vm
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
|
|
6
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
type ControllerContext struct {
|
|
10
|
+
Context sdk.Context
|
|
11
|
+
StoragePort int
|
|
12
|
+
IBCChannelHandlerPort int
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type ControllerAdmissionMsg interface {
|
|
16
|
+
sdk.Msg
|
|
17
|
+
CheckAdmissibility(sdk.Context, interface{}) error
|
|
18
|
+
|
|
19
|
+
// GetInboundMsgCount returns the number of Swingset messages which will
|
|
20
|
+
// be added to the inboundQueue.
|
|
21
|
+
GetInboundMsgCount() int32
|
|
22
|
+
|
|
23
|
+
// IsHighPriority returns whether the message should be considered for
|
|
24
|
+
// high priority processing, including bypass of some inbound checks
|
|
25
|
+
// and queueing on higher priority queues.
|
|
26
|
+
IsHighPriority(sdk.Context, interface{}) (bool, error)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Jsonable is a value, j, that can be passed through json.Marshal(j).
|
|
30
|
+
type Jsonable interface{}
|
|
31
|
+
|
|
32
|
+
// ActionPusher enqueues data for later consumption by the controller.
|
|
33
|
+
type ActionPusher func(ctx sdk.Context, action Jsonable) error
|
|
34
|
+
|
|
35
|
+
var controllerContext ControllerContext
|
|
36
|
+
|
|
37
|
+
type PortHandler interface {
|
|
38
|
+
Receive(*ControllerContext, string) (string, error)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
var portToHandler = make(map[int]PortHandler)
|
|
42
|
+
var portToName = make(map[int]string)
|
|
43
|
+
var nameToPort = make(map[string]int)
|
|
44
|
+
var lastPort = 0
|
|
45
|
+
|
|
46
|
+
func SetControllerContext(ctx sdk.Context) func() {
|
|
47
|
+
// We are only called by the controller, so we assume that it is billing its
|
|
48
|
+
// own meter usage.
|
|
49
|
+
controllerContext.Context = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
|
50
|
+
return func() {
|
|
51
|
+
controllerContext.Context = sdk.Context{}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
func GetPort(name string) int {
|
|
56
|
+
return nameToPort[name]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
func RegisterPortHandler(name string, portHandler PortHandler) int {
|
|
60
|
+
lastPort++
|
|
61
|
+
portToHandler[lastPort] = portHandler
|
|
62
|
+
portToName[lastPort] = name
|
|
63
|
+
nameToPort[name] = lastPort
|
|
64
|
+
return lastPort
|
|
65
|
+
}
|
|
66
|
+
func UnregisterPortHandler(portNum int) error {
|
|
67
|
+
delete(portToHandler, portNum)
|
|
68
|
+
name := portToName[portNum]
|
|
69
|
+
delete(portToName, portNum)
|
|
70
|
+
delete(nameToPort, name)
|
|
71
|
+
return nil
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
func ReceiveFromController(portNum int, msg string) (string, error) {
|
|
75
|
+
handler := portToHandler[portNum]
|
|
76
|
+
if handler == nil {
|
|
77
|
+
return "", fmt.Errorf("Unregistered port %d", portNum)
|
|
78
|
+
}
|
|
79
|
+
return handler.Receive(&controllerContext, msg)
|
|
80
|
+
}
|