Skip to content

Commit 3762489

Browse files
committed
gas data on execution results
1 parent bd99d5a commit 3762489

File tree

10 files changed

+66
-14
lines changed

10 files changed

+66
-14
lines changed

cmd/elasticindexer/config/indices/executionresults.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@
5959
"gasUsed": {
6060
"type": "double"
6161
},
62+
"gasPenalized": {
63+
"type": "double"
64+
},
65+
"gasProvided": {
66+
"type": "double"
67+
},
68+
"gasRefunded": {
69+
"type": "double"
70+
},
71+
"maxGasLimit": {
72+
"type": "double"
73+
},
6274
"txCount": {
6375
"index": "false",
6476
"type": "long"

cmd/elasticindexer/config/prefs.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# After a message will be sent it will wait for an ack message if this flag is enabled
1616
with-acknowledge = true
1717
# The duration in seconds to wait for an acknowledgment message, after this time passes an error will be returned
18-
acknowledge-timeout-in-seconds = 50
18+
acknowledge-timeout-in-seconds = 5
1919

2020
[config.elastic-cluster]
2121
url = "http://localhost:9200"

data/block.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ type ExecutionResult struct {
6868
DeveloperFees string `json:"developerFees"`
6969
TxCount uint64 `json:"txCount"`
7070
GasUsed uint64 `json:"gasUsed"`
71+
GasProvided uint64 `json:"gasProvided"`
72+
GasRefunded uint64 `json:"gasRefunded"`
73+
GasPenalized uint64 `json:"gasPenalized"`
74+
MaxGasLimit uint64 `json:"maxGasLimit"`
7175
Nonce uint64 `json:"nonce"`
7276
Round uint64 `json:"round"`
7377
TimestampMs uint64 `json:"timestampMs"`

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/gin-gonic/gin v1.10.0
99
github.com/google/uuid v1.6.0
1010
github.com/multiversx/mx-chain-communication-go v1.3.0
11-
github.com/multiversx/mx-chain-core-go v1.4.2-0.20260210121034-184d4fbfa371
11+
github.com/multiversx/mx-chain-core-go v1.4.2-0.20260219091525-015123fd1603
1212
github.com/multiversx/mx-chain-logger-go v1.1.0
1313
github.com/multiversx/mx-chain-vm-common-go v1.6.1-0.20251127112501-0b5f28e33b2e
1414
github.com/prometheus/client_model v0.6.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
118118
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
119119
github.com/multiversx/mx-chain-communication-go v1.3.0 h1:ziNM1dRuiR/7al2L/jGEA/a/hjurtJ/HEqgazHNt9P8=
120120
github.com/multiversx/mx-chain-communication-go v1.3.0/go.mod h1:gDVWn6zUW6aCN1YOm/FbbT5MUmhgn/L1Rmpl8EoH3Yg=
121-
github.com/multiversx/mx-chain-core-go v1.4.2-0.20260210121034-184d4fbfa371 h1:5a94TjX7IG7K4zKO87SF3D4gzfNiy56RCAM+Qw9M4TY=
122-
github.com/multiversx/mx-chain-core-go v1.4.2-0.20260210121034-184d4fbfa371/go.mod h1:IO+vspNan+gT0WOHnJ95uvWygiziHZvfXpff6KnxV7g=
121+
github.com/multiversx/mx-chain-core-go v1.4.2-0.20260219091525-015123fd1603 h1:PhvZUz2zHo3cjx/zySG02enKgvY4r0Vy39l0FKxc+D4=
122+
github.com/multiversx/mx-chain-core-go v1.4.2-0.20260219091525-015123fd1603/go.mod h1:IO+vspNan+gT0WOHnJ95uvWygiziHZvfXpff6KnxV7g=
123123
github.com/multiversx/mx-chain-crypto-go v1.3.0 h1:0eK2bkDOMi8VbSPrB1/vGJSYT81IBtfL4zw+C4sWe/k=
124124
github.com/multiversx/mx-chain-crypto-go v1.3.0/go.mod h1:nPIkxxzyTP8IquWKds+22Q2OJ9W7LtusC7cAosz7ojM=
125125
github.com/multiversx/mx-chain-logger-go v1.1.0 h1:97x84A6L4RfCa6YOx1HpAFxZp1cf/WI0Qh112whgZNM=

integrationtests/testdata/executionResults/execution-result-1.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
"accumulatedFees": "0",
55
"developerFees": "0",
66
"txCount": 0,
7+
"gasPenalized": 0,
8+
"gasProvided": 0,
9+
"gasRefunded": 0,
710
"gasUsed": 0,
11+
"maxGasLimit": 0,
812
"nonce": 1,
913
"round": 2,
1014
"epoch": 3,

integrationtests/testdata/executionResults/execution-result-2.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
"accumulatedFees": "0",
55
"developerFees": "0",
66
"txCount": 0,
7+
"gasPenalized": 0,
8+
"gasProvided": 0,
9+
"gasRefunded": 0,
710
"gasUsed": 0,
11+
"maxGasLimit": 0,
812
"nonce": 2,
913
"round": 3,
1014
"epoch": 3,

process/elasticproc/block/blockProcessor.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ const (
2626
)
2727

2828
var (
29-
log = logger.GetOrCreate("indexer/process/block")
30-
errNilBlockData = errors.New("nil block data")
31-
errNilHeaderGasConsumed = errors.New("nil header gas consumed data")
29+
log = logger.GetOrCreate("indexer/process/block")
30+
errNilBlockData = errors.New("nil block data")
3231
)
3332

3433
type blockProcessor struct {
@@ -67,9 +66,6 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader)
6766
if obh.BlockData.Body == nil {
6867
return nil, indexer.ErrNilBlockBody
6968
}
70-
if obh.HeaderGasConsumption == nil {
71-
return nil, errNilHeaderGasConsumed
72-
}
7369

7470
blockSizeInBytes, err := bp.computeBlockSize(obh.BlockData.HeaderBytes, obh.BlockData.Body)
7571
if err != nil {
@@ -102,10 +98,6 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader)
10298
PrevHash: hex.EncodeToString(obh.Header.GetPrevHash()),
10399
SearchOrder: computeBlockSearchOrder(obh.Header),
104100
EpochStartBlock: obh.Header.IsStartOfEpochBlock(),
105-
GasProvided: obh.HeaderGasConsumption.GasProvided,
106-
GasRefunded: obh.HeaderGasConsumption.GasRefunded,
107-
GasPenalized: obh.HeaderGasConsumption.GasPenalized,
108-
MaxGasLimit: obh.HeaderGasConsumption.MaxGasPerBlock,
109101
AccumulatedFees: converters.BigIntToString(obh.Header.GetAccumulatedFees()),
110102
DeveloperFees: converters.BigIntToString(obh.Header.GetDeveloperFees()),
111103
RandSeed: hex.EncodeToString(obh.Header.GetRandSeed()),
@@ -119,6 +111,13 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader)
119111
UUID: converters.GenerateBase64UUID(),
120112
}
121113

