|
9 | 9 | cmtlog "github.com/cometbft/cometbft/libs/log" |
10 | 10 | "github.com/cometbft/cometbft/libs/math" |
11 | 11 | "github.com/cometbft/cometbft/light" |
| 12 | + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" |
12 | 13 | ctypes "github.com/cometbft/cometbft/rpc/core/types" |
13 | 14 | rpctypes "github.com/cometbft/cometbft/rpc/jsonrpc/types" |
14 | 15 | cmttypes "github.com/cometbft/cometbft/types" |
@@ -239,8 +240,8 @@ func TestCommit_VerifyCometBFTLightClientCompatibility_MultipleBlocks(t *testing |
239 | 240 | err = env.Adapter.Store.SaveBlockID(context.Background(), blockHeight, blockID) |
240 | 241 | require.NoError(err, "Failed to save BlockID for height %d", blockHeight) |
241 | 242 |
|
242 | | - // create the signature for the rollkit block |
243 | | - realSignature := signBlock(t, env.Adapter, rollkitHeader, aggregatorPrivKey) |
| 243 | + // Create signature over the actual blockID for light client compatibility |
| 244 | + realSignature := signBlockWithBlockID(t, rollkitHeader, aggregatorPrivKey, blockID) |
244 | 245 |
|
245 | 246 | // mock the store to return our signed block |
246 | 247 | mockBlock(blockHeight, rollkitHeader, blockData, realSignature, aggregatorPubKey, validatorAddress) |
@@ -297,6 +298,27 @@ func signBlock(t *testing.T, executor *adapter.Adapter, header types.Header, pri |
297 | 298 | return signature |
298 | 299 | } |
299 | 300 |
|
| 301 | +func signBlockWithBlockID(t *testing.T, header types.Header, privKey crypto.PrivKey, blockID *cmttypes.BlockID) []byte { |
| 302 | + // create vote bytes using the createVote helper from adapter |
| 303 | + vote := cmtproto.Vote{ |
| 304 | + Type: cmtproto.PrecommitType, |
| 305 | + Height: int64(header.Height()), |
| 306 | + BlockID: blockID.ToProto(), |
| 307 | + Round: 0, |
| 308 | + Timestamp: header.Time(), |
| 309 | + ValidatorAddress: header.ProposerAddress, |
| 310 | + ValidatorIndex: 0, |
| 311 | + } |
| 312 | + |
| 313 | + chainID := header.ChainID() |
| 314 | + signBytes := cmttypes.VoteSignBytes(chainID, &vote) |
| 315 | + |
| 316 | + signature, err := privKey.Sign(signBytes) |
| 317 | + require.NoError(t, err) |
| 318 | + |
| 319 | + return signature |
| 320 | +} |
| 321 | + |
300 | 322 | func mockBlock(height uint64, header types.Header, data *types.Data, signature []byte, pubKey crypto.PubKey, address []byte) { |
301 | 323 | signedHeader := &types.SignedHeader{ |
302 | 324 | Header: header, |
|
0 commit comments