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

chore(api)!: removing solomachine header sequence #2941

Merged
merged 3 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 1 addition & 5 deletions modules/light-clients/06-solomachine/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ func (h Header) GetPubKey() (cryptotypes.PubKey, error) {
return publicKey, nil
}

// ValidateBasic ensures that the sequence, signature and public key have all
// ValidateBasic ensures that the timestamp, signature and public key have all
// been initialized.
func (h Header) ValidateBasic() error {
if h.Sequence == 0 {
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "sequence number cannot be zero")
}

if h.Timestamp == 0 {
return sdkerrors.Wrap(clienttypes.ErrInvalidHeader, "timestamp cannot be zero")
}
Expand Down
15 changes: 0 additions & 15 deletions modules/light-clients/06-solomachine/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,9 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() {
header,
true,
},
{
"sequence is zero",
&solomachine.Header{
Sequence: 0,
Timestamp: header.Timestamp,
Signature: header.Signature,
NewPublicKey: header.NewPublicKey,
NewDiversifier: header.NewDiversifier,
},
false,
},
{
"timestamp is zero",
&solomachine.Header{
Sequence: header.Sequence,
Timestamp: 0,
Signature: header.Signature,
NewPublicKey: header.NewPublicKey,
Expand All @@ -47,7 +35,6 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() {
{
"signature is empty",
&solomachine.Header{
Sequence: header.Sequence,
Timestamp: header.Timestamp,
Signature: []byte{},
NewPublicKey: header.NewPublicKey,
Expand All @@ -58,7 +45,6 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() {
{
"diversifier contains only spaces",
&solomachine.Header{
Sequence: header.Sequence,
Timestamp: header.Timestamp,
Signature: header.Signature,
NewPublicKey: header.NewPublicKey,
Expand All @@ -69,7 +55,6 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() {
{
"public key is nil",
&solomachine.Header{
Sequence: header.Sequence,
Timestamp: header.Timestamp,
Signature: header.Signature,
NewPublicKey: nil,
Expand Down
141 changes: 56 additions & 85 deletions modules/light-clients/06-solomachine/solomachine.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 1 addition & 9 deletions modules/light-clients/06-solomachine/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ func (cs ClientState) VerifyClientMessage(ctx sdk.Context, cdc codec.BinaryCodec
}

func (cs ClientState) verifyHeader(ctx sdk.Context, cdc codec.BinaryCodec, clientStore sdk.KVStore, header *Header) error {
// assert update sequence is current sequence
if header.Sequence != cs.Sequence {
return sdkerrors.Wrapf(
clienttypes.ErrInvalidHeader,
"header sequence does not match the client state sequence (%d != %d)", header.Sequence, cs.Sequence,
)
}

// assert update timestamp is not less than current consensus state timestamp
if header.Timestamp < cs.ConsensusState.Timestamp {
return sdkerrors.Wrapf(
Expand All @@ -54,7 +46,7 @@ func (cs ClientState) verifyHeader(ctx sdk.Context, cdc codec.BinaryCodec, clien
}

signBytes := &SignBytes{
Sequence: header.Sequence,
Sequence: cs.Sequence,
Timestamp: header.Timestamp,
Diversifier: cs.ConsensusState.Diversifier,
Path: []byte(SentinelHeaderPath),
Expand Down
11 changes: 0 additions & 11 deletions modules/light-clients/06-solomachine/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() {
},
false,
},
{
"wrong sequence in header",
func() {
// store in temp before assigning to interface type
h := sm.CreateHeader(sm.Diversifier)
h.Sequence++
clientMsg = h
},
false,
},
{
"invalid header Signature",
func() {
Expand Down Expand Up @@ -458,7 +448,6 @@ func (suite *SoloMachineTestSuite) TestUpdateState() {
suite.Require().Equal(newClientState.(*solomachine.ClientState).Sequence, consensusHeights[0].GetRevisionHeight())

suite.Require().False(newClientState.(*solomachine.ClientState).IsFrozen)
suite.Require().Equal(clientMsg.(*solomachine.Header).Sequence+1, newClientState.(*solomachine.ClientState).Sequence)
suite.Require().Equal(clientMsg.(*solomachine.Header).NewPublicKey, newClientState.(*solomachine.ClientState).ConsensusState.PublicKey)
suite.Require().Equal(clientMsg.(*solomachine.Header).NewDiversifier, newClientState.(*solomachine.ClientState).ConsensusState.Diversifier)
suite.Require().Equal(clientMsg.(*solomachine.Header).Timestamp, newClientState.(*solomachine.ClientState).ConsensusState.Timestamp)
Expand Down
25 changes: 13 additions & 12 deletions proto/ibc/lightclients/solomachine/v3/solomachine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ message ConsensusState {
// Header defines a solo machine consensus header
message Header {
option (gogoproto.goproto_getters) = false;
// sequence to update solo machine public key at
uint64 sequence = 1;
uint64 timestamp = 2;
bytes signature = 3;
google.protobuf.Any new_public_key = 4 [(gogoproto.moretags) = "yaml:\"new_public_key\""];
string new_diversifier = 5 [(gogoproto.moretags) = "yaml:\"new_diversifier\""];

uint64 timestamp = 1;
bytes signature = 2;
google.protobuf.Any new_public_key = 3 [(gogoproto.moretags) = "yaml:\"new_public_key\""];
string new_diversifier = 4 [(gogoproto.moretags) = "yaml:\"new_diversifier\""];
}

// Misbehaviour defines misbehaviour for a solo machine which consists
Expand All @@ -57,18 +56,20 @@ message Misbehaviour {
// signature.
message SignatureAndData {
option (gogoproto.goproto_getters) = false;
bytes signature = 1;
bytes path = 2;
bytes data = 3;
uint64 timestamp = 4;

bytes signature = 1;
bytes path = 2;
bytes data = 3;
uint64 timestamp = 4;
}

// TimestampedSignatureData contains the signature data and the timestamp of the
// signature.
message TimestampedSignatureData {
option (gogoproto.goproto_getters) = false;
bytes signature_data = 1 [(gogoproto.moretags) = "yaml:\"signature_data\""];
uint64 timestamp = 2;

bytes signature_data = 1 [(gogoproto.moretags) = "yaml:\"signature_data\""];
uint64 timestamp = 2;
}

// SignBytes defines the signed bytes used for signature verification.
Expand Down
1 change: 0 additions & 1 deletion testing/solomachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ func (solo *Solomachine) CreateHeader(newDiversifier string) *solomachine.Header
sig := solo.GenerateSignature(bz)

header := &solomachine.Header{
Sequence: solo.Sequence,
Timestamp: solo.Time,
Signature: sig,
NewPublicKey: publicKey,
Expand Down