114+
if obh.HeaderGasConsumption != nil {
115+
elasticBlock.MaxGasLimit = obh.HeaderGasConsumption.MaxGasPerBlock
116+
elasticBlock.GasPenalized = obh.HeaderGasConsumption.GasPenalized
117+
elasticBlock.GasProvided = obh.HeaderGasConsumption.GasProvided
118+
elasticBlock.GasRefunded = obh.HeaderGasConsumption.GasRefunded
119+
}
120+
122121
additionalData := obh.Header.GetAdditionalData()
123122
if obh.Header.GetAdditionalData() != nil {
124123
elasticBlock.ScheduledData = &data.ScheduledData{
@@ -207,6 +206,13 @@ func (bp *blockProcessor) prepareExecutionResult(baseExecutionResult coreData.Ba
207206

208207
executionResult.MiniBlocksHashes = bp.getEncodedMBSHashes(executionResultData.Body, executionResultData.IntraShardMiniBlocks)
209208
executionResult.TimestampMs = executionResultData.TimestampMs
209+
if executionResultData.HeaderGasConsumption != nil {
210+
executionResult.GasProvided = executionResultData.HeaderGasConsumption.GasProvided
211+
executionResult.GasRefunded = executionResultData.HeaderGasConsumption.GasRefunded
212+
executionResult.GasPenalized = executionResultData.HeaderGasConsumption.GasPenalized
213+
executionResult.MaxGasLimit = executionResultData.HeaderGasConsumption.MaxGasPerBlock
214+
215+
}
210216

211217
switch t := baseExecutionResult.(type) {
212218
case *nodeBlock.MetaExecutionResult:

process/elasticproc/block/blockProcessor_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,12 @@ func TestPrepareExecutionResult(t *testing.T) {
608608
Body: &dataBlock.Body{},
609609
Results: map[string]*outport.ExecutionResultData{
610610
hex.EncodeToString(executionResultHeaderHash): {
611+
HeaderGasConsumption: &outport.HeaderGasConsumption{
612+
GasProvided: 200,
613+
GasRefunded: 100,
614+
GasPenalized: 100,
615+
MaxGasPerBlock: 500_000,
616+
},
611617
TimestampMs: 1234567890,
612618
Body: &dataBlock.Body{
613619
MiniBlocks: []*dataBlock.MiniBlock{
@@ -651,6 +657,10 @@ func TestPrepareExecutionResult(t *testing.T) {
651657
TimestampMs: 1234567890,
652658
Epoch: 3,
653659
ShardID: 2,
660+
GasProvided: 200,
661+
GasRefunded: 100,
662+
GasPenalized: 100,
663+
MaxGasLimit: 500_000,
654664
MiniBlocksHashes: []string{"2dae16da63bc04a18cf7609e0a79d7867b11463660dbab048b044b8434bf0a82"},
655665
MiniBlocksDetails: []*data.MiniBlocksDetails{
656666
{

templates/indices/executionResults.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ var ExecutionResults = Object{
5858
"gasUsed": Object{
5959
"type": "double",
6060
},
61+
"gasPenalized": Object{
62+
"type": "double",
63+
},
64+
"gasProvided": Object{
65+
"type": "double",
66+
},
67+
"gasRefunded": Object{
68+
"type": "double",
69+
},
70+
"maxGasLimit": Object{
71+
"type": "double",
72+
},
6173
"txCount": Object{
6274
"index": "false",
6375
"type": "long",

0 commit comments

Comments
 (0)