Skip to content

Commit

Permalink
Node: Initial guardiand changes for accounting (wormhole-foundation#2181
Browse files Browse the repository at this point in the history
)

* node: guardiand support for accounting

Change-Id: I97fe1f6d6d71a5803881ff4c793e3c30f22b14d8

* Node: Tie accounting into the guardian

Change-Id: I31600d18176f516b75b3eb046fd7ac6e54e1b133

* Node: accounting tests and metrics

Change-Id: Ieb139772edf464ed1ab202861babeaf0f857ad6b

* Node: minor tweak to accounting metrics

Change-Id: Iad2b7e34870734f0c5e5d538c0ac86269a9a4728

* Node: load accounting key

Change-Id: I228ce23e63b556d751000b97097202eda48650aa

* More work in progress

Change-Id: I85088d26c05cf02d26043cf6ee8c67efd13f2ea4

* Node: send observations to accounting contract

Change-Id: Ib90909c2ee705d5e2a7e6cf3a6ec4ba7519e2eb1

* Node: Fix lint error in accounting tests

Change-Id: Id73397cf45107243a9f68ba82bed3ccf2b0299b5

* Node: Need to copy libwasmvm.so

Change-Id: I2856c8964ca082f1f4014d6db9fb1b2dc4e64409

* Node: Rename wormchain to wormconn

Change-Id: I6782be733ebdd92b908228d3984a906aa4c795f7

* Node: moving accounting check after governor

Change-Id: I064c77d30514715c6f8b6b5da50806a5e1adf657

* Node: Add accounting status to heartbeat

Change-Id: I0ae3e476386cfaccc5c877ee1351dbe41c0358c7

* Node: start of accounting integration work

Change-Id: I8ad206eb7fc07aa9e1a2ebc321f2c490ec36b51e

* Node: More broadcast tx stuff

Change-Id: Id2cc83df859310c013665eaa9c6ce3033bb1d9c5

* Node: Can actually send a request to accounting

Change-Id: I6af5d59c53939f58b2f13ae501914bef260592f2

* Node: More accounting tx broadcast stuff

Change-Id: If758e49f8928807e87053320e9330c7208aad490

* Node: config changes for accounting

Change-Id: I2803cceb188d04c557a52aa9aa8ba7296da8879f

* Node: More accounting changes

Change-Id: Id979af0ec6ab8484bc094072f3febf39355351ca

* Node/Acct: Use new observation request format

* Node/acct: use new contract interface

* Node/acct: fix minor copy/paste error

* Node: Clean up comments and lint errors

* Node: disable accounting in dev by default

* Node: Fix test failure

* Remove test code

* Switch messages to debug, rename Run()

* check for "out of gas"

* Use worker routine to submit observations

* Rename mutex to reflect what it protects

* Create handleEvents func

* Remove FinalizeObservation

* Node/Acct: Trying to use tm library for watcher

* Node/acct: switch watcher to use tm library

* Node/Acct: Need separate WS parm for accounting

* Node/Acct: Fix compile error in tests

* Node/Acct: Minor rework

* Node: add wormchain as a dep to remove stale code

* Node/Acct: GS index is not correct in requests

* Node/Acct: Peg connection error metric

* Node/Acct: Add wormchain to node docker file

* Node/Acct: Fix for double base64 decode

* Node/Acct: Change public key to sender address

* Node/Acct: Fix lint error

* Node/Acct: key pass phrase change

* Node/Acct: Pass guardian index in obs req

* Node/Acct: No go on submit observation

* Node/Acct: Don't double encode tx_hash

* Node/Acct: Remove unneeded base64 encoding

* Node/Acct: handle submit channel overflow

* Node/Acct: Added a TODO to document a review issue

* Node/Acct: Fix for checking if channel is full

Co-authored-by: Conor Patrick <conorpp94@gmail.com>
  • Loading branch information
