Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed proto definition along with converting system. #24

Merged
merged 12 commits into from
Aug 7, 2024
2,725 changes: 1,753 additions & 972 deletions data/hyperOutportBlocks/hyperOutportBlock.pb.go

Large diffs are not rendered by default.

101 changes: 84 additions & 17 deletions data/hyperOutportBlocks/hyperOutportBlock.proto
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can remove the structs that will not be used anymore

Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ option go_package = "github.com/multiversx/mx-chain-ws-connector-firehose-go/dat
// TODO: move proto definition file in a shared space.

message HyperOutportBlock {
MetaOutportBlock MetaOutportBlock = 1;
repeated NotarizedHeaderOutportData NotarizedHeadersOutportData = 2;
MetaOutportBlock MetaOutportBlock = 1;
repeated NotarizedHeaderOutportData NotarizedHeadersOutportData = 2;
}

message NotarizedHeaderOutportData {
string NotarizedHeaderHash = 1;
ShardOutportBlock OutportBlock = 2 ;
string NotarizedHeaderHash = 1;
ShardOutportBlock OutportBlock = 2;
}

message MetaOutportBlock {
Expand Down Expand Up @@ -43,6 +43,25 @@ message ShardOutportBlock {
bytes HighestFinalBlockHash = 10;
}

message ShardOutportBlockV2 {
uint32 ShardID = 1;
BlockData BlockData = 2;
TransactionPoolV2 TransactionPool = 3;
HeaderGasConsumption HeaderGasConsumption = 4;
map <string, AlteredAccount> AlteredAccounts = 5;
repeated string NotarizedHeadersHashes = 6;
uint32 NumberOfShards = 7;
repeated uint64 SignersIndexes = 8;
uint64 HighestFinalBlockNonce = 9;
bytes HighestFinalBlockHash = 10;
}

message TransactionPoolV2 {
map<string, TxInfoV2> Transactions = 1;
repeated string ScheduledExecutedSCRSHashesPrevBlock = 2;
repeated string ScheduledExecutedInvalidTxsHashesPrevBlock = 3;
}

// Header holds the metadata of a block. This is the part that is being hashed and run through consensus.
// The header holds the hash of the body and also the link to the previous block header hash
message Header {
Expand Down Expand Up @@ -73,29 +92,29 @@ message Header {
}

message MetaHeader {
uint64 Nonce = 1;
uint32 Epoch = 2;
uint64 Round = 3;
uint64 TimeStamp = 4;
uint64 Nonce = 1;
uint32 Epoch = 2;
uint64 Round = 3;
uint64 TimeStamp = 4;
repeated ShardData ShardInfo = 5;
repeated PeerData PeerInfo = 6;
bytes Signature = 7;
bytes LeaderSignature = 8;
bytes PubKeysBitmap = 9;
bytes PrevHash = 10;
bytes PrevRandSeed = 11 ;
bytes RandSeed = 12 ;
bytes RootHash = 13 ;
bytes ValidatorStatsRootHash = 14 ;
repeated MiniBlockHeader MiniBlockHeaders = 16 ;
bytes ReceiptsHash = 17 ;
EpochStart EpochStart = 18 ;
bytes PrevRandSeed = 11;
bytes RandSeed = 12;
bytes RootHash = 13;
bytes ValidatorStatsRootHash = 14;
repeated MiniBlockHeader MiniBlockHeaders = 16;
bytes ReceiptsHash = 17;
EpochStart EpochStart = 18;
bytes ChainID = 19;
bytes SoftwareVersion = 20;
bytes AccumulatedFees = 21;
bytes AccumulatedFeesInEpoch = 22;
bytes DeveloperFees = 23;
bytes DevFeesInEpoch = 24;
bytes DevFeesInEpoch = 24;
uint32 TxCount = 25;
bytes Reserved = 26;
}
Expand Down Expand Up @@ -238,6 +257,54 @@ message TxInfo {
uint32 ExecutionOrder = 3;
}

message TxInfoV2 {
WrappedTx Transaction = 1;
FeeInfo FeeInfo = 2;
Receipt Receipt = 3;
repeated WrappedTx ResultTxs = 4;
repeated Log Logs = 5;
}

message WrappedTx {
uint64 Nonce = 1;
bytes Value = 2;
bytes RcvAddr = 3;
bytes RcvUserName = 4;
bytes SndAddr = 5;
bytes SndUserName = 6;
uint64 GasPrice = 7;
uint64 GasLimit = 8;
bytes Data = 9;
bytes ChainID = 10;
uint32 Version = 11;
bytes Signature = 12;
uint32 Options = 13;
bytes GuardianAddr = 14;
bytes GuardianSignature = 15;
bytes RelayerAddr = 16;
bytes RelayedValue = 17;
bytes Code = 18;
bytes PrevTxHash = 19;
bytes OriginalTxHash = 20;
int64 CallType = 21;
bytes CodeMetadata = 22;
bytes ReturnMessage = 23;
bytes OriginalSender = 24;
uint32 ExecutionOrder = 25;

uint64 Round = 26;
uint32 Epoch = 27;

TxType TxType = 28;
}

enum TxType {
SCR = 0;
Invalid = 1;
UserTx = 2;
Reward = 3;
}

message SCRInfo {
SmartContractResult SmartContractResult = 1;
FeeInfo FeeInfo = 2;
Expand Down Expand Up @@ -377,9 +444,9 @@ message Event {

message RewardTx {
uint64 Round = 1;
uint32 Epoch = 2;
bytes Value = 3;
bytes RcvAddr = 4;
uint32 Epoch = 2;
}

enum Type {
Expand Down
12 changes: 12 additions & 0 deletions data/hyperOutportBlocks/shardOutportBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@ func (x *ShardOutportBlock) GetHeaderNonce() (uint64, error) {

return x.BlockData.Header.Nonce, nil
}

// GetHeaderNonce will return header nonce
func (y *ShardOutportBlockV2) GetHeaderNonce() (uint64, error) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add missing comment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

if y.BlockData == nil {
return 0, fmt.Errorf("shard outport block: nil block data")
}
if y.BlockData.Header == nil {
return 0, fmt.Errorf("shard outport block: nil header")
}

return y.BlockData.Header.Nonce, nil
}
1 change: 1 addition & 0 deletions process/blocksPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/marshal"

"github.com/multiversx/mx-chain-ws-connector-firehose-go/data"
"github.com/multiversx/mx-chain-ws-connector-firehose-go/data/hyperOutportBlocks"
)
Expand Down
2 changes: 1 addition & 1 deletion process/dataProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (dp *dataProcessor) handleMetaOutportBlock(outportBlock *outport.OutportBlo
}

func (dp *dataProcessor) handleShardOutportBlock(outportBlock *outport.OutportBlock) error {
shardOutportBlock, err := dp.outportBlockConverter.HandleShardOutportBlock(outportBlock)
shardOutportBlock, err := dp.outportBlockConverter.HandleShardOutportBlockV2(outportBlock)
if err != nil {
return fmt.Errorf("failed to handle shardOutportBlock: %w", err)
}
Expand Down
3 changes: 3 additions & 0 deletions process/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ var ErrNilBlockServiceContext = errors.New("nil block service context")

// ErrInvalidValue signals that an invalid value was provded
var ErrInvalidValue = errors.New("invalid value provided")

// ErrNilBlockData signals than a block data is nil
var ErrNilBlockData = errors.New("nil block data")
2 changes: 2 additions & 0 deletions process/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/data/block"
"github.com/multiversx/mx-chain-core-go/data/outport"

"github.com/multiversx/mx-chain-ws-connector-firehose-go/data"
"github.com/multiversx/mx-chain-ws-connector-firehose-go/data/hyperOutportBlocks"
)
Expand Down Expand Up @@ -101,6 +102,7 @@ type PruningStorer interface {
// OutportBlockConverter handles the conversion between gogo and google proto buffer definitions.
type OutportBlockConverter interface {
HandleShardOutportBlock(outportBlock *outport.OutportBlock) (*hyperOutportBlocks.ShardOutportBlock, error)
HandleShardOutportBlockV2(outportBlock *outport.OutportBlock) (*hyperOutportBlocks.ShardOutportBlockV2, error)
HandleMetaOutportBlock(outportBlock *outport.OutportBlock) (*hyperOutportBlocks.MetaOutportBlock, error)
IsInterfaceNil() bool
}
Expand Down
Loading
Loading