Skip to content

Commit

Permalink
Remove gas info (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored Oct 31, 2024
1 parent b13d9f0 commit 81c31b4
Show file tree
Hide file tree
Showing 27 changed files with 33 additions and 176 deletions.
24 changes: 1 addition & 23 deletions cmd/api/docs/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 1 addition & 23 deletions cmd/api/docs/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions cmd/api/docs/swagger.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions cmd/api/handler/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@ func (s *AddressTestSuite) TestTransactions() {
s.Require().Equal(testTime, tx.Time)
s.Require().Equal(testTxHash, tx.Hash)
s.Require().EqualValues(1, tx.Position)
s.Require().EqualValues(10, tx.GasWanted)
s.Require().EqualValues(8, tx.GasUsed)
s.Require().EqualValues(10, tx.Nonce)
s.Require().EqualValues([]string{types.ActionTypeRollupDataSubmission.String()}, tx.ActionTypes)
s.Require().EqualValues(1, tx.ActionsCount)
Expand Down
4 changes: 0 additions & 4 deletions cmd/api/handler/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ var (
Height: 100,
Time: testTime,
Position: 1,
GasWanted: 10,
GasUsed: 8,
ActionsCount: 1,
Status: types.StatusSuccess,
Nonce: 10,
Expand Down Expand Up @@ -519,8 +517,6 @@ func (s *BlockTestSuite) TestGetTransactions() {
s.Require().Equal(testTime, tx.Time)
s.Require().Equal(testTxHash, tx.Hash)
s.Require().EqualValues(1, tx.Position)
s.Require().EqualValues(10, tx.GasWanted)
s.Require().EqualValues(8, tx.GasUsed)
s.Require().EqualValues(1, tx.ActionsCount)
s.Require().EqualValues(10, tx.Nonce)
s.Require().EqualValues(testAddress.Hash, tx.Signer)
Expand Down
4 changes: 0 additions & 4 deletions cmd/api/handler/responses/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ type BlockStats struct {
Fee string `example:"28347628346" json:"fee" swaggertype:"string"`
SupplyChange string `example:"8635234" json:"supply_change" swaggertype:"string"`
BlockTime uint64 `example:"12354" json:"block_time" swaggertype:"integer"`
GasWanted int64 `example:"1234" json:"gas_wanted" swaggertype:"integer"`
GasUsed int64 `example:"1234" json:"gas_used" swaggertype:"integer"`
BytesInBlock int64 `example:"1234" json:"bytes_in_block" swaggertype:"integer"`
}

Expand All @@ -77,8 +75,6 @@ func NewBlockStats(stats *storage.BlockStats) *BlockStats {
Fee: stats.Fee.String(),
SupplyChange: stats.SupplyChange.String(),
BlockTime: stats.BlockTime,
GasUsed: stats.GasUsed,
GasWanted: stats.GasWanted,
BytesInBlock: stats.BytesInBlock,
}
}
4 changes: 0 additions & 4 deletions cmd/api/handler/responses/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ type Tx struct {
Id uint64 `example:"321" format:"int64" json:"id" swaggertype:"integer"`
Height pkgTypes.Level `example:"100" format:"int64" json:"height" swaggertype:"integer"`
Position int64 `example:"11" format:"int64" json:"position" swaggertype:"integer"`
GasWanted int64 `example:"9348" format:"int64" json:"gas_wanted" swaggertype:"integer"`
GasUsed int64 `example:"4253" format:"int64" json:"gas_used" swaggertype:"integer"`
ActionsCount int64 `example:"1" format:"int64" json:"actions_count" swaggertype:"integer"`
Nonce uint32 `example:"1" format:"int64" json:"nonce" swaggertype:"integer"`
Hash string `example:"652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF" format:"binary" json:"hash" swaggertype:"string"`
Expand All @@ -39,8 +37,6 @@ func NewTx(tx storage.Tx) Tx {
Height: tx.Height,
Time: tx.Time,
Position: tx.Position,
GasWanted: tx.GasWanted,
GasUsed: tx.GasUsed,
ActionsCount: tx.ActionsCount,
Nonce: tx.Nonce,
Status: tx.Status,
Expand Down
4 changes: 2 additions & 2 deletions cmd/api/handler/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (sh StatsHandler) SummaryTimeframe(c echo.Context) error {

type seriesRequest struct {
Timeframe string `example:"hour" param:"timeframe" swaggertype:"string" validate:"required,oneof=hour day month"`
SeriesName string `example:"tps" param:"name" swaggertype:"string" validate:"required,oneof=data_size tps bps rbps fee supply_change block_time tx_count bytes_in_block gas_price gas_efficiency gas_used gas_wanted"`
SeriesName string `example:"tps" param:"name" swaggertype:"string" validate:"required,oneof=data_size tps bps rbps fee supply_change block_time tx_count bytes_in_block"`
From int64 `example:"1692892095" query:"from" swaggertype:"integer" validate:"omitempty,min=1"`
To int64 `example:"1692892095" query:"to" swaggertype:"integer" validate:"omitempty,min=1"`
}
Expand All @@ -85,7 +85,7 @@ type seriesRequest struct {
// @Tags stats
// @ID stats-series
// @Param timeframe path string true "Timeframe" Enums(hour, day, month)
// @Param name path string true "Series name" Enums(data_size, tps, bps, rbps, fee, supply_change, block_time, tx_count, bytes_in_block, gas_price, gas_efficiency, gas_used, gas_wanted)
// @Param name path string true "Series name" Enums(data_size, tps, bps, rbps, fee, supply_change, block_time, tx_count, bytes_in_block)
// @Param from query integer false "Time from in unix timestamp" mininum(1)
// @Param to query integer false "Time to in unix timestamp" mininum(1)
// @Produce json
Expand Down
4 changes: 0 additions & 4 deletions cmd/api/handler/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ func (s *StatsTestSuite) TestBlockStatsHistogram() {
storage.SeriesSupplyChange,
storage.SeriesTPS,
storage.SeriesTxCount,
storage.SeriesGasEfficiency,
storage.SeriesGasWanted,
storage.SeriesGasPrice,
storage.SeriesGasUsed,
} {

for _, tf := range []storage.Timeframe{
Expand Down
8 changes: 0 additions & 8 deletions cmd/api/handler/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ func (s *TxTestSuite) TestGet() {
s.Require().Equal(testTime, tx.Time)
s.Require().Equal(testTxHash, tx.Hash)
s.Require().EqualValues(1, tx.Position)
s.Require().EqualValues(10, tx.GasWanted)
s.Require().EqualValues(8, tx.GasUsed)
s.Require().EqualValues(1, tx.ActionsCount)
s.Require().EqualValues(10, tx.Nonce)
s.Require().EqualValues(testAddress.Hash, tx.Signer)
Expand Down Expand Up @@ -148,8 +146,6 @@ func (s *TxTestSuite) TestList() {
s.Require().Equal(testTime, tx.Time)
s.Require().Equal(testTxHash, tx.Hash)
s.Require().EqualValues(1, tx.Position)
s.Require().EqualValues(10, tx.GasWanted)
s.Require().EqualValues(8, tx.GasUsed)
s.Require().EqualValues(1, tx.ActionsCount)
s.Require().EqualValues(10, tx.Nonce)
s.Require().EqualValues(testAddress.Hash, tx.Signer)
Expand Down Expand Up @@ -245,8 +241,6 @@ func (s *TxTestSuite) TestListTime() {
s.Require().Equal(testTime, tx.Time)
s.Require().Equal(testTxHash, tx.Hash)
s.Require().EqualValues(1, tx.Position)
s.Require().EqualValues(10, tx.GasWanted)
s.Require().EqualValues(8, tx.GasUsed)
s.Require().EqualValues(1, tx.ActionsCount)
s.Require().EqualValues(10, tx.Nonce)
s.Require().EqualValues(testAddress.Hash, tx.Signer)
Expand Down Expand Up @@ -298,8 +292,6 @@ func (s *TxTestSuite) TestListWithActions() {
s.Require().Equal(testTime, tx.Time)
s.Require().Equal(testTxHash, tx.Hash)
s.Require().EqualValues(1, tx.Position)
s.Require().EqualValues(10, tx.GasWanted)
s.Require().EqualValues(8, tx.GasUsed)
s.Require().EqualValues(1, tx.ActionsCount)
s.Require().EqualValues(10, tx.Nonce)
s.Require().EqualValues(testAddress.Hash, tx.Signer)
Expand Down
4 changes: 0 additions & 4 deletions database/views/00_block_stats_by_hour.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS
sum(tx_count) as tx_count,
avg(block_time) as block_time,
percentile_agg(block_time) as block_time_pct,
sum(gas_wanted) as gas_wanted,
sum(gas_used) as gas_used,
(case when sum(gas_wanted) > 0 then sum(fee) / sum(gas_wanted) else 0 end) as gas_price,
(case when sum(gas_wanted) > 0 then sum(gas_used) / sum(gas_wanted) else 0 end) as gas_efficiency,
sum(supply_change) as supply_change,
sum(fee) as fee,
sum(bytes_in_block) as bytes_in_block,
Expand Down
4 changes: 0 additions & 4 deletions database/views/01_block_stats_by_day.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS
sum(tx_count) as tx_count,
mean(rollup(block_time_pct)) as block_time,
rollup(block_time_pct) as block_time_pct,
sum(gas_wanted) as gas_wanted,
sum(gas_used) as gas_used,
(case when sum(gas_wanted) > 0 then sum(fee) / sum(gas_wanted) else 0 end) as gas_price,
(case when sum(gas_wanted) > 0 then sum(gas_used) / sum(gas_wanted) else 0 end) as gas_efficiency,
sum(fee) as fee,
sum(supply_change) as supply_change,
sum(bytes_in_block) as bytes_in_block,
Expand Down
4 changes: 0 additions & 4 deletions database/views/02_block_stats_by_month.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ WITH (timescaledb.continuous, timescaledb.materialized_only=false) AS
sum(tx_count) as tx_count,
mean(rollup(block_time_pct)) as block_time,
rollup(block_time_pct) as block_time_pct,
sum(gas_wanted) as gas_wanted,
sum(gas_used) as gas_used,
(case when sum(gas_wanted) > 0 then sum(fee) / sum(gas_wanted) else 0 end) as gas_price,
(case when sum(gas_wanted) > 0 then sum(gas_used) / sum(gas_wanted) else 0 end) as gas_efficiency,
sum(fee) as fee,
sum(supply_change) as supply_change,
sum(bytes_in_block) as bytes_in_block,
Expand Down
2 changes: 0 additions & 2 deletions internal/storage/block_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type BlockStats struct {

TxCount int64 `bun:"tx_count" comment:"Count of transactions in block"`
BlockTime uint64 `bun:"block_time" comment:"Time in milliseconds between current and previous block"`
GasWanted int64 `bun:"gas_wanted" comment:"Total gas limit in the block"`
GasUsed int64 `bun:"gas_used" comment:"Total gas used in the block"`
SupplyChange decimal.Decimal `bun:",type:numeric" comment:"Change of total supply in the block"`
Fee decimal.Decimal `bun:"fee,type:numeric" comment:"Summary block fee"`
BytesInBlock int64 `bun:"bytes_in_block" comment:"Size of all transactions in bytes"`
Expand Down
10 changes: 5 additions & 5 deletions internal/storage/postgres/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (b *Blocks) ByHeight(ctx context.Context, height types.Level, withStats boo
query = query.
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee, stats.gas_used AS stats__gas_used, stats.gas_wanted AS stats__gas_wanted").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
Join("left join block_stats as stats ON stats.height = block.height")
}

Expand Down Expand Up @@ -76,7 +76,7 @@ func (b *Blocks) ByHash(ctx context.Context, hash []byte) (block storage.Block,
ColumnExpr("validator.id as proposer__id, validator.address as proposer__address, validator.name as proposer__name").
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee, stats.gas_used AS stats__gas_used, stats.gas_wanted AS stats__gas_wanted").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
Join("left join validator on block.proposer_id = validator.id").
Join("left join block_stats as stats ON stats.height = block.height").
Scan(ctx, &block)
Expand All @@ -93,7 +93,7 @@ func (b *Blocks) ListWithStats(ctx context.Context, limit, offset uint64, order
ColumnExpr("v.id AS proposer__id, v.address as proposer__address, v.name as proposer__name").
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee, stats.gas_used AS stats__gas_used, stats.gas_wanted AS stats__gas_wanted").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
TableExpr("(?) as block", subQuery).
Join("LEFT JOIN block_stats as stats ON stats.height = block.height").
Join("LEFT JOIN validator as v ON v.id = block.proposer_id")
Expand All @@ -116,7 +116,7 @@ func (b *Blocks) ByProposer(ctx context.Context, proposerId uint64, limit, offse
ColumnExpr("v.id AS proposer__id, v.address as proposer__address, v.name as proposer__name").
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee, stats.gas_used AS stats__gas_used, stats.gas_wanted AS stats__gas_wanted").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
TableExpr("(?) as block", subQuery).
Join("LEFT JOIN block_stats as stats ON stats.height = block.height").
Join("LEFT JOIN validator as v ON v.id = block.proposer_id")
Expand All @@ -137,7 +137,7 @@ func (b *Blocks) ByIdWithRelations(ctx context.Context, id uint64) (block storag
ColumnExpr("validator.id as proposer__id, validator.address as proposer__address, validator.name as proposer__name, validator.pubkey as proposer__pubkey, validator.pubkey_type as proposer__pubkey_type, validator.power as proposer__power, validator.height as proposer__height").
ColumnExpr("stats.id AS stats__id, stats.height AS stats__height, stats.time AS stats__time, stats.tx_count AS stats__tx_count").
ColumnExpr("stats.block_time AS stats__block_time, stats.bytes_in_block AS stats__bytes_in_block").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee, stats.gas_used AS stats__gas_used, stats.gas_wanted AS stats__gas_wanted").
ColumnExpr("stats.supply_change AS stats__supply_change, stats.fee AS stats__fee").
Join("left join validator on block.proposer_id = validator.id").
Join("left join block_stats as stats ON stats.height = block.height").
Scan(ctx, &block)
Expand Down
2 changes: 0 additions & 2 deletions internal/storage/postgres/block_stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ func (s *StorageTestSuite) TestBlockStatsByHeight() {
s.Require().EqualValues(1, stats.TxCount)
s.Require().EqualValues(2317, stats.BlockTime)
s.Require().EqualValues(266, stats.BytesInBlock)
s.Require().EqualValues(0, stats.GasUsed)
s.Require().EqualValues(0, stats.GasWanted)
s.Require().EqualValues("0", stats.SupplyChange.String())
}
8 changes: 0 additions & 8 deletions internal/storage/postgres/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ func (s Stats) Series(ctx context.Context, timeframe storage.Timeframe, name str
query.ColumnExpr("ts, tx_count as value")
case storage.SeriesBytesInBlock:
query.ColumnExpr("ts, bytes_in_block as value")
case storage.SeriesGasPrice:
query.ColumnExpr("ts, gas_price as value")
case storage.SeriesGasEfficiency:
query.ColumnExpr("ts, gas_efficiency as value")
case storage.SeriesGasWanted:
query.ColumnExpr("ts, gas_wanted as value")
case storage.SeriesGasUsed:
query.ColumnExpr("ts, gas_used as value")
default:
return nil, errors.Errorf("unexpected series name: %s", name)
}
Expand Down
22 changes: 9 additions & 13 deletions internal/storage/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,15 @@ type SeriesItem struct {
}

const (
SeriesDataSize = "data_size"
SeriesTPS = "tps"
SeriesBPS = "bps"
SeriesRBPS = "rbps"
SeriesFee = "fee"
SeriesSupplyChange = "supply_change"
SeriesBlockTime = "block_time"
SeriesTxCount = "tx_count"
SeriesBytesInBlock = "bytes_in_block"
SeriesGasPrice = "gas_price"
SeriesGasUsed = "gas_used"
SeriesGasWanted = "gas_wanted"
SeriesGasEfficiency = "gas_efficiency"
SeriesDataSize = "data_size"
SeriesTPS = "tps"
SeriesBPS = "bps"
SeriesRBPS = "rbps"
SeriesFee = "fee"
SeriesSupplyChange = "supply_change"
SeriesBlockTime = "block_time"
SeriesTxCount = "tx_count"
SeriesBytesInBlock = "bytes_in_block"

RollupSeriesActionsCount = "actions_count"
RollupSeriesSize = "size"
Expand Down
Loading

0 comments on commit 81c31b4

Please sign in to comment.