Skip to content

Commit

Permalink
Merge pull request #13 from datachainlab/message-aggregation
Browse files Browse the repository at this point in the history
Message aggregation support

Signed-off-by: Jun Kimura <[email protected]>
  • Loading branch information
bluele authored Dec 28, 2023
2 parents 850951c + 3f8ada9 commit d1aae15
Show file tree
Hide file tree
Showing 14 changed files with 1,239 additions and 465 deletions.
2 changes: 1 addition & 1 deletion lcp
Submodule lcp updated 135 files
28 changes: 14 additions & 14 deletions light-clients/lcp/types/client_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,32 @@ func (cs ClientState) VerifyMembership(
if err != nil {
return err
}
c, err := commitmentProof.GetCommitment()
m, err := commitmentProof.GetELCMessage()
if err != nil {
return err
}
commitment, err := c.GetStateCommitment()
msg, err := m.GetVerifyMembershipMessage()
if err != nil {
return err
}
commitmentValue := crypto.Keccak256Hash(value)
hashedValue := crypto.Keccak256Hash(value)

if !height.EQ(commitment.Height) {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid height: expected=%v got=%v", height, commitment.Height)
if !height.EQ(msg.Height) {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid height: expected=%v got=%v", height, msg.Height)
}
if !bytes.Equal(prefixBytes, commitment.Prefix) {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid prefix: expected=%v got=%v", prefixBytes, commitment.Prefix)
if !bytes.Equal(prefixBytes, msg.Prefix) {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid prefix: expected=%v got=%v", prefixBytes, msg.Prefix)
}
if !bytes.Equal(commitmentPath, commitment.Path) {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid path: expected=%v got=%v", string(commitmentPath), string(commitment.Path))
if !bytes.Equal(commitmentPath, msg.Path) {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid path: expected=%v got=%v", string(commitmentPath), string(msg.Path))
}
if commitmentValue != commitment.Value {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid value: expected=%X got=%X", commitmentValue[:], commitment.Value)
if hashedValue != msg.Value {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid value: expected=%X got=%X", hashedValue[:], msg.Value)
}
if !commitment.StateID.EqualBytes(consensusState.StateId) {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid state ID: expected=%v got=%v", consensusState.StateId, commitment.StateID)
if !msg.StateID.EqualBytes(consensusState.StateId) {
return sdkerrors.Wrapf(ErrInvalidStateCommitment, "invalid state ID: expected=%v got=%v", consensusState.StateId, msg.StateID)
}
if err := VerifySignatureWithSignBytes(commitmentProof.CommitmentBytes, commitmentProof.Signature, commitmentProof.Signer); err != nil {
if err := VerifySignatureWithSignBytes(commitmentProof.Message, commitmentProof.Signature, commitmentProof.Signer); err != nil {
return sdkerrors.Wrapf(ErrInvalidStateCommitmentProof, "failed to verify state commitment proof: %v", err)
}
if !cs.IsActiveKey(ctx.BlockTime(), clientStore, commitmentProof.Signer) {
Expand Down
16 changes: 8 additions & 8 deletions light-clients/lcp/types/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ func (UpdateClientMessage) ClientType() string {
return ClientTypeLCP
}

func (m UpdateClientMessage) GetHeight() exported.Height {
c, err := m.GetCommitment()
func (ucm UpdateClientMessage) GetHeight() exported.Height {
m, err := ucm.GetELCMessage()
if err != nil {
panic(err)
}
return c.NewHeight
return m.PostHeight
}

func (m UpdateClientMessage) ValidateBasic() error {
if _, err := m.GetCommitment(); err != nil {
func (ucm UpdateClientMessage) ValidateBasic() error {
if _, err := ucm.GetELCMessage(); err != nil {
return err
}
return nil
}

func (h UpdateClientMessage) GetCommitment() (*UpdateClientCommitment, error) {
c, err := EthABIDecodeHeaderedCommitment(h.Commitment)
func (ucm UpdateClientMessage) GetELCMessage() (*ELCUpdateClientMessage, error) {
m, err := EthABIDecodeHeaderedMessage(ucm.ElcMessage)
if err != nil {
return nil, err
}
return c.GetUpdateClientCommitment()
return m.GetUpdateClientMessage()
}

var _ exported.ClientMessage = (*RegisterEnclaveKeyMessage)(nil)
Expand Down
80 changes: 40 additions & 40 deletions light-clients/lcp/types/lcp.pb.go

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

Loading

0 comments on commit d1aae15

Please sign in to comment.