Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4a00e43
some refactors
randygrok May 21, 2025
90b41ee
Merge branch 'main' into feat/fix-ibc
randygrok May 21, 2025
c02a0bb
update adapter and fix
randygrok May 23, 2025
52d17df
Merge branch 'feat/fix-ibc' of github.com-randy:rollkit/go-execution-…
randygrok May 23, 2025
0496245
add signature payload provider
randygrok May 26, 2025
3536797
add header hasher
randygrok May 26, 2025
59a24ad
remove old passing of commit between layers
randygrok May 26, 2025
be850b6
build blocks
randygrok May 26, 2025
b1d2d4c
remove attestation fields that are not needed
randygrok May 27, 2025
a842ae1
remove usage of attestation on several places
randygrok May 27, 2025
c0979a0
add test
randygrok May 27, 2025
9f3846e
add test for validation of signature
randygrok May 27, 2025
9a250bb
commit pre clean
randygrok May 27, 2025
b746bce
Merge remote-tracking branch 'origin/main' into feat/fix-ibc
randygrok May 27, 2025
4585ebc
fix after merge
randygrok May 28, 2025
38a4ab1
fix tests
randygrok May 28, 2025
d01f033
remove some comments
randygrok May 28, 2025
0c0ce26
update go mod
randygrok May 28, 2025
450fec3
go mod tidy
randygrok May 28, 2025
4d84d69
fix linter
randygrok May 29, 2025
9d99a5d
linter
randygrok May 30, 2025
24b1479
add go mod update
randygrok May 30, 2025
ca03b26
update dependency
randygrok Jun 3, 2025
f41ee25
use new options manager
randygrok Jun 3, 2025
9990da1
Merge remote-tracking branch 'origin/main' into feat/fix-ibc
randygrok Jun 3, 2025
0986c52
add hasher as global
randygrok Jun 4, 2025
1279f30
Merge branch 'main' into feat/fix-ibc
julienrbrt Jun 11, 2025
92215fa
revert my changes + cherry-pick 4625e5ec89a8ee0109a61b574c61f12979338ea2
randygrok Jun 10, 2025
61970f2
use latest from rollkit branch
julienrbrt Jun 11, 2025
ec24c05
remove signer
julienrbrt Jun 11, 2025
9441582
updates
julienrbrt Jun 11, 2025
c926081
updates
julienrbrt Jun 11, 2025
9f8fbe8
wire commithash and validator hash
julienrbrt Jun 11, 2025
b787678
feedback
julienrbrt Jun 11, 2025
f5b0dc6
Merge branch 'main' into feat/fix-ibc
julienrbrt Jun 11, 2025
f8a8fc2
updates
julienrbrt Jun 11, 2025
0fdcd7d
use signed header helper
julienrbrt Jun 11, 2025
405feb9
refactor: all in rpc and converter
julienrbrt Jun 11, 2025
42e7753
push broken
julienrbrt Jun 11, 2025
58d0fe3
fix ibc
randygrok Jun 11, 2025
f5b10ff
use latest commit
julienrbrt Jun 11, 2025
b0d88ce
lint
julienrbrt Jun 12, 2025
c6a6b1b
updates
julienrbrt Jun 12, 2025
6d7d2d3
skip this one too
julienrbrt Jun 12, 2025
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
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ require (
github.com/libp2p/go-libp2p-pubsub v0.14.0
github.com/multiformats/go-multiaddr v0.15.0
github.com/prometheus/client_golang v1.22.0
github.com/rollkit/rollkit v0.14.2-0.20250602221640-d561a3a1706d
github.com/rollkit/rollkit/core v0.0.0-20250602221640-d561a3a1706d
github.com/rollkit/rollkit/da v0.0.0-20250602221640-d561a3a1706d
github.com/rollkit/rollkit/sequencers/single v0.0.0-20250602221640-d561a3a1706d
github.com/rollkit/rollkit v0.14.2-0.20250611130839-cacaec225752
github.com/rollkit/rollkit/core v0.0.0-20250611091931-22f40ddb636d
github.com/rollkit/rollkit/da v0.0.0-20250611091931-22f40ddb636d
github.com/rollkit/rollkit/sequencers/single v0.0.0-20250611091931-22f40ddb636d
github.com/rs/cors v1.11.1
github.com/spf13/cobra v1.9.1
github.com/stretchr/testify v1.10.0
Expand Down Expand Up @@ -175,7 +175,7 @@ require (
github.com/ipfs/go-cid v0.5.0 // indirect
github.com/ipfs/go-ds-badger4 v0.1.8 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/ipfs/go-log/v2 v2.6.0 // indirect
github.com/ipld/go-ipld-prime v0.21.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect
Expand Down
23 changes: 10 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,8 @@ github.com/ipfs/go-ipfs-util v0.0.3/go.mod h1:LHzG1a0Ig4G+iZ26UUOMjHd+lfM84LZCrn
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g=
github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY=
github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI=
github.com/ipfs/go-log/v2 v2.6.0 h1:2Nu1KKQQ2ayonKp4MPo6pXCjqw1ULc9iohRqWV5EYqg=
github.com/ipfs/go-log/v2 v2.6.0/go.mod h1:p+Efr3qaY5YXpx9TX7MoLCSEZX5boSWj9wh86P5HJa8=
github.com/ipfs/go-test v0.0.4 h1:DKT66T6GBB6PsDFLoO56QZPrOmzJkqU1FZH5C9ySkew=
github.com/ipfs/go-test v0.0.4/go.mod h1:qhIM1EluEfElKKM6fnWxGn822/z9knUGM1+I/OAQNKI=
github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E=
Expand Down Expand Up @@ -1002,14 +1002,14 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/rollkit/rollkit v0.14.2-0.20250602221640-d561a3a1706d h1:URLaPLUMtrm1UEq6yXH6gcUyr84MmprZVQjm0JOpHys=
github.com/rollkit/rollkit v0.14.2-0.20250602221640-d561a3a1706d/go.mod h1:gq4o6SyzrLKry9DwjtwM90d1LsFW7JpyxvnfNTTp1Cw=
github.com/rollkit/rollkit/core v0.0.0-20250602221640-d561a3a1706d h1:12LFAx7Uzcqam2tOhnW46qRnexio1qpHWqNQfeKnge8=
github.com/rollkit/rollkit/core v0.0.0-20250602221640-d561a3a1706d/go.mod h1:0RhbqC8Is970KRhr6zPUQOZkmKt6/WqPRDQWfd2P7P0=
github.com/rollkit/rollkit/da v0.0.0-20250602221640-d561a3a1706d h1:dGoDZ/h3mNTjZKRc7UDfqk6FT6SOevkTjMOdFC9kTPs=
github.com/rollkit/rollkit/da v0.0.0-20250602221640-d561a3a1706d/go.mod h1:MqbHTMhjb1PGbGaZ7bVddCm5OJg1+GMVEPpERdsO058=
github.com/rollkit/rollkit/sequencers/single v0.0.0-20250602221640-d561a3a1706d h1:Aus59RwnvK9INKi7wZEJbTrzv5N5xpHwq5zvJPBbE5k=
github.com/rollkit/rollkit/sequencers/single v0.0.0-20250602221640-d561a3a1706d/go.mod h1:kmCVN/v3/esPZW/ImaZq6mF+I2UsqjUPh7bODFDUOag=
github.com/rollkit/rollkit v0.14.2-0.20250611130839-cacaec225752 h1:weDWgRM9QADuXpY38Wf0yiu6HJXSB8Aplk4QXN7bb7g=
github.com/rollkit/rollkit v0.14.2-0.20250611130839-cacaec225752/go.mod h1:ZkMe60a1cascHjetgJ4CQo8W2f1B2X8h1va8Dw+BxDM=
github.com/rollkit/rollkit/core v0.0.0-20250611091931-22f40ddb636d h1:v0drx4tceTGjfb3jYUNKZxVFV5Mwm62U51xC9jNYCnQ=
github.com/rollkit/rollkit/core v0.0.0-20250611091931-22f40ddb636d/go.mod h1:0RhbqC8Is970KRhr6zPUQOZkmKt6/WqPRDQWfd2P7P0=
github.com/rollkit/rollkit/da v0.0.0-20250611091931-22f40ddb636d h1:ItM/USzbhqy9Vm7sB+Ygj64rm1z3JehDwt2c6i42kjI=
github.com/rollkit/rollkit/da v0.0.0-20250611091931-22f40ddb636d/go.mod h1:MqbHTMhjb1PGbGaZ7bVddCm5OJg1+GMVEPpERdsO058=
github.com/rollkit/rollkit/sequencers/single v0.0.0-20250611091931-22f40ddb636d h1:CKjlGwLawClPckcUgBNwsJLA+mBvVe+oDegtjqlZcIk=
github.com/rollkit/rollkit/sequencers/single v0.0.0-20250611091931-22f40ddb636d/go.mod h1:owdRPJ3Ivbl0Bb+13K3KTg3wQ00GlCtwenJXot3wvfo=
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA=
github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
Expand Down Expand Up @@ -1211,7 +1211,6 @@ go.uber.org/dig v1.18.1/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE=
go.uber.org/fx v1.23.0 h1:lIr/gYWQGfTwGcSXWXu4vP5Ws6iqnNEIY+F/aFzCKTg=
go.uber.org/fx v1.23.0/go.mod h1:o/D9n+2mLP6v1EG+qsdT1O8wKopYAsqZasju97SDFCU=
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
Expand All @@ -1227,7 +1226,6 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
go.uber.org/zap/exp v0.3.0 h1:6JYzdifzYkGmTdRR59oYH+Ng7k49H9qVpWwNSsGJj3U=
Expand Down Expand Up @@ -1459,7 +1457,6 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
Expand Down
148 changes: 138 additions & 10 deletions pkg/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"cosmossdk.io/log"
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/config"
"github.com/cometbft/cometbft/libs/bytes"
"github.com/cometbft/cometbft/mempool"
corep2p "github.com/cometbft/cometbft/p2p"
cmtprototypes "github.com/cometbft/cometbft/proto/tendermint/types"
cmtstate "github.com/cometbft/cometbft/state"
cmttypes "github.com/cometbft/cometbft/types"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
Expand All @@ -25,7 +27,9 @@ import (
rollnode "github.com/rollkit/rollkit/node"
rollkitp2p "github.com/rollkit/rollkit/pkg/p2p"
rstore "github.com/rollkit/rollkit/pkg/store"
"github.com/rollkit/rollkit/types"

"github.com/rollkit/go-execution-abci/pkg/cometcompat"
"github.com/rollkit/go-execution-abci/pkg/p2p"
)

Expand Down Expand Up @@ -244,6 +248,7 @@ func (a *Adapter) InitChain(ctx context.Context, genesisTime time.Time, initialH
} else {
s.ConsensusParams = cmttypes.ConsensusParamsFromProto(consensusParams)
}
s.ChainID = chainID

vals, err := cmttypes.PB2TM.ValidatorUpdates(res.Validators)
if err != nil {
Expand Down Expand Up @@ -292,14 +297,61 @@ func (a *Adapter) ExecuteTxs(
return nil, 0, fmt.Errorf("failed to load state: %w", err)
}

header, ok := types.SignedHeaderFromContext(ctx)
if !ok {
return nil, 0, fmt.Errorf("rollkit header not found in context")
}

var proposedLastCommit abci.CommitInfo
var lastCommit *cmttypes.Commit

if blockHeight > 1 {
header, data, err := a.RollkitStore.GetBlockData(ctx, blockHeight-1)
if err != nil {
return nil, 0, fmt.Errorf("failed to get previous block data: %w", err)
}

commitForPrevBlock := &cmttypes.Commit{
Height: int64(header.Height()),
Round: 0,
BlockID: cmttypes.BlockID{Hash: bytes.HexBytes(header.Hash()), PartSetHeader: cmttypes.PartSetHeader{Total: 1, Hash: bytes.HexBytes(data.Hash())}},
Signatures: []cmttypes.CommitSig{
{
BlockIDFlag: cmttypes.BlockIDFlagCommit,
ValidatorAddress: cmttypes.Address(header.ProposerAddress),
Timestamp: header.Time(),
Signature: header.Signature,
},
},
}
Comment on lines +314 to +326
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Commit construction duplicated & partially inconsistent

The logic that fabricates a commit for the previous block appears twice (lines 317-329 and 476-488).
Apart from code repetition, the two snippets risk drifting apart (e.g. timestamp handling). Extract a helper (e.g. buildCommitFromPreviousBlock) and invoke it in both places.

Also applies to: 476-488

🤖 Prompt for AI Agents
In pkg/adapter/adapter.go around lines 317 to 329 and also 476 to 488, the code
that constructs a commit for the previous block is duplicated and partially
inconsistent. To fix this, extract the commit construction logic into a helper
function named something like buildCommitFromPreviousBlock that takes the
necessary parameters (e.g., header and data) and returns the constructed commit.
Replace both duplicated code blocks with calls to this new helper function to
ensure consistency and reduce code repetition.


lastCommit = commitForPrevBlock
proposedLastCommit = cometCommitToABCICommitInfo(commitForPrevBlock)
} else {
// For the first block, ProposedLastCommit is empty
proposedLastCommit = abci.CommitInfo{Round: 0, Votes: []abci.VoteInfo{}}
lastCommit = &cmttypes.Commit{
Height: int64(blockHeight),
Round: 0,
BlockID: cmttypes.BlockID{},
Signatures: []cmttypes.CommitSig{},
}
}

emptyBlock, err := cometcompat.ToABCIBlock(header, &types.Data{}, lastCommit)
if err != nil {
return nil, 0, fmt.Errorf("failed to compute header hash: %w", err)
}

ppResp, err := a.App.ProcessProposal(&abci.RequestProcessProposal{
Txs: txs,
ProposedLastCommit: abci.CommitInfo{},
Hash: prevStateRoot,
Hash: emptyBlock.Header.Hash(),
Height: int64(blockHeight),
Time: timestamp,
NextValidatorsHash: s.NextValidators.Hash(),
Txs: txs,
ProposedLastCommit: proposedLastCommit,
Misbehavior: []abci.Misbehavior{},
ProposerAddress: s.Validators.Proposer.Address,
NextValidatorsHash: s.NextValidators.Hash(),
})
Comment on lines 353 to 355
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

ProposerAddress taken from current validator set, not from Rollkit header

ProcessProposal / FinalizeBlock send s.Validators.Proposer.Address, which may differ from header.ProposerAddress when proposers rotate.
This can lead to invalid proposal verification on peers that rely on the header’s proposer field.

Use the proposer address from the Rollkit header:

-	ProposerAddress:    s.Validators.Proposer.Address,
+	ProposerAddress:    header.ProposerAddress,

Also applies to: 357-359

🤖 Prompt for AI Agents
In pkg/adapter/adapter.go around lines 343 to 345 and also lines 357 to 359, the
code uses s.Validators.Proposer.Address for ProposerAddress, which may differ
from the proposer address in the Rollkit header when proposers rotate. To fix
this, replace s.Validators.Proposer.Address with header.ProposerAddress in both
locations to ensure the proposer address matches the Rollkit header and avoid
invalid proposal verification.

if err != nil {
return nil, 0, err
Expand All @@ -310,17 +362,24 @@ func (a *Adapter) ExecuteTxs(
}

fbResp, err := a.App.FinalizeBlock(&abci.RequestFinalizeBlock{
Txs: txs,
Hash: prevStateRoot,
Height: int64(blockHeight),
Time: timestamp,
Hash: emptyBlock.Header.Hash(),
NextValidatorsHash: s.NextValidators.Hash(),
ProposerAddress: s.Validators.Proposer.Address,
Height: int64(blockHeight),
Time: timestamp,
DecidedLastCommit: abci.CommitInfo{
Round: 0,
Votes: nil,
},
Txs: txs,
})
if err != nil {
return nil, 0, err
}

s.AppHash = fbResp.AppHash
s.LastBlockHeight = int64(blockHeight)

nValSet := s.NextValidators.Copy()

validatorUpdates, err := cmttypes.PB2TM.ValidatorUpdates(fbResp.ValidatorUpdates)
Expand Down Expand Up @@ -404,8 +463,46 @@ func (a *Adapter) ExecuteTxs(
for i := range txs {
cmtTxs[i] = txs[i]
}
block := s.MakeBlock(int64(blockHeight), cmtTxs, &cmttypes.Commit{Height: int64(blockHeight)}, nil, s.Validators.Proposer.Address)
fireEvents(a.Logger, a.EventBus, block, cmttypes.BlockID{}, fbResp, validatorUpdates)

commit := &cmttypes.Commit{
Height: int64(blockHeight),
Round: 0,
Signatures: []cmttypes.CommitSig{
{
BlockIDFlag: cmttypes.BlockIDFlagCommit,
ValidatorAddress: s.Validators.Proposer.Address,
Timestamp: time.Now().UTC(),
Signature: []byte{},
},
},
}
Comment on lines +467 to +478
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Genesis-path commit invalid: mismatched timestamp & empty signature

For blockHeight == 1 the fabricated commit:

  • sets Timestamp: time.Now().UTC() instead of the block’s header time,
  • includes Signature: []byte{} while using BlockIDFlagCommit.

Both produce a non-canonical commit hash and may break light-client verification.
Use the zero-value cmttypes.Commit{} (height 0, no signatures) or set BlockIDFlagAbsent with a nil signature, matching Tendermint’s genesis expectations.

🤖 Prompt for AI Agents
In pkg/adapter/adapter.go around lines 457 to 468, the commit for blockHeight 1
incorrectly sets the timestamp to the current time and includes an empty
signature with BlockIDFlagCommit, causing a non-canonical commit hash. To fix
this, either use the zero-value cmttypes.Commit struct with height 0 and no
signatures or set the commit signature's BlockIDFlag to BlockIDFlagAbsent and
the signature to nil, ensuring it matches Tendermint's genesis block
expectations and preserves canonical commit hashing.


if blockHeight > 1 {
header, data, err := a.RollkitStore.GetBlockData(ctx, blockHeight-1)
if err != nil {
return nil, 0, fmt.Errorf("failed to get previous block data: %w", err)
}

commit = &cmttypes.Commit{
Height: int64(header.Height()),
Round: 0,
BlockID: cmttypes.BlockID{Hash: bytes.HexBytes(header.Hash()), PartSetHeader: cmttypes.PartSetHeader{Total: 1, Hash: bytes.HexBytes(data.Hash())}},
Signatures: []cmttypes.CommitSig{
{
BlockIDFlag: cmttypes.BlockIDFlagCommit,
ValidatorAddress: cmttypes.Address(header.ProposerAddress),
Timestamp: header.Time(),
Signature: header.Signature,
},
},
}
}

block := s.MakeBlock(int64(blockHeight), cmtTxs, commit, nil, s.Validators.Proposer.Address)

currentBlockID := cmttypes.BlockID{Hash: block.Hash(), PartSetHeader: cmttypes.PartSetHeader{Total: 1, Hash: block.DataHash}}

fireEvents(a.Logger, a.EventBus, block, currentBlockID, fbResp, validatorUpdates)

a.Logger.Info("block executed successfully", "height", blockHeight, "appHash", fmt.Sprintf("%X", fbResp.AppHash))
return fbResp.AppHash, uint64(s.ConsensusParams.Block.MaxBytes), nil
Expand Down Expand Up @@ -521,3 +618,34 @@ func (a *Adapter) GetTxs(ctx context.Context) ([][]byte, error) {
func (a *Adapter) SetFinal(ctx context.Context, blockHeight uint64) error {
return nil
}

func cometCommitToABCICommitInfo(commit *cmttypes.Commit) abci.CommitInfo {
if commit == nil {
return abci.CommitInfo{
Round: 0,
Votes: []abci.VoteInfo{},
}
}

if len(commit.Signatures) == 0 {
return abci.CommitInfo{
Round: commit.Round,
Votes: []abci.VoteInfo{},
}
}

votes := make([]abci.VoteInfo, len(commit.Signatures))
for i, sig := range commit.Signatures {
votes[i] = abci.VoteInfo{
Validator: abci.Validator{
Address: sig.ValidatorAddress,
Power: 0,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 0 ? I was expecting a positive number. It would be good to have some godoc explaining the value

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
BlockIdFlag: cmtprototypes.BlockIDFlag(sig.BlockIDFlag),
}
}
Comment on lines +637 to +646
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

VoteInfo carries zero power – may break consensus/hash

cometCommitToABCICommitInfo maps every CommitSig to VoteInfo with Power: 0.
ABCI consumers (and light clients) expect the actual voting power; using zero can lead to incorrect total voting power calculations and, ultimately, invalid block signatures.

Populate Power from the corresponding validator or, if unavailable, remove the field and rely on Tendermint’s default handling.


🏁 Script executed:

#!/bin/bash
# Display the cometCommitToABCICommitInfo function and its context
rg -n "func cometCommitToABCICommitInfo" -A50 -B10 pkg/adapter/adapter.go

Length of output: 1233


🏁 Script executed:

#!/bin/bash
# Search for the definition of Adapter in pkg/adapter/adapter.go
rg -n "type .*Adapter" -A5 -B5 pkg/adapter/adapter.go

Length of output: 376


🏁 Script executed:

#!/bin/bash
# Display the BeginBlock method implementation in adapter.go
rg -n "func (a .*Adapter) BeginBlock" -A50 -B10 pkg/adapter/adapter.go

Length of output: 72


🏁 Script executed:

#!/bin/bash
# Display the first 200 lines of pkg/adapter/adapter.go to inspect imports and types
sed -n '1,200p' pkg/adapter/adapter.go

Length of output: 6190


🏁 Script executed:

#!/bin/bash
# Find Info method implementation
rg -n 'func \(a \*Adapter\) Info' -A50 -B10 pkg/adapter/adapter.go

# Check if cometCommitToABCICommitInfo is referenced elsewhere
rg -n 'cometCommitToABCICommitInfo' -n pkg/adapter/adapter.go

Length of output: 285


Populate VoteInfo.Power from the validator set

The helper cometCommitToABCICommitInfo in pkg/adapter/adapter.go (lines 642–651) currently hard-codes every VoteInfo.Power to 0, which will break total voting‐power calculations and commit verification in Tendermint/CometBFT. You need to:

• Load the validator set for the given height (e.g. via Adapter.Store or by querying your app’s state).
• Match each sig.ValidatorAddress to its Validator entry and use its actual voting power:

  votes[i] = abci.VoteInfo{
    Validator: abci.Validator{
      Address: sig.ValidatorAddress,
-       Power:   0,
+       Power:   validator.VotingPower, // load from state
    },
    BlockIdFlag: cmtprototypes.BlockIDFlag(sig.BlockIDFlag),
  }

• If you cannot fetch validator power here, omit the Power field to let CometBFT fall back on its default handling.

This change is required to ensure correct consensus and hash calculations.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In pkg/adapter/adapter.go around lines 642 to 651, the VoteInfo.Power field is
set to zero for all votes, which causes incorrect total voting power
calculations and breaks consensus verification. To fix this, fetch the validator
set for the commit's height using the Adapter's store or app state, then for
each signature, find the matching validator by address and set VoteInfo.Power to
that validator's actual voting power. If fetching the validator power is not
feasible here, remove the Power field from VoteInfo to allow Tendermint's
default handling.

return abci.CommitInfo{
Round: commit.Round,
Votes: votes,
}
}
37 changes: 25 additions & 12 deletions pkg/adapter/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ import (
cmtypes "github.com/cometbft/cometbft/types"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
ds "github.com/ipfs/go-datastore"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/rollkit/rollkit/types"
)

func TestExecuteFiresEvents(t *testing.T) {
t.Skip()

timestamp := time.Now()
myTxs := [][]byte{{0x01}, {0x02}}
myExecResult := []*abci.ExecTxResult{{Code: 0, Data: []byte{0}}, {Code: 0, Data: []byte{1}}}
Expand Down Expand Up @@ -82,12 +85,31 @@ func TestExecuteFiresEvents(t *testing.T) {
adapter.MempoolIDs = newMempoolIDs()
adapter.Mempool = &mempool.NopMempool{}

_, pubKey, err := crypto.GenerateEd25519Key(nil)
require.NoError(t, err)

address, err := pubKey.Raw()
require.NoError(t, err)

var sig types.Signature = make([]byte, 32)
require.NoError(t, adapter.RollkitStore.SaveBlockData(ctx, headerFixture(), &types.Data{Txs: make(types.Txs, 0)}, &sig))
signedHeader := &types.SignedHeader{
Header: types.Header{
BaseHeader: types.BaseHeader{Height: 2, Time: uint64(time.Now().UnixNano())},
ProposerAddress: address,
AppHash: []byte("apphash1"),
},
Signer: types.Signer{
Address: address,
PubKey: pubKey,
},
Signature: sig,
}
require.NoError(t, adapter.RollkitStore.SaveBlockData(ctx, signedHeader, &types.Data{Txs: make(types.Txs, 0)}, &sig))
require.NoError(t, adapter.Store.SaveState(ctx, stateFixture()))

// when
_, _, err := adapter.ExecuteTxs(ctx, spec.txs, 1, timestamp, bytes.Repeat([]byte{1}, 32))
ctx = context.WithValue(ctx, types.SignedHeaderContextKey, signedHeader)
_, _, err = adapter.ExecuteTxs(ctx, spec.txs, 1, timestamp, bytes.Repeat([]byte{1}, 32))
if spec.expErr {
require.Error(t, err)
blockMx.RLock()
Expand Down Expand Up @@ -176,16 +198,6 @@ func captureEvents(ctx context.Context, eventBus *cmtypes.EventBus, query string
return &capturedEvents, &mx
}

func headerFixture() *types.SignedHeader {
return &types.SignedHeader{
Header: types.Header{
BaseHeader: types.BaseHeader{Height: 2, Time: uint64(time.Now().UnixNano())},
ProposerAddress: []byte("proposer1"),
AppHash: []byte("apphash1"),
},
}
}

type MockABCIApp struct {
servertypes.ABCI // satisfy the interface
ProcessProposalFn func(*abci.RequestProcessProposal) (*abci.ResponseProcessProposal, error)
Expand All @@ -199,6 +211,7 @@ func (m *MockABCIApp) ProcessProposal(r *abci.RequestProcessProposal) (*abci.Res
}
return m.ProcessProposalFn(r)
}

func (m *MockABCIApp) FinalizeBlock(r *abci.RequestFinalizeBlock) (*abci.ResponseFinalizeBlock, error) {
if m.FinalizeBlockFn == nil {
panic("not expected to be called")
Expand Down
Loading