You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

439 lines
11 KiB

Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
Close and retry a RemoteSigner on err (#2923) * Close and recreate a RemoteSigner on err * Update changelog * Address Anton's comments / suggestions: - update changelog - restart TCPVal - shut down on `ErrUnexpectedResponse` * re-init remote signer client with fresh connection if Ping fails - add/update TODOs in secret connection - rename tcp.go -> tcp_client.go, same with ipc to clarify their purpose * account for `conn returned by waitConnection can be `nil` - also add TODO about RemoteSigner conn field * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn * Tests for retrying: IPC / TCP - shorter info log on success - set conn and use it in tests to close conn - add rwmutex for conn field in IPC * comments and doc.go * fix ipc tests. fixes #2677 * use constants for tests * cleanup some error statements * fixes #2784, race in tests * remove print statement * minor fixes from review * update comment on sts spec * cosmetics * p2p/conn: add failing tests * p2p/conn: make SecretConnection thread safe * changelog * IPCVal signer refactor - use a .reset() method - don't use embedded RemoteSignerClient - guard RemoteSignerClient with mutex - drop the .conn - expose Close() on RemoteSignerClient * apply IPCVal refactor to TCPVal * remove mtx from RemoteSignerClient * consolidate IPCVal and TCPVal, fixes #3104 - done in tcp_client.go - now called SocketVal - takes a listener in the constructor - make tcpListener and unixListener contain all the differences * delete ipc files * introduce unix and tcp dialer for RemoteSigner * rename files - drop tcp_ prefix - rename priv_validator.go to file.go * bring back listener options * fix node * fix priv_val_server * fix node test * minor cleanup and comments
6 years ago
  1. package privval
  2. import (
  3. "fmt"
  4. "net"
  5. "testing"
  6. "time"
  7. "github.com/stretchr/testify/assert"
  8. "github.com/stretchr/testify/require"
  9. "github.com/tendermint/tendermint/crypto/ed25519"
  10. cmn "github.com/tendermint/tendermint/libs/common"
  11. "github.com/tendermint/tendermint/libs/log"
  12. p2pconn "github.com/tendermint/tendermint/p2p/conn"
  13. "github.com/tendermint/tendermint/types"
  14. )
  15. var (
  16. testAcceptDeadline = defaultAcceptDeadlineSeconds * time.Second
  17. testConnDeadline = 100 * time.Millisecond
  18. testConnDeadline2o3 = 66 * time.Millisecond // 2/3 of the other one
  19. testHeartbeatTimeout = 10 * time.Millisecond
  20. testHeartbeatTimeout3o2 = 6 * time.Millisecond // 3/2 of the other one
  21. )
  22. func TestSocketPVAddress(t *testing.T) {
  23. var (
  24. chainID = cmn.RandStr(12)
  25. sc, rs = testSetupSocketPair(t, chainID, types.NewMockPV())
  26. )
  27. defer sc.Stop()
  28. defer rs.Stop()
  29. serverAddr := rs.privVal.GetPubKey().Address()
  30. clientAddr := sc.GetPubKey().Address()
  31. assert.Equal(t, serverAddr, clientAddr)
  32. }
  33. func TestSocketPVPubKey(t *testing.T) {
  34. var (
  35. chainID = cmn.RandStr(12)
  36. sc, rs = testSetupSocketPair(t, chainID, types.NewMockPV())
  37. )
  38. defer sc.Stop()
  39. defer rs.Stop()
  40. clientKey := sc.GetPubKey()
  41. privvalPubKey := rs.privVal.GetPubKey()
  42. assert.Equal(t, privvalPubKey, clientKey)
  43. }
  44. func TestSocketPVProposal(t *testing.T) {
  45. var (
  46. chainID = cmn.RandStr(12)
  47. sc, rs = testSetupSocketPair(t, chainID, types.NewMockPV())
  48. ts = time.Now()
  49. privProposal = &types.Proposal{Timestamp: ts}
  50. clientProposal = &types.Proposal{Timestamp: ts}
  51. )
  52. defer sc.Stop()
  53. defer rs.Stop()
  54. require.NoError(t, rs.privVal.SignProposal(chainID, privProposal))
  55. require.NoError(t, sc.SignProposal(chainID, clientProposal))
  56. assert.Equal(t, privProposal.Signature, clientProposal.Signature)
  57. }
  58. func TestSocketPVVote(t *testing.T) {
  59. var (
  60. chainID = cmn.RandStr(12)
  61. sc, rs = testSetupSocketPair(t, chainID, types.NewMockPV())
  62. ts = time.Now()
  63. vType = types.PrecommitType
  64. want = &types.Vote{Timestamp: ts, Type: vType}
  65. have = &types.Vote{Timestamp: ts, Type: vType}
  66. )
  67. defer sc.Stop()
  68. defer rs.Stop()
  69. require.NoError(t, rs.privVal.SignVote(chainID, want))
  70. require.NoError(t, sc.SignVote(chainID, have))
  71. assert.Equal(t, want.Signature, have.Signature)
  72. }
  73. func TestSocketPVVoteResetDeadline(t *testing.T) {
  74. var (
  75. chainID = cmn.RandStr(12)
  76. sc, rs = testSetupSocketPair(t, chainID, types.NewMockPV())
  77. ts = time.Now()
  78. vType = types.PrecommitType
  79. want = &types.Vote{Timestamp: ts, Type: vType}
  80. have = &types.Vote{Timestamp: ts, Type: vType}
  81. )
  82. defer sc.Stop()
  83. defer rs.Stop()
  84. time.Sleep(testConnDeadline2o3)
  85. require.NoError(t, rs.privVal.SignVote(chainID, want))
  86. require.NoError(t, sc.SignVote(chainID, have))
  87. assert.Equal(t, want.Signature, have.Signature)
  88. // This would exceed the deadline if it was not extended by the previous message
  89. time.Sleep(testConnDeadline2o3)
  90. require.NoError(t, rs.privVal.SignVote(chainID, want))
  91. require.NoError(t, sc.SignVote(chainID, have))
  92. assert.Equal(t, want.Signature, have.Signature)
  93. }
  94. func TestSocketPVVoteKeepalive(t *testing.T) {
  95. var (
  96. chainID = cmn.RandStr(12)
  97. sc, rs = testSetupSocketPair(t, chainID, types.NewMockPV())
  98. ts = time.Now()
  99. vType = types.PrecommitType
  100. want = &types.Vote{Timestamp: ts, Type: vType}
  101. have = &types.Vote{Timestamp: ts, Type: vType}
  102. )
  103. defer sc.Stop()
  104. defer rs.Stop()
  105. time.Sleep(testConnDeadline * 2)
  106. require.NoError(t, rs.privVal.SignVote(chainID, want))
  107. require.NoError(t, sc.SignVote(chainID, have))
  108. assert.Equal(t, want.Signature, have.Signature)
  109. }
  110. func TestSocketPVDeadline(t *testing.T) {
  111. var (
  112. addr = testFreeAddr(t)
  113. listenc = make(chan struct{})
  114. thisConnTimeout = 100 * time.Millisecond
  115. sc = newSocketVal(log.TestingLogger(), addr, thisConnTimeout)
  116. )
  117. go func(sc *SocketVal) {
  118. defer close(listenc)
  119. assert.Equal(t, sc.Start().(cmn.Error).Data(), ErrConnTimeout)
  120. assert.False(t, sc.IsRunning())
  121. }(sc)
  122. for {
  123. conn, err := cmn.Connect(addr)
  124. if err != nil {
  125. continue
  126. }
  127. _, err = p2pconn.MakeSecretConnection(
  128. conn,
  129. ed25519.GenPrivKey(),
  130. )
  131. if err == nil {
  132. break
  133. }
  134. }
  135. <-listenc
  136. }
  137. func TestRemoteSignerRetry(t *testing.T) {
  138. var (
  139. attemptc = make(chan int)
  140. retries = 2
  141. )
  142. ln, err := net.Listen("tcp", "127.0.0.1:0")
  143. require.NoError(t, err)
  144. go func(ln net.Listener, attemptc chan<- int) {
  145. attempts := 0
  146. for {
  147. conn, err := ln.Accept()
  148. require.NoError(t, err)
  149. err = conn.Close()
  150. require.NoError(t, err)
  151. attempts++
  152. if attempts == retries {
  153. attemptc <- attempts
  154. break
  155. }
  156. }
  157. }(ln, attemptc)
  158. rs := NewRemoteSigner(
  159. log.TestingLogger(),
  160. cmn.RandStr(12),
  161. types.NewMockPV(),
  162. DialTCPFn(ln.Addr().String(), testConnDeadline, ed25519.GenPrivKey()),
  163. )
  164. defer rs.Stop()
  165. RemoteSignerConnDeadline(time.Millisecond)(rs)
  166. RemoteSignerConnRetries(retries)(rs)
  167. assert.Equal(t, rs.Start(), ErrDialRetryMax)
  168. select {
  169. case attempts := <-attemptc:
  170. assert.Equal(t, retries, attempts)
  171. case <-time.After(100 * time.Millisecond):
  172. t.Error("expected remote to observe connection attempts")
  173. }
  174. }
  175. func TestRemoteSignVoteErrors(t *testing.T) {
  176. var (
  177. chainID = cmn.RandStr(12)
  178. sc, rs = testSetupSocketPair(t, chainID, types.NewErroringMockPV())
  179. ts = time.Now()
  180. vType = types.PrecommitType
  181. vote = &types.Vote{Timestamp: ts, Type: vType}
  182. )
  183. defer sc.Stop()
  184. defer rs.Stop()
  185. err := sc.SignVote("", vote)
  186. require.Equal(t, err.(*RemoteSignerError).Description, types.ErroringMockPVErr.Error())
  187. err = rs.privVal.SignVote(chainID, vote)
  188. require.Error(t, err)
  189. err = sc.SignVote(chainID, vote)
  190. require.Error(t, err)
  191. }
  192. func TestRemoteSignProposalErrors(t *testing.T) {
  193. var (
  194. chainID = cmn.RandStr(12)
  195. sc, rs = testSetupSocketPair(t, chainID, types.NewErroringMockPV())
  196. ts = time.Now()
  197. proposal = &types.Proposal{Timestamp: ts}
  198. )
  199. defer sc.Stop()
  200. defer rs.Stop()
  201. err := sc.SignProposal("", proposal)
  202. require.Equal(t, err.(*RemoteSignerError).Description, types.ErroringMockPVErr.Error())
  203. err = rs.privVal.SignProposal(chainID, proposal)
  204. require.Error(t, err)
  205. err = sc.SignProposal(chainID, proposal)
  206. require.Error(t, err)
  207. }
  208. func TestErrUnexpectedResponse(t *testing.T) {
  209. var (
  210. addr = testFreeAddr(t)
  211. logger = log.TestingLogger()
  212. chainID = cmn.RandStr(12)
  213. readyc = make(chan struct{})
  214. errc = make(chan error, 1)
  215. rs = NewRemoteSigner(
  216. logger,
  217. chainID,
  218. types.NewMockPV(),
  219. DialTCPFn(addr, testConnDeadline, ed25519.GenPrivKey()),
  220. )
  221. sc = newSocketVal(logger, addr, testConnDeadline)
  222. )
  223. testStartSocketPV(t, readyc, sc)
  224. defer sc.Stop()
  225. RemoteSignerConnDeadline(time.Millisecond)(rs)
  226. RemoteSignerConnRetries(100)(rs)
  227. // we do not want to Start() the remote signer here and instead use the connection to
  228. // reply with intentionally wrong replies below:
  229. rsConn, err := rs.connect()
  230. defer rsConn.Close()
  231. require.NoError(t, err)
  232. require.NotNil(t, rsConn)
  233. // send over public key to get the remote signer running:
  234. go testReadWriteResponse(t, &PubKeyResponse{}, rsConn)
  235. <-readyc
  236. // Proposal:
  237. go func(errc chan error) {
  238. errc <- sc.SignProposal(chainID, &types.Proposal{})
  239. }(errc)
  240. // read request and write wrong response:
  241. go testReadWriteResponse(t, &SignedVoteResponse{}, rsConn)
  242. err = <-errc
  243. require.Error(t, err)
  244. require.Equal(t, err, ErrUnexpectedResponse)
  245. // Vote:
  246. go func(errc chan error) {
  247. errc <- sc.SignVote(chainID, &types.Vote{})
  248. }(errc)
  249. // read request and write wrong response:
  250. go testReadWriteResponse(t, &SignedProposalResponse{}, rsConn)
  251. err = <-errc
  252. require.Error(t, err)
  253. require.Equal(t, err, ErrUnexpectedResponse)
  254. }
  255. func TestRetryTCPConnToRemoteSigner(t *testing.T) {
  256. var (
  257. addr = testFreeAddr(t)
  258. logger = log.TestingLogger()
  259. chainID = cmn.RandStr(12)
  260. readyc = make(chan struct{})
  261. rs = NewRemoteSigner(
  262. logger,
  263. chainID,
  264. types.NewMockPV(),
  265. DialTCPFn(addr, testConnDeadline, ed25519.GenPrivKey()),
  266. )
  267. thisConnTimeout = testConnDeadline
  268. sc = newSocketVal(logger, addr, thisConnTimeout)
  269. )
  270. // Ping every:
  271. SocketValHeartbeat(testHeartbeatTimeout)(sc)
  272. RemoteSignerConnDeadline(testConnDeadline)(rs)
  273. RemoteSignerConnRetries(10)(rs)
  274. testStartSocketPV(t, readyc, sc)
  275. defer sc.Stop()
  276. require.NoError(t, rs.Start())
  277. assert.True(t, rs.IsRunning())
  278. <-readyc
  279. time.Sleep(testHeartbeatTimeout * 2)
  280. rs.Stop()
  281. rs2 := NewRemoteSigner(
  282. logger,
  283. chainID,
  284. types.NewMockPV(),
  285. DialTCPFn(addr, testConnDeadline, ed25519.GenPrivKey()),
  286. )
  287. // let some pings pass
  288. time.Sleep(testHeartbeatTimeout3o2)
  289. require.NoError(t, rs2.Start())
  290. assert.True(t, rs2.IsRunning())
  291. defer rs2.Stop()
  292. // give the client some time to re-establish the conn to the remote signer
  293. // should see sth like this in the logs:
  294. //
  295. // E[10016-01-10|17:12:46.128] Ping err="remote signer timed out"
  296. // I[10016-01-10|17:16:42.447] Re-created connection to remote signer impl=SocketVal
  297. time.Sleep(testConnDeadline * 2)
  298. }
  299. func newSocketVal(logger log.Logger, addr string, connDeadline time.Duration) *SocketVal {
  300. ln, err := net.Listen(cmn.ProtocolAndAddress(addr))
  301. if err != nil {
  302. panic(err)
  303. }
  304. tcpLn := NewTCPListener(ln, ed25519.GenPrivKey())
  305. TCPListenerAcceptDeadline(testAcceptDeadline)(tcpLn)
  306. TCPListenerConnDeadline(testConnDeadline)(tcpLn)
  307. return NewSocketVal(logger, tcpLn)
  308. }
  309. func testSetupSocketPair(
  310. t *testing.T,
  311. chainID string,
  312. privValidator types.PrivValidator,
  313. ) (*SocketVal, *RemoteSigner) {
  314. var (
  315. addr = testFreeAddr(t)
  316. logger = log.TestingLogger()
  317. privVal = privValidator
  318. readyc = make(chan struct{})
  319. rs = NewRemoteSigner(
  320. logger,
  321. chainID,
  322. privVal,
  323. DialTCPFn(addr, testConnDeadline, ed25519.GenPrivKey()),
  324. )
  325. thisConnTimeout = testConnDeadline
  326. sc = newSocketVal(logger, addr, thisConnTimeout)
  327. )
  328. SocketValHeartbeat(testHeartbeatTimeout)(sc)
  329. RemoteSignerConnDeadline(testConnDeadline)(rs)
  330. RemoteSignerConnRetries(1e6)(rs)
  331. testStartSocketPV(t, readyc, sc)
  332. require.NoError(t, rs.Start())
  333. assert.True(t, rs.IsRunning())
  334. <-readyc
  335. return sc, rs
  336. }
  337. func testReadWriteResponse(t *testing.T, resp RemoteSignerMsg, rsConn net.Conn) {
  338. _, err := readMsg(rsConn)
  339. require.NoError(t, err)
  340. err = writeMsg(rsConn, resp)
  341. require.NoError(t, err)
  342. }
  343. func testStartSocketPV(t *testing.T, readyc chan struct{}, sc *SocketVal) {
  344. go func(sc *SocketVal) {
  345. require.NoError(t, sc.Start())
  346. assert.True(t, sc.IsRunning())
  347. readyc <- struct{}{}
  348. }(sc)
  349. }
  350. // testFreeAddr claims a free port so we don't block on listener being ready.
  351. func testFreeAddr(t *testing.T) string {
  352. ln, err := net.Listen("tcp", "127.0.0.1:0")
  353. require.NoError(t, err)
  354. defer ln.Close()
  355. return fmt.Sprintf("127.0.0.1:%d", ln.Addr().(*net.TCPAddr).Port)
  356. }