bruce-riley and conorpp authored Jan 16, 2023
1 parent 8777c22 commit 499c842
Show file tree
Hide file tree
Showing 29 changed files with 4,803 additions and 396 deletions.
1 change: 1 addition & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ if wormchain:
"guardian-validator",
port_forwards = [
port_forward(1319, container_port = 1317, name = "REST [:1319]", host = webHost),
port_forward(9090, container_port = 9090, name = "GRPC", host = webHost),
port_forward(26659, container_port = 26657, name = "TENDERMINT [:26659]", host = webHost)
],
resource_deps = [],
Expand Down
37 changes: 34 additions & 3 deletions devnet/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,32 @@ spec:
# mount shared between containers for runtime state
- name: node-rundir
emptyDir: {}
- name: node-keysdir
- name: node-bigtable-key
secret:
secretName: node-bigtable-key
optional: true
items:
- key: bigtable-key.json
path: bigtable-key.json
- name: node-wormchain-key
secret:
secretName: node-wormchain-key
optional: false
items:
- key: wormchainKey0
path: wormchainKey0
- key: wormchainKey1
path: wormchainKey1
containers:
- name: guardiand
image: guardiand-image
volumeMounts:
- mountPath: /run/node
name: node-rundir
- mountPath: /tmp/mounted-keys
name: node-keysdir
- mountPath: /tmp/mounted-keys/bigtable
name: node-bigtable-key
- mountPath: /tmp/mounted-keys/wormchain
name: node-wormchain-key
command:
- /guardiand
- node
Expand Down Expand Up @@ -96,6 +107,17 @@ spec:
# - ws://guardian-validator:26657/websocket
# - --wormchainLCD
# - http://guardian-validator:1317
# - --wormchainURL
# - guardian-validator:9090
# - --wormchainKeyPath
# - /tmp/mounted-keys/wormchain/wormchainKey
# - --wormchainKeyPassPhrase
# - test0000
# - --accountingWS
# - http://guardian-validator:26657
# - --accountingContract
# - wormhole1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjq4lyjmh
# - --accountingCheckEnabled=true
# - --terraWS
# - ws://terra-terrad:26657/websocket
# - --terraLCD
Expand Down Expand Up @@ -170,3 +192,12 @@ spec:
- containerPort: 2345
name: debugger
protocol: TCP
---
apiVersion: v1
kind: Secret
metadata:
name: node-wormchain-key
type: Opaque
data:
wormchainKey0: LS0tLS1CRUdJTiBURU5ERVJNSU5UIFBSSVZBVEUgS0VZLS0tLS0Ka2RmOiBiY3J5cHQKc2FsdDogNDc2ODc2NkE3OEZEN0ZBQjMwMUJGOTM5MUYwQ0Y2M0YKdHlwZTogc2VjcDI1NmsxCgpkbEZuN1ZqRk02RnJjYkdaVDRWeE5yRlE3SUhQS2RyVVBCRTYraW8yK0w0VFZqcis5emNIQTF3dzNubWtqNVFlCnVSekJWMjQyeUdTc3hNTTJZckI2Q1ZXdzlaWXJJY3JFeks1c0FuST0KPXB2aHkKLS0tLS1FTkQgVEVOREVSTUlOVCBQUklWQVRFIEtFWS0tLS0t
wormchainKey1: LS0tLS1CRUdJTiBURU5ERVJNSU5UIFBSSVZBVEUgS0VZLS0tLS0Ka2RmOiBiY3J5cHQKc2FsdDogMjMyRTU2NDMyMjBBNTcwRkVEQjFFMTFFOTNFM0E4NEIKdHlwZTogc2VjcDI1NmsxCgpBZjJ3aXNLdlBDOW4vaExYcDZaS1k5S091aVNYZG1lb3VvSzd3QVJ3cmNtTDV3MGs0YjFDSE5xTEp3ZXU1OEFGCkdTWGJsU3oySzNuWEl1V2hJZWtSNXE5WGRuUko4cGhSRWltbFNZST0KPU1vY1QKLS0tLS1FTkQgVEVOREVSTUlOVCBQUklWQVRFIEtFWS0tLS0tCg==
6 changes: 5 additions & 1 deletion node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go \

COPY node node
COPY sdk sdk
COPY wormchain wormchain

ARG GO_BUILD_ARGS=-race

RUN --mount=type=cache,target=/root/.cache --mount=type=cache,target=/go \
cd node && \
go build ${GO_BUILD_ARGS} -gcflags="all=-N -l" --ldflags '-extldflags "-Wl,--allow-multiple-definition" -X "github.com/certusone/wormhole/node/cmd/guardiand.Build=dev"' -mod=readonly -o /guardiand github.com/certusone/wormhole/node
go build ${GO_BUILD_ARGS} -gcflags="all=-N -l" --ldflags '-extldflags "-Wl,--allow-multiple-definition" -X "github.com/certusone/wormhole/node/cmd/guardiand.Build=dev"' -mod=readonly -o /guardiand github.com/certusone/wormhole/node && \
go get github.com/CosmWasm/wasmvm@v1.0.0 && \
cp /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.0.0/api/libwasmvm.x86_64.so /usr/lib/

# Only export the final binary (+ shared objects). This reduces the image size
# from ~1GB to ~150MB.
Expand All @@ -33,6 +36,7 @@ FROM scratch as export
# have to copy all the dynamic libraries
COPY --from=build /lib/* /lib/
COPY --from=build /lib64/* /lib64/
COPY --from=build /usr/lib/libwasmvm.x86_64.so /usr/lib/

# Copy the shells as entrypoints, but no utilities are necessary
COPY --from=build /bin/bash /bin/dash /bin/sh /bin/
Expand Down
6 changes: 3 additions & 3 deletions node/cmd/guardiand/adminclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"strings"
"time"

ethcommon "github.com/ethereum/go-ethereum/common"

"github.com/cosmos/cosmos-sdk/types"
"github.com/davecgh/go-spew/spew"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/mr-tron/base58"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -210,7 +210,7 @@ func runSignWormchainValidatorAddress(cmd *cobra.Command, args []string) error {
if err != nil {
return fmt.Errorf("failed to load guardian key: %w", err)
}
addr, err := getFromBech32(wormchainAddress, "wormhole")
addr, err := types.GetFromBech32(wormchainAddress, "wormhole")
if err != nil {
return fmt.Errorf("failed to decode wormchain address: %w", err)
}
Expand Down
Loading

0 comments on commit 499c842

Please sign in to comment.