Skip to content

Commit

Permalink
penumbra - pclientd integration (#480)
Browse files Browse the repository at this point in the history
* wip penumbra pclientd

* Updates for 049-pasiphae

* build: bring in ability to pull penumbra protos & gen code

* WIP: implementing missing penumbra methods + smoke test

* WIP: debugging npe in grpc calls

* WIP: balance by addr returns EOF

* update penumbra dep & change rust log level to debug

* WIP: debugging address weirdness

* use raw byte slices in getAddress

we can rather naively convert address strings to byte slices, and not
have to worry about bech32m encoding: the protos will accept the raw
byte slice as sufficient to reconstitute the address.

sprinkled around some debug logging to make sense of what's breaking.

* more debugging around allocations

* fix allocations file format

pd was *silently failing* to process the weirdly constructed csv file.
the golang code was inserting liternal `\n`s rather than newlines.
pd should definitely error on this.

A previous debugging commit touched up the allocations indexing logic,
which wasn't necessary to fix the bug, but sure made things more
comprehensible. This commit restores the original allocations to the
pre-debugging values, aiui.

* handle grpc streaming request for balance

Updates the GetBalanceByAddress request to handle a gRPC streaming
request. Sadly the Penumbra docs aren't very clear that this method
returns a stream; we'll work on that! For now, the
for-loop-and-break-on-EOF seems a sufficiently idiomatic pattern for our
needs. Still to come is making the balance info intelligble.

* fix: get pcli balance checks working + remove debug output

* remove more debug output

* cleanup tx build, auth, broadcast logic + implement func for handling hi/lo amount bytes

* update protos

* filter balances for target denom

* fix proto gen issue in client.pb.go

* get balance checks completely working

* update penumbra 0.57.0, pull new protos, adjust code to account for bigint and rpc changes

* WIP: working on testing local transfers on penumbra

* get balance checks working again + adjust test assertions

* fix get addr and update protos

* update protos and continue work on smoke test

* update to penumbra v0.60.0 and begin cleanup

* more cleanup

* update protos for ictest v8

* update penumbra protos for ibc-go v8 support

* fix: adjust polkadot docker calls to pass env arg

* fix: adjust penumbra implementation with new assumptions in mind

* chore: remove unused code and cleanup comments

* chore: remove unnecessary todos

* chore: use more descriptive homedir for pclientd config files

* chore: implement HomeDir method + utilize const for abci port

---------

Co-authored-by: jtieri <[email protected]>
Co-authored-by: Conor Schaefer <[email protected]>
Co-authored-by: Justin Tieri <[email protected]>
  • Loading branch information
4 people authored Sep 22, 2023
1 parent 23178ec commit fa08aa0
Show file tree
Hide file tree
Showing 34 changed files with 93,796 additions and 194 deletions.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
DOCKER := $(shell which docker)
protoVer=0.13.2
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

default: help

.PHONY: help
Expand All @@ -23,4 +28,9 @@ docker-mac-nuke: ## macOS only. Try docker-reset first. Kills and restarts Docke

.PHONY: gen
gen: ## Run code generators
go generate ./...
go generate ./...

.PHONY: proto-gen
proto-gen: ## Generate code from protos
@echo "Generating Protobuf files"
@$(protoImage) sh ./scripts/protocgen.sh
2 changes: 1 addition & 1 deletion chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ func (tn *ChainNode) CreateNodeContainer(ctx context.Context) error {
cmd = []string{chainCfg.Bin, "start", "--home", tn.HomeDir(), "--x-crisis-skip-assert-invariants"}
}

return tn.containerLifecycle.CreateContainer(ctx, tn.TestName, tn.NetworkID, tn.Image, sentryPorts, tn.Bind(), tn.HostName(), cmd)
return tn.containerLifecycle.CreateContainer(ctx, tn.TestName, tn.NetworkID, tn.Image, sentryPorts, tn.Bind(), tn.HostName(), cmd, nil)
}

func (tn *ChainNode) StartContainer(ctx context.Context) error {
Expand Down
2 changes: 1 addition & 1 deletion chain/cosmos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (s *SidecarProcess) logger() *zap.Logger {
}

func (s *SidecarProcess) CreateContainer(ctx context.Context) error {
return s.containerLifecycle.CreateContainer(ctx, s.TestName, s.NetworkID, s.Image, s.ports, s.Bind(), s.HostName(), s.startCmd)
return s.containerLifecycle.CreateContainer(ctx, s.TestName, s.NetworkID, s.Image, s.ports, s.Bind(), s.HostName(), s.startCmd, nil)
}

func (s *SidecarProcess) StartContainer(ctx context.Context) error {
Expand Down
39 changes: 36 additions & 3 deletions chain/internal/tendermint/tendermint_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
rpcclient "github.com/cometbft/cometbft/rpc/client"
rpchttp "github.com/cometbft/cometbft/rpc/client/http"
libclient "github.com/cometbft/cometbft/rpc/jsonrpc/client"
volumetypes "github.com/docker/docker/api/types/volume"
dockerclient "github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
"github.com/hashicorp/go-version"
Expand All @@ -39,13 +40,45 @@ type TendermintNode struct {
containerLifecycle *dockerutil.ContainerLifecycle
}

func NewTendermintNode(log *zap.Logger, i int, c ibc.Chain, dockerClient *dockerclient.Client, networkID string, testName string, image ibc.DockerImage) *TendermintNode {
func NewTendermintNode(
ctx context.Context,
log *zap.Logger,
i int,
c ibc.Chain,
dockerClient *dockerclient.Client,
networkID string,
testName string,
image ibc.DockerImage,
) (*TendermintNode, error) {
tn := &TendermintNode{Log: log, Index: i, Chain: c,
DockerClient: dockerClient, NetworkID: networkID, TestName: testName, Image: image}

tn.containerLifecycle = dockerutil.NewContainerLifecycle(log, dockerClient, tn.Name())

return tn
tv, err := dockerClient.VolumeCreate(ctx, volumetypes.CreateOptions{
Labels: map[string]string{
dockerutil.CleanupLabel: testName,
dockerutil.NodeOwnerLabel: tn.Name(),
},
})
if err != nil {
return nil, fmt.Errorf("creating tendermint volume: %w", err)
}
tn.VolumeName = tv.Name
if err := dockerutil.SetVolumeOwner(ctx, dockerutil.VolumeOwnerOptions{
Log: log,

Client: dockerClient,

VolumeName: tn.VolumeName,
ImageRef: tn.Image.Ref(),
TestName: tn.TestName,
UidGid: tn.Image.UidGid,
}); err != nil {
return nil, fmt.Errorf("set tendermint volume owner: %w", err)
}

return tn, nil
}

// TendermintNodes is a collection of TendermintNode
Expand Down Expand Up @@ -226,7 +259,7 @@ func (tn *TendermintNode) CreateNodeContainer(ctx context.Context, additionalFla
cmd := []string{chainCfg.Bin, "start", "--home", tn.HomeDir()}
cmd = append(cmd, additionalFlags...)

return tn.containerLifecycle.CreateContainer(ctx, tn.TestName, tn.NetworkID, tn.Image, sentryPorts, tn.Bind(), tn.HostName(), cmd)
return tn.containerLifecycle.CreateContainer(ctx, tn.TestName, tn.NetworkID, tn.Image, sentryPorts, tn.Bind(), tn.HostName(), cmd, nil)
}

func (tn *TendermintNode) StopContainer(ctx context.Context) error {
Expand Down
Loading

0 comments on commit fa08aa0

Please sign in to comment.