Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/elasticindexer/config/indices/executionresults.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@
"gasUsed": {
"type": "double"
},
"gasPenalized": {
"type": "double"
},
"gasProvided": {
"type": "double"
},
"gasRefunded": {
"type": "double"
},
"maxGasLimit": {
"type": "double"
},
"txCount": {
"index": "false",
"type": "long"
Expand Down
2 changes: 1 addition & 1 deletion cmd/elasticindexer/config/prefs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions data/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 16 additions & 10 deletions process/elasticproc/block/blockProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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()),
Expand All @@ -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{
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions process/elasticproc/block/blockProcessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
{
Expand Down
12 changes: 12 additions & 0 deletions templates/indices/executionResults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading