light: return light client status on rpc /status (#7536)

*light: rpc /status returns status of light client ; code refactoring
 light: moved lightClientInfo into light.go, renamed String to ID
test/e2e: Return light client trusted height instead of SyncInfo trusted height
test/e2e/start.go: Not waiting for light client to catch up in tests. Removed querying of syncInfo in start if the node is a light node

* light: Removed call to primary /status. Added trustedPeriod to light info
* light/provider: added ID function to return IP of primary and witnesses
* light/provider/http/http_test: renamed String() to ID()
This commit is contained in:
Jasmina Malicevic
2022-01-20 14:53:20 +01:00
committed by GitHub
parent 4e5c2b5e8f
commit d68d25dcd5
15 changed files with 213 additions and 11 deletions

View File

@@ -32,6 +32,7 @@ type LightClient interface {
Update(ctx context.Context, now time.Time) (*types.LightBlock, error)
VerifyLightBlockAtHeight(ctx context.Context, height int64, now time.Time) (*types.LightBlock, error)
TrustedLightBlock(height int64) (*types.LightBlock, error)
Status(ctx context.Context) *types.LightClientInfo
}
var _ rpcclient.Client = (*Client)(nil)
@@ -124,8 +125,18 @@ func (c *Client) OnStop() {
}
}
// Returns the status of the light client. Previously this was querying the primary connected to the client
// As a consequence of this change, running /status on the light client will return nil for SyncInfo, NodeInfo
// and ValdiatorInfo.
func (c *Client) Status(ctx context.Context) (*coretypes.ResultStatus, error) {
return c.next.Status(ctx)
lightClientInfo := c.lc.Status(ctx)
return &coretypes.ResultStatus{
NodeInfo: types.NodeInfo{},
SyncInfo: coretypes.SyncInfo{},
ValidatorInfo: coretypes.ValidatorInfo{},
LightClientInfo: *lightClientInfo,
}, nil
}
func (c *Client) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error) {

View File

@@ -31,6 +31,22 @@ func (_m *LightClient) ChainID() string {
return r0
}
// Status provides a mock function with given fields: ctx
func (_m *LightClient) Status(ctx context.Context) *types.LightClientInfo {
ret := _m.Called(ctx)
var r0 *types.LightClientInfo
if rf, ok := ret.Get(0).(func(context.Context) *types.LightClientInfo); ok {
r0 = rf(ctx)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*types.LightClientInfo)
}
}
return r0
}
// TrustedLightBlock provides a mock function with given fields: height
func (_m *LightClient) TrustedLightBlock(height int64) (*types.LightBlock, error) {
ret := _m.Called(height)