Skip to content

Commit

Permalink
Merge pull request #98 from multiversx/merge_main_into_rc17next1_2024…
Browse files Browse the repository at this point in the history
….07.25

Merge main into rc17next1 2024.07.25
  • Loading branch information
sstanculeanu authored Jul 25, 2024
2 parents 7ada80a + 9cc1ffa commit 0458b14
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ communication protocol and send a payload signalling the intention of
subscribing. This will generate a subscription for that session.

There are two types of events:
- Protocol based events, such as `ESDTTrasnfer` or `NFTCreate`
- Protocol based events, such as `ESDTTransfer` or `NFTCreate`
- Smart contract based events. These are defined inside a smart contract.
The event will automatically be assigned the smart contract address,
and the identifier will be the function by which it was triggered.
Expand Down
10 changes: 6 additions & 4 deletions data/outport.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ type BlockEvents struct {

// RevertBlock holds revert event data
type RevertBlock struct {
Hash string `json:"hash"`
Nonce uint64 `json:"nonce"`
Round uint64 `json:"round"`
Epoch uint32 `json:"epoch"`
Hash string `json:"hash"`
Nonce uint64 `json:"nonce"`
Round uint64 `json:"round"`
Epoch uint32 `json:"epoch"`
ShardID uint32 `json:"shardId"`
TimeStamp uint64 `json:"timestamp"`
}

// FinalizedBlock holds finalized block data
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/go-redis/redis/v8 v8.11.3
github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0
github.com/multiversx/mx-chain-core-go v1.2.21-0.20240508071047-fefea5737840
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240508072523-3f00a726af57
github.com/multiversx/mx-chain-core-go v1.2.21-0.20240725065431-6e9bfee5a4c6
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240725065747-176bd697c775
github.com/spaolacci/murmur3 v1.1.0
github.com/streadway/amqp v1.0.0
github.com/stretchr/testify v1.8.4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1533,13 +1533,13 @@ github.com/multiversx/concurrent-map v0.1.4/go.mod h1:8cWFRJDOrWHOTNSqgYCUvwT7c7
github.com/multiversx/mx-chain-communication-go v1.0.7 h1:7qeDBcqmGYYhSqFcpwv0qKkR3ahOfIMbRwXYEnOt/do=
github.com/multiversx/mx-chain-communication-go v1.0.7/go.mod h1:+oaUowpq+SqrEmAsMPGwhz44g7L81loWb6AiNQU9Ms4=
github.com/multiversx/mx-chain-core-go v1.2.13/go.mod h1:BILOGHUOIG5dNNX8cgkzCNfDaVtoYrJRYcPnpxRMH84=
github.com/multiversx/mx-chain-core-go v1.2.21-0.20240508071047-fefea5737840 h1:2mCrTUmbbA+Xv4UifZY9xptrGjcJBcJ2wavSb4FwejU=
github.com/multiversx/mx-chain-core-go v1.2.21-0.20240508071047-fefea5737840/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-core-go v1.2.21-0.20240725065431-6e9bfee5a4c6 h1:Q7uUjTYTrt8Mw9oq5JWPv+WHhpxHTv6lhZZlhPuNcoQ=
github.com/multiversx/mx-chain-core-go v1.2.21-0.20240725065431-6e9bfee5a4c6/go.mod h1:B5zU4MFyJezmEzCsAHE9YNULmGCm2zbPHvl9hazNxmE=
github.com/multiversx/mx-chain-crypto-go v1.2.8 h1:wOgVlUaO5X4L8iEbFjcQcL8SZvv6WZ7LqH73BiRPhxU=
github.com/multiversx/mx-chain-crypto-go v1.2.8/go.mod h1:fkaWKp1rbQN9wPKya5jeoRyC+c/SyN/NfggreyeBw+8=
github.com/multiversx/mx-chain-logger-go v1.0.13/go.mod h1:MZJhTAtZTJxT+yK2EHc4ZW3YOHUc1UdjCD0iahRNBZk=
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240508072523-3f00a726af57 h1:g9t410dqjcb7UUptbVd/H6Ua12sEzWU4v7VplyNvRZ0=
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240508072523-3f00a726af57/go.mod h1:cY6CIXpndW5g5PTPn4WzPwka/UBEf+mgw+PSY5pHGAU=
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240725065747-176bd697c775 h1:a8LOfz3p4MQfRtbF00rGDAJiebziwtSfVmBHIaHBDdY=
github.com/multiversx/mx-chain-logger-go v1.0.15-0.20240725065747-176bd697c775/go.mod h1:owPYyrK7RcsLx9eOCAZQ22fIyW6BE7ttJr4XIhFIbQw=
github.com/multiversx/mx-chain-storage-go v1.0.12/go.mod h1:/8VrMbO9CbIi0Ym3F1QPY6EENGcUq5DpEBPDt4evn9Q=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
Expand Down
10 changes: 6 additions & 4 deletions process/preprocess/eventsPreProcessorV1.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ func (d *eventsPreProcessorV1) RevertIndexedBlock(marshalledData []byte) error {
}

revertData := &data.RevertBlock{
Hash: hex.EncodeToString(blockData.GetHeaderHash()),
Nonce: header.GetNonce(),
Round: header.GetRound(),
Epoch: header.GetEpoch(),
Hash: hex.EncodeToString(blockData.GetHeaderHash()),
Nonce: header.GetNonce(),
Round: header.GetRound(),
Epoch: header.GetEpoch(),
ShardID: blockData.GetShardID(),
TimeStamp: header.GetTimeStamp(),
}

d.facade.HandleRevertEvents(*revertData)
Expand Down
38 changes: 36 additions & 2 deletions process/preprocess/eventsPreProcessorV1_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package preprocess_test

import (
"encoding/hex"
"encoding/json"
"errors"
"testing"
Expand Down Expand Up @@ -138,22 +139,55 @@ func TestPreProcessorV1_RevertIndexerBlock(t *testing.T) {
t.Run("should work", func(t *testing.T) {
t.Parallel()

shardID := uint32(2)
nonce := uint64(11)
round := uint64(12)
epoch := uint32(3)
timestamp := uint64(1234)
headerHash := []byte("headerHash1")

b := &block.Header{
Nonce: 1,
Nonce: nonce,
Round: round,
Epoch: epoch,
TimeStamp: timestamp,
}
blockBytes, _ := json.Marshal(b)

blockData := &outport.BlockData{
HeaderBytes: blockBytes,
HeaderHash: headerHash,
HeaderType: "Header",
ShardID: shardID,
}

dp, err := preprocess.NewEventsPreProcessorV1(createMockEventsDataPreProcessorArgs())
expRevertBlock := data.RevertBlock{
Hash: hex.EncodeToString(headerHash),
Nonce: nonce,
Round: round,
Epoch: epoch,
ShardID: shardID,
TimeStamp: timestamp,
}

args := createMockEventsDataPreProcessorArgs()

revertCalled := false
args.Facade = &mocks.FacadeStub{
HandleRevertEventsCalled: func(events data.RevertBlock) {
revertCalled = true
require.Equal(t, expRevertBlock, events)
},
}

dp, err := preprocess.NewEventsPreProcessorV1(args)
require.Nil(t, err)

marshalledBlock, _ := json.Marshal(blockData)
err = dp.RevertIndexedBlock(marshalledBlock)
require.Nil(t, err)

require.True(t, revertCalled)
})
}

Expand Down

0 comments on commit 0458b14

Please sign in to comment.