From 6d38592e18e58dc105726451f5d7e0fb6753d06b Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Tue, 6 Dec 2022 18:53:48 +0900 Subject: [PATCH 1/2] Remove unused `Ping` --- privval/retry_signer_client.go | 4 ---- privval/signer_client.go | 16 ---------------- privval/signer_client_test.go | 19 ------------------- test/kms/bench_test.go | 11 ----------- 4 files changed, 50 deletions(-) diff --git a/privval/retry_signer_client.go b/privval/retry_signer_client.go index fd7049434..ec601f7c3 100644 --- a/privval/retry_signer_client.go +++ b/privval/retry_signer_client.go @@ -40,10 +40,6 @@ func (sc *RetrySignerClient) WaitForConnection(maxWait time.Duration) error { //-------------------------------------------------------- // Implement PrivValidator -func (sc *RetrySignerClient) Ping() error { - return sc.next.Ping() -} - func (sc *RetrySignerClient) GetPubKey() (crypto.PubKey, error) { var ( pk crypto.PubKey diff --git a/privval/signer_client.go b/privval/signer_client.go index a0932a5c9..2c2a21c63 100644 --- a/privval/signer_client.go +++ b/privval/signer_client.go @@ -50,22 +50,6 @@ func (sc *SignerClient) WaitForConnection(maxWait time.Duration) error { //-------------------------------------------------------- // Implement PrivValidator -// Ping sends a ping request to the remote signer -func (sc *SignerClient) Ping() error { - response, err := sc.endpoint.SendRequest(mustWrapMsg(&privvalproto.PingRequest{})) - if err != nil { - sc.endpoint.Logger.Error("SignerClient::Ping", "err", err) - return nil - } - - pb := response.GetPingResponse() - if pb == nil { - return err - } - - return nil -} - // GetPubKey retrieves a public key from a remote signer // returns an error if client is not able to provide the key func (sc *SignerClient) GetPubKey() (crypto.PubKey, error) { diff --git a/privval/signer_client_test.go b/privval/signer_client_test.go index 08e5bd523..188a79e68 100644 --- a/privval/signer_client_test.go +++ b/privval/signer_client_test.go @@ -71,25 +71,6 @@ func TestSignerClose(t *testing.T) { } } -func TestSignerPing(t *testing.T) { - for _, tc := range getSignerTestCases(t, nil, true) { - tc := tc - t.Cleanup(func() { - if err := tc.signerServer.Stop(); err != nil { - t.Error(err) - } - }) - t.Cleanup(func() { - if err := tc.signerClient.Close(); err != nil { - t.Error(err) - } - }) - - err := tc.signerClient.Ping() - assert.NoError(t, err) - } -} - func TestSignerGetPubKey(t *testing.T) { for _, tc := range getSignerTestCases(t, nil, true) { tc := tc diff --git a/test/kms/bench_test.go b/test/kms/bench_test.go index 02cf16262..1df535581 100644 --- a/test/kms/bench_test.go +++ b/test/kms/bench_test.go @@ -42,17 +42,6 @@ func BenchmarkKMS(b *testing.B) { client, err := privval.NewSignerClient(endpoint, chainID) require.NoError(b, err) - // ensure connection and warm up - b.Run("Ping", func(b *testing.B) { - var err error - b.ResetTimer() - for i := 0; i < b.N; i++ { - err = client.Ping() - } - b.StopTimer() - require.NoError(b, err) - }) - benchmarkPrivValidator(b, client) } From 9753d1fe5c9b2a23d5bbbd8f0c6e1303b91960a9 Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Wed, 7 Dec 2022 12:20:19 +0900 Subject: [PATCH 2/2] Add `ping` for benchmark --- test/kms/bench_test.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/kms/bench_test.go b/test/kms/bench_test.go index 1df535581..d4b83949e 100644 --- a/test/kms/bench_test.go +++ b/test/kms/bench_test.go @@ -19,6 +19,7 @@ import ( tmnet "github.com/line/ostracon/libs/net" "github.com/line/ostracon/node" "github.com/line/ostracon/privval" + privvalproto "github.com/line/ostracon/proto/ostracon/privval" types2 "github.com/line/ostracon/proto/ostracon/types" "github.com/line/ostracon/types" "github.com/stretchr/testify/require" @@ -42,6 +43,15 @@ func BenchmarkKMS(b *testing.B) { client, err := privval.NewSignerClient(endpoint, chainID) require.NoError(b, err) + // ensure connection and warm up + b.Run("Ping", func(b *testing.B) { + b.ResetTimer() + for i := 0; i < b.N; i++ { + ping(endpoint) + } + b.StopTimer() + }) + benchmarkPrivValidator(b, client) } @@ -147,7 +157,7 @@ func benchmarkSignProposal(b *testing.B, pv types.PrivValidator, pubKey crypto.P // evaluate execution results require.NoError(b, err) - require.Equalf(b, len(pb.Signature), ed25519.SignatureSize, "ignProposal: signature size = %d != %d", + require.Equalf(b, len(pb.Signature), ed25519.SignatureSize, "SignProposal: signature size = %d != %d", len(pb.Signature), ed25519.SignatureSize) bytes := types.ProposalSignBytes(chainID, pb) require.Truef(b, pubKey.VerifySignature(bytes, pb.Signature), "SignProposal: signature verification") @@ -172,3 +182,15 @@ func benchmarkVRFProof(b *testing.B, pv types.PrivValidator, pubKey crypto.PubKe require.NoError(b, err) require.Equalf(b, len(output), VrfOutputSize, "VRFProof: output size = %d != %d", len(output), VrfOutputSize) } + +func ping(sl *privval.SignerListenerEndpoint) { + msg := privvalproto.Message{ + Sum: &privvalproto.Message_PingRequest{ + PingRequest: &privvalproto.PingRequest{}, + }, + } + _, err := sl.SendRequest(msg) + if err != nil { + sl.Logger.Error("Benchmark::ping", "err", err) + } +}