Skip to content
Draft
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
3 changes: 3 additions & 0 deletions l2node/l2node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package l2node
import (
"fmt"

eth "github.com/morph-l2/go-ethereum/core/types"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/types"
)
Expand Down Expand Up @@ -91,6 +92,8 @@ type Batcher interface {
AppendBlsData(height int64, batchHash []byte, data BlsData) error

BatchHash(batchHeader []byte) ([]byte, error)

BatchByIndex(index uint64) (*eth.RollupBatch, []*eth.BatchSignature, error)
}
type GetFromBatchStartFunc func() (
parentBatchHeader []byte,
Expand Down
6 changes: 6 additions & 0 deletions l2node/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"fmt"
"os"

ethtypes "github.com/morph-l2/go-ethereum/core/types"

"github.com/tendermint/tendermint/crypto/tmhash"
tmjson "github.com/tendermint/tendermint/libs/json"
tmos "github.com/tendermint/tendermint/libs/os"
Expand Down Expand Up @@ -244,3 +246,7 @@ func (l *MockL2Node) AppendBlsData(height int64, batchHash []byte, data BlsData)
func (l *MockL2Node) BatchHash(batchHeader []byte) ([]byte, error) {
return tmhash.Sum(batchHeader), nil
}

func (l *MockL2Node) BatchByIndex(index uint64) (*ethtypes.RollupBatch, []*ethtypes.BatchSignature, error) {
return nil, nil, fmt.Errorf("not implemented")
}
8 changes: 8 additions & 0 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ type Node struct {
blockIndexer indexer.BlockIndexer
indexerService *txindex.IndexerService
prometheusSrv *http.Server
l2Node l2node.L2Node
}

func initDBs(config *cfg.Config, dbProvider DBProvider) (blockStore *store.BlockStore, stateDB dbm.DB, err error) {
Expand Down Expand Up @@ -942,6 +943,7 @@ func NewNode(
indexerService: indexerService,
blockIndexer: blockIndexer,
eventBus: eventBus,
l2Node: l2Node,
}
node.BaseService = *service.NewBaseService(logger, "Node", node)

Expand Down Expand Up @@ -1094,6 +1096,7 @@ func (n *Node) ConfigureRPC() error {
ConsensusState: n.consensusState,
P2PPeers: n.sw,
P2PTransport: n,
L2Node: n.l2Node,

PubKey: pubKey,
GenDoc: n.genesisDoc,
Expand Down Expand Up @@ -1263,6 +1266,11 @@ func (n *Node) BlockStore() *store.BlockStore {
return n.blockStore
}

// StateStore returns the Node's StateStore.
func (n *Node) StateStore() sm.Store {
return n.stateStore
}

// ConsensusState returns the Node's ConsensusState.
func (n *Node) ConsensusState() *cs.State {
return n.consensusState
Expand Down
20 changes: 20 additions & 0 deletions rpc/core/batch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package core

import (
"errors"

eth "github.com/morph-l2/go-ethereum/core/types"
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
)

// BatchByIndex(index uint64) (*eth.RollupBatch, []*eth.BatchSignature, error)
func BatchByIndex(ctx *rpctypes.Context, index uint64) (*eth.RollupBatch, []*eth.BatchSignature, error) {
if env == nil {
return nil, nil, errors.New("env is nil")
}
if env.L2Node == nil {
return nil, nil, errors.New("env.L2Node is nil")
}

return env.L2Node.BatchByIndex(index)
}
2 changes: 2 additions & 0 deletions rpc/core/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/consensus"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/l2node"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/p2p"
Expand Down Expand Up @@ -82,6 +83,7 @@ type Environment struct {
ConsensusState Consensus
P2PPeers peers
P2PTransport transport
L2Node l2node.L2Node

// objects
PubKey crypto.PubKey
Expand Down
3 changes: 3 additions & 0 deletions rpc/core/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ var Routes = map[string]*rpc.RPCFunc{

// evidence API
"broadcast_evidence": rpc.NewRPCFunc(BroadcastEvidence, "evidence"),

// batch API
"batch_by_index": rpc.NewRPCFunc(BatchByIndex, "index"),
}

// AddUnsafeRoutes adds unsafe routes.
Expand Down
Loading