From 81c31b4a58beccb1e2127ae617dbb5ca0a72fcdc Mon Sep 17 00:00:00 2001 From: Artem Poltorzhitskiy Date: Thu, 31 Oct 2024 19:32:59 +0100 Subject: [PATCH] Remove gas info (#64) --- cmd/api/docs/docs.go | 24 +------------------ cmd/api/docs/swagger.json | 24 +------------------ cmd/api/docs/swagger.yaml | 18 -------------- cmd/api/handler/address_test.go | 2 -- cmd/api/handler/block_test.go | 4 ---- cmd/api/handler/responses/block.go | 4 ---- cmd/api/handler/responses/tx.go | 4 ---- cmd/api/handler/stats.go | 4 ++-- cmd/api/handler/stats_test.go | 4 ---- cmd/api/handler/tx_test.go | 8 ------- database/views/00_block_stats_by_hour.sql | 4 ---- database/views/01_block_stats_by_day.sql | 4 ---- database/views/02_block_stats_by_month.sql | 4 ---- internal/storage/block_stats.go | 2 -- internal/storage/postgres/block.go | 10 ++++---- internal/storage/postgres/block_stats_test.go | 2 -- internal/storage/postgres/stats.go | 8 ------- internal/storage/stats.go | 22 +++++++---------- internal/storage/tx.go | 2 -- pkg/indexer/decode/context.go | 4 ++++ pkg/indexer/parser/parse.go | 2 -- pkg/indexer/parser/parseTxs.go | 5 +--- pkg/indexer/parser/parseTxs_test.go | 20 ++++------------ pkg/indexer/parser/parser_test.go | 2 -- pkg/types/block_results.go | 14 +++++------ test/data/block_stats.yml | 4 ---- test/data/tx.yml | 4 ---- 27 files changed, 33 insertions(+), 176 deletions(-) diff --git a/cmd/api/docs/docs.go b/cmd/api/docs/docs.go index 21afd1b..023422c 100644 --- a/cmd/api/docs/docs.go +++ b/cmd/api/docs/docs.go @@ -1849,11 +1849,7 @@ const docTemplate = `{ "supply_change", "block_time", "tx_count", - "bytes_in_block", - "gas_price", - "gas_efficiency", - "gas_used", - "gas_wanted" + "bytes_in_block" ], "type": "string", "description": "Series name", @@ -2907,14 +2903,6 @@ const docTemplate = `{ "type": "string", "example": "28347628346" }, - "gas_used": { - "type": "integer", - "example": 1234 - }, - "gas_wanted": { - "type": "integer", - "example": 1234 - }, "supply_change": { "type": "string", "example": "8635234" @@ -3514,16 +3502,6 @@ const docTemplate = `{ "format": "string", "example": "some error text" }, - "gas_used": { - "type": "integer", - "format": "int64", - "example": 4253 - }, - "gas_wanted": { - "type": "integer", - "format": "int64", - "example": 9348 - }, "hash": { "type": "string", "format": "binary", diff --git a/cmd/api/docs/swagger.json b/cmd/api/docs/swagger.json index 32f540a..49f1056 100644 --- a/cmd/api/docs/swagger.json +++ b/cmd/api/docs/swagger.json @@ -1839,11 +1839,7 @@ "supply_change", "block_time", "tx_count", - "bytes_in_block", - "gas_price", - "gas_efficiency", - "gas_used", - "gas_wanted" + "bytes_in_block" ], "type": "string", "description": "Series name", @@ -2897,14 +2893,6 @@ "type": "string", "example": "28347628346" }, - "gas_used": { - "type": "integer", - "example": 1234 - }, - "gas_wanted": { - "type": "integer", - "example": 1234 - }, "supply_change": { "type": "string", "example": "8635234" @@ -3504,16 +3492,6 @@ "format": "string", "example": "some error text" }, - "gas_used": { - "type": "integer", - "format": "int64", - "example": 4253 - }, - "gas_wanted": { - "type": "integer", - "format": "int64", - "example": 9348 - }, "hash": { "type": "string", "format": "binary", diff --git a/cmd/api/docs/swagger.yaml b/cmd/api/docs/swagger.yaml index 1fda29f..97a3716 100644 --- a/cmd/api/docs/swagger.yaml +++ b/cmd/api/docs/swagger.yaml @@ -146,12 +146,6 @@ definitions: fee: example: "28347628346" type: string - gas_used: - example: 1234 - type: integer - gas_wanted: - example: 1234 - type: integer supply_change: example: "8635234" type: string @@ -603,14 +597,6 @@ definitions: example: some error text format: string type: string - gas_used: - example: 4253 - format: int64 - type: integer - gas_wanted: - example: 9348 - format: int64 - type: integer hash: example: 652452A670018D629CC116E510BA88C1CABE061336661B1F3D206D248BD558AF format: binary @@ -1945,10 +1931,6 @@ paths: - block_time - tx_count - bytes_in_block - - gas_price - - gas_efficiency - - gas_used - - gas_wanted in: path name: name required: true diff --git a/cmd/api/handler/address_test.go b/cmd/api/handler/address_test.go index 9e154ae..16bb891 100644 --- a/cmd/api/handler/address_test.go +++ b/cmd/api/handler/address_test.go @@ -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) diff --git a/cmd/api/handler/block_test.go b/cmd/api/handler/block_test.go index a4e6097..8308220 100644 --- a/cmd/api/handler/block_test.go +++ b/cmd/api/handler/block_test.go @@ -111,8 +111,6 @@ var ( Height: 100, Time: testTime, Position: 1, - GasWanted: 10, - GasUsed: 8, ActionsCount: 1, Status: types.StatusSuccess, Nonce: 10, @@ -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) diff --git a/cmd/api/handler/responses/block.go b/cmd/api/handler/responses/block.go index 0cb695b..cb78cfe 100644 --- a/cmd/api/handler/responses/block.go +++ b/cmd/api/handler/responses/block.go @@ -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"` } @@ -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, } } diff --git a/cmd/api/handler/responses/tx.go b/cmd/api/handler/responses/tx.go index 00218a9..4c2308a 100644 --- a/cmd/api/handler/responses/tx.go +++ b/cmd/api/handler/responses/tx.go @@ -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"` @@ -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, diff --git a/cmd/api/handler/stats.go b/cmd/api/handler/stats.go index 9487623..f680fc5 100644 --- a/cmd/api/handler/stats.go +++ b/cmd/api/handler/stats.go @@ -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"` } @@ -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 diff --git a/cmd/api/handler/stats_test.go b/cmd/api/handler/stats_test.go index 889ed3f..7eb49e9 100644 --- a/cmd/api/handler/stats_test.go +++ b/cmd/api/handler/stats_test.go @@ -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{ diff --git a/cmd/api/handler/tx_test.go b/cmd/api/handler/tx_test.go index 3759cb6..eb96e84 100644 --- a/cmd/api/handler/tx_test.go +++ b/cmd/api/handler/tx_test.go @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/database/views/00_block_stats_by_hour.sql b/database/views/00_block_stats_by_hour.sql index 2e174a2..45b75f6 100644 --- a/database/views/00_block_stats_by_hour.sql +++ b/database/views/00_block_stats_by_hour.sql @@ -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, diff --git a/database/views/01_block_stats_by_day.sql b/database/views/01_block_stats_by_day.sql index 34667c2..6734111 100644 --- a/database/views/01_block_stats_by_day.sql +++ b/database/views/01_block_stats_by_day.sql @@ -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, diff --git a/database/views/02_block_stats_by_month.sql b/database/views/02_block_stats_by_month.sql index 9c03adc..a7d26f6 100644 --- a/database/views/02_block_stats_by_month.sql +++ b/database/views/02_block_stats_by_month.sql @@ -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, diff --git a/internal/storage/block_stats.go b/internal/storage/block_stats.go index 07de78f..4a5aa9e 100644 --- a/internal/storage/block_stats.go +++ b/internal/storage/block_stats.go @@ -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"` diff --git a/internal/storage/postgres/block.go b/internal/storage/postgres/block.go index 9589efb..d728cb2 100644 --- a/internal/storage/postgres/block.go +++ b/internal/storage/postgres/block.go @@ -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") } @@ -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) @@ -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") @@ -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") @@ -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) diff --git a/internal/storage/postgres/block_stats_test.go b/internal/storage/postgres/block_stats_test.go index 585fb3d..3f4366b 100644 --- a/internal/storage/postgres/block_stats_test.go +++ b/internal/storage/postgres/block_stats_test.go @@ -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()) } diff --git a/internal/storage/postgres/stats.go b/internal/storage/postgres/stats.go index ee03236..be67b1c 100644 --- a/internal/storage/postgres/stats.go +++ b/internal/storage/postgres/stats.go @@ -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) } diff --git a/internal/storage/stats.go b/internal/storage/stats.go index 16aefba..a423f33 100644 --- a/internal/storage/stats.go +++ b/internal/storage/stats.go @@ -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" diff --git a/internal/storage/tx.go b/internal/storage/tx.go index 82454e6..040dbbd 100644 --- a/internal/storage/tx.go +++ b/internal/storage/tx.go @@ -44,8 +44,6 @@ type Tx struct { Height pkgTypes.Level `bun:",notnull" comment:"The number (height) of this block"` Time time.Time `bun:"time,pk,notnull" comment:"The time of block"` Position int64 `bun:"position" comment:"Position in block"` - GasWanted int64 `bun:"gas_wanted" comment:"Gas wanted"` - GasUsed int64 `bun:"gas_used" comment:"Gas used"` ActionsCount int64 `bun:"actions_count" comment:"Actions count in transaction"` Status types.Status `bun:"status,type:status" comment:"Transaction status"` diff --git a/pkg/indexer/decode/context.go b/pkg/indexer/decode/context.go index 513c8f1..a85d37f 100644 --- a/pkg/indexer/decode/context.go +++ b/pkg/indexer/decode/context.go @@ -83,6 +83,10 @@ func (ctx *Context) AddFee(idx int64, fee *storage.Fee) { ctx.Fees[idx] = fee } +func (ctx *Context) ClearFee() { + clear(ctx.Fees) +} + func (ctx *Context) AddBridgeAsset(bridge, asset string) { ctx.bridgeAssets[bridge] = asset } diff --git a/pkg/indexer/parser/parse.go b/pkg/indexer/parser/parse.go index 7c435ae..933b067 100644 --- a/pkg/indexer/parser/parse.go +++ b/pkg/indexer/parser/parse.go @@ -76,8 +76,6 @@ func (p *Module) parse(ctx context.Context, b types.BlockData) error { Fee: decimal.Zero, SupplyChange: decodeCtx.SupplyChange, BytesInBlock: decodeCtx.BytesInBlock, - GasWanted: decodeCtx.GasWanted, - GasUsed: decodeCtx.GasUsed, DataSize: decodeCtx.DataSize, }, } diff --git a/pkg/indexer/parser/parseTxs.go b/pkg/indexer/parser/parseTxs.go index c10c83b..6f64f2e 100644 --- a/pkg/indexer/parser/parseTxs.go +++ b/pkg/indexer/parser/parseTxs.go @@ -40,8 +40,7 @@ func parseTxs(ctx context.Context, b types.BlockData, decodeCtx *decode.Context, } txs[i-index] = &t - decodeCtx.GasWanted += b.TxsResults[i].GasWanted - decodeCtx.GasUsed += b.TxsResults[i].GasUsed + decodeCtx.ClearFee() } return txs, nil @@ -59,8 +58,6 @@ func parseTx(b types.BlockData, index int, ctx *decode.Context) (storage.Tx, err Height: b.Height, Time: b.Block.Time, Position: int64(index), - GasWanted: result.GasWanted, - GasUsed: result.GasUsed, ActionsCount: int64(len(d.Actions)), Status: storageTypes.StatusSuccess, Codespace: result.Codespace, diff --git a/pkg/indexer/parser/parseTxs_test.go b/pkg/indexer/parser/parseTxs_test.go index 31de162..f8b0c12 100644 --- a/pkg/indexer/parser/parseTxs_test.go +++ b/pkg/indexer/parser/parseTxs_test.go @@ -31,12 +31,10 @@ func TestParseTxs_EmptyTxsResults(t *testing.T) { func TestParseTxs_SuccessTx(t *testing.T) { txRes := types.ResponseDeliverTx{ - Code: 0, - Data: []byte{}, - Log: "[]", - Info: "info", - GasWanted: 12000, - GasUsed: 1000, + Code: 0, + Data: []byte{}, + Log: "[]", + Info: "info", Events: []types.Event{ { Type: "tx.deposit", @@ -83,8 +81,6 @@ func TestParseTxs_SuccessTx(t *testing.T) { assert.Equal(t, now, f.Time) assert.Equal(t, storageTypes.StatusSuccess, f.Status) assert.Equal(t, "", f.Error) - assert.Equal(t, int64(12000), f.GasWanted) - assert.Equal(t, int64(1000), f.GasUsed) assert.Equal(t, "codespace", f.Codespace) } @@ -94,8 +90,6 @@ func TestParseTxs_FailedTx(t *testing.T) { Data: []byte{}, Log: "something weird happened", Info: "info", - GasWanted: 12000, - GasUsed: 1000, Events: nil, Codespace: "codespace", } @@ -113,8 +107,6 @@ func TestParseTxs_FailedTx(t *testing.T) { assert.Equal(t, now, f.Time) assert.Equal(t, storageTypes.StatusFailed, f.Status) assert.Equal(t, "something weird happened", f.Error) - assert.Equal(t, int64(12000), f.GasWanted) - assert.Equal(t, int64(1000), f.GasUsed) assert.Equal(t, "codespace", f.Codespace) } @@ -124,8 +116,6 @@ func TestParseTxs_FailedTxWithNonstandardErrorCode(t *testing.T) { Data: []byte{}, Log: "something unusual happened", Info: "info", - GasWanted: 12000, - GasUsed: 1000, Events: nil, Codespace: "codespace", } @@ -143,7 +133,5 @@ func TestParseTxs_FailedTxWithNonstandardErrorCode(t *testing.T) { assert.Equal(t, now, f.Time) assert.Equal(t, storageTypes.StatusFailed, f.Status) assert.Equal(t, "something unusual happened", f.Error) - assert.Equal(t, int64(12000), f.GasWanted) - assert.Equal(t, int64(1000), f.GasUsed) assert.Equal(t, "codespace", f.Codespace) } diff --git a/pkg/indexer/parser/parser_test.go b/pkg/indexer/parser/parser_test.go index 6c9e29c..344418b 100644 --- a/pkg/indexer/parser/parser_test.go +++ b/pkg/indexer/parser/parser_test.go @@ -237,8 +237,6 @@ func TestModule_OnParseError(t *testing.T) { Data: []byte{18, 45, 10, 43, 47, 99, 111, 115, 109, 111, 115, 46, 115, 116, 97, 107, 105, 110, 103, 46, 118, 49, 98, 101, 116, 97}, Log: "", Info: "", - GasWanted: 20, - GasUsed: 10, Events: nil, Codespace: "", }, diff --git a/pkg/types/block_results.go b/pkg/types/block_results.go index 172764f..f904fcc 100644 --- a/pkg/types/block_results.go +++ b/pkg/types/block_results.go @@ -19,14 +19,12 @@ type ResultBlockResults struct { } type ResponseDeliverTx struct { - Code uint32 `json:"code,omitempty" protobuf:"varint,1,opt,name=code,proto3"` - Data json.RawMessage `json:"data,omitempty" protobuf:"bytes,2,opt,name=data,proto3"` - Log string `json:"log,omitempty" protobuf:"bytes,3,opt,name=log,proto3"` - Info string `json:"info,omitempty" protobuf:"bytes,4,opt,name=info,proto3"` - GasWanted int64 `json:"gas_wanted,omitempty,string" protobuf:"varint,5,opt,name=gas_wanted,proto3"` - GasUsed int64 `json:"gas_used,omitempty,string" protobuf:"varint,6,opt,name=gas_used,proto3"` - Events []Event `json:"events,omitempty" protobuf:"bytes,7,rep,name=events,proto3"` - Codespace string `json:"codespace,omitempty" protobuf:"bytes,8,opt,name=codespace,proto3"` + Code uint32 `json:"code,omitempty" protobuf:"varint,1,opt,name=code,proto3"` + Data json.RawMessage `json:"data,omitempty" protobuf:"bytes,2,opt,name=data,proto3"` + Log string `json:"log,omitempty" protobuf:"bytes,3,opt,name=log,proto3"` + Info string `json:"info,omitempty" protobuf:"bytes,4,opt,name=info,proto3"` + Events []Event `json:"events,omitempty" protobuf:"bytes,7,rep,name=events,proto3"` + Codespace string `json:"codespace,omitempty" protobuf:"bytes,8,opt,name=codespace,proto3"` } func (tx *ResponseDeliverTx) IsFailed() bool { diff --git a/test/data/block_stats.yml b/test/data/block_stats.yml index 867692f..17f71f7 100644 --- a/test/data/block_stats.yml +++ b/test/data/block_stats.yml @@ -3,8 +3,6 @@ time: '2023-12-01T00:18:05.257Z' tx_count: 0 block_time: 2337 - gas_wanted: 0 - gas_used: 0 supply_change: 0 fee: 0 bytes_in_block: 64 @@ -14,8 +12,6 @@ time: '2023-12-01T00:18:07.575Z' tx_count: 1 block_time: 2317 - gas_wanted: 0 - gas_used: 0 supply_change: 0 fee: 0 bytes_in_block: 266 diff --git a/test/data/tx.yml b/test/data/tx.yml index 8ac4f2f..1a2812b 100644 --- a/test/data/tx.yml +++ b/test/data/tx.yml @@ -2,8 +2,6 @@ height: 7316 time: '2023-11-30T23:52:23.265Z' position: 2 - gas_wanted: 0 - gas_used: 0 actions_count: 1 action_types: 2 status: success @@ -17,8 +15,6 @@ height: 7965 time: '2023-12-01T00:18:07.575Z' position: 2 - gas_wanted: 0 - gas_used: 0 actions_count: 1 action_types: 1 status: success