Skip to content

Commit 6880646

Browse files
committed
feat(cosmos)!: compile agd binary to supercede ag-chain-cosmos
1 parent 868964e commit 6880646

File tree

8 files changed

+61
-63
lines changed

8 files changed

+61
-63
lines changed

golang/cosmos/Makefile

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ VersionName := $(shell echo "$(NAME)" | sed -e 's/[^A-Za-z0-9]//g')
2323

2424
# process linker flags
2525
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(VersionName) \
26-
-X github.com/cosmos/cosmos-sdk/version.AppName=agoricd \
26+
-X github.com/cosmos/cosmos-sdk/version.AppName=agd \
2727
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
2828
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
2929
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"
@@ -42,8 +42,8 @@ BUILD_FLAGS_HELPER := -buildmode=exe -tags "$(build_tags)" -gcflags '$(gcflags)
4242

4343
all: compile-chain
4444

45-
compile-chain: compile-agoricd compile-helper compile-daemon
46-
compile-go: compile-agoricd compile-helper compile-libdaemon
45+
compile-chain: compile-agd compile-helper compile-daemon
46+
compile-go: compile-agd compile-helper compile-libdaemon
4747
compile-node: node-compile-gyp
4848

4949
compile-daemon: compile-libdaemon node-compile-gyp
@@ -56,11 +56,11 @@ node-compile-gyp:
5656
npm run build:gyp; \
5757
fi
5858

59-
compile-agoricd: go-mod-cache
60-
go build -v $(MOD_READONLY) $(BUILD_FLAGS_HELPER) -o build/agoricd ./cmd/agoricd
59+
compile-agd: go-mod-cache
60+
go build -v $(MOD_READONLY) $(BUILD_FLAGS_HELPER) -o build/agd ./cmd/agd
6161

62-
install-agoricd: go-mod-cache
63-
go install -v $(MOD_READONLY) $(BUILD_FLAGS_HELPER) ./cmd/agoricd
62+
install-agd: go-mod-cache
63+
go install -v $(MOD_READONLY) $(BUILD_FLAGS_HELPER) ./cmd/agd
6464

6565
# Only run from the package.json build:gyp script.
6666
compile-gyp:

golang/cosmos/app/app.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func init() {
225225
stdlog.Println("Failed to get home dir %2", err)
226226
}
227227

228-
DefaultNodeHome = filepath.Join(userHomeDir, ".ag-chain-cosmos")
228+
DefaultNodeHome = filepath.Join(userHomeDir, ".agoric")
229229
}
230230

231231
// NewGaiaApp returns a reference to an initialized Gaia.

golang/cosmos/cmd/agd/main.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"os/exec"
6+
"syscall"
7+
8+
"github.com/tendermint/tendermint/libs/log"
9+
10+
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
11+
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon"
12+
daemoncmd "github.com/Agoric/agoric-sdk/golang/cosmos/daemon/cmd"
13+
)
14+
15+
func main() {
16+
// We need to delegate to our default app for running the actual chain.
17+
daemoncmd.OnStartHook = func(logger log.Logger) {
18+
logger.Info("Start chain delegating to ag-chain-cosmos executable")
19+
20+
binary, lookErr := exec.LookPath("ag-chain-cosmos")
21+
if lookErr != nil {
22+
panic(lookErr)
23+
}
24+
25+
args := []string{"ag-chain-cosmos", "--home", gaia.DefaultNodeHome}
26+
args = append(args, os.Args[1:]...)
27+
28+
execErr := syscall.Exec(binary, args, os.Environ())
29+
if execErr != nil {
30+
panic(execErr)
31+
}
32+
}
33+
34+
daemon.RunWithController(nil)
35+
}

golang/cosmos/cmd/agoricd/main.go

-50
This file was deleted.

golang/cosmos/cmd/helper/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
88
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon"
9+
daemoncmd "github.com/Agoric/agoric-sdk/golang/cosmos/daemon/cmd"
910
)
1011

1112
func main() {
@@ -15,5 +16,6 @@ func main() {
1516
}
1617

1718
gaia.DefaultNodeHome = filepath.Join(userHomeDir, ".ag-cosmos-helper")
19+
daemoncmd.AppName = "ag-cosmos-helper"
1820
daemon.Run()
1921
}

golang/cosmos/cmd/libdaemon/main.go

+11
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import (
1313
"encoding/json"
1414
"errors"
1515
"os"
16+
"path/filepath"
1617

18+
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
1719
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon"
20+
daemoncmd "github.com/Agoric/agoric-sdk/golang/cosmos/daemon/cmd"
1821
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
1922
)
2023

@@ -30,6 +33,14 @@ var lastReply = 0
3033

3134
//export RunAgCosmosDaemon
3235
func RunAgCosmosDaemon(nodePort C.int, toNode C.sendFunc, cosmosArgs []*C.char) C.int {
36+
userHomeDir, err := os.UserHomeDir()
37+
if err != nil {
38+
panic(err)
39+
}
40+
41+
gaia.DefaultNodeHome = filepath.Join(userHomeDir, ".ag-chain-cosmos")
42+
daemoncmd.AppName = "ag-chain-cosmos"
43+
3344
// FIXME: Decouple the sending logic from the Cosmos app.
3445
sendToNode := func(needReply bool, str string) (string, error) {
3546
var rPort int

golang/cosmos/daemon/cmd/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
// Sender is a function that sends a request to the controller.
4040
type Sender func(needReply bool, str string) (string, error)
4141

42-
var AppName = "ag-chain-cosmos"
42+
var AppName = "agd"
4343
var OnStartHook func(log.Logger)
4444

4545
// NewRootCmd creates a new root command for simd. It is called once in the

golang/cosmos/x/vbank/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ not be bank purses by default.
5656
To use Cosmos governance to change the `fee_epoch_duration_blocks` value:
5757

5858
```sh
59-
$ ag-cosmos-helper query vbank params
59+
$ agd query vbank params
6060
{"fee_epoch_duration_blocks":"720"}
6161
$ cat <<EOF > epoch-duration-proposal.json
6262
{
@@ -72,11 +72,11 @@ $ cat <<EOF > epoch-duration-proposal.json
7272
"deposit": "1000000ubld"
7373
}
7474
EOF
75-
$ ag-cosmos-helper tx gov submit-proposal param-change epochdur.json --from=mykey --chain-id=agoric
75+
$ agd tx gov submit-proposal param-change epochdur.json --from=mykey --chain-id=agoric
7676
# Then vote on the proposal.
77-
$ ag-cosmos-helper tx vote ...
77+
$ agd tx vote ...
7878
# After passing,
79-
$ ag-cosmos-helper query vbank params
79+
$ agd query vbank params
8080
{"fee_epoch_duration_blocks":"30"}
8181
$
8282
```

0 commit comments

Comments
 (0)