diff --git a/cmd/elasticindexer/config/indices/executionresults.json b/cmd/elasticindexer/config/indices/executionresults.json index 0e42e2cd..713663d4 100644 --- a/cmd/elasticindexer/config/indices/executionresults.json +++ b/cmd/elasticindexer/config/indices/executionresults.json @@ -59,6 +59,18 @@ "gasUsed": { "type": "double" }, + "gasPenalized": { + "type": "double" + }, + "gasProvided": { + "type": "double" + }, + "gasRefunded": { + "type": "double" + }, + "maxGasLimit": { + "type": "double" + }, "txCount": { "index": "false", "type": "long" diff --git a/cmd/elasticindexer/config/prefs.toml b/cmd/elasticindexer/config/prefs.toml index f0fce3e4..0a00d132 100644 --- a/cmd/elasticindexer/config/prefs.toml +++ b/cmd/elasticindexer/config/prefs.toml @@ -15,7 +15,7 @@ # After a message will be sent it will wait for an ack message if this flag is enabled with-acknowledge = true # The duration in seconds to wait for an acknowledgment message, after this time passes an error will be returned - acknowledge-timeout-in-seconds = 50 + acknowledge-timeout-in-seconds = 5 [config.elastic-cluster] url = "http://localhost:9200" diff --git a/data/block.go b/data/block.go index 411393cc..eff799f0 100644 --- a/data/block.go +++ b/data/block.go @@ -68,6 +68,10 @@ type ExecutionResult struct { DeveloperFees string `json:"developerFees"` TxCount uint64 `json:"txCount"` GasUsed uint64 `json:"gasUsed"` + GasProvided uint64 `json:"gasProvided"` + GasRefunded uint64 `json:"gasRefunded"` + GasPenalized uint64 `json:"gasPenalized"` + MaxGasLimit uint64 `json:"maxGasLimit"` Nonce uint64 `json:"nonce"` Round uint64 `json:"round"` TimestampMs uint64 `json:"timestampMs"` diff --git a/go.mod b/go.mod index 6945d3f9..ccfafa3b 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/gin-gonic/gin v1.10.0 github.com/google/uuid v1.6.0 github.com/multiversx/mx-chain-communication-go v1.3.0 - github.com/multiversx/mx-chain-core-go v1.4.2-0.20260210121034-184d4fbfa371 + github.com/multiversx/mx-chain-core-go v1.4.2-0.20260219091525-015123fd1603 github.com/multiversx/mx-chain-logger-go v1.1.0 github.com/multiversx/mx-chain-vm-common-go v1.6.1-0.20251127112501-0b5f28e33b2e github.com/prometheus/client_model v0.6.1 diff --git a/go.sum b/go.sum index 070962da..5683c728 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/multiversx/mx-chain-communication-go v1.3.0 h1:ziNM1dRuiR/7al2L/jGEA/a/hjurtJ/HEqgazHNt9P8= github.com/multiversx/mx-chain-communication-go v1.3.0/go.mod h1:gDVWn6zUW6aCN1YOm/FbbT5MUmhgn/L1Rmpl8EoH3Yg= -github.com/multiversx/mx-chain-core-go v1.4.2-0.20260210121034-184d4fbfa371 h1:5a94TjX7IG7K4zKO87SF3D4gzfNiy56RCAM+Qw9M4TY= -github.com/multiversx/mx-chain-core-go v1.4.2-0.20260210121034-184d4fbfa371/go.mod h1:IO+vspNan+gT0WOHnJ95uvWygiziHZvfXpff6KnxV7g= +github.com/multiversx/mx-chain-core-go v1.4.2-0.20260219091525-015123fd1603 h1:PhvZUz2zHo3cjx/zySG02enKgvY4r0Vy39l0FKxc+D4= +github.com/multiversx/mx-chain-core-go v1.4.2-0.20260219091525-015123fd1603/go.mod h1:IO+vspNan+gT0WOHnJ95uvWygiziHZvfXpff6KnxV7g= github.com/multiversx/mx-chain-crypto-go v1.3.0 h1:0eK2bkDOMi8VbSPrB1/vGJSYT81IBtfL4zw+C4sWe/k= github.com/multiversx/mx-chain-crypto-go v1.3.0/go.mod h1:nPIkxxzyTP8IquWKds+22Q2OJ9W7LtusC7cAosz7ojM= github.com/multiversx/mx-chain-logger-go v1.1.0 h1:97x84A6L4RfCa6YOx1HpAFxZp1cf/WI0Qh112whgZNM= diff --git a/integrationtests/testdata/executionResults/execution-result-1.json b/integrationtests/testdata/executionResults/execution-result-1.json index 033c2612..96e5e931 100644 --- a/integrationtests/testdata/executionResults/execution-result-1.json +++ b/integrationtests/testdata/executionResults/execution-result-1.json @@ -4,7 +4,11 @@ "accumulatedFees": "0", "developerFees": "0", "txCount": 0, + "gasPenalized": 0, + "gasProvided": 0, + "gasRefunded": 0, "gasUsed": 0, + "maxGasLimit": 0, "nonce": 1, "round": 2, "epoch": 3, diff --git a/integrationtests/testdata/executionResults/execution-result-2.json b/integrationtests/testdata/executionResults/execution-result-2.json index 90966238..c962a8eb 100644 --- a/integrationtests/testdata/executionResults/execution-result-2.json +++ b/integrationtests/testdata/executionResults/execution-result-2.json @@ -4,7 +4,11 @@ "accumulatedFees": "0", "developerFees": "0", "txCount": 0, + "gasPenalized": 0, + "gasProvided": 0, + "gasRefunded": 0, "gasUsed": 0, + "maxGasLimit": 0, "nonce": 2, "round": 3, "epoch": 3, diff --git a/process/elasticproc/block/blockProcessor.go b/process/elasticproc/block/blockProcessor.go index 4370c41c..403e77c0 100644 --- a/process/elasticproc/block/blockProcessor.go +++ b/process/elasticproc/block/blockProcessor.go @@ -26,9 +26,8 @@ const ( ) var ( - log = logger.GetOrCreate("indexer/process/block") - errNilBlockData = errors.New("nil block data") - errNilHeaderGasConsumed = errors.New("nil header gas consumed data") + log = logger.GetOrCreate("indexer/process/block") + errNilBlockData = errors.New("nil block data") ) type blockProcessor struct { @@ -67,9 +66,6 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader) if obh.BlockData.Body == nil { return nil, indexer.ErrNilBlockBody } - if obh.HeaderGasConsumption == nil { - return nil, errNilHeaderGasConsumed - } blockSizeInBytes, err := bp.computeBlockSize(obh.BlockData.HeaderBytes, obh.BlockData.Body) if err != nil { @@ -102,10 +98,6 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader) PrevHash: hex.EncodeToString(obh.Header.GetPrevHash()), SearchOrder: computeBlockSearchOrder(obh.Header), EpochStartBlock: obh.Header.IsStartOfEpochBlock(), - GasProvided: obh.HeaderGasConsumption.GasProvided, - GasRefunded: obh.HeaderGasConsumption.GasRefunded, - GasPenalized: obh.HeaderGasConsumption.GasPenalized, - MaxGasLimit: obh.HeaderGasConsumption.MaxGasPerBlock, AccumulatedFees: converters.BigIntToString(obh.Header.GetAccumulatedFees()), DeveloperFees: converters.BigIntToString(obh.Header.GetDeveloperFees()), RandSeed: hex.EncodeToString(obh.Header.GetRandSeed()), @@ -119,6 +111,13 @@ func (bp *blockProcessor) PrepareBlockForDB(obh *outport.OutportBlockWithHeader) UUID: converters.GenerateBase64UUID(), } + if obh.HeaderGasConsumption != nil { + elasticBlock.MaxGasLimit = obh.HeaderGasConsumption.MaxGasPerBlock + elasticBlock.GasPenalized = obh.HeaderGasConsumption.GasPenalized + elasticBlock.GasProvided = obh.HeaderGasConsumption.GasProvided + elasticBlock.GasRefunded = obh.HeaderGasConsumption.GasRefunded + } + additionalData := obh.Header.GetAdditionalData() if obh.Header.GetAdditionalData() != nil { elasticBlock.ScheduledData = &data.ScheduledData{ @@ -207,6 +206,13 @@ func (bp *blockProcessor) prepareExecutionResult(baseExecutionResult coreData.Ba executionResult.MiniBlocksHashes = bp.getEncodedMBSHashes(executionResultData.Body, executionResultData.IntraShardMiniBlocks) executionResult.TimestampMs = executionResultData.TimestampMs + if executionResultData.HeaderGasConsumption != nil { + executionResult.GasProvided = executionResultData.HeaderGasConsumption.GasProvided + executionResult.GasRefunded = executionResultData.HeaderGasConsumption.GasRefunded + executionResult.GasPenalized = executionResultData.HeaderGasConsumption.GasPenalized + executionResult.MaxGasLimit = executionResultData.HeaderGasConsumption.MaxGasPerBlock + + } switch t := baseExecutionResult.(type) { case *nodeBlock.MetaExecutionResult: diff --git a/process/elasticproc/block/blockProcessor_test.go b/process/elasticproc/block/blockProcessor_test.go index d4cb5e3e..c2ac6524 100644 --- a/process/elasticproc/block/blockProcessor_test.go +++ b/process/elasticproc/block/blockProcessor_test.go @@ -608,6 +608,12 @@ func TestPrepareExecutionResult(t *testing.T) { Body: &dataBlock.Body{}, Results: map[string]*outport.ExecutionResultData{ hex.EncodeToString(executionResultHeaderHash): { + HeaderGasConsumption: &outport.HeaderGasConsumption{ + GasProvided: 200, + GasRefunded: 100, + GasPenalized: 100, + MaxGasPerBlock: 500_000, + }, TimestampMs: 1234567890, Body: &dataBlock.Body{ MiniBlocks: []*dataBlock.MiniBlock{ @@ -651,6 +657,10 @@ func TestPrepareExecutionResult(t *testing.T) { TimestampMs: 1234567890, Epoch: 3, ShardID: 2, + GasProvided: 200, + GasRefunded: 100, + GasPenalized: 100, + MaxGasLimit: 500_000, MiniBlocksHashes: []string{"2dae16da63bc04a18cf7609e0a79d7867b11463660dbab048b044b8434bf0a82"}, MiniBlocksDetails: []*data.MiniBlocksDetails{ { diff --git a/templates/indices/executionResults.go b/templates/indices/executionResults.go index fc162882..150a18b1 100644 --- a/templates/indices/executionResults.go +++ b/templates/indices/executionResults.go @@ -58,6 +58,18 @@ var ExecutionResults = Object{ "gasUsed": Object{ "type": "double", }, + "gasPenalized": Object{ + "type": "double", + }, + "gasProvided": Object{ + "type": "double", + }, + "gasRefunded": Object{ + "type": "double", + }, + "maxGasLimit": Object{ + "type": "double", + }, "txCount": Object{ "index": "false", "type": "long",