diff --git a/.gitignore b/.gitignore index bd3ce4287..c046ac465 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ proto/pb .idea .go-version build + +vendor/ \ No newline at end of file diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 000000000..f3ab91414 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +golang 1.20 diff --git a/block/metrics.go b/block/metrics.go index 430a428c2..7934edc29 100644 --- a/block/metrics.go +++ b/block/metrics.go @@ -13,3 +13,11 @@ var rollappHubHeightGauge = promauto.NewGauge(prometheus.GaugeOpts{ Name: "rollapp_hub_height", Help: "The latest height of the Rollapp that has been synced to the hub.", }) +var rollappBlockSizeBytesGauge = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "rollapp_block_size_bytes", + Help: "Rollapp ", +}) +var rollappBlockSizeTxsGauge = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "rollapp_block_size_txs", + Help: "Rollapp ", +}) diff --git a/block/produce.go b/block/produce.go index 540ab55f5..10420430a 100644 --- a/block/produce.go +++ b/block/produce.go @@ -157,6 +157,8 @@ func (m *Manager) produceBlock(ctx context.Context, allowEmpty bool) error { } m.logger.Info("block created", "height", newHeight, "num_tx", len(block.Data.Txs)) + rollappBlockSizeBytesGauge.Set(float64(len(block.Data.Txs))) + rollappBlockSizeTxsGauge.Set(float64(len(block.Data.Txs))) rollappHeightGauge.Set(float64(newHeight)) return nil } diff --git a/cmd/dymint/commands/start.go b/cmd/dymint/commands/start.go index bf4294e5f..e3cc6554f 100644 --- a/cmd/dymint/commands/start.go +++ b/cmd/dymint/commands/start.go @@ -10,6 +10,7 @@ import ( cfg "github.com/dymensionxyz/dymint/config" "github.com/dymensionxyz/dymint/conv" + "github.com/dymensionxyz/dymint/mempool" "github.com/dymensionxyz/dymint/node" "github.com/dymensionxyz/dymint/rpc" "github.com/spf13/cobra" @@ -95,6 +96,7 @@ func startInProcess(config *cfg.NodeConfig, tmConfig *tmcfg.Config, logger log.L proxy.DefaultClientCreator(tmConfig.ProxyApp, tmConfig.ABCI, tmConfig.DBDir()), genesis, logger, + mempool.PrometheusMetrics("dymint"), ) if err != nil { return err diff --git a/node/integration_test.go b/node/integration_test.go index 22e5773c6..fdd83344b 100644 --- a/node/integration_test.go +++ b/node/integration_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "github.com/dymensionxyz/dymint/mempool" "github.com/dymensionxyz/dymint/p2p" "github.com/dymensionxyz/dymint/settlement" "github.com/stretchr/testify/assert" @@ -66,7 +67,7 @@ func TestAggregatorMode(t *testing.T) { SettlementLayer: "mock", SettlementConfig: settlement.Config{ProposerPubKey: proposerKey}, } - node, err := NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger()) + node, err := NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger(), mempool.NopMetrics()) require.NoError(err) require.NotNil(node) diff --git a/node/node.go b/node/node.go index 43fc6a8e6..4af00daef 100644 --- a/node/node.go +++ b/node/node.go @@ -117,7 +117,7 @@ type Node struct { } // NewNode creates new Dymint node. -func NewNode(ctx context.Context, conf config.NodeConfig, p2pKey crypto.PrivKey, signingKey crypto.PrivKey, clientCreator proxy.ClientCreator, genesis *tmtypes.GenesisDoc, logger log.Logger) (*Node, error) { +func NewNode(ctx context.Context, conf config.NodeConfig, p2pKey crypto.PrivKey, signingKey crypto.PrivKey, clientCreator proxy.ClientCreator, genesis *tmtypes.GenesisDoc, logger log.Logger, metrics *mempool.Metrics) (*Node, error) { proxyApp := proxy.NewAppConns(clientCreator) proxyApp.SetLogger(logger.With("module", "proxy")) if err := proxyApp.Start(); err != nil { diff --git a/node/node_test.go b/node/node_test.go index f0e09b786..6a1480391 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -76,7 +76,7 @@ func TestMempoolDirectly(t *testing.T) { SettlementLayer: "mock", SettlementConfig: settlement.Config{}, } - node, err := NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger()) + node, err := NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger(), mempool.NopMetrics()) require.NoError(err) require.NotNil(node) diff --git a/node/testutils.go b/node/testutils.go index 79b8703be..d18d7d6dc 100644 --- a/node/testutils.go +++ b/node/testutils.go @@ -7,6 +7,7 @@ import ( "time" "github.com/dymensionxyz/dymint/config" + "github.com/dymensionxyz/dymint/mempool" "github.com/dymensionxyz/dymint/settlement" "github.com/dymensionxyz/dymint/testutil" "github.com/libp2p/go-libp2p/core/crypto" @@ -39,7 +40,7 @@ func CreateNode(isAggregator bool, blockManagerConfig *config.BlockManagerConfig // SL config nodeConfig.SettlementConfig = settlement.Config{ProposerPubKey: hex.EncodeToString(pubkeyBytes)} - node, err := NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger()) + node, err := NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger(), mempool.NopMetrics()) if err != nil { return nil, err } diff --git a/rpc/client/client_test.go b/rpc/client/client_test.go index fb18c5150..41cdb467d 100644 --- a/rpc/client/client_test.go +++ b/rpc/client/client_test.go @@ -27,6 +27,7 @@ import ( "github.com/dymensionxyz/dymint/config" abciconv "github.com/dymensionxyz/dymint/conv/abci" + "github.com/dymensionxyz/dymint/mempool" "github.com/dymensionxyz/dymint/mocks" "github.com/dymensionxyz/dymint/node" "github.com/dymensionxyz/dymint/settlement" @@ -112,7 +113,7 @@ func TestGenesisChunked(t *testing.T) { SettlementLayer: "mock", SettlementConfig: settlement.Config{}, } - n, _ := node.NewNode(context.Background(), config, privKey, signingKey, proxy.NewLocalClientCreator(mockApp), genDoc, log.TestingLogger()) + n, _ := node.NewNode(context.Background(), config, privKey, signingKey, proxy.NewLocalClientCreator(mockApp), genDoc, log.TestingLogger(), mempool.NopMetrics()) rpc := NewClient(n) @@ -447,7 +448,7 @@ func TestTx(t *testing.T) { }, key, signingKey, proxy.NewLocalClientCreator(mockApp), &tmtypes.GenesisDoc{ChainID: "test"}, - log.TestingLogger()) + log.TestingLogger(), mempool.NopMetrics()) require.NoError(err) require.NotNil(node) @@ -715,7 +716,7 @@ func TestValidatorSetHandling(t *testing.T) { SettlementConfig: settlement.Config{ProposerPubKey: hex.EncodeToString(proposerPubKeyBytes)}, } - node, err := node.NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test", Validators: genesisValidators}, log.TestingLogger()) + node, err := node.NewNode(context.Background(), nodeConfig, key, signingKey, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test", Validators: genesisValidators}, log.TestingLogger(), mempool.NopMetrics()) require.NoError(err) require.NotNil(node) @@ -837,7 +838,7 @@ func getRPC(t *testing.T) (*mocks.Application, *Client) { SettlementLayer: "mock", SettlementConfig: settlement.Config{ProposerPubKey: proposerKey}, } - node, err := node.NewNode(context.Background(), config, key, signingKey, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger()) + node, err := node.NewNode(context.Background(), config, key, signingKey, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger(), mempool.NopMetrics()) require.NoError(err) require.NotNil(node) @@ -923,7 +924,7 @@ func TestMempool2Nodes(t *testing.T) { P2P: config.P2PConfig{ ListenAddress: "/ip4/127.0.0.1/tcp/9001", }, - }, key1, signingKey1, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger()) + }, key1, signingKey1, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger(), mempool.NopMetrics()) require.NoError(err) require.NotNil(node1) @@ -943,7 +944,7 @@ func TestMempool2Nodes(t *testing.T) { ListenAddress: "/ip4/127.0.0.1/tcp/9002", Seeds: "/ip4/127.0.0.1/tcp/9001/p2p/" + id1.String(), }, - }, key2, signingKey2, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger()) + }, key2, signingKey2, proxy.NewLocalClientCreator(app), &tmtypes.GenesisDoc{ChainID: "test"}, log.TestingLogger(), mempool.NopMetrics()) require.NoError(err) require.NotNil(node1) diff --git a/rpc/json/service_test.go b/rpc/json/service_test.go index 87840d37b..476bba249 100644 --- a/rpc/json/service_test.go +++ b/rpc/json/service_test.go @@ -26,6 +26,7 @@ import ( "github.com/tendermint/tendermint/types" "github.com/dymensionxyz/dymint/config" + "github.com/dymensionxyz/dymint/mempool" "github.com/dymensionxyz/dymint/mocks" "github.com/dymensionxyz/dymint/node" "github.com/dymensionxyz/dymint/rpc/client" @@ -307,7 +308,7 @@ func getRPC(t *testing.T) (*mocks.Application, *client.Client) { SettlementConfig: settlement.Config{ ProposerPubKey: hex.EncodeToString(proposerPubKeyBytes)}, } - node, err := node.NewNode(context.Background(), config, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger()) + node, err := node.NewNode(context.Background(), config, key, signingKey, proxy.NewLocalClientCreator(app), &types.GenesisDoc{ChainID: "test"}, log.TestingLogger(), mempool.NopMetrics()) require.NoError(err) require.NotNil(node)