Skip to content

Commit

Permalink
Merge pull request lightninglabs#609 from lightninglabs/multi-bugfix
Browse files Browse the repository at this point in the history
multi: add proof courier addr to CLI, fix gRPC max message size, fix linter
  • Loading branch information
guggero authored Oct 24, 2023
2 parents c7d57c5 + 123681d commit 34f3283
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 28 deletions.
23 changes: 15 additions & 8 deletions cmd/tapcli/addrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ var addrCommands = []cli.Command{
}

const (
groupKeyName = "group_key"

amtName = "amt"

assetVersionName = "asset_version"
groupKeyName = "group_key"
amtName = "amt"
assetVersionName = "asset_version"
proofCourierAddrName = "proof_courier_addr"
)

var newAddrCommand = cli.Command{
Expand All @@ -53,6 +52,13 @@ var newAddrCommand = cli.Command{
Name: assetVersionName,
Usage: "the asset version of the asset to receive",
},
cli.StringFlag{
Name: proofCourierAddrName,
Usage: "(optional) the address of the proof courier " +
"to use for this specific address, if the " +
"default proof courier should be " +
"overwritten; format: protocol://host:port",
},
},
Action: newAddr,
}
Expand Down Expand Up @@ -80,9 +86,10 @@ func newAddr(ctx *cli.Context) error {
}

addr, err := client.NewAddr(ctxc, &taprpc.NewAddrRequest{
AssetId: assetID,
Amt: ctx.Uint64(amtName),
AssetVersion: assetVersion,
AssetId: assetID,
Amt: ctx.Uint64(amtName),
AssetVersion: assetVersion,
ProofCourierAddr: ctx.String(proofCourierAddrName),
})
if err != nil {
return fmt.Errorf("unable to make addr: %w", err)
Expand Down
7 changes: 1 addition & 6 deletions cmd/tapcli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
wrpc "github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
"github.com/lightningnetwork/lnd/lncfg"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/macaroons"
"github.com/lightningnetwork/lnd/tor"
"github.com/urfave/cli"
Expand Down Expand Up @@ -49,10 +48,6 @@ const (
var (
defaultTapdDir = btcutil.AppDataDir("tapd", false)
defaultTLSCertPath = filepath.Join(defaultTapdDir, defaultTLSCertFilename)

// maxMsgRecvSize is the largest message our client will receive. We
// set this to 200MiB atm.
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(lnrpc.MaxGrpcMsgSize)
)

func fatal(err error) {
Expand Down Expand Up @@ -202,7 +197,7 @@ func getClientConn(ctx *cli.Context, skipMacaroons bool) *grpc.ClientConn {
opts = append(opts, grpc.WithContextDialer(genericDialer))
}

opts = append(opts, grpc.WithDefaultCallOptions(maxMsgRecvSize))
opts = append(opts, grpc.WithDefaultCallOptions(tap.MaxMsgReceiveSize))

conn, err := grpc.Dial(profile.RPCServer, opts...)
if err != nil {
Expand Down
8 changes: 2 additions & 6 deletions itest/loadtest/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import (
"time"

"github.com/btcsuite/btcd/rpcclient"
tap "github.com/lightninglabs/taproot-assets"
"github.com/lightninglabs/taproot-assets/itest"
"github.com/lightninglabs/taproot-assets/taprpc"
"github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"
"github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
"github.com/lightninglabs/taproot-assets/taprpc/universerpc"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/macaroons"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
Expand All @@ -26,10 +26,6 @@ import (
)

var (
// maxMsgRecvSize is the largest message our client will receive. We
// set this to 200MiB atm.
maxMsgRecvSize = grpc.MaxCallRecvMsgSize(lnrpc.MaxGrpcMsgSize)

// defaultTimeout is a timeout that will be used for various wait
// scenarios where no custom timeout value is defined.
defaultTimeout = time.Second * 10
Expand Down Expand Up @@ -147,7 +143,7 @@ func getTapClient(t *testing.T, ctx context.Context,
// Create a dial options array.
opts := []grpc.DialOption{
grpc.WithTransportCredentials(creds),
grpc.WithDefaultCallOptions(maxMsgRecvSize),
grpc.WithDefaultCallOptions(tap.MaxMsgReceiveSize),
}

if cfg.MacPath != "" {
Expand Down
2 changes: 1 addition & 1 deletion itest/tapd_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func defaultDialOptions(serverCertPath, macaroonPath string) ([]grpc.DialOption,
Backoff: backoff.DefaultConfig,
MinConnectTimeout: 10 * time.Second,
}),
grpc.WithMaxMsgSize(lnrpc.MaxGrpcMsgSize),
grpc.WithDefaultCallOptions(tap.MaxMsgReceiveSize),
}

if serverCertPath != "" {
Expand Down
12 changes: 11 additions & 1 deletion rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,22 @@ import (
"github.com/lightninglabs/taproot-assets/universe"
"github.com/lightningnetwork/lnd/build"
"github.com/lightningnetwork/lnd/keychain"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
"github.com/lightningnetwork/lnd/signal"
"google.golang.org/grpc"
)

var (
// MaxMsgReceiveSize is the largest message our client will receive. We
// set this to 200MiB atm.
MaxMsgReceiveSize = grpc.MaxCallRecvMsgSize(lnrpc.MaxGrpcMsgSize)

// ServerMaxMsgReceiveSize is the largest message our server will
// receive.
ServerMaxMsgReceiveSize = grpc.MaxRecvMsgSize(lnrpc.MaxGrpcMsgSize)
)

const (
// tapdMacaroonLocation is the value we use for the tapd macaroons'
// "Location" field when baking them.
Expand Down Expand Up @@ -2331,7 +2342,6 @@ func marshalMintingBatch(batch *tapgarden.MintingBatch,
} else {
rpcsLog.Errorf("unable to extract batch tx: %v", err)
}

}

// If we don't need to include the seedlings, we can return here.
Expand Down
4 changes: 1 addition & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ func (s *Server) RunUntilShutdown(mainErrChan <-chan error) error {
},
)
serverOpts = append(serverOpts, rpcServerOpts...)
serverOpts = append(
serverOpts, grpc.MaxRecvMsgSize(lnrpc.MaxGrpcMsgSize),
)
serverOpts = append(serverOpts, ServerMaxMsgReceiveSize)

grpcServer := grpc.NewServer(serverOpts...)
defer grpcServer.Stop()
Expand Down
4 changes: 1 addition & 3 deletions tapcfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,7 @@ func getTLSConfig(cfg *Config,
// in cmd/tapcli/main.go.
restDialOpts := []grpc.DialOption{
grpc.WithTransportCredentials(restCreds),
grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(lnrpc.MaxGrpcMsgSize),
),
grpc.WithDefaultCallOptions(tap.MaxMsgReceiveSize),
}

// Return a function closure that can be used to listen on a given
Expand Down
1 change: 1 addition & 0 deletions universe_rpc_registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func ConnectUniverse(
// Create a dial options array.
opts := []grpc.DialOption{
grpc.WithTransportCredentials(creds),
grpc.WithDefaultCallOptions(MaxMsgReceiveSize),
}

uniAddr, err := serverAddr.Addr()
Expand Down

0 comments on commit 34f3283

Please sign in to comment.