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

Message aggregation support #13

Merged
merged 6 commits into from
Dec 28, 2023
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
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