Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d06c288
WIP on node interface seggregation
yarikbratashchuk Nov 27, 2024
3fce7ae
Fix compile errors
yarikbratashchuk Dec 3, 2024
fb1e4ec
Remove rpc server from rollkit
yarikbratashchuk Dec 10, 2024
12f7e65
Fix lint errors
yarikbratashchuk Dec 12, 2024
d3df482
Fix some more lint issues
yarikbratashchuk Dec 12, 2024
1704717
Comment out unreachable code
yarikbratashchuk Dec 12, 2024
75872c2
Handle CI mode for node
yarikbratashchuk Dec 12, 2024
13cc399
Fix full node
yarikbratashchuk Dec 16, 2024
503c98b
Docs gen
yarikbratashchuk Dec 16, 2024
0fb08e1
Fix lint errors
yarikbratashchuk Dec 17, 2024
00ad30d
Fix vulns found by dependabot
yarikbratashchuk Dec 17, 2024
b7d5ec0
Fix markdown lint
yarikbratashchuk Dec 17, 2024
a2c4b28
Fixes for lint fixes
yarikbratashchuk Dec 17, 2024
975a289
Remove rpc-equivalency-coverage
yarikbratashchuk Dec 17, 2024
0abc30d
Fix serialization tests
yarikbratashchuk Dec 17, 2024
590b8a6
Remove proxy client creator
yarikbratashchuk Jan 7, 2025
a8529b5
Fix linting issues
yarikbratashchuk Jan 7, 2025
6468fc5
Fix tests, typos
yarikbratashchuk Jan 9, 2025
5bb907a
Start mock executor on rollkit start
yarikbratashchuk Jan 9, 2025
efa6ad2
Comment out publish block test
yarikbratashchuk Jan 9, 2025
5a9cb2d
Comment out node failing tests for now, will uncomment and fix them o…
yarikbratashchuk Jan 9, 2025
f6b391d
Revorking tests, commenting out execution bits
yarikbratashchuk Jan 15, 2025
c93989b
WIP: revorking tests
yarikbratashchuk Jan 16, 2025
fa42d1a
Remove tendermint types from state proto to make restarting work
yarikbratashchuk Jan 17, 2025
ca9bcfe
Fix linting issues
yarikbratashchuk Jan 21, 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
Prev Previous commit
Next Next commit
Fix linting issues
  • Loading branch information
yarikbratashchuk committed Jan 7, 2025
commit a8529b5be9b3f7fb30c5024b38e5e60c8d2733f6
13 changes: 3 additions & 10 deletions block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ func (m *Manager) sign(payload []byte) ([]byte, error) {
}
}

func (m *Manager) processVoteExtension(ctx context.Context, header *types.SignedHeader, data *types.Data, newHeight uint64) error {
func (m *Manager) processVoteExtension(_ context.Context, _ *types.SignedHeader, _ *types.Data, _ uint64) error {
// TODO(tzdybal): remove this function completely
return nil // noop
/*
Expand Down Expand Up @@ -1418,13 +1418,6 @@ func (m *Manager) exponentialBackoff(backoff time.Duration) time.Duration {
return backoff
}

//nolint:unused // This function is kept for future validator set management
func (m *Manager) getLastStateValidators() *cmtypes.ValidatorSet {
m.lastStateMtx.RLock()
defer m.lastStateMtx.RUnlock()
return m.lastState.Validators
}

// Updates the state stored in manager's store along the manager's lastState
func (m *Manager) updateState(ctx context.Context, s types.State) error {
m.lastStateMtx.Lock()
Expand Down Expand Up @@ -1461,12 +1454,12 @@ func (m *Manager) execValidate(_ types.State, _ *types.SignedHeader, _ *types.Da
return nil
}

func (m *Manager) execCommit(ctx context.Context, newState types.State, h *types.SignedHeader, d *types.Data, responses *abci.ResponseFinalizeBlock) ([]byte, error) {
func (m *Manager) execCommit(ctx context.Context, newState types.State, h *types.SignedHeader, _ *types.Data, _ *abci.ResponseFinalizeBlock) ([]byte, error) {
err := m.exec.SetFinal(ctx, h.Height())
return newState.AppHash, err
}

func (m *Manager) execCreateBlock(ctx context.Context, height uint64, lastSignature *types.Signature, commit abci.ExtendedCommitInfo, hash types.Hash, lastState types.State, txs cmtypes.Txs, timestamp time.Time) (*types.SignedHeader, *types.Data, error) {
func (m *Manager) execCreateBlock(_ context.Context, height uint64, lastSignature *types.Signature, _ abci.ExtendedCommitInfo, _ types.Hash, lastState types.State, txs cmtypes.Txs, timestamp time.Time) (*types.SignedHeader, *types.Data, error) {
// TODO(tzdybal): get rid of cmtypes.Tx, probable we should have common-shared-dep with basic types
rawTxs := make([]execTypes.Tx, len(txs))
for i := range txs {
Expand Down
24 changes: 0 additions & 24 deletions node/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import (
"google.golang.org/grpc/credentials/insecure"

abci "github.com/cometbft/cometbft/abci/types"
llcfg "github.com/cometbft/cometbft/config"
"github.com/cometbft/cometbft/libs/log"
"github.com/cometbft/cometbft/libs/service"
corep2p "github.com/cometbft/cometbft/p2p"
proxy "github.com/cometbft/cometbft/proxy"
cmtypes "github.com/cometbft/cometbft/types"

proxyda "github.com/rollkit/go-da/proxy"
Expand Down Expand Up @@ -187,16 +185,6 @@ func newFullNode(
return node, nil
}

//nolint:unused
func initProxyApp(clientCreator proxy.ClientCreator, logger log.Logger, metrics *proxy.Metrics) (proxy.AppConns, error) {
proxyApp := proxy.NewAppConns(clientCreator, metrics)
proxyApp.SetLogger(logger.With("module", "proxy"))
if err := proxyApp.Start(); err != nil {
return nil, fmt.Errorf("error while starting proxy app connections: %w", err)
}
return proxyApp, nil
}

func initEventBus(logger log.Logger) (*cmtypes.EventBus, error) {
eventBus := cmtypes.NewEventBus()
eventBus.SetLogger(logger.With("module", "events"))
Expand Down Expand Up @@ -239,18 +227,6 @@ func initDALC(nodeConfig config.NodeConfig, logger log.Logger) (*da.DAClient, er
namespace, submitOpts, logger.With("module", "da_client")), nil
}

//nolint:unused
func initMempool(memplMetrics *mempool.Metrics) *mempool.CListMempool {
mempool := mempool.NewCListMempool(llcfg.DefaultMempoolConfig(), nil, 0, mempool.WithMetrics(memplMetrics))
mempool.EnableTxsAvailable()
return mempool
}

//nolint:unused
func initMempoolReaper(m mempool.Mempool, rollupID []byte, seqClient *seqGRPC.Client, logger log.Logger) *mempool.CListMempoolReaper {
return mempool.NewCListMempoolReaper(m, rollupID, seqClient, logger)
}

func initHeaderSyncService(mainKV ds.TxnDatastore, nodeConfig config.NodeConfig, genesis *cmtypes.GenesisDoc, p2pClient *p2p.Client, logger log.Logger) (*block.HeaderSyncService, error) {
headerSyncService, err := block.NewHeaderSyncService(mainKV, nodeConfig, genesis, p2pClient, logger.With("module", "HeaderSyncService"))
if err != nil {
Expand Down
20 changes: 17 additions & 3 deletions node/full_node_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/rollkit/rollkit/block"
"github.com/rollkit/rollkit/config"
"github.com/rollkit/rollkit/da"
test "github.com/rollkit/rollkit/test/log"
testlog "github.com/rollkit/rollkit/test/log"
"github.com/rollkit/rollkit/test/mocks"
"github.com/rollkit/rollkit/types"
)
Expand All @@ -57,6 +57,9 @@ func TestAggregatorMode(t *testing.T) {
app.On("FinalizeBlock", mock.Anything, mock.Anything).Return(finalizeBlockResponse)
app.On("Commit", mock.Anything, mock.Anything).Return(&abci.ResponseCommit{}, nil)

// Create and configure mock DA client
dalc := getMockDA(t)

key, _, _ := crypto.GenerateEd25519Key(rand.Reader)
genesisDoc, genesisValidatorKey := types.GetGenesisWithPrivkey(types.DefaultSigningKeyType, "TestAggregatorMode")
signingKey, err := types.PrivKeyToSigningKey(genesisValidatorKey)
Expand All @@ -66,10 +69,21 @@ func TestAggregatorMode(t *testing.T) {
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
node, err := newFullNode(ctx, config.NodeConfig{DAAddress: MockDAAddress, DANamespace: MockDANamespace, Aggregator: true, BlockManagerConfig: blockManagerConfig, SequencerAddress: MockSequencerAddress}, key, signingKey, genesisDoc, DefaultMetricsProvider(cmconfig.DefaultInstrumentationConfig()), log.TestingLogger())

node, err := newFullNode(ctx, config.NodeConfig{
DAAddress: MockDAAddress,
DANamespace: MockDANamespace,
Aggregator: true,
BlockManagerConfig: blockManagerConfig,
SequencerAddress: MockSequencerAddress,
}, key, signingKey, genesisDoc, DefaultMetricsProvider(cmconfig.DefaultInstrumentationConfig()), log.TestingLogger())
require.NoError(err)
require.NotNil(node)

// Set the mock DA client
node.dalc = dalc
node.blockManager.SetDALC(dalc)

assert.False(node.IsRunning())

startNodeWithCleanup(t, node)
Expand Down Expand Up @@ -1098,7 +1112,7 @@ func createNode(ctx context.Context, n int, aggregator bool, isLight bool, keys
keys[n],
genesis,
DefaultMetricsProvider(cmconfig.DefaultInstrumentationConfig()),
test.NewFileLoggerCustom(t, test.TempLogFileName(t, fmt.Sprintf("node%v", n))).With("node", n))
testlog.NewFileLoggerCustom(t, testlog.TempLogFileName(t, fmt.Sprintf("node%v", n))).With("node", n))
require.NoError(err)
require.NotNil(node)

Expand Down
24 changes: 1 addition & 23 deletions node/full_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/stretchr/testify/require"

"github.com/libp2p/go-libp2p/core/crypto"
"github.com/libp2p/go-libp2p/core/peer"

goDA "github.com/rollkit/go-da"
damock "github.com/rollkit/go-da/mocks"
Expand Down Expand Up @@ -436,7 +435,7 @@ func createAggregatorWithPersistence(ctx context.Context, dbPath string, dalc *d
return fullNode, app
}

func createAggregatorWithApp(ctx context.Context, chainID string, app abci.Application, voteExtensionEnableHeight int64, signingKeyType string, t *testing.T) (Node, cmcrypto.PubKey) {
func createAggregatorWithApp(ctx context.Context, chainID string, _ abci.Application, voteExtensionEnableHeight int64, signingKeyType string, t *testing.T) (Node, cmcrypto.PubKey) {
t.Helper()

key, _, _ := crypto.GenerateEd25519Key(rand.Reader)
Expand Down Expand Up @@ -477,18 +476,6 @@ func createAggregatorWithApp(ctx context.Context, chainID string, app abci.Appli
return node, genesis.Validators[0].PubKey
}

// setupMockApplication initializes a mock application
func setupMockApplication() *mocks.Application {
app := &mocks.Application{}
app.On("InitChain", mock.Anything, mock.Anything).Return(&abci.ResponseInitChain{}, nil)
app.On("CheckTx", mock.Anything, mock.Anything).Return(&abci.ResponseCheckTx{}, nil)
app.On("PrepareProposal", mock.Anything, mock.Anything).Return(prepareProposalResponse).Maybe()
app.On("ProcessProposal", mock.Anything, mock.Anything).Return(&abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_ACCEPT}, nil)
app.On("FinalizeBlock", mock.Anything, mock.Anything).Return(&abci.ResponseFinalizeBlock{AppHash: []byte{1, 2, 3, 4}}, nil)
app.On("Commit", mock.Anything, mock.Anything).Return(&abci.ResponseCommit{}, nil)
return app
}

// generateSingleKey generates a single private key
func generateSingleKey() crypto.PrivKey {
key, _, err := crypto.GenerateEd25519Key(rand.Reader)
Expand All @@ -497,12 +484,3 @@ func generateSingleKey() crypto.PrivKey {
}
return key
}

//nolint:unused
func getPeerID(t *testing.T) peer.ID {
key := generateSingleKey()

peerID, err := peer.IDFromPrivateKey(key)
assert.NoError(t, err)
return peerID
}
9 changes: 0 additions & 9 deletions node/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,3 @@ func (ids *mempoolIDs) GetForPeer(peer peer.ID) uint16 {

return id
}

//nolint:unused
func newMempoolIDs() *mempoolIDs {
return &mempoolIDs{
peerMap: make(map[peer.ID]uint16),
activeIDs: map[uint16]struct{}{0: {}},
nextID: 1, // reserve unknownPeerID(0) for mempoolReactor.BroadcastTx
}
}
9 changes: 5 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,22 @@ func NewNode(
metricsProvider MetricsProvider,
logger log.Logger,
) (Node, error) {
if !conf.Light {
return newFullNode(
if conf.Light {
return newLightNode(
ctx,
conf,
p2pKey,
signingKey,
genesis,
metricsProvider,
logger,
)
}
return newLightNode(

return newFullNode(
ctx,
conf,
p2pKey,
signingKey,
genesis,
metricsProvider,
logger,
Expand Down
5 changes: 2 additions & 3 deletions state/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (e *BlockExecutor) updateConsensusParams(height uint64, params cmtypes.Cons
return nextParams.ToProto(), nextParams.Version.App, nil
}

func (e *BlockExecutor) updateState(state types.State, header *types.SignedHeader, data *types.Data, finalizeBlockResponse *abci.ResponseFinalizeBlock, validatorUpdates []*cmtypes.Validator) (types.State, error) {
func (e *BlockExecutor) updateState(state types.State, header *types.SignedHeader, _ *types.Data, finalizeBlockResponse *abci.ResponseFinalizeBlock, validatorUpdates []*cmtypes.Validator) (types.State, error) {
height := header.Height()
if finalizeBlockResponse.ConsensusParamUpdates != nil {
nextParamsProto, appVersion, err := e.updateConsensusParams(height, types.ConsensusParamsFromProto(state.ConsensusParams), finalizeBlockResponse.ConsensusParamUpdates)
Expand Down Expand Up @@ -428,7 +428,6 @@ func (e *BlockExecutor) execute(ctx context.Context, state types.State, header *
if err != nil {
return nil, err
}
abciHeader.ChainID = e.chainID
abciBlock, err := abciconv.ToABCIBlock(header, data)
if err != nil {
return nil, err
Expand Down Expand Up @@ -473,7 +472,7 @@ func (e *BlockExecutor) execute(ctx context.Context, state types.State, header *
return finalizeBlockResponse, nil
}

func (e *BlockExecutor) publishEvents(resp *abci.ResponseFinalizeBlock, header *types.SignedHeader, data *types.Data, state types.State) {
func (e *BlockExecutor) publishEvents(resp *abci.ResponseFinalizeBlock, header *types.SignedHeader, data *types.Data, _ types.State) {
if e.eventBus == nil {
return
}
Expand Down