Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove strange Ping #523

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions privval/retry_signer_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions privval/signer_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 0 additions & 19 deletions privval/signer_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions test/kms/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -44,13 +45,11 @@ func BenchmarkKMS(b *testing.B) {

// ensure connection and warm up
b.Run("Ping", func(b *testing.B) {
torao marked this conversation as resolved.
Show resolved Hide resolved
var err error
b.ResetTimer()
for i := 0; i < b.N; i++ {
err = client.Ping()
ping(endpoint)
}
b.StopTimer()
require.NoError(b, err)
})

benchmarkPrivValidator(b, client)
Expand Down Expand Up @@ -158,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")
Expand All @@ -183,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)
}
}