Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6563f8e
`tendermint` -> `cometbft` 👉🥺👈
Ferret-san Mar 22, 2023
f16a4c1
update modules
Ferret-san Mar 22, 2023
6e788c1
Update mod replace
Ferret-san Mar 23, 2023
4ab9757
Merge branch 'main' into diego/cometbft
Ferret-san Mar 23, 2023
623abd1
more changes :wrench:
Ferret-san Mar 23, 2023
fcd6685
updates
Ferret-san Mar 27, 2023
9cd5034
bump btcsuite deps
Ferret-san Mar 28, 2023
8fd15d9
remove unnecessary `string([]byte)`s
Ferret-san Apr 20, 2023
9207829
switch `tm` prefix for `cm`
Ferret-san Apr 20, 2023
2434650
fix broken links
Ferret-san Apr 20, 2023
2db8f6e
Merge branch 'main' into diego/cometbft
Ferret-san Apr 20, 2023
9f2bf05
Update node.go
Ferret-san Apr 20, 2023
482f357
:wrench:
Ferret-san Apr 20, 2023
5a074df
fix json
Ferret-san Apr 20, 2023
231fde8
Merge branch 'main' into diego/cometbft
Ferret-san Jun 6, 2023
ea5d18c
:wrench:
Ferret-san Jun 6, 2023
a8b0ff0
Adapting mempool
Ferret-san Jun 7, 2023
1f9d2d8
Merge branch 'main' into diego/cometbft
Ferret-san Jun 29, 2023
e40e5a9
Updating from main
Ferret-san Jun 29, 2023
791723f
skip golangci-lint for math.rand, until math.rand and crypto.rand are…
Jun 29, 2023
25373cc
Merge branch 'diego/cometbft' into diego/cometbft-0.37.1-mempool
Ferret-san Jun 29, 2023
ca05435
fix go mod
Ferret-san Jun 29, 2023
1a36c2c
Update executor.go
Ferret-san Jul 7, 2023
6b452f2
Merge pull request #991 from rollkit/diego/cometbft-0.37.1-mempool
Ferret-san Jul 7, 2023
d811d37
Merge branch 'main' into diego/cometbft
Ferret-san Jul 7, 2023
3850f87
updating dependencies on changes from main
Ferret-san Jul 7, 2023
b6eb326
disable golangci-lint check for rand read
Jul 10, 2023
c1993c9
update to fixed rollkit cometbft version instead of commit hash
Jul 10, 2023
f8be03f
remove ToProto and string()
Jul 14, 2023
e4f271d
Merge remote-tracking branch 'origin/main' into diego/cometbft
Jul 19, 2023
48184e3
fix cmproto link
Jul 19, 2023
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
40 changes: 20 additions & 20 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ import (
"time"

"github.com/celestiaorg/go-fraud/fraudserv"
abci "github.com/cometbft/cometbft/abci/types"
cmcrypto "github.com/cometbft/cometbft/crypto"
"github.com/cometbft/cometbft/crypto/merkle"
cmstate "github.com/cometbft/cometbft/proto/tendermint/state"
"github.com/cometbft/cometbft/proxy"
cmtypes "github.com/cometbft/cometbft/types"
"github.com/libp2p/go-libp2p/core/crypto"
abci "github.com/tendermint/tendermint/abci/types"
tmcrypto "github.com/tendermint/tendermint/crypto"
tmstate "github.com/tendermint/tendermint/proto/tendermint/state"

"github.com/tendermint/tendermint/crypto/merkle"
"github.com/tendermint/tendermint/proxy"
tmtypes "github.com/tendermint/tendermint/types"
"go.uber.org/multierr"

"github.com/rollkit/rollkit/config"
Expand Down Expand Up @@ -51,8 +50,9 @@ type Manager struct {
lastStateMtx *sync.RWMutex
store store.Store

conf config.BlockManagerConfig
genesis *tmtypes.GenesisDoc
conf config.BlockManagerConfig
genesis *cmtypes.GenesisDoc

proposerKey crypto.PrivKey

executor *state.BlockExecutor
Expand Down Expand Up @@ -81,7 +81,7 @@ type Manager struct {
}

// getInitialState tries to load lastState from Store, and if it's not available it reads GenesisDoc.
func getInitialState(store store.Store, genesis *tmtypes.GenesisDoc) (types.State, error) {
func getInitialState(store store.Store, genesis *cmtypes.GenesisDoc) (types.State, error) {
s, err := store.LoadState()
if err != nil {
s, err = types.NewFromGenesisDoc(genesis)
Expand All @@ -93,12 +93,12 @@ func getInitialState(store store.Store, genesis *tmtypes.GenesisDoc) (types.Stat
func NewManager(
proposerKey crypto.PrivKey,
conf config.BlockManagerConfig,
genesis *tmtypes.GenesisDoc,
genesis *cmtypes.GenesisDoc,
store store.Store,
mempool mempool.Mempool,
proxyApp proxy.AppConnConsensus,
dalc da.DataAvailabilityLayerClient,
eventBus *tmtypes.EventBus,
eventBus *cmtypes.EventBus,
logger log.Logger,
doneBuildingCh chan struct{},
) (*Manager, error) {
Expand Down Expand Up @@ -172,7 +172,7 @@ func getAddress(key crypto.PrivKey) ([]byte, error) {
if err != nil {
return nil, err
}
return tmcrypto.AddressHash(rawKey), nil
return cmcrypto.AddressHash(rawKey), nil
}

// SetDALC is used to set DataAvailabilityLayerClient used by Manager.
Expand Down Expand Up @@ -670,7 +670,7 @@ func (m *Manager) saveValidatorsToStore(height uint64) error {
return m.store.SaveValidators(height, m.lastState.Validators)
}

func (m *Manager) getLastStateValidators() *tmtypes.ValidatorSet {
func (m *Manager) getLastStateValidators() *cmtypes.ValidatorSet {
m.lastStateMtx.RLock()
defer m.lastStateMtx.RUnlock()
return m.lastState.Validators
Expand All @@ -688,7 +688,7 @@ func (m *Manager) createBlock(height uint64, lastCommit *types.Commit, lastHeade
return m.executor.CreateBlock(height, lastCommit, lastHeaderHash, m.lastState)
}

func (m *Manager) applyBlock(ctx context.Context, block *types.Block) (types.State, *tmstate.ABCIResponses, error) {
func (m *Manager) applyBlock(ctx context.Context, block *types.Block) (types.State, *cmstate.ABCIResponses, error) {
m.lastStateMtx.RLock()
defer m.lastStateMtx.RUnlock()
return m.executor.ApplyBlock(ctx, m.lastState, block)
Expand Down Expand Up @@ -718,20 +718,20 @@ func updateState(s *types.State, res *abci.ResponseInitChain) {
s.ConsensusParams.Validator.PubKeyTypes = append([]string{}, params.Validator.PubKeyTypes...)
}
if params.Version != nil {
s.ConsensusParams.Version.AppVersion = params.Version.AppVersion
s.ConsensusParams.Version.App = params.Version.App
}
s.Version.Consensus.App = s.ConsensusParams.Version.AppVersion
s.Version.Consensus.App = s.ConsensusParams.Version.App
}
// We update the last results hash with the empty hash, to conform with RFC-6962.
s.LastResultsHash = merkle.HashFromByteSlices(nil)

if len(res.Validators) > 0 {
vals, err := tmtypes.PB2TM.ValidatorUpdates(res.Validators)
vals, err := cmtypes.PB2TM.ValidatorUpdates(res.Validators)
if err != nil {
// TODO(tzdybal): handle error properly
panic(err)
}
s.Validators = tmtypes.NewValidatorSet(vals)
s.NextValidators = tmtypes.NewValidatorSet(vals).CopyIncrementProposerPriority(1)
s.Validators = cmtypes.NewValidatorSet(vals)
s.NextValidators = cmtypes.NewValidatorSet(vals).CopyIncrementProposerPriority(1)
}
}
8 changes: 4 additions & 4 deletions block/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"testing"
"time"

"github.com/cometbft/cometbft/libs/log"
cmtypes "github.com/cometbft/cometbft/types"
"github.com/libp2p/go-libp2p/core/crypto"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/rollkit/rollkit/config"
"github.com/rollkit/rollkit/da"
Expand All @@ -20,7 +20,7 @@ import (
)

func TestInitialState(t *testing.T) {
genesis := &tmtypes.GenesisDoc{
genesis := &cmtypes.GenesisDoc{
ChainID: "genesis id",
InitialHeight: 100,
}
Expand All @@ -46,7 +46,7 @@ func TestInitialState(t *testing.T) {
cases := []struct {
name string
store store.Store
genesis *tmtypes.GenesisDoc
genesis *cmtypes.GenesisDoc
expectedInitialHeight int64
expectedLastBlockHeight int64
expectedChainID string
Expand Down
74 changes: 37 additions & 37 deletions conv/abci/block.go
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
package abci

import (
tmbytes "github.com/tendermint/tendermint/libs/bytes"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
tmtypes "github.com/tendermint/tendermint/types"
cmbytes "github.com/cometbft/cometbft/libs/bytes"
cmproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmversion "github.com/cometbft/cometbft/proto/tendermint/version"
cmtypes "github.com/cometbft/cometbft/types"

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

// ToABCIHeaderPB converts Rollkit header to Header format defined in ABCI.
// Caller should fill all the fields that are not available in Rollkit header (like ChainID).
func ToABCIHeaderPB(header *types.Header) (tmproto.Header, error) {
return tmproto.Header{
Version: tmversion.Consensus{
func ToABCIHeaderPB(header *types.Header) (cmproto.Header, error) {
return cmproto.Header{
Version: cmversion.Consensus{
Block: header.Version.Block,
App: header.Version.App,
},
Height: int64(header.Height()),
Time: header.Time(),
LastBlockId: tmproto.BlockID{
LastBlockId: cmproto.BlockID{
Hash: header.LastHeaderHash[:],
PartSetHeader: tmproto.PartSetHeader{
PartSetHeader: cmproto.PartSetHeader{
Total: 0,
Hash: nil,
},
},
LastCommitHash: header.LastCommitHash[:],
LastCommitHash: header.LastHeaderHash[:],
DataHash: header.DataHash[:],
ValidatorsHash: header.AggregatorsHash[:],
NextValidatorsHash: nil,
ConsensusHash: header.ConsensusHash[:],
AppHash: header.AppHash[:],
LastResultsHash: header.LastResultsHash[:],
EvidenceHash: new(tmtypes.EvidenceData).Hash(),
EvidenceHash: new(cmtypes.EvidenceData).Hash(),
ProposerAddress: header.ProposerAddress,
ChainID: header.ChainID(),
}, nil
}

// ToABCIHeader converts Rollkit header to Header format defined in ABCI.
// Caller should fill all the fields that are not available in Rollkit header (like ChainID).
func ToABCIHeader(header *types.Header) (tmtypes.Header, error) {
return tmtypes.Header{
Version: tmversion.Consensus{
func ToABCIHeader(header *types.Header) (cmtypes.Header, error) {
return cmtypes.Header{
Version: cmversion.Consensus{
Block: header.Version.Block,
App: header.Version.App,
},
Height: int64(header.Height()),
Time: header.Time(),
LastBlockID: tmtypes.BlockID{
Hash: tmbytes.HexBytes(header.LastHeaderHash),
PartSetHeader: tmtypes.PartSetHeader{
LastBlockID: cmtypes.BlockID{
Hash: cmbytes.HexBytes(header.LastHeaderHash[:]),
PartSetHeader: cmtypes.PartSetHeader{
Total: 0,
Hash: nil,
},
},
LastCommitHash: tmbytes.HexBytes(header.LastCommitHash),
DataHash: tmbytes.HexBytes(header.DataHash),
ValidatorsHash: tmbytes.HexBytes(header.AggregatorsHash),
LastCommitHash: cmbytes.HexBytes(header.LastCommitHash),
DataHash: cmbytes.HexBytes(header.DataHash),
ValidatorsHash: cmbytes.HexBytes(header.AggregatorsHash),
NextValidatorsHash: nil,
ConsensusHash: tmbytes.HexBytes(header.ConsensusHash),
AppHash: tmbytes.HexBytes(header.AppHash),
LastResultsHash: tmbytes.HexBytes(header.LastResultsHash),
EvidenceHash: new(tmtypes.EvidenceData).Hash(),
ConsensusHash: cmbytes.HexBytes(header.ConsensusHash),
AppHash: cmbytes.HexBytes(header.AppHash),
LastResultsHash: cmbytes.HexBytes(header.LastResultsHash),
EvidenceHash: new(cmtypes.EvidenceData).Hash(),
ProposerAddress: header.ProposerAddress,
ChainID: header.ChainID(),
}, nil
}

// ToABCIBlock converts Rolkit block into block format defined by ABCI.
// Returned block should pass `ValidateBasic`.
func ToABCIBlock(block *types.Block) (*tmtypes.Block, error) {
func ToABCIBlock(block *types.Block) (*cmtypes.Block, error) {
abciHeader, err := ToABCIHeader(&block.SignedHeader.Header)
if err != nil {
return nil, err
Expand All @@ -81,34 +81,34 @@ func ToABCIBlock(block *types.Block) (*tmtypes.Block, error) {
if len(abciCommit.Signatures) == 1 {
abciCommit.Signatures[0].ValidatorAddress = block.SignedHeader.Header.ProposerAddress
}
abciBlock := tmtypes.Block{
abciBlock := cmtypes.Block{
Header: abciHeader,
Evidence: tmtypes.EvidenceData{
Evidence: cmtypes.EvidenceData{
Evidence: nil,
},
LastCommit: abciCommit,
}
abciBlock.Data.Txs = make([]tmtypes.Tx, len(block.Data.Txs))
abciBlock.Data.Txs = make([]cmtypes.Tx, len(block.Data.Txs))
for i := range block.Data.Txs {
abciBlock.Data.Txs[i] = tmtypes.Tx(block.Data.Txs[i])
abciBlock.Data.Txs[i] = cmtypes.Tx(block.Data.Txs[i])
}
abciBlock.Header.DataHash = tmbytes.HexBytes(block.SignedHeader.Header.DataHash)
abciBlock.Header.DataHash = cmbytes.HexBytes(block.SignedHeader.Header.DataHash)

return &abciBlock, nil
}

// ToABCIBlockMeta converts Rollkit block into BlockMeta format defined by ABCI
func ToABCIBlockMeta(block *types.Block) (*tmtypes.BlockMeta, error) {
tmblock, err := ToABCIBlock(block)
func ToABCIBlockMeta(block *types.Block) (*cmtypes.BlockMeta, error) {
cmblock, err := ToABCIBlock(block)
if err != nil {
return nil, err
}
blockID := tmtypes.BlockID{Hash: tmblock.Hash()}
blockID := cmtypes.BlockID{Hash: cmblock.Hash()}

return &tmtypes.BlockMeta{
return &cmtypes.BlockMeta{
BlockID: blockID,
BlockSize: tmblock.Size(),
Header: tmblock.Header,
NumTxs: len(tmblock.Txs),
BlockSize: cmblock.Size(),
Header: cmblock.Header,
NumTxs: len(cmblock.Txs),
}, nil
}
32 changes: 16 additions & 16 deletions conv/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package conv

import (
tmcfg "github.com/tendermint/tendermint/config"
cmcfg "github.com/cometbft/cometbft/config"

"github.com/rollkit/rollkit/config"
)
Expand All @@ -10,22 +10,22 @@ import (
//
// This method only translates configuration, and doesn't verify it. If some option is missing in Tendermint's
// config, it's skipped during translation.
func GetNodeConfig(nodeConf *config.NodeConfig, tmConf *tmcfg.Config) {
if tmConf != nil {
nodeConf.RootDir = tmConf.RootDir
nodeConf.DBPath = tmConf.DBPath
if tmConf.P2P != nil {
nodeConf.P2P.ListenAddress = tmConf.P2P.ListenAddress
nodeConf.P2P.Seeds = tmConf.P2P.Seeds
func GetNodeConfig(nodeConf *config.NodeConfig, cmConf *cmcfg.Config) {
if cmConf != nil {
nodeConf.RootDir = cmConf.RootDir
nodeConf.DBPath = cmConf.DBPath
if cmConf.P2P != nil {
nodeConf.P2P.ListenAddress = cmConf.P2P.ListenAddress
nodeConf.P2P.Seeds = cmConf.P2P.Seeds
}
if tmConf.RPC != nil {
nodeConf.RPC.ListenAddress = tmConf.RPC.ListenAddress
nodeConf.RPC.CORSAllowedOrigins = tmConf.RPC.CORSAllowedOrigins
nodeConf.RPC.CORSAllowedMethods = tmConf.RPC.CORSAllowedMethods
nodeConf.RPC.CORSAllowedHeaders = tmConf.RPC.CORSAllowedHeaders
nodeConf.RPC.MaxOpenConnections = tmConf.RPC.MaxOpenConnections
nodeConf.RPC.TLSCertFile = tmConf.RPC.TLSCertFile
nodeConf.RPC.TLSKeyFile = tmConf.RPC.TLSKeyFile
if cmConf.RPC != nil {
nodeConf.RPC.ListenAddress = cmConf.RPC.ListenAddress
nodeConf.RPC.CORSAllowedOrigins = cmConf.RPC.CORSAllowedOrigins
nodeConf.RPC.CORSAllowedMethods = cmConf.RPC.CORSAllowedMethods
nodeConf.RPC.CORSAllowedHeaders = cmConf.RPC.CORSAllowedHeaders
nodeConf.RPC.MaxOpenConnections = cmConf.RPC.MaxOpenConnections
nodeConf.RPC.TLSCertFile = cmConf.RPC.TLSCertFile
nodeConf.RPC.TLSKeyFile = cmConf.RPC.TLSKeyFile
}
}
}
12 changes: 6 additions & 6 deletions conv/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/stretchr/testify/assert"

tmcfg "github.com/tendermint/tendermint/config"
cmcfg "github.com/cometbft/cometbft/config"

"github.com/rollkit/rollkit/config"
)
Expand All @@ -15,14 +15,14 @@ func TestGetNodeConfig(t *testing.T) {

cases := []struct {
name string
input *tmcfg.Config
input *cmcfg.Config
expected config.NodeConfig
}{
{"empty", nil, config.NodeConfig{}},
{"Seeds", &tmcfg.Config{P2P: &tmcfg.P2PConfig{Seeds: "seeds"}}, config.NodeConfig{P2P: config.P2PConfig{Seeds: "seeds"}}},
{"ListenAddress", &tmcfg.Config{P2P: &tmcfg.P2PConfig{ListenAddress: "127.0.0.1:7676"}}, config.NodeConfig{P2P: config.P2PConfig{ListenAddress: "127.0.0.1:7676"}}},
{"RootDir", &tmcfg.Config{BaseConfig: tmcfg.BaseConfig{RootDir: "~/root"}}, config.NodeConfig{RootDir: "~/root"}},
{"DBPath", &tmcfg.Config{BaseConfig: tmcfg.BaseConfig{DBPath: "./database"}}, config.NodeConfig{DBPath: "./database"}},
{"Seeds", &cmcfg.Config{P2P: &cmcfg.P2PConfig{Seeds: "seeds"}}, config.NodeConfig{P2P: config.P2PConfig{Seeds: "seeds"}}},
{"ListenAddress", &cmcfg.Config{P2P: &cmcfg.P2PConfig{ListenAddress: "127.0.0.1:7676"}}, config.NodeConfig{P2P: config.P2PConfig{ListenAddress: "127.0.0.1:7676"}}},
{"RootDir", &cmcfg.Config{BaseConfig: cmcfg.BaseConfig{RootDir: "~/root"}}, config.NodeConfig{RootDir: "~/root"}},
{"DBPath", &cmcfg.Config{BaseConfig: cmcfg.BaseConfig{DBPath: "./database"}}, config.NodeConfig{DBPath: "./database"}},
}

for _, c := range cases {
Expand Down
3 changes: 1 addition & 2 deletions conv/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"errors"
"fmt"

p2p "github.com/cometbft/cometbft/p2p"
"github.com/libp2p/go-libp2p/core/crypto"

"github.com/tendermint/tendermint/p2p"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions conv/crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cometbft/cometbft/crypto/ed25519"
"github.com/cometbft/cometbft/crypto/secp256k1"
"github.com/cometbft/cometbft/p2p"
pb "github.com/libp2p/go-libp2p/core/crypto/pb"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/tendermint/tendermint/p2p"
)

func TestGetNodeKey(t *testing.T) {
Expand Down
Loading