diff --git a/README.md b/README.md index e67da938f..c175ef2a3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # mx-chain-core-go + mx-chain-go common components and data that can be used in other repositories as well diff --git a/core/accumulator/timeAccumulator.go b/core/accumulator/timeAccumulator.go index 443ffbf6e..60fb7522b 100644 --- a/core/accumulator/timeAccumulator.go +++ b/core/accumulator/timeAccumulator.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" ) var _ core.Accumulator = (*timeAccumulator)(nil) diff --git a/core/accumulator/timeAccumulator_test.go b/core/accumulator/timeAccumulator_test.go index 8d51de047..c6d9244aa 100644 --- a/core/accumulator/timeAccumulator_test.go +++ b/core/accumulator/timeAccumulator_test.go @@ -5,10 +5,10 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/accumulator" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/core/mock" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/accumulator" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/mock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/core/alarm/alarm_test.go b/core/alarm/alarm_test.go index c2a7f7f03..3354ddf98 100644 --- a/core/alarm/alarm_test.go +++ b/core/alarm/alarm_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/alarm" - "github.com/ElrondNetwork/elrond-go-core/core/atomic" + "github.com/multiversx/mx-chain-core-go/core/alarm" + "github.com/multiversx/mx-chain-core-go/core/atomic" "github.com/stretchr/testify/require" ) diff --git a/core/appStatusPolling/appStatusPolling.go b/core/appStatusPolling/appStatusPolling.go index 021737dd6..b688e2e67 100644 --- a/core/appStatusPolling/appStatusPolling.go +++ b/core/appStatusPolling/appStatusPolling.go @@ -5,8 +5,8 @@ import ( "sync" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" ) const minPollingDuration = time.Second diff --git a/core/appStatusPolling/appStatusPolling_test.go b/core/appStatusPolling/appStatusPolling_test.go index 0809047b7..e3a0e2137 100644 --- a/core/appStatusPolling/appStatusPolling_test.go +++ b/core/appStatusPolling/appStatusPolling_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/appStatusPolling" - "github.com/ElrondNetwork/elrond-go-core/core/mock" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/appStatusPolling" + "github.com/multiversx/mx-chain-core-go/core/mock" "github.com/stretchr/testify/assert" ) diff --git a/core/check/ifNil_test.go b/core/check/ifNil_test.go index e82fd6661..09cbfeccc 100644 --- a/core/check/ifNil_test.go +++ b/core/check/ifNil_test.go @@ -3,7 +3,7 @@ package check_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" ) diff --git a/core/check/ifZero_test.go b/core/check/ifZero_test.go index 17ed330ac..f7071b368 100644 --- a/core/check/ifZero_test.go +++ b/core/check/ifZero_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" ) diff --git a/core/closing/safeChanCloser_test.go b/core/closing/safeChanCloser_test.go index cab34965f..1ee5b56ad 100644 --- a/core/closing/safeChanCloser_test.go +++ b/core/closing/safeChanCloser_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" ) diff --git a/core/closing/shuffleOutCloser.go b/core/closing/shuffleOutCloser.go index 71aa55bf0..816b9e95e 100644 --- a/core/closing/shuffleOutCloser.go +++ b/core/closing/shuffleOutCloser.go @@ -5,10 +5,10 @@ import ( "fmt" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/core/random" - "github.com/ElrondNetwork/elrond-go-core/data/endProcess" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/random" + "github.com/multiversx/mx-chain-core-go/data/endProcess" ) const minDuration = time.Second diff --git a/core/closing/shuffleOutCloser_test.go b/core/closing/shuffleOutCloser_test.go index 29047b94a..df5ae2894 100644 --- a/core/closing/shuffleOutCloser_test.go +++ b/core/closing/shuffleOutCloser_test.go @@ -5,10 +5,10 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/core/mock" - "github.com/ElrondNetwork/elrond-go-core/data/endProcess" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/data/endProcess" "github.com/stretchr/testify/assert" ) diff --git a/core/computers.go b/core/computers.go index 48d209dd9..687369e51 100644 --- a/core/computers.go +++ b/core/computers.go @@ -5,6 +5,9 @@ import ( "strconv" "strings" "time" + + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data" ) // MaxInt32 returns the maximum of two given numbers @@ -182,3 +185,17 @@ func IsValidESDTRole(role string) bool { return false } } + +// GetHeaderType will return the type of the provided header +func GetHeaderType(header data.HeaderHandler) HeaderType { + switch { + case check.IfNil(header): + return "" + case header.GetShardID() == MetachainShardId: + return MetaHeader + case check.IfNil(header.GetAdditionalData()): + return ShardHeaderV1 + default: + return ShardHeaderV2 + } +} diff --git a/core/computers_test.go b/core/computers_test.go index 15d1d9b63..1155cf4b3 100644 --- a/core/computers_test.go +++ b/core/computers_test.go @@ -7,7 +7,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" + dataCore "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -502,3 +504,16 @@ func TestIsValidESDTRole(t *testing.T) { require.Equal(t, tt.output, core.IsValidESDTRole(tt.input)) } } + +func TestGetHeaderType(t *testing.T) { + t.Parallel() + + require.Equal(t, core.HeaderType(""), core.GetHeaderType(nil)) + + var nilHeader dataCore.HeaderHandler + require.Equal(t, core.HeaderType(""), core.GetHeaderType(nilHeader)) + + require.Equal(t, core.MetaHeader, core.GetHeaderType(&block.MetaBlock{})) + require.Equal(t, core.ShardHeaderV1, core.GetHeaderType(&block.Header{})) + require.Equal(t, core.ShardHeaderV2, core.GetHeaderType(&block.HeaderV2{})) +} diff --git a/core/constants.go b/core/constants.go index 829b8841d..3ed15b3e9 100644 --- a/core/constants.go +++ b/core/constants.go @@ -1,5 +1,17 @@ package core +// HeaderType defines the type to be used for the header that is sent +type HeaderType string + +const ( + // MetaHeader defines the type of *block.MetaBlock + MetaHeader HeaderType = "MetaBlock" + // ShardHeaderV1 defines the type of *block.Header + ShardHeaderV1 HeaderType = "Header" + // ShardHeaderV2 defines the type of *block.HeaderV2 + ShardHeaderV2 HeaderType = "HeaderV2" +) + // NodeType represents the node's role in the network type NodeType string @@ -40,69 +52,69 @@ const BuiltInFunctionSetUserName = "SetUserName" // BuiltInFunctionSaveKeyValue is the key for the save key value built-in function const BuiltInFunctionSaveKeyValue = "SaveKeyValue" -// BuiltInFunctionESDTTransfer is the key for the elrond standard digital token transfer built-in function +// BuiltInFunctionESDTTransfer is the key for the electronic standard digital token transfer built-in function const BuiltInFunctionESDTTransfer = "ESDTTransfer" -// BuiltInFunctionESDTBurn is the key for the elrond standard digital token burn built-in function +// BuiltInFunctionESDTBurn is the key for the electronic standard digital token burn built-in function const BuiltInFunctionESDTBurn = "ESDTBurn" -// BuiltInFunctionESDTFreeze is the key for the elrond standard digital token freeze built-in function +// BuiltInFunctionESDTFreeze is the key for the electronic standard digital token freeze built-in function const BuiltInFunctionESDTFreeze = "ESDTFreeze" -// BuiltInFunctionESDTUnFreeze is the key for the elrond standard digital token unfreeze built-in function +// BuiltInFunctionESDTUnFreeze is the key for the electronic standard digital token unfreeze built-in function const BuiltInFunctionESDTUnFreeze = "ESDTUnFreeze" -// BuiltInFunctionESDTWipe is the key for the elrond standard digital token wipe built-in function +// BuiltInFunctionESDTWipe is the key for the electronic standard digital token wipe built-in function const BuiltInFunctionESDTWipe = "ESDTWipe" -// BuiltInFunctionESDTPause is the key for the elrond standard digital token pause built-in function +// BuiltInFunctionESDTPause is the key for the electronic standard digital token pause built-in function const BuiltInFunctionESDTPause = "ESDTPause" -// BuiltInFunctionESDTUnPause is the key for the elrond standard digital token unpause built-in function +// BuiltInFunctionESDTUnPause is the key for the electronic standard digital token unpause built-in function const BuiltInFunctionESDTUnPause = "ESDTUnPause" -// BuiltInFunctionSetESDTRole is the key for the elrond standard digital token set built-in function +// BuiltInFunctionSetESDTRole is the key for the electronic standard digital token set built-in function const BuiltInFunctionSetESDTRole = "ESDTSetRole" -// BuiltInFunctionUnSetESDTRole is the key for the elrond standard digital token unset built-in function +// BuiltInFunctionUnSetESDTRole is the key for the electronic standard digital token unset built-in function const BuiltInFunctionUnSetESDTRole = "ESDTUnSetRole" -// BuiltInFunctionESDTSetLimitedTransfer is the key for the elrond standard digital token built-in function which sets the property +// BuiltInFunctionESDTSetLimitedTransfer is the key for the electronic standard digital token built-in function which sets the property // for the token to be transferable only through accounts with transfer roles const BuiltInFunctionESDTSetLimitedTransfer = "ESDTSetLimitedTransfer" -// BuiltInFunctionESDTUnSetLimitedTransfer is the key for the elrond standard digital token built-in function which unsets the property +// BuiltInFunctionESDTUnSetLimitedTransfer is the key for the electronic standard digital token built-in function which unsets the property // for the token to be transferable only through accounts with transfer roles const BuiltInFunctionESDTUnSetLimitedTransfer = "ESDTUnSetLimitedTransfer" -// BuiltInFunctionESDTLocalMint is the key for the elrond standard digital token local mint built-in function +// BuiltInFunctionESDTLocalMint is the key for the electronic standard digital token local mint built-in function const BuiltInFunctionESDTLocalMint = "ESDTLocalMint" -// BuiltInFunctionESDTLocalBurn is the key for the elrond standard digital token local burn built-in function +// BuiltInFunctionESDTLocalBurn is the key for the electronic standard digital token local burn built-in function const BuiltInFunctionESDTLocalBurn = "ESDTLocalBurn" -// BuiltInFunctionESDTNFTTransfer is the key for the elrond standard digital token NFT transfer built-in function +// BuiltInFunctionESDTNFTTransfer is the key for the electronic standard digital token NFT transfer built-in function const BuiltInFunctionESDTNFTTransfer = "ESDTNFTTransfer" -// BuiltInFunctionESDTNFTCreate is the key for the elrond standard digital token NFT create built-in function +// BuiltInFunctionESDTNFTCreate is the key for the electronic standard digital token NFT create built-in function const BuiltInFunctionESDTNFTCreate = "ESDTNFTCreate" -// BuiltInFunctionESDTNFTAddQuantity is the key for the elrond standard digital token NFT add quantity built-in function +// BuiltInFunctionESDTNFTAddQuantity is the key for the electronic standard digital token NFT add quantity built-in function const BuiltInFunctionESDTNFTAddQuantity = "ESDTNFTAddQuantity" -// BuiltInFunctionESDTNFTCreateRoleTransfer is the key for the elrond standard digital token create role transfer function +// BuiltInFunctionESDTNFTCreateRoleTransfer is the key for the electronic standard digital token create role transfer function const BuiltInFunctionESDTNFTCreateRoleTransfer = "ESDTNFTCreateRoleTransfer" -// BuiltInFunctionESDTNFTBurn is the key for the elrond standard digital token NFT burn built-in function +// BuiltInFunctionESDTNFTBurn is the key for the electronic standard digital token NFT burn built-in function const BuiltInFunctionESDTNFTBurn = "ESDTNFTBurn" -// BuiltInFunctionESDTNFTAddURI is the key for the elrond standard digital token NFT add URI built-in function +// BuiltInFunctionESDTNFTAddURI is the key for the electronic standard digital token NFT add URI built-in function const BuiltInFunctionESDTNFTAddURI = "ESDTNFTAddURI" -// BuiltInFunctionESDTNFTUpdateAttributes is the key for the elrond standard digital token NFT update attributes built-in function +// BuiltInFunctionESDTNFTUpdateAttributes is the key for the electronic standard digital token NFT update attributes built-in function const BuiltInFunctionESDTNFTUpdateAttributes = "ESDTNFTUpdateAttributes" -// BuiltInFunctionMultiESDTNFTTransfer is the key for the elrond standard digital token multi transfer built-in function +// BuiltInFunctionMultiESDTNFTTransfer is the key for the electronic standard digital token multi transfer built-in function const BuiltInFunctionMultiESDTNFTTransfer = "MultiESDTNFTTransfer" // BuiltInFunctionSetGuardian is the key for setting a guardian built-in function @@ -163,17 +175,17 @@ const SemiFungibleESDT = "SemiFungibleESDT" // MaxRoyalty defines 100% as uint32 const MaxRoyalty = uint32(10000) -// RelayedTransaction is the key for the elrond meta/gassless/relayed transaction standard +// RelayedTransaction is the key for the electronic meta/gassless/relayed transaction standard const RelayedTransaction = "relayedTx" -// RelayedTransactionV2 is the key for the optimized elrond meta/gassless/relayed transaction standard +// RelayedTransactionV2 is the key for the optimized electronic meta/gassless/relayed transaction standard const RelayedTransactionV2 = "relayedTxV2" // SCDeployInitFunctionName is the key for the function which is called at smart contract deploy time const SCDeployInitFunctionName = "_init" -// ElrondProtectedKeyPrefix is the key prefix which is protected from writing in the trie - only for special builtin functions -const ElrondProtectedKeyPrefix = "ELROND" +// ProtectedKeyPrefix is the key prefix which is protected from writing in the trie - only for special builtin functions +const ProtectedKeyPrefix = "E" + "L" + "R" + "O" + "N" + "D" // DelegationSystemSCKey is the key under which there is data in case of system delegation smart contracts const DelegationSystemSCKey = "delegation" @@ -230,3 +242,15 @@ const SCDeployIdentifier = "SCDeploy" // SCUpgradeIdentifier is the identifier for a smart contract upgrade const SCUpgradeIdentifier = "SCUpgrade" + +// WriteLogIdentifier is the identifier for the information log that is generated by a smart contract call/esdt transfer +const WriteLogIdentifier = "writeLog" + +// SignalErrorOperation is the identifier for the log that is generated when a smart contract is executed but return an error +const SignalErrorOperation = "signalError" + +// CompletedTxEventIdentifier is the identifier for the log that is generated when the execution of a smart contract call is done +const CompletedTxEventIdentifier = "completedTxEvent" + +// GasRefundForRelayerMessage is the return message for to the smart contract result with refund for the relayer +const GasRefundForRelayerMessage = "gas refund for relayer" diff --git a/core/converters.go b/core/converters.go index 8019248cd..f3e395194 100644 --- a/core/converters.go +++ b/core/converters.go @@ -7,9 +7,9 @@ import ( "strconv" "strings" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/hashing" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/hashing" + "github.com/multiversx/mx-chain-core-go/marshal" ) // ConvertBytes converts the input bytes in a readable string using multipliers (k, M, G) diff --git a/core/converters_test.go b/core/converters_test.go index f220e2035..dc0951765 100644 --- a/core/converters_test.go +++ b/core/converters_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/mock" - "github.com/ElrondNetwork/elrond-go-core/data/batch" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/data/batch" "github.com/stretchr/testify/assert" ) diff --git a/core/counting/concurrentShardedCountsWithSize.go b/core/counting/concurrentShardedCountsWithSize.go index 4e1907ee6..5ba503064 100644 --- a/core/counting/concurrentShardedCountsWithSize.go +++ b/core/counting/concurrentShardedCountsWithSize.go @@ -6,7 +6,7 @@ import ( "strings" "sync" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" ) var _ CountsWithSize = (*ConcurrentShardedCountsWithSize)(nil) diff --git a/core/counting/concurrentShardedCountsWithSize_test.go b/core/counting/concurrentShardedCountsWithSize_test.go index 3be0d5cef..31d60895a 100644 --- a/core/counting/concurrentShardedCountsWithSize_test.go +++ b/core/counting/concurrentShardedCountsWithSize_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/core/file_test.go b/core/file_test.go index 29b09a79b..8d80d9627 100644 --- a/core/file_test.go +++ b/core/file_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" "github.com/stretchr/testify/assert" ) diff --git a/core/keyValStorage/keyValStorage.go b/core/keyValStorage/keyValStorage.go index a66bf5b20..b3cbc49b6 100644 --- a/core/keyValStorage/keyValStorage.go +++ b/core/keyValStorage/keyValStorage.go @@ -3,7 +3,7 @@ package keyValStorage import ( "bytes" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" ) // KeyValStorage holds a key and an associated value diff --git a/core/keyValStorage/keyValStorage_test.go b/core/keyValStorage/keyValStorage_test.go index de5dd5753..57a4001f8 100644 --- a/core/keyValStorage/keyValStorage_test.go +++ b/core/keyValStorage/keyValStorage_test.go @@ -3,8 +3,8 @@ package keyValStorage_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/keyValStorage" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/keyValStorage" "github.com/stretchr/testify/assert" ) diff --git a/core/libLocator/vmLocator_darwin.go b/core/libLocator/vmLocator_darwin.go index f5eb77f85..8a42ea15c 100644 --- a/core/libLocator/vmLocator_darwin.go +++ b/core/libLocator/vmLocator_darwin.go @@ -1,3 +1,4 @@ +//go:build darwin // +build darwin package vm @@ -13,5 +14,5 @@ func WASMLibLocation() string { if err != nil { return "" } - return usr.HomeDir + "/elrond-vm-binaries/" + libName + return usr.HomeDir + "/multiversx-vm-binaries/" + libName } diff --git a/core/libLocator/vmLocator_linux.go b/core/libLocator/vmLocator_linux.go index ca31f8282..36fd5c9c0 100644 --- a/core/libLocator/vmLocator_linux.go +++ b/core/libLocator/vmLocator_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package vm @@ -14,5 +15,5 @@ func WASMLibLocation() string { if err != nil { return "" } - return usr.HomeDir + "/elrond-vm-binaries/" + libName + return usr.HomeDir + "/multiversx-vm-binaries/" + libName } diff --git a/core/libLocator/vmLocator_windows.go b/core/libLocator/vmLocator_windows.go index 9b44adf2b..a86f6abcc 100644 --- a/core/libLocator/vmLocator_windows.go +++ b/core/libLocator/vmLocator_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package vm @@ -13,5 +14,5 @@ func WASMLibLocation() string { if err != nil { return "" } - return usr.HomeDir + "\\elrond-vm-binaries\\" + libName + return usr.HomeDir + "\\multiversx-vm-binaries\\" + libName } diff --git a/core/loggingFunctions_test.go b/core/loggingFunctions_test.go index f77ea9b04..6aed20a01 100644 --- a/core/loggingFunctions_test.go +++ b/core/loggingFunctions_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/mock" + "github.com/multiversx/mx-chain-core-go/core/mock" "github.com/stretchr/testify/require" ) diff --git a/core/mock/headerHandlerStub.go b/core/mock/headerHandlerStub.go deleted file mode 100644 index 29d5df68c..000000000 --- a/core/mock/headerHandlerStub.go +++ /dev/null @@ -1,255 +0,0 @@ -package mock - -import ( - "math/big" - - "github.com/ElrondNetwork/elrond-go-core/data" -) - -// HeaderHandlerStub - -type HeaderHandlerStub struct { - EpochField uint32 - TimestampField uint64 - GetMiniBlockHeadersWithDstCalled func(destId uint32) map[string]uint32 - GetOrderedCrossMiniblocksWithDstCalled func(destId uint32) []*data.MiniBlockInfo - GetPubKeysBitmapCalled func() []byte - GetSignatureCalled func() []byte - GetRootHashCalled func() []byte - GetRandSeedCalled func() []byte - GetPrevRandSeedCalled func() []byte - GetPrevHashCalled func() []byte - CloneCalled func() data.HeaderHandler - GetChainIDCalled func() []byte - CheckChainIDCalled func(reference []byte) error - GetReservedCalled func() []byte - IsStartOfEpochBlockCalled func() bool -} - -// GetAccumulatedFees - -func (hhs *HeaderHandlerStub) GetAccumulatedFees() *big.Int { - return big.NewInt(0) -} - -// GetDeveloperFees - -func (hhs *HeaderHandlerStub) GetDeveloperFees() *big.Int { - return big.NewInt(0) -} - -// SetAccumulatedFees - -func (hhs *HeaderHandlerStub) SetAccumulatedFees(_ *big.Int) { -} - -// SetDeveloperFees - -func (hhs *HeaderHandlerStub) SetDeveloperFees(_ *big.Int) { -} - -// GetReceiptsHash - -func (hhs *HeaderHandlerStub) GetReceiptsHash() []byte { - return []byte("receipt") -} - -// SetShardID - -func (hhs *HeaderHandlerStub) SetShardID(_ uint32) { -} - -// IsStartOfEpochBlock - -func (hhs *HeaderHandlerStub) IsStartOfEpochBlock() bool { - if hhs.IsStartOfEpochBlockCalled != nil { - return hhs.IsStartOfEpochBlockCalled() - } - - return false -} - -// Clone - -func (hhs *HeaderHandlerStub) Clone() data.HeaderHandler { - return hhs.CloneCalled() -} - -// GetShardID - -func (hhs *HeaderHandlerStub) GetShardID() uint32 { - return 1 -} - -// GetNonce - -func (hhs *HeaderHandlerStub) GetNonce() uint64 { - return 1 -} - -// GetEpoch - -func (hhs *HeaderHandlerStub) GetEpoch() uint32 { - return hhs.EpochField -} - -// GetRound - -func (hhs *HeaderHandlerStub) GetRound() uint64 { - return 1 -} - -// GetTimeStamp - -func (hhs *HeaderHandlerStub) GetTimeStamp() uint64 { - return hhs.TimestampField -} - -// GetRootHash - -func (hhs *HeaderHandlerStub) GetRootHash() []byte { - return hhs.GetRootHashCalled() -} - -// GetPrevHash - -func (hhs *HeaderHandlerStub) GetPrevHash() []byte { - return hhs.GetPrevHashCalled() -} - -// GetPrevRandSeed - -func (hhs *HeaderHandlerStub) GetPrevRandSeed() []byte { - return hhs.GetPrevRandSeedCalled() -} - -// GetRandSeed - -func (hhs *HeaderHandlerStub) GetRandSeed() []byte { - return hhs.GetRandSeedCalled() -} - -// GetPubKeysBitmap - -func (hhs *HeaderHandlerStub) GetPubKeysBitmap() []byte { - return hhs.GetPubKeysBitmapCalled() -} - -// GetSignature - -func (hhs *HeaderHandlerStub) GetSignature() []byte { - return hhs.GetSignatureCalled() -} - -// GetLeaderSignature - -func (hhs *HeaderHandlerStub) GetLeaderSignature() []byte { - return hhs.GetSignatureCalled() -} - -// GetChainID - -func (hhs *HeaderHandlerStub) GetChainID() []byte { - return hhs.GetChainIDCalled() -} - -// GetTxCount - -func (hhs *HeaderHandlerStub) GetTxCount() uint32 { - return 0 -} - -// GetReserved - -func (hhs *HeaderHandlerStub) GetReserved() []byte { - if hhs.GetReservedCalled != nil { - return hhs.GetReservedCalled() - } - - return nil -} - -// SetNonce - -func (hhs *HeaderHandlerStub) SetNonce(_ uint64) { - panic("implement me") -} - -// SetEpoch - -func (hhs *HeaderHandlerStub) SetEpoch(_ uint32) { - panic("implement me") -} - -// SetRound - -func (hhs *HeaderHandlerStub) SetRound(_ uint64) { - panic("implement me") -} - -// SetTimeStamp - -func (hhs *HeaderHandlerStub) SetTimeStamp(_ uint64) { - panic("implement me") -} - -// SetRootHash - -func (hhs *HeaderHandlerStub) SetRootHash(_ []byte) { - panic("implement me") -} - -// SetPrevHash - -func (hhs *HeaderHandlerStub) SetPrevHash(_ []byte) { - panic("implement me") -} - -// SetPrevRandSeed - -func (hhs *HeaderHandlerStub) SetPrevRandSeed(_ []byte) { - panic("implement me") -} - -// SetRandSeed - -func (hhs *HeaderHandlerStub) SetRandSeed(_ []byte) { - panic("implement me") -} - -// SetPubKeysBitmap - -func (hhs *HeaderHandlerStub) SetPubKeysBitmap(_ []byte) { - panic("implement me") -} - -// SetSignature - -func (hhs *HeaderHandlerStub) SetSignature(_ []byte) { - panic("implement me") -} - -// SetLeaderSignature - -func (hhs *HeaderHandlerStub) SetLeaderSignature(_ []byte) { - panic("implement me") -} - -// SetChainID - -func (hhs *HeaderHandlerStub) SetChainID(_ []byte) { - panic("implement me") -} - -// SetTxCount - -func (hhs *HeaderHandlerStub) SetTxCount(_ uint32) { - panic("implement me") -} - -// GetMiniBlockHeadersWithDst - -func (hhs *HeaderHandlerStub) GetMiniBlockHeadersWithDst(destId uint32) map[string]uint32 { - return hhs.GetMiniBlockHeadersWithDstCalled(destId) -} - -// GetOrderedCrossMiniblocksWithDst - -func (hhs *HeaderHandlerStub) GetOrderedCrossMiniblocksWithDst(destId uint32) []*data.MiniBlockInfo { - return hhs.GetOrderedCrossMiniblocksWithDstCalled(destId) -} - -// GetMiniBlockHeadersHashes - -func (hhs *HeaderHandlerStub) GetMiniBlockHeadersHashes() [][]byte { - panic("implement me") -} - -// GetValidatorStatsRootHash - -func (hhs *HeaderHandlerStub) GetValidatorStatsRootHash() []byte { - return []byte("vs root hash") -} - -// SetValidatorStatsRootHash - -func (hhs *HeaderHandlerStub) SetValidatorStatsRootHash(_ []byte) { - panic("implement me") -} - -// IsInterfaceNil returns true if there is no value under the interface -func (hhs *HeaderHandlerStub) IsInterfaceNil() bool { - return hhs == nil -} - -// GetEpochStartMetaHash - -func (hhs *HeaderHandlerStub) GetEpochStartMetaHash() []byte { - panic("implement me") -} - -// GetSoftwareVersion - -func (hhs *HeaderHandlerStub) GetSoftwareVersion() []byte { - return []byte("softwareVersion") -} - -// SetSoftwareVersion - -func (hhs *HeaderHandlerStub) SetSoftwareVersion(_ []byte) { -} diff --git a/core/nodetype/nodeTypeProvider.go b/core/nodetype/nodeTypeProvider.go index ba08dfbff..feb059bc2 100644 --- a/core/nodetype/nodeTypeProvider.go +++ b/core/nodetype/nodeTypeProvider.go @@ -3,7 +3,7 @@ package nodetype import ( "sync" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" ) type nodeTypeProvider struct { diff --git a/core/nodetype/nodeTypeProvider_test.go b/core/nodetype/nodeTypeProvider_test.go index 371140b4d..1b4251ab7 100644 --- a/core/nodetype/nodeTypeProvider_test.go +++ b/core/nodetype/nodeTypeProvider_test.go @@ -4,8 +4,8 @@ import ( "sync" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/require" ) diff --git a/core/partitioning/dataSplit.go b/core/partitioning/dataSplit.go index 911711606..08ef2b678 100644 --- a/core/partitioning/dataSplit.go +++ b/core/partitioning/dataSplit.go @@ -1,7 +1,7 @@ package partitioning import ( - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" ) const minimumMaxPacketNum = 1 diff --git a/core/partitioning/dataSplit_test.go b/core/partitioning/dataSplit_test.go index ebb555dba..41d09f641 100644 --- a/core/partitioning/dataSplit_test.go +++ b/core/partitioning/dataSplit_test.go @@ -5,8 +5,8 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/partitioning" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/partitioning" "github.com/stretchr/testify/assert" ) diff --git a/core/partitioning/simpleDataPacker.go b/core/partitioning/simpleDataPacker.go index 841c9e415..1c54f7359 100644 --- a/core/partitioning/simpleDataPacker.go +++ b/core/partitioning/simpleDataPacker.go @@ -1,9 +1,9 @@ package partitioning import ( - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/data/batch" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data/batch" + "github.com/multiversx/mx-chain-core-go/marshal" ) // SimpleDataPacker can split a large slice of byte slices in chunks <= maxPacketSize diff --git a/core/partitioning/simpleDataPacker_test.go b/core/partitioning/simpleDataPacker_test.go index dc02e62ee..e57b41718 100644 --- a/core/partitioning/simpleDataPacker_test.go +++ b/core/partitioning/simpleDataPacker_test.go @@ -4,9 +4,9 @@ import ( "crypto/rand" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/mock" - "github.com/ElrondNetwork/elrond-go-core/core/partitioning" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/core/partitioning" "github.com/stretchr/testify/assert" ) diff --git a/core/partitioning/sizeDataPacker.go b/core/partitioning/sizeDataPacker.go index a7e2301ea..10f6781f7 100644 --- a/core/partitioning/sizeDataPacker.go +++ b/core/partitioning/sizeDataPacker.go @@ -1,9 +1,9 @@ package partitioning import ( - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/data/batch" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data/batch" + "github.com/multiversx/mx-chain-core-go/marshal" ) const minimumMaxPacketSizeInBytes = 1 diff --git a/core/partitioning/sizeDataPacker_test.go b/core/partitioning/sizeDataPacker_test.go index 4dfbfe0f7..22104c12a 100644 --- a/core/partitioning/sizeDataPacker_test.go +++ b/core/partitioning/sizeDataPacker_test.go @@ -6,11 +6,11 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/mock" - "github.com/ElrondNetwork/elrond-go-core/core/partitioning" - "github.com/ElrondNetwork/elrond-go-core/data/batch" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/core/partitioning" + "github.com/multiversx/mx-chain-core-go/data/batch" + "github.com/multiversx/mx-chain-core-go/marshal" "github.com/pkg/errors" "github.com/stretchr/testify/assert" ) diff --git a/core/pubkeyConverter/bech32PubkeyConverter.go b/core/pubkeyConverter/bech32PubkeyConverter.go index cbef5d2d9..3361d007b 100644 --- a/core/pubkeyConverter/bech32PubkeyConverter.go +++ b/core/pubkeyConverter/bech32PubkeyConverter.go @@ -5,9 +5,9 @@ import ( "fmt" "runtime/debug" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/btcsuite/btcutil/bech32" + "github.com/btcsuite/btcd/btcutil/bech32" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" ) type config struct { diff --git a/core/pubkeyConverter/bech32PubkeyConverter_test.go b/core/pubkeyConverter/bech32PubkeyConverter_test.go index 5b99b3f7b..cb8f896b5 100644 --- a/core/pubkeyConverter/bech32PubkeyConverter_test.go +++ b/core/pubkeyConverter/bech32PubkeyConverter_test.go @@ -6,9 +6,9 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/core/mock" - "github.com/ElrondNetwork/elrond-go-core/core/pubkeyConverter" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/core/pubkeyConverter" "github.com/stretchr/testify/assert" ) diff --git a/core/pubkeyConverter/hexPubkeyConverter_test.go b/core/pubkeyConverter/hexPubkeyConverter_test.go index 4d3025380..84f1b7c91 100644 --- a/core/pubkeyConverter/hexPubkeyConverter_test.go +++ b/core/pubkeyConverter/hexPubkeyConverter_test.go @@ -4,8 +4,8 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/core/pubkeyConverter" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/pubkeyConverter" "github.com/stretchr/testify/assert" ) diff --git a/core/random/fisherYates_test.go b/core/random/fisherYates_test.go index 53a961f80..c881e31cf 100644 --- a/core/random/fisherYates_test.go +++ b/core/random/fisherYates_test.go @@ -3,7 +3,7 @@ package random import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core/mock" + "github.com/multiversx/mx-chain-core-go/core/mock" "github.com/stretchr/testify/assert" ) diff --git a/core/sharding/errors.go b/core/sharding/errors.go new file mode 100644 index 000000000..d72d0d9ea --- /dev/null +++ b/core/sharding/errors.go @@ -0,0 +1,9 @@ +package sharding + +import "errors" + +// ErrInvalidNumberOfShards signals that an invalid number of shards was passed to the sharding registry +var ErrInvalidNumberOfShards = errors.New("the number of shards must be greater than zero") + +// ErrInvalidShardId signals that an invalid shard is was passed +var ErrInvalidShardId = errors.New("shard id must be smaller than the total number of shards") diff --git a/core/sharding/multiShardCoordinator.go b/core/sharding/multiShardCoordinator.go new file mode 100644 index 000000000..ce4b39540 --- /dev/null +++ b/core/sharding/multiShardCoordinator.go @@ -0,0 +1,134 @@ +package sharding + +import ( + "bytes" + "math" + + "github.com/multiversx/mx-chain-core-go/core" +) + +// multiShardCoordinator struct defines the functionality for handling transaction dispatching to +// the corresponding shards. The number of shards is currently passed as a constructor +// parameter and later it should be calculated by this structure +type multiShardCoordinator struct { + maskHigh uint32 + maskLow uint32 + selfId uint32 + numberOfShards uint32 +} + +// NewMultiShardCoordinator returns a new multiShardCoordinator and initializes the masks +func NewMultiShardCoordinator(numberOfShards, selfId uint32) (*multiShardCoordinator, error) { + if numberOfShards < 1 { + return nil, ErrInvalidNumberOfShards + } + if selfId >= numberOfShards && selfId != core.MetachainShardId { + return nil, ErrInvalidShardId + } + + sr := &multiShardCoordinator{} + sr.selfId = selfId + sr.numberOfShards = numberOfShards + sr.maskHigh, sr.maskLow = calculateMasks(numberOfShards) + + return sr, nil +} + +// calculateMasks will create two numbers who's binary form is composed from as many +// ones needed to be taken into consideration for the shard assignment. The result +// of a bitwise AND operation of an address with this mask will result in the +// shard id where a transaction from that address will be dispatched +func calculateMasks(numOfShards uint32) (uint32, uint32) { + n := math.Ceil(math.Log2(float64(numOfShards))) + return (1 << uint(n)) - 1, (1 << uint(n-1)) - 1 +} + +// ComputeId calculates the shard for a given address container +func (msc *multiShardCoordinator) ComputeId(address []byte) uint32 { + return msc.ComputeIdFromBytes(address) +} + +// ComputeShardID will compute shard id of the given address based on the number of shards parameter +func ComputeShardID(address []byte, numberOfShards uint32) uint32 { + maskHigh, maskLow := calculateMasks(numberOfShards) + + return computeIdBasedOfNrOfShardAndMasks(address, numberOfShards, maskHigh, maskLow) +} + +// ComputeIdFromBytes calculates the shard for a given address +func (msc *multiShardCoordinator) ComputeIdFromBytes(address []byte) uint32 { + if core.IsEmptyAddress(address) { + return msc.selfId + } + + return computeIdBasedOfNrOfShardAndMasks(address, msc.numberOfShards, msc.maskHigh, msc.maskLow) +} + +func computeIdBasedOfNrOfShardAndMasks(address []byte, numberOfShards, maskHigh, maskLow uint32) uint32 { + var bytesNeed int + if numberOfShards <= 256 { + bytesNeed = 1 + } else if numberOfShards <= 65536 { + bytesNeed = 2 + } else if numberOfShards <= 16777216 { + bytesNeed = 3 + } else { + bytesNeed = 4 + } + + startingIndex := 0 + if len(address) > bytesNeed { + startingIndex = len(address) - bytesNeed + } + + buffNeeded := address[startingIndex:] + if core.IsSmartContractOnMetachain(buffNeeded, address) { + return core.MetachainShardId + } + + addr := uint32(0) + for i := 0; i < len(buffNeeded); i++ { + addr = addr<<8 + uint32(buffNeeded[i]) + } + + shard := addr & maskHigh + if shard > numberOfShards-1 { + shard = addr & maskLow + } + + return shard +} + +// NumberOfShards returns the number of shards +func (msc *multiShardCoordinator) NumberOfShards() uint32 { + return msc.numberOfShards +} + +// SelfId gets the shard id of the current node +func (msc *multiShardCoordinator) SelfId() uint32 { + return msc.selfId +} + +// SameShard returns weather two addresses belong to the same shard +func (msc *multiShardCoordinator) SameShard(firstAddress, secondAddress []byte) bool { + if core.IsEmptyAddress(firstAddress) || core.IsEmptyAddress(secondAddress) { + return true + } + + if bytes.Equal(firstAddress, secondAddress) { + return true + } + + return msc.ComputeId(firstAddress) == msc.ComputeId(secondAddress) +} + +// CommunicationIdentifier returns the identifier between current shard ID and destination shard ID +// identifier is generated such as the first shard from identifier is always smaller or equal than the last +func (msc *multiShardCoordinator) CommunicationIdentifier(destShardID uint32) string { + return core.CommunicationIdentifierBetweenShards(msc.selfId, destShardID) +} + +// IsInterfaceNil returns true if there is no value under the interface +func (msc *multiShardCoordinator) IsInterfaceNil() bool { + return msc == nil +} diff --git a/core/sharding/multiShardCoordinator_test.go b/core/sharding/multiShardCoordinator_test.go new file mode 100644 index 000000000..4bb44f111 --- /dev/null +++ b/core/sharding/multiShardCoordinator_test.go @@ -0,0 +1,225 @@ +package sharding + +import ( + "bytes" + "encoding/binary" + "encoding/hex" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +func getAddressFromUint32(address uint32) []byte { + buff := make([]byte, 4) + binary.BigEndian.PutUint32(buff, address) + + return buff +} + +func TestMultiShardCoordinator_NewMultiShardCoordinator(t *testing.T) { + numOfShards := uint32(10) + sr, _ := NewMultiShardCoordinator(numOfShards, 0) + assert.Equal(t, numOfShards, sr.NumberOfShards()) + expectedMask1, expectedMask2 := calculateMasks(sr.NumberOfShards()) + actualMask1 := sr.maskHigh + actualMask2 := sr.maskLow + assert.Equal(t, expectedMask1, actualMask1) + assert.Equal(t, expectedMask2, actualMask2) +} + +func TestMultiShardCoordinator_NewMultiShardCoordinatorInvalidNumberOfShards(t *testing.T) { + sr, err := NewMultiShardCoordinator(0, 0) + assert.Nil(t, sr) + assert.Equal(t, ErrInvalidNumberOfShards, err) +} + +func TestMultiShardCoordinator_NewMultiShardCoordinatorSelfIdGraterThanNumOfShardsShouldError(t *testing.T) { + _, err := NewMultiShardCoordinator(1, 2) + assert.Equal(t, ErrInvalidShardId, err) +} + +func TestMultiShardCoordinator_NewMultiShardCoordinatorCorrectSelfId(t *testing.T) { + currentShardId := uint32(0) + sr, _ := NewMultiShardCoordinator(1, currentShardId) + assert.Equal(t, currentShardId, sr.SelfId()) +} + +func TestMultiShardCoordinator_ComputeIdDoesNotGenerateInvalidShards(t *testing.T) { + numOfShards := uint32(10) + selfId := uint32(0) + sr, _ := NewMultiShardCoordinator(numOfShards, selfId) + + for i := 0; i < 200; i++ { + addr := getAddressFromUint32(uint32(i)) + shardId := sr.ComputeId(addr) + assert.True(t, shardId < sr.NumberOfShards()) + } +} + +func TestMultiShardCoordinator_ComputeId10ShardsShouldWork(t *testing.T) { + numOfShards := uint32(10) + selfId := uint32(0) + sr, _ := NewMultiShardCoordinator(numOfShards, selfId) + + dataSet := []struct { + address, shardId uint32 + }{ + {0, 0}, + {1, 1}, + {2, 2}, + {3, 3}, + {4, 4}, + {5, 5}, + {6, 6}, + {7, 7}, + {8, 8}, + {9, 9}, + {10, 2}, + {11, 3}, + {12, 4}, + {13, 5}, + {14, 6}, + {15, 7}, + } + for _, data := range dataSet { + addr := getAddressFromUint32(data.address) + shardId := sr.ComputeId(addr) + + assert.Equal(t, data.shardId, shardId) + } +} + +func TestMultiShardCoordinator_ComputeId10ShardsBigNumbersShouldWork(t *testing.T) { + numOfShards := uint32(10) + selfId := uint32(0) + sr, _ := NewMultiShardCoordinator(numOfShards, selfId) + + dataSet := []struct { + address string + shardId uint32 + }{ + {"2ca2ed0a1c77b5ddeabf99e3f17074f1c77b5ddea37dbaacf501ef1752950c50", 0}, + {"5f7e73b922883bf97b5ddeab9e3f103b8ddea37dbaaca24b5ddea37dbaac1061", 1}, + {"65b9926097345bf7b5ddeab99e3f1cc7c71c01bfd3e1efacc1d0df1ba8f96172", 2}, + {"c1c77b5ddea5c71c4160c861c01ba8f9617a65010d2baac7827a501bbf29aad3", 3}, + {"22c2e1facc1d1c77b5d16160c861c01ba8f96170c86783b8deabaac782733b84", 4}, + {"4cc88bdac668dc1878271e79a67b5ddeaddea37dbaacbbf99e3f1f4e5a4d7085", 5}, + {"b533facc1daa3a617466f4160c861c01ba8f9617a65010d160c86783b82a5836", 6}, + {"b1487283ad280316baa160c861c01ba8f9617c78270c8668dc18b5ddea37dba7", 7}, + {"acfba138faed1c7b5d668dc1878b5ddea37dbaac271edeab7160c861c01ba8f8", 8}, + {"cc3757647aebf9d160c86e9f9eb5dde0c86783b89160a37dbaac3f15c8f48999", 9}, + {"1a30b33104a94a65010d2a5e87285eb0ea37dbaac60c86c3facc1d4d1ba8f96a", 2}, + {"fcca8da9ba5160c86783b89160ea37dbaac60c86c86783b8c868be1ba8f9617b", 3}, + {"8f9b094668dc1878271ed1b1b5ddea37dbaac60c86760f2e4c71c01bf6a913cc", 4}, + {"a2d768be59a607d160c86eb5ddea37dbaafacc1dc9fa0e0c86783b8916092cbd", 5}, + {"365865f21b2e0d668dc18ea37dbaac60c8678271e160c86e9160c86783b8fe6e", 6}, + {"16cc745884a65ba160c861c01ba8f9617ac7827d160c86e9f010d2a592b3a52f", 7}, + } + for _, data := range dataSet { + buff, err := hex.DecodeString(data.address) + assert.Nil(t, err) + + shardId := sr.ComputeId(buff) + second := ComputeShardID(buff, sr.numberOfShards) + + assert.Equal(t, data.shardId, shardId) + assert.Equal(t, data.shardId, second) + } +} + +func TestMultiShardCoordinator_ComputeIdSameSuffixHasSameShard(t *testing.T) { + numOfShards := uint32(2) + selfId := uint32(0) + sr, _ := NewMultiShardCoordinator(numOfShards, selfId) + + dataSet := []struct { + address, shardId uint32 + }{ + {0, 0}, + {1, 1}, + {2, 0}, + {3, 1}, + {4, 0}, + {5, 1}, + {6, 0}, + {7, 1}, + {8, 0}, + {9, 1}, + } + for _, data := range dataSet { + addr := getAddressFromUint32(data.address) + shardId := sr.ComputeId(addr) + + assert.Equal(t, data.shardId, shardId) + } +} + +func TestMultiShardCoordinator_SameShardSameAddress(t *testing.T) { + shard, _ := NewMultiShardCoordinator(1, 0) + addr1 := getAddressFromUint32(uint32(1)) + addr2 := getAddressFromUint32(uint32(1)) + + assert.True(t, shard.SameShard(addr1, addr2)) +} + +func TestMultiShardCoordinator_SameShardSameAddressMultipleShards(t *testing.T) { + shard, _ := NewMultiShardCoordinator(11, 0) + addr1 := getAddressFromUint32(uint32(1)) + addr2 := getAddressFromUint32(uint32(1)) + + assert.True(t, shard.SameShard(addr1, addr2)) +} + +func TestMultiShardCoordinator_SameShardDifferentAddress(t *testing.T) { + shard, _ := NewMultiShardCoordinator(1, 0) + addr1 := getAddressFromUint32(uint32(1)) + addr2 := getAddressFromUint32(uint32(2)) + + assert.True(t, shard.SameShard(addr1, addr2)) +} + +func TestMultiShardCoordinator_SameShardDifferentAddressMultipleShards(t *testing.T) { + shard, _ := NewMultiShardCoordinator(2, 0) + + addr1 := getAddressFromUint32(uint32(1)) + addr2 := getAddressFromUint32(uint32(2)) + + assert.False(t, shard.SameShard(addr1, addr2)) +} + +func TestMultiShardCoordinator_ComputeIDContractDeploy(t *testing.T) { + shard, _ := NewMultiShardCoordinator(2, 1) + + addr1 := bytes.Repeat([]byte{0}, 32) + assert.Equal(t, shard.ComputeId(addr1), shard.SelfId()) +} + +func TestMultiShardCoordinator_SameShardContractDeploy(t *testing.T) { + shard, _ := NewMultiShardCoordinator(2, 0) + + addr1 := bytes.Repeat([]byte{0}, 32) + addr2 := bytes.Repeat([]byte{1}, 32) + assert.True(t, shard.SameShard(addr1, addr2)) +} + +func TestMultiShardCoordinator_CommunicationIdentifierSameShard(t *testing.T) { + destId := uint32(1) + selfId := uint32(1) + shard, _ := NewMultiShardCoordinator(2, selfId) + assert.Equal(t, fmt.Sprintf("_%d", selfId), shard.CommunicationIdentifier(destId)) +} + +func TestMultiShardCoordinator_CommunicationIdentifierSmallerDestination(t *testing.T) { + destId := uint32(0) + selfId := uint32(1) + shard, _ := NewMultiShardCoordinator(2, selfId) + assert.Equal(t, fmt.Sprintf("_%d_%d", destId, selfId), shard.CommunicationIdentifier(destId)) +} + +func TestMultiShardCoordinator_CommunicationIdentifier(t *testing.T) { + destId := uint32(1) + selfId := uint32(0) + shard, _ := NewMultiShardCoordinator(2, selfId) + assert.Equal(t, fmt.Sprintf("_%d_%d", selfId, destId), shard.CommunicationIdentifier(destId)) +} diff --git a/core/sliceUtil/sliceUtil_test.go b/core/sliceUtil/sliceUtil_test.go index 2e3d3f1ee..107aa21cb 100644 --- a/core/sliceUtil/sliceUtil_test.go +++ b/core/sliceUtil/sliceUtil_test.go @@ -3,7 +3,7 @@ package sliceUtil_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core/sliceUtil" + "github.com/multiversx/mx-chain-core-go/core/sliceUtil" "github.com/stretchr/testify/assert" ) diff --git a/core/stopWatch_test.go b/core/stopWatch_test.go index 947651cd6..135def969 100644 --- a/core/stopWatch_test.go +++ b/core/stopWatch_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/mock" + "github.com/multiversx/mx-chain-core-go/core/mock" "github.com/stretchr/testify/assert" ) diff --git a/core/throttler/numGoRoutinesThrottler.go b/core/throttler/numGoRoutinesThrottler.go index 01b4ed782..2286e6cbc 100644 --- a/core/throttler/numGoRoutinesThrottler.go +++ b/core/throttler/numGoRoutinesThrottler.go @@ -3,7 +3,7 @@ package throttler import ( "sync/atomic" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" ) // NumGoRoutinesThrottler can limit the number of go routines launched diff --git a/core/throttler/numGoRoutinesThrottler_test.go b/core/throttler/numGoRoutinesThrottler_test.go index 996103847..28dc28f20 100644 --- a/core/throttler/numGoRoutinesThrottler_test.go +++ b/core/throttler/numGoRoutinesThrottler_test.go @@ -3,9 +3,9 @@ package throttler_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/core/throttler" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/throttler" "github.com/stretchr/testify/assert" ) diff --git a/core/transaction/transactionSorter.go b/core/transaction/transactionSorter.go new file mode 100644 index 000000000..5f6267cb2 --- /dev/null +++ b/core/transaction/transactionSorter.go @@ -0,0 +1,106 @@ +package transaction + +import ( + "bytes" + "sort" + + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/hashing" +) + +// SortTransactionsBySenderAndNonceWithFrontRunningProtection - sorts the transactions by address and randomness source to protect from front running +func SortTransactionsBySenderAndNonceWithFrontRunningProtection(transactions []data.TransactionHandler, hasher hashing.Hasher, randomness []byte) { + // make sure randomness is 32bytes and uniform + randSeed := hasher.Compute(string(randomness)) + xoredAddresses := make(map[string][]byte) + + for _, tx := range transactions { + xoredBytes := xorBytes(tx.GetSndAddr(), randSeed) + xoredAddresses[string(tx.GetSndAddr())] = hasher.Compute(string(xoredBytes)) + } + + sorter := func(i, j int) bool { + txI := transactions[i] + txJ := transactions[j] + + delta := bytes.Compare(xoredAddresses[string(txI.GetSndAddr())], xoredAddresses[string(txJ.GetSndAddr())]) + if delta == 0 { + delta = int(txI.GetNonce()) - int(txJ.GetNonce()) + } + + return delta < 0 + } + + sort.Slice(transactions, sorter) +} + +// TODO remove duplicated function when will use the version of mx-chain-go which exports transaction order during processing + +// SortTransactionsBySenderAndNonceWithFrontRunningProtectionExtendedTransactions - sorts the transactions by address and randomness source to protect from front running +func SortTransactionsBySenderAndNonceWithFrontRunningProtectionExtendedTransactions(transactions []data.TransactionHandlerWithGasUsedAndFee, hasher hashing.Hasher, randomness []byte) { + // make sure randomness is 32bytes and uniform + randSeed := hasher.Compute(string(randomness)) + xoredAddresses := make(map[string][]byte) + + for _, tx := range transactions { + xoredBytes := xorBytes(tx.GetSndAddr(), randSeed) + xoredAddresses[string(tx.GetSndAddr())] = hasher.Compute(string(xoredBytes)) + } + + sorter := func(i, j int) bool { + txI := transactions[i] + txJ := transactions[j] + + delta := bytes.Compare(xoredAddresses[string(txI.GetSndAddr())], xoredAddresses[string(txJ.GetSndAddr())]) + if delta == 0 { + delta = int(txI.GetNonce()) - int(txJ.GetNonce()) + } + + return delta < 0 + } + + sort.Slice(transactions, sorter) +} + +// SortTransactionsBySenderAndNonce - sorts the transactions by address without the front running protection +func SortTransactionsBySenderAndNonce(transactions []data.TransactionHandler) { + sorter := func(i, j int) bool { + txI := transactions[i] + txJ := transactions[j] + + delta := bytes.Compare(txI.GetSndAddr(), txJ.GetSndAddr()) + if delta == 0 { + delta = int(txI.GetNonce()) - int(txJ.GetNonce()) + } + + return delta < 0 + } + + sort.Slice(transactions, sorter) +} + +// SortTransactionsBySenderAndNonceExtendedTransactions - sorts the transactions by address without the front running protection +func SortTransactionsBySenderAndNonceExtendedTransactions(transactions []data.TransactionHandlerWithGasUsedAndFee) { + sorter := func(i, j int) bool { + txI := transactions[i] + txJ := transactions[j] + + delta := bytes.Compare(txI.GetSndAddr(), txJ.GetSndAddr()) + if delta == 0 { + delta = int(txI.GetNonce()) - int(txJ.GetNonce()) + } + + return delta < 0 + } + + sort.Slice(transactions, sorter) +} + +// parameters need to be of the same len, otherwise it will panic (if second slice shorter) +func xorBytes(a, b []byte) []byte { + res := make([]byte, len(a)) + for i := range a { + res[i] = a[i] ^ b[i] + } + return res +} diff --git a/core/transaction/transactionSorter_test.go b/core/transaction/transactionSorter_test.go new file mode 100644 index 000000000..f690f2269 --- /dev/null +++ b/core/transaction/transactionSorter_test.go @@ -0,0 +1,110 @@ +package transaction + +import ( + "encoding/hex" + "fmt" + "math/big" + "testing" + + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/outport" + "github.com/multiversx/mx-chain-core-go/data/transaction" + "github.com/stretchr/testify/assert" +) + +func Test_SortTransactionsBySenderAndNonceWithFrontRunningProtection(t *testing.T) { + randomness := "randomness" + nbSenders := 5 + + hasher := &mock.HasherStub{ + ComputeCalled: func(s string) []byte { + if s == randomness { + return []byte{0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} + } + + return []byte(s) + }, + } + + usedRandomness := hasher.Compute(randomness) + senders := make([][]byte, 0) + for i := 0; i < nbSenders; i++ { + sender := make([]byte, len(usedRandomness)) + copy(sender, usedRandomness) + sender[len(usedRandomness)-1-i] = 0 + senders = append(senders, sender) + } + + txs := []data.TransactionHandler{ + &transaction.Transaction{Nonce: 1, SndAddr: senders[0]}, + &transaction.Transaction{Nonce: 2, SndAddr: senders[2]}, + &transaction.Transaction{Nonce: 1, SndAddr: senders[2]}, + &transaction.Transaction{Nonce: 2, SndAddr: senders[0]}, + &transaction.Transaction{Nonce: 7, SndAddr: senders[1]}, + &transaction.Transaction{Nonce: 6, SndAddr: senders[1]}, + &transaction.Transaction{Nonce: 1, SndAddr: senders[4]}, + &transaction.Transaction{Nonce: 3, SndAddr: senders[3]}, + &transaction.Transaction{Nonce: 3, SndAddr: senders[2]}, + } + wrappedTxs := make([]data.TransactionHandlerWithGasUsedAndFee, 0, len(txs)) + for _, tx := range txs { + wrappedTxs = append(wrappedTxs, outport.NewTransactionHandlerWithGasAndFee(tx, 0, big.NewInt(0))) + } + + SortTransactionsBySenderAndNonceWithFrontRunningProtection(txs, hasher, []byte(randomness)) + SortTransactionsBySenderAndNonceWithFrontRunningProtectionExtendedTransactions(wrappedTxs, hasher, []byte(randomness)) + + expectedOutput := []string{ + "1 ffffffffffffffffffffffffffffff00", + "2 ffffffffffffffffffffffffffffff00", + "6 ffffffffffffffffffffffffffff00ff", + "7 ffffffffffffffffffffffffffff00ff", + "1 ffffffffffffffffffffffffff00ffff", + "2 ffffffffffffffffffffffffff00ffff", + "3 ffffffffffffffffffffffffff00ffff", + "3 ffffffffffffffffffffffff00ffffff", + "1 ffffffffffffffffffffff00ffffffff", + } + + for i, item := range txs { + assert.Equal(t, expectedOutput[i], fmt.Sprintf("%d %s", item.GetNonce(), hex.EncodeToString(item.GetSndAddr()))) + assert.Equal(t, expectedOutput[i], fmt.Sprintf("%d %s", wrappedTxs[i].GetNonce(), hex.EncodeToString(wrappedTxs[i].GetSndAddr()))) + } +} + +func Test_SortTransactionsBySenderAndNonceLegacy(t *testing.T) { + txs := []data.TransactionHandler{ + &transaction.Transaction{Nonce: 3, SndAddr: []byte("bbbb")}, + &transaction.Transaction{Nonce: 1, SndAddr: []byte("aaaa")}, + &transaction.Transaction{Nonce: 5, SndAddr: []byte("bbbb")}, + &transaction.Transaction{Nonce: 2, SndAddr: []byte("aaaa")}, + &transaction.Transaction{Nonce: 7, SndAddr: []byte("aabb")}, + &transaction.Transaction{Nonce: 6, SndAddr: []byte("aabb")}, + &transaction.Transaction{Nonce: 3, SndAddr: []byte("ffff")}, + &transaction.Transaction{Nonce: 3, SndAddr: []byte("eeee")}, + } + wrappedTxs := make([]data.TransactionHandlerWithGasUsedAndFee, 0, len(txs)) + for _, tx := range txs { + wrappedTxs = append(wrappedTxs, outport.NewTransactionHandlerWithGasAndFee(tx, 0, big.NewInt(0))) + } + + SortTransactionsBySenderAndNonce(txs) + SortTransactionsBySenderAndNonceExtendedTransactions(wrappedTxs) + + expectedOutput := []string{ + "1 aaaa", + "2 aaaa", + "6 aabb", + "7 aabb", + "3 bbbb", + "5 bbbb", + "3 eeee", + "3 ffff", + } + + for i, item := range txs { + assert.Equal(t, expectedOutput[i], fmt.Sprintf("%d %s", item.GetNonce(), string(item.GetSndAddr()))) + assert.Equal(t, expectedOutput[i], fmt.Sprintf("%d %s", wrappedTxs[i].GetNonce(), string(wrappedTxs[i].GetSndAddr()))) + } +} diff --git a/core/trimmers_test.go b/core/trimmers_test.go index 588f7c1da..4064ca105 100644 --- a/core/trimmers_test.go +++ b/core/trimmers_test.go @@ -3,7 +3,7 @@ package core_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" "github.com/stretchr/testify/assert" ) diff --git a/core/versioning/txVersionChecker.go b/core/versioning/txVersionChecker.go index 0c010ac97..3dc2c8d53 100644 --- a/core/versioning/txVersionChecker.go +++ b/core/versioning/txVersionChecker.go @@ -1,8 +1,8 @@ package versioning import ( - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data/transaction" ) const ( diff --git a/core/versioning/txVersionChecker_test.go b/core/versioning/txVersionChecker_test.go index caefc517d..d54d4fd66 100644 --- a/core/versioning/txVersionChecker_test.go +++ b/core/versioning/txVersionChecker_test.go @@ -3,8 +3,8 @@ package versioning import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/stretchr/testify/require" ) diff --git a/core/versioning/versionComparator.go b/core/versioning/versionComparator.go index 98f4a9472..9c0d3b4c0 100644 --- a/core/versioning/versionComparator.go +++ b/core/versioning/versionComparator.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" ) const numComponents = 3 diff --git a/core/versioning/versionComparator_test.go b/core/versioning/versionComparator_test.go index 48c0d113f..fb84e3d4c 100644 --- a/core/versioning/versionComparator_test.go +++ b/core/versioning/versionComparator_test.go @@ -4,8 +4,8 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" ) diff --git a/core/watchdog/watchdog.go b/core/watchdog/watchdog.go index 9b0594339..240732d2c 100644 --- a/core/watchdog/watchdog.go +++ b/core/watchdog/watchdog.go @@ -5,9 +5,9 @@ import ( "runtime/pprof" "time" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data/endProcess" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data/endProcess" ) type watchdog struct { diff --git a/core/watchdog/watchdog_test.go b/core/watchdog/watchdog_test.go index 5a519ca9a..c87de8a40 100644 --- a/core/watchdog/watchdog_test.go +++ b/core/watchdog/watchdog_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/core/mock" - "github.com/ElrondNetwork/elrond-go-core/core/watchdog" - "github.com/ElrondNetwork/elrond-go-core/data/endProcess" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/core/watchdog" + "github.com/multiversx/mx-chain-core-go/data/endProcess" "github.com/stretchr/testify/assert" ) diff --git a/data/api/apiBlock.go b/data/api/apiBlock.go index 85b878be3..5387c1099 100644 --- a/data/api/apiBlock.go +++ b/data/api/apiBlock.go @@ -4,7 +4,8 @@ import ( "math/big" "time" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" + "github.com/multiversx/mx-chain-core-go/data/outport" + "github.com/multiversx/mx-chain-core-go/data/transaction" ) // Block represents the structure for block that is returned by api routes @@ -22,6 +23,8 @@ type Block struct { AccumulatedFeesInEpoch string `json:"accumulatedFeesInEpoch,omitempty"` DeveloperFeesInEpoch string `json:"developerFeesInEpoch,omitempty"` Status string `json:"status,omitempty"` + RandSeed string `json:"randSeed,omitempty"` + PrevRandSeed string `json:"prevRandSeed,omitempty"` Timestamp time.Duration `json:"timestamp,omitempty"` NotarizedBlocks []*NotarizedBlock `json:"notarizedBlocks,omitempty"` MiniBlocks []*MiniBlock `json:"miniBlocks,omitempty"` @@ -54,10 +57,13 @@ type EpochStartInfo struct { // NotarizedBlock represents a notarized block type NotarizedBlock struct { - Hash string `json:"hash"` - Nonce uint64 `json:"nonce"` - Round uint64 `json:"round"` - Shard uint32 `json:"shard"` + Hash string `json:"hash"` + Nonce uint64 `json:"nonce"` + Round uint64 `json:"round"` + Shard uint32 `json:"shard"` + RootHash string `json:"rootHash"` + MiniBlockHashes []string `json:"miniBlockHashes,omitempty"` + AlteredAccounts []*outport.AlteredAccount `json:"alteredAccounts,omitempty"` } // EpochStartShardData is a structure that holds data about the epoch start shard data @@ -116,3 +122,33 @@ type Delegator struct { Total string `json:"total"` TotalAsBigInt *big.Int `json:"-"` } + +// BlockFetchType is the type that specifies how a block should be queried from API +type BlockFetchType string + +func (aft BlockFetchType) String() string { + return string(aft) +} + +const ( + // BlockFetchTypeByHash is to be used when a block should be fetched from API based on its hash + BlockFetchTypeByHash BlockFetchType = "by-hash" + + // BlockFetchTypeByNonce is to be used when a block should be fetched from API based on its nonce + BlockFetchTypeByNonce BlockFetchType = "by-nonce" +) + +// TODO: GetBlockParameters can be used for other endpoints as well + +// GetBlockParameters holds the parameters for requesting a block on API +type GetBlockParameters struct { + RequestType BlockFetchType + Hash []byte + Nonce uint64 +} + +// GetAlteredAccountsForBlockOptions specifies the options for returning altered accounts for a given block +type GetAlteredAccountsForBlockOptions struct { + GetBlockParameters + TokensFilter string +} diff --git a/data/api/apiBlock_test.go b/data/api/apiBlock_test.go new file mode 100644 index 000000000..3528369c1 --- /dev/null +++ b/data/api/apiBlock_test.go @@ -0,0 +1,16 @@ +package api_test + +import ( + "testing" + + "github.com/multiversx/mx-chain-core-go/data/api" + "github.com/stretchr/testify/require" +) + +func TestAPIBlockFetchType(t *testing.T) { + byNonceType := api.BlockFetchTypeByNonce + require.Equal(t, "by-nonce", byNonceType.String()) + + byHashType := api.BlockFetchTypeByHash + require.Equal(t, "by-hash", byHashType.String()) +} diff --git a/data/api/apiHyperBlock.go b/data/api/apiHyperBlock.go new file mode 100644 index 000000000..84bceae39 --- /dev/null +++ b/data/api/apiHyperBlock.go @@ -0,0 +1,28 @@ +package api + +import ( + "time" + + "github.com/multiversx/mx-chain-core-go/data/transaction" +) + +// Hyperblock contains all fully executed (both in source and in destination shards) transactions notarized in a given metablock +type Hyperblock struct { + Hash string `json:"hash"` + PrevBlockHash string `json:"prevBlockHash"` + StateRootHash string `json:"stateRootHash"` + Nonce uint64 `json:"nonce"` + Round uint64 `json:"round"` + Epoch uint32 `json:"epoch"` + NumTxs uint32 `json:"numTxs"` + AccumulatedFees string `json:"accumulatedFees,omitempty"` + DeveloperFees string `json:"developerFees,omitempty"` + AccumulatedFeesInEpoch string `json:"accumulatedFeesInEpoch,omitempty"` + DeveloperFeesInEpoch string `json:"developerFeesInEpoch,omitempty"` + Timestamp time.Duration `json:"timestamp,omitempty"` + EpochStartInfo *EpochStartInfo `json:"epochStartInfo,omitempty"` + EpochStartShardsData []*EpochStartShardData `json:"epochStartShardsData,omitempty"` + ShardBlocks []*NotarizedBlock `json:"shardBlocks"` + Transactions []*transaction.ApiTransactionResult `json:"transactions"` + Status string `json:"status,omitempty"` +} diff --git a/data/api/options.go b/data/api/options.go index 0b4e773ec..66ce40dd4 100644 --- a/data/api/options.go +++ b/data/api/options.go @@ -1,6 +1,6 @@ package api -import "github.com/ElrondNetwork/elrond-go-core/core" +import "github.com/multiversx/mx-chain-core-go/core" // AccountQueryOptions holds options for account queries type AccountQueryOptions struct { diff --git a/data/batch/batch.go b/data/batch/batch.go index 6bcb7d228..353994a1d 100644 --- a/data/batch/batch.go +++ b/data/batch/batch.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. batch.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. batch.proto package batch // New returns a new batch from given buffers diff --git a/data/block/block.go b/data/block/block.go index bc1e91a29..cc8a1fd8a 100644 --- a/data/block/block.go +++ b/data/block/block.go @@ -1,11 +1,12 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. block.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. block.proto package block import ( + "fmt" "math/big" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/headerVersionData" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/headerVersionData" ) // TODO: add access protection through wrappers @@ -581,3 +582,36 @@ func (h *Header) GetAdditionalData() headerVersionData.HeaderAdditionalData { // no extra data for the initial version of shard block header return nil } + +// CheckFieldsForNil checks a predefined set of fields for nil values +func (h *Header) CheckFieldsForNil() error { + if h == nil { + return data.ErrNilPointerReceiver + } + if h.PrevHash == nil { + return fmt.Errorf("%w in Header.PrevHash", data.ErrNilValue) + } + if h.PrevRandSeed == nil { + return fmt.Errorf("%w in Header.PrevRandSeed", data.ErrNilValue) + } + if h.RandSeed == nil { + return fmt.Errorf("%w in Header.RandSeed", data.ErrNilValue) + } + if h.RootHash == nil { + return fmt.Errorf("%w in Header.RootHash", data.ErrNilValue) + } + if h.ChainID == nil { + return fmt.Errorf("%w in Header.ChainID", data.ErrNilValue) + } + if h.SoftwareVersion == nil { + return fmt.Errorf("%w in Header.SoftwareVersion", data.ErrNilValue) + } + if h.AccumulatedFees == nil { + return fmt.Errorf("%w in Header.AccumulatedFees", data.ErrNilValue) + } + if h.DeveloperFees == nil { + return fmt.Errorf("%w in Header.DeveloperFees", data.ErrNilValue) + } + + return nil +} diff --git a/data/block/block.pb.go b/data/block/block.pb.go index 080fb4781..880b6eee5 100644 --- a/data/block/block.pb.go +++ b/data/block/block.pb.go @@ -6,9 +6,9 @@ package block import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" io "io" math "math" math_big "math/big" @@ -336,8 +336,8 @@ type Header struct { ReceiptsHash []byte `protobuf:"bytes,19,opt,name=ReceiptsHash,proto3" json:"ReceiptsHash,omitempty"` ChainID []byte `protobuf:"bytes,20,opt,name=ChainID,proto3" json:"ChainID,omitempty"` SoftwareVersion []byte `protobuf:"bytes,21,opt,name=SoftwareVersion,proto3" json:"SoftwareVersion,omitempty"` - AccumulatedFees *math_big.Int `protobuf:"bytes,22,opt,name=AccumulatedFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"AccumulatedFees,omitempty"` - DeveloperFees *math_big.Int `protobuf:"bytes,23,opt,name=DeveloperFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"DeveloperFees,omitempty"` + AccumulatedFees *math_big.Int `protobuf:"bytes,22,opt,name=AccumulatedFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"AccumulatedFees,omitempty"` + DeveloperFees *math_big.Int `protobuf:"bytes,23,opt,name=DeveloperFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"DeveloperFees,omitempty"` Reserved []byte `protobuf:"bytes,24,opt,name=Reserved,proto3" json:"Reserved,omitempty"` } @@ -639,68 +639,68 @@ func init() { func init() { proto.RegisterFile("block.proto", fileDescriptor_8e550b1f5926e92d) } var fileDescriptor_8e550b1f5926e92d = []byte{ - // 961 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x3b, 0x6f, 0x1b, 0x47, - 0x10, 0xe6, 0x49, 0x24, 0x2d, 0x0d, 0x1f, 0xa2, 0xd6, 0x8e, 0x72, 0x30, 0x8c, 0x13, 0x21, 0xb8, - 0x10, 0x04, 0x88, 0x4a, 0x94, 0x26, 0x0f, 0x23, 0x41, 0xa8, 0x07, 0x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, 0xd7, 0x1a, 0xdc, 0x07, 0x00, - 0x00, + // 962 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x3b, 0x6f, 0xe3, 0xc6, + 0x13, 0x17, 0x6d, 0x49, 0x3e, 0x8f, 0x1e, 0x96, 0xf7, 0xee, 0xef, 0x3f, 0x71, 0x38, 0xd0, 0x82, + 0x71, 0x85, 0x61, 0xc0, 0x72, 0xe2, 0x34, 0x79, 0x1c, 0x12, 0x44, 0x7e, 0xc0, 0x42, 0x72, 0x07, + 0x81, 0x32, 0x52, 0x5c, 0xb7, 0x22, 0xe7, 0x24, 0x22, 0x22, 0x57, 0x58, 0x2e, 0x75, 0x72, 0x97, + 0x32, 0x65, 0xaa, 0x7c, 0x86, 0x20, 0x75, 0x3e, 0xc4, 0x15, 0x29, 0x5c, 0xba, 0x4a, 0x62, 0xb9, + 0x49, 0x79, 0x9f, 0x20, 0x09, 0x76, 0x96, 0xd4, 0x83, 0x76, 0x91, 0x22, 0x95, 0x38, 0xbf, 0x9d, + 0xc7, 0x6f, 0x66, 0x7f, 0x3b, 0x82, 0x4a, 0x7f, 0x24, 0xbc, 0x6f, 0x5b, 0x63, 0x29, 0x94, 0x60, + 0x25, 0xfa, 0x79, 0x7a, 0x38, 0x08, 0xd4, 0x30, 0xe9, 0xb7, 0x3c, 0x11, 0x1e, 0x0d, 0xc4, 0x40, + 0x1c, 0x11, 0xdc, 0x4f, 0xde, 0x90, 0x45, 0x06, 0x7d, 0x99, 0xa8, 0xbd, 0x5f, 0x2c, 0xd8, 0x7c, + 0x19, 0x44, 0x41, 0x5b, 0x67, 0x62, 0x4f, 0xe1, 0xd1, 0xe5, 0xf4, 0x82, 0xc7, 0x43, 0x8c, 0x6d, + 0xab, 0xb9, 0xbe, 0x5f, 0x75, 0xe7, 0x36, 0xdb, 0x87, 0x2d, 0x17, 0x3d, 0x0c, 0x26, 0x28, 0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 0xaa, 0xf5, 0x16, 0x30, + 0x1a, 0x74, 0x4f, 0x71, 0xa9, 0x74, 0x18, 0x55, 0x62, 0x54, 0xe9, 0x81, 0x13, 0xad, 0x2c, 0x7a, + 0x48, 0x63, 0x15, 0x93, 0xe7, 0x63, 0xa3, 0xac, 0x65, 0x4c, 0x57, 0x3b, 0x19, 0xf2, 0x20, 0xea, + 0x9c, 0xda, 0x4f, 0xe8, 0x38, 0x33, 0x35, 0xe3, 0x9e, 0x78, 0xa3, 0xde, 0x72, 0x89, 0xdf, 0xa0, + 0x8c, 0x03, 0x11, 0xd9, 0xff, 0x33, 0xc3, 0xcf, 0xc1, 0x2c, 0x86, 0xad, 0x2f, 0x3d, 0x2f, 0x09, + 0x93, 0x11, 0x57, 0xe8, 0x9f, 0x23, 0xc6, 0xf6, 0x8e, 0xf6, 0x6c, 0x77, 0x7e, 0xfe, 0x7d, 0xf7, + 0x2c, 0xe4, 0x6a, 0x78, 0xd4, 0x0f, 0x06, 0xad, 0x4e, 0xa4, 0x3e, 0x5b, 0xda, 0x92, 0x61, 0x32, + 0x52, 0xfa, 0x8d, 0xc7, 0xd3, 0xa3, 0x70, 0x7a, 0xe8, 0xe9, 0xaa, 0x87, 0x9e, 0x90, 0x78, 0x38, + 0x10, 0x47, 0x3e, 0x57, 0xbc, 0xd5, 0x0e, 0x06, 0x9d, 0x48, 0x9d, 0xf0, 0x58, 0xa1, 0x74, 0xf3, + 0x15, 0x98, 0x80, 0xda, 0x29, 0x4e, 0x70, 0x24, 0xc6, 0x28, 0xa9, 0xe4, 0xff, 0xff, 0xeb, 0x92, + 0xab, 0xf9, 0x57, 0x16, 0x89, 0x9d, 0x5b, 0x24, 0x1f, 0x43, 0x51, 0x4b, 0x9a, 0x7d, 0x00, 0x30, + 0x17, 0x94, 0x59, 0xe5, 0x95, 0xe3, 0x46, 0x5e, 0x80, 0xee, 0x92, 0xcf, 0xde, 0x0b, 0xa8, 0xeb, + 0x48, 0xa3, 0xbe, 0x2e, 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0xde, 0xcd, 0x1c, 0xeb, 0x7a, 0xe6, + 0x58, 0x37, 0x33, 0xc7, 0xfa, 0x63, 0xe6, 0x58, 0x7f, 0xce, 0x9c, 0xc2, 0xfb, 0x99, 0x63, 0xfd, + 0x70, 0xe7, 0x14, 0xae, 0xef, 0x9c, 0xc2, 0xcd, 0x9d, 0x53, 0x78, 0x5d, 0xa2, 0xbf, 0xf2, 0x7e, + 0x99, 0xae, 0xe8, 0xa3, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x89, 0x48, 0xfc, 0x4a, 0xda, 0x07, + 0x00, 0x00, } func (x Type) String() string { @@ -929,13 +929,13 @@ func (this *Header) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.AccumulatedFees, that1.AccumulatedFees) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.DeveloperFees, that1.DeveloperFees) { return false } @@ -1293,7 +1293,7 @@ func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0xc2 } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.DeveloperFees) i -= size if _, err := __caster.MarshalTo(m.DeveloperFees, dAtA[i:]); err != nil { @@ -1306,7 +1306,7 @@ func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0xba { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.AccumulatedFees) i -= size if _, err := __caster.MarshalTo(m.AccumulatedFees, dAtA[i:]); err != nil { @@ -1730,12 +1730,12 @@ func (m *Header) Size() (n int) { n += 2 + l + sovBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.AccumulatedFees) n += 2 + l + sovBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.DeveloperFees) n += 2 + l + sovBlock(uint64(l)) } @@ -3046,7 +3046,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3084,7 +3084,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { diff --git a/data/block/block.proto b/data/block/block.proto index c8290675f..0ace1958f 100644 --- a/data/block/block.proto +++ b/data/block/block.proto @@ -83,8 +83,8 @@ message Header { bytes ReceiptsHash = 19; bytes ChainID = 20; bytes SoftwareVersion = 21; - bytes AccumulatedFees = 22 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes DeveloperFees = 23 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes AccumulatedFees = 22 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DeveloperFees = 23 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes Reserved = 24; } diff --git a/data/block/blockChecks_test.go b/data/block/blockChecks_test.go new file mode 100644 index 000000000..e4d99a805 --- /dev/null +++ b/data/block/blockChecks_test.go @@ -0,0 +1,150 @@ +package block + +import ( + "fmt" + "math/big" + "reflect" + "testing" + + "github.com/multiversx/mx-chain-core-go/data" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var headerV1ExceptionFields = []string{ + "Signature", + "LeaderSignature", + "PubKeysBitmap", + "MetaBlockHashes", + "EpochStartMetaHash", + "ReceiptsHash", + "Reserved", +} + +type field struct { + name string + typeValue string + objFieldIndex int +} + +type fieldsChecker interface { + CheckFieldsForNil() error +} + +func prepareFieldsList(object interface{}, fieldNameExceptions ...string) []field { + list := make([]field, 0) + val := reflect.ValueOf(object).Elem() + for i := 0; i < val.NumField(); i++ { + fieldName := val.Type().Field(i).Name + fieldType := fmt.Sprintf("%v", val.Field(i).Type()) + switch fieldType { + case "uint64", "uint32", "int", "string": + continue + case "block.Type", "[]block.MiniBlockHeader", "[]block.PeerChange": + continue + } + if search(fieldName, fieldNameExceptions...) { + continue + } + + list = append(list, field{ + name: fieldName, + typeValue: fieldType, + objFieldIndex: i, + }) + } + + return list +} + +func search(needle string, haystack ...string) bool { + for _, item := range haystack { + if item == needle { + return true + } + } + return false +} + +func populateFieldsWithRandomValue(tb testing.TB, object interface{}, fields []field) { + val := reflect.ValueOf(object) + for counter, f := range fields { + fieldValue := val.Elem().FieldByName(f.name) + + switch f.typeValue { + case "[]uint8": + fieldValue.SetBytes([]byte(fmt.Sprintf("test field %d", counter))) + case "[][]uint8": + fieldValue.Set(reflect.ValueOf([][]byte{ + []byte(fmt.Sprintf("test field1 %d", counter)), + []byte(fmt.Sprintf("test field2 %d", counter)), + })) + case "*big.Int": + fieldValue.Set(reflect.ValueOf(big.NewInt(int64(counter)))) + default: + assert.Fail(tb, "unimplemented field type "+f.typeValue+" for field "+f.name) + } + } +} + +func unsetField(tb testing.TB, object interface{}, f field) { + v := reflect.ValueOf(object) + + fieldValue := v.Elem().FieldByName(f.name) + switch f.typeValue { + case "[]uint8", "[][]uint8", "*big.Int": + fieldValue.Set(reflect.Zero(fieldValue.Type())) + default: + assert.Fail(tb, "unimplemented field type "+f.typeValue+" for field "+f.name) + } +} + +func testField(tb testing.TB, object interface{}, fields []field, fieldIndex int) { + f := fields[fieldIndex] + fmt.Printf(" testing field %s of type %s\n", f.name, f.typeValue) + populateFieldsWithRandomValue(tb, object, fields) + unsetField(tb, object, fields[fieldIndex]) + + checker := object.(fieldsChecker) + err := checker.CheckFieldsForNil() + require.NotNil(tb, err, "should have return a non nil error for nil field %s", f.name) + assert.ErrorIs(tb, err, data.ErrNilValue) +} + +func TestBlockHeader_Checks(t *testing.T) { + t.Parallel() + + t.Run("nil pointer receiver", func(t *testing.T) { + t.Parallel() + + var objectToTest *Header + err := objectToTest.CheckFieldsForNil() + require.NotNil(t, err) + assert.ErrorIs(t, err, data.ErrNilPointerReceiver) + }) + t.Run("test all fields when set", func(t *testing.T) { + t.Parallel() + + objectToTest := &Header{} + + fields := prepareFieldsList(objectToTest, headerV1ExceptionFields...) + assert.NotEmpty(t, fields) + }) + t.Run("test all fields when one is unset", func(t *testing.T) { + t.Parallel() + + objectToTest := &Header{} + + fields := prepareFieldsList(objectToTest, headerV1ExceptionFields...) + assert.NotEmpty(t, fields) + + populateFieldsWithRandomValue(t, objectToTest, fields) + err := objectToTest.CheckFieldsForNil() + require.Nil(t, err) + + fmt.Printf("fields tests on %T\n", objectToTest) + for i := 0; i < len(fields); i++ { + testField(t, objectToTest, fields, i) + } + }) +} diff --git a/data/block/blockV2.go b/data/block/blockV2.go index 4aa1ec3b6..0a690e2ee 100644 --- a/data/block/blockV2.go +++ b/data/block/blockV2.go @@ -1,12 +1,13 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. blockV2.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. blockV2.proto package block import ( + "fmt" "math/big" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/headerVersionData" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/headerVersionData" ) // GetShardID returns the header shardID @@ -629,3 +630,23 @@ func (hv2 *HeaderV2) GetAdditionalData() headerVersionData.HeaderAdditionalData } return additionalVersionData } + +// CheckFieldsForNil checks a predefined set of fields for nil values +func (hv2 *HeaderV2) CheckFieldsForNil() error { + if hv2 == nil { + return data.ErrNilPointerReceiver + } + err := hv2.Header.CheckFieldsForNil() + if err != nil { + return err + } + + if hv2.ScheduledAccumulatedFees == nil { + return fmt.Errorf("%w in HeaderV2.ScheduledAccumulatedFees", data.ErrNilValue) + } + if hv2.ScheduledDeveloperFees == nil { + return fmt.Errorf("%w in HeaderV2.ScheduledDeveloperFees", data.ErrNilValue) + } + + return nil +} diff --git a/data/block/blockV2.pb.go b/data/block/blockV2.pb.go index 4599aa8ed..fedd77586 100644 --- a/data/block/blockV2.pb.go +++ b/data/block/blockV2.pb.go @@ -6,9 +6,9 @@ package block import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" io "io" math "math" math_big "math/big" @@ -32,8 +32,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type HeaderV2 struct { Header *Header `protobuf:"bytes,1,opt,name=Header,proto3" json:"Header,omitempty"` ScheduledRootHash []byte `protobuf:"bytes,2,opt,name=ScheduledRootHash,proto3" json:"ScheduledRootHash,omitempty"` - ScheduledAccumulatedFees *math_big.Int `protobuf:"bytes,3,opt,name=ScheduledAccumulatedFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"ScheduledAccumulatedFees,omitempty"` - ScheduledDeveloperFees *math_big.Int `protobuf:"bytes,4,opt,name=ScheduledDeveloperFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"ScheduledDeveloperFees,omitempty"` + ScheduledAccumulatedFees *math_big.Int `protobuf:"bytes,3,opt,name=ScheduledAccumulatedFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"ScheduledAccumulatedFees,omitempty"` + ScheduledDeveloperFees *math_big.Int `protobuf:"bytes,4,opt,name=ScheduledDeveloperFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"ScheduledDeveloperFees,omitempty"` ScheduledGasProvided uint64 `protobuf:"varint,5,opt,name=ScheduledGasProvided,proto3" json:"ScheduledGasProvided,omitempty"` ScheduledGasPenalized uint64 `protobuf:"varint,6,opt,name=ScheduledGasPenalized,proto3" json:"ScheduledGasPenalized,omitempty"` ScheduledGasRefunded uint64 `protobuf:"varint,7,opt,name=ScheduledGasRefunded,proto3" json:"ScheduledGasRefunded,omitempty"` @@ -235,40 +235,40 @@ func init() { func init() { proto.RegisterFile("blockV2.proto", fileDescriptor_17a3844aa051366e) } var fileDescriptor_17a3844aa051366e = []byte{ - // 524 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x3f, 0x6f, 0x13, 0x3f, - 0x1c, 0xc6, 0xcf, 0xbf, 0x5f, 0x12, 0x90, 0x4b, 0x10, 0xb5, 0x68, 0x7b, 0xea, 0x60, 0xa2, 0x48, - 0x48, 0x11, 0x90, 0x44, 0x0a, 0x08, 0x21, 0x75, 0x40, 0x04, 0x1a, 0x1a, 0xc4, 0x9f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2, 0xfd, 0x48, 0x49, 0xc1, 0x9f, 0x83, 0x79, 0x25, 0xd5, 0x49, 0x15, - 0xec, 0x54, 0x0e, 0x64, 0xd9, 0x97, 0x0a, 0xaa, 0x9c, 0x19, 0x56, 0xa9, 0x87, 0x41, 0x53, 0x98, - 0x87, 0x4c, 0x1b, 0x50, 0xde, 0xda, 0x2c, 0xf2, 0x1e, 0xe1, 0xed, 0x05, 0x7c, 0x04, 0x03, 0x88, - 0x64, 0x1f, 0x94, 0xbd, 0x46, 0xe6, 0xdc, 0xaf, 0xb1, 0x26, 0x89, 0xd4, 0xf0, 0xd5, 0x05, 0x79, - 0xcc, 0xf4, 0xa1, 0x92, 0x83, 0x90, 0x03, 0x77, 0xb3, 0x05, 0x54, 0xca, 0x78, 0x67, 0x32, 0x72, - 0x07, 0x6f, 0x2d, 0xe9, 0x20, 0x58, 0x14, 0xbe, 0x01, 0xee, 0xe6, 0xac, 0xe9, 0x6c, 0xf8, 0x6f, - 0x92, 0x07, 0x9d, 0x58, 0xcc, 0x92, 0x2e, 0xac, 0x26, 0xfd, 0x66, 0xc5, 0xb7, 0x78, 0xf3, 0x59, - 0x28, 0xc2, 0xfa, 0xac, 0x20, 0x1e, 0x68, 0x50, 0x03, 0xe0, 0x64, 0x0f, 0xe7, 0xf7, 0x87, 0xe0, - 0xc7, 0x26, 0x94, 0xa2, 0xf5, 0xba, 0x0f, 0xb6, 0x1c, 0x97, 0x6b, 0x5b, 0xf3, 0x72, 0x1c, 0x2a, - 0xe9, 0x83, 0xd6, 0xa1, 0x08, 0x66, 0xd0, 0x5b, 0xde, 0x4b, 0x6e, 0xe0, 0x2b, 0x2d, 0xc5, 0x84, - 0x66, 0xfe, 0x4c, 0xd2, 0xd6, 0x9f, 0x56, 0x65, 0x45, 0x2f, 0xfe, 0x44, 0x78, 0x67, 0x11, 0x3f, - 0xef, 0xdc, 0xb9, 0x5c, 0xe2, 0x26, 0xce, 0x1e, 0x19, 0x66, 0xd2, 0xe4, 0x3f, 0xa6, 0x45, 0x96, - 0x85, 0x5e, 0xba, 0x87, 0xdc, 0xc3, 0x3b, 0x4d, 0xc1, 0x61, 0xf8, 0xa2, 0xd3, 0x08, 0x95, 0x36, - 0xad, 0xe1, 0xfc, 0x6c, 0xe0, 0xb6, 0xad, 0x59, 0x6f, 0x1d, 0x26, 0x77, 0xf1, 0xf6, 0x1c, 0x3d, - 0x65, 0xcb, 0xc6, 0x8c, 0x35, 0xae, 0xa1, 0xf5, 0xfb, 0xa3, 0x09, 0x75, 0xc6, 0x13, 0xea, 0x9c, - 0x4e, 0x28, 0x7a, 0x97, 0x50, 0xf4, 0x39, 0xa1, 0xe8, 0x6b, 0x42, 0xd1, 0x28, 0xa1, 0x68, 0x9c, - 0x50, 0xf4, 0x3d, 0xa1, 0xe8, 0x47, 0x42, 0x9d, 0xd3, 0x84, 0xa2, 0x4f, 0x53, 0xea, 0x8c, 0xa6, - 0xd4, 0x19, 0x4f, 0xa9, 0xf3, 0x32, 0x6b, 0x7f, 0xe5, 0x76, 0xce, 0xbe, 0xe7, 0xf6, 0xaf, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x83, 0xb1, 0x76, 0x7e, 0x1f, 0x04, 0x00, 0x00, + // 522 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x31, 0x6f, 0x13, 0x31, + 0x1c, 0xc5, 0xcf, 0x90, 0x04, 0xe4, 0x12, 0x44, 0x2d, 0xda, 0x9e, 0x3a, 0x98, 0x28, 0x12, 0x52, + 0x04, 0x24, 0x91, 0x02, 0x42, 0x48, 0x1d, 0x10, 0x81, 0x96, 0x46, 0x02, 0x51, 0x5d, 0xa3, 0x0e, + 0x6c, 0xce, 0xf9, 0x9f, 0x8b, 0xc5, 0xe5, 0x1c, 0xd9, 0xbe, 0x28, 0x20, 0x06, 0x18, 0x18, 0xd8, + 0xf8, 0x18, 0x88, 0x4f, 0xc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3, 0x6a, 0x4d, 0x11, 0xb4, 0x22, 0xf3, + 0x94, 0x69, 0x03, 0xca, 0x5b, 0x1b, 0x45, 0x3e, 0x22, 0xbc, 0x9d, 0xc1, 0x67, 0x30, 0x84, 0x50, + 0x0e, 0x40, 0xd9, 0x29, 0x72, 0x17, 0x3d, 0xc5, 0x9a, 0x20, 0xd2, 0xc0, 0x37, 0x33, 0xf2, 0x9c, + 0xe9, 0x23, 0x25, 0x87, 0x82, 0x03, 0x77, 0xf3, 0x25, 0x54, 0xc9, 0x79, 0xe7, 0x32, 0xf2, 0x00, + 0x6f, 0x2d, 0xe9, 0x10, 0xb1, 0x50, 0xbc, 0x03, 0xee, 0x16, 0xac, 0xe9, 0x7c, 0x78, 0x36, 0xc9, + 0x83, 0x6e, 0x1c, 0xcd, 0x93, 0xae, 0xac, 0x26, 0xfd, 0x65, 0xe5, 0xf7, 0x78, 0xf3, 0xa5, 0x88, + 0x44, 0x73, 0x5e, 0x0f, 0x0f, 0x34, 0xa8, 0x21, 0x70, 0xb2, 0x87, 0x8b, 0xfb, 0x23, 0xf0, 0x63, + 0x23, 0x64, 0xd4, 0x7e, 0x3b, 0x00, 0x5b, 0x8d, 0xeb, 0x8d, 0xad, 0x45, 0x35, 0x8e, 0x94, 0xf4, + 0x41, 0x6b, 0x11, 0x05, 0x73, 0xe8, 0x2d, 0x9f, 0x25, 0x77, 0xf0, 0x8d, 0xb6, 0x62, 0x91, 0x66, + 0xfe, 0x5c, 0xd2, 0xd6, 0x9f, 0x16, 0x65, 0x45, 0x2f, 0xff, 0x46, 0x78, 0x27, 0x8b, 0x5f, 0x34, + 0xee, 0x42, 0x86, 0xb8, 0x8b, 0xf3, 0xc7, 0x86, 0x99, 0x34, 0xf9, 0x9f, 0x29, 0xcb, 0xb2, 0xd0, + 0x4b, 0xcf, 0x90, 0x47, 0x78, 0xa7, 0x15, 0x71, 0x18, 0xbd, 0xea, 0x1e, 0x08, 0xa5, 0x4d, 0x7b, + 0xb4, 0xb8, 0x1b, 0xb8, 0xed, 0x6a, 0xde, 0x5b, 0x87, 0xc9, 0x43, 0xbc, 0xbd, 0x40, 0x2f, 0xd8, + 0xb2, 0x31, 0x67, 0x8d, 0x6b, 0x68, 0xf3, 0xf1, 0x78, 0x4a, 0x9d, 0xc9, 0x94, 0x3a, 0xa7, 0x53, + 0x8a, 0x3e, 0x24, 0x14, 0x7d, 0x4d, 0x28, 0xfa, 0x9e, 0x50, 0x34, 0x4e, 0x28, 0x9a, 0x24, 0x14, + 0xfd, 0x4c, 0x28, 0xfa, 0x95, 0x50, 0xe7, 0x34, 0xa1, 0xe8, 0xcb, 0x8c, 0x3a, 0xe3, 0x19, 0x75, + 0x26, 0x33, 0xea, 0xbc, 0xce, 0xdb, 0x1f, 0xb9, 0x53, 0xb0, 0xef, 0xb9, 0xff, 0x27, 0x00, 0x00, + 0xff, 0xff, 0x86, 0xdd, 0xb3, 0x54, 0x1d, 0x04, 0x00, 0x00, } func (this *HeaderV2) Equal(that interface{}) bool { @@ -297,13 +297,13 @@ func (this *HeaderV2) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.ScheduledAccumulatedFees, that1.ScheduledAccumulatedFees) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.ScheduledDeveloperFees, that1.ScheduledDeveloperFees) { return false } @@ -465,7 +465,7 @@ func (m *HeaderV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x28 } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.ScheduledDeveloperFees) i -= size if _, err := __caster.MarshalTo(m.ScheduledDeveloperFees, dAtA[i:]); err != nil { @@ -476,7 +476,7 @@ func (m *HeaderV2) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.ScheduledAccumulatedFees) i -= size if _, err := __caster.MarshalTo(m.ScheduledAccumulatedFees, dAtA[i:]); err != nil { @@ -612,12 +612,12 @@ func (m *HeaderV2) Size() (n int) { n += 1 + l + sovBlockV2(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.ScheduledAccumulatedFees) n += 1 + l + sovBlockV2(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.ScheduledDeveloperFees) n += 1 + l + sovBlockV2(uint64(l)) } @@ -853,7 +853,7 @@ func (m *HeaderV2) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -891,7 +891,7 @@ func (m *HeaderV2) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { diff --git a/data/block/blockV2.proto b/data/block/blockV2.proto index 5d4b7b9c1..274f179cf 100644 --- a/data/block/blockV2.proto +++ b/data/block/blockV2.proto @@ -13,8 +13,8 @@ import "block.proto"; message HeaderV2 { Header Header = 1; bytes ScheduledRootHash = 2; - bytes ScheduledAccumulatedFees = 3 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes ScheduledDeveloperFees = 4 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes ScheduledAccumulatedFees = 3 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes ScheduledDeveloperFees = 4 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; uint64 ScheduledGasProvided = 5; uint64 ScheduledGasPenalized = 6; uint64 ScheduledGasRefunded = 7; diff --git a/data/block/blockV2Checks_test.go b/data/block/blockV2Checks_test.go new file mode 100644 index 000000000..b44e2d439 --- /dev/null +++ b/data/block/blockV2Checks_test.go @@ -0,0 +1,90 @@ +package block + +import ( + "fmt" + "testing" + + "github.com/multiversx/mx-chain-core-go/data" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var headerV2ExceptionFields = []string{ + "Header", + "ScheduledRootHash", +} + +func TestBlockHeaderV2_Checks(t *testing.T) { + t.Parallel() + + t.Run("nil pointer receiver", func(t *testing.T) { + t.Parallel() + + var objectToTest *HeaderV2 + err := objectToTest.CheckFieldsForNil() + require.NotNil(t, err) + assert.ErrorIs(t, err, data.ErrNilPointerReceiver) + }) + t.Run("inner header is a nil pointer receiver", func(t *testing.T) { + t.Parallel() + + objectToTest := &HeaderV2{} + err := objectToTest.CheckFieldsForNil() + require.NotNil(t, err) + assert.ErrorIs(t, err, data.ErrNilPointerReceiver) + }) + t.Run("test all fields when set", func(t *testing.T) { + t.Parallel() + + objectToTest := &HeaderV2{} + + fields := prepareFieldsList(objectToTest, headerV1ExceptionFields...) + assert.NotEmpty(t, fields) + }) + t.Run("test all fields when one is unset on inner Header", func(t *testing.T) { + t.Parallel() + + objectToTest := &HeaderV2{ + Header: &Header{}, + } + + fieldsForHeaderV2 := prepareFieldsList(objectToTest, headerV2ExceptionFields...) + assert.NotEmpty(t, fieldsForHeaderV2) + populateFieldsWithRandomValue(t, objectToTest, fieldsForHeaderV2) + + fieldsForHeaderV1 := prepareFieldsList(objectToTest.Header, headerV1ExceptionFields...) + assert.NotEmpty(t, fieldsForHeaderV1) + + populateFieldsWithRandomValue(t, objectToTest.Header, fieldsForHeaderV1) + err := objectToTest.CheckFieldsForNil() + require.Nil(t, err) + + fmt.Printf("fields tests on %T\n", objectToTest.Header) + for i := 0; i < len(fieldsForHeaderV1); i++ { + testField(t, objectToTest.Header, fieldsForHeaderV1, i) + } + }) + t.Run("test all fields when one is unset on HeaderV2", func(t *testing.T) { + t.Parallel() + + objectToTest := &HeaderV2{ + Header: &Header{}, + } + + fieldsForHeaderV1 := prepareFieldsList(objectToTest.Header, headerV1ExceptionFields...) + assert.NotEmpty(t, fieldsForHeaderV1) + populateFieldsWithRandomValue(t, objectToTest.Header, fieldsForHeaderV1) + + fields := prepareFieldsList(objectToTest, headerV2ExceptionFields...) + assert.NotEmpty(t, fields) + + populateFieldsWithRandomValue(t, objectToTest, fields) + err := objectToTest.CheckFieldsForNil() + require.Nil(t, err) + + fmt.Printf("fields tests on %T\n", objectToTest) + for i := 0; i < len(fields); i++ { + testField(t, objectToTest, fields, i) + } + }) +} diff --git a/data/block/blockV2_test.go b/data/block/blockV2_test.go index 6503f92d1..a0e28f582 100644 --- a/data/block/blockV2_test.go +++ b/data/block/blockV2_test.go @@ -5,10 +5,10 @@ import ( "reflect" "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go-core/data/headerVersionData" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/data/headerVersionData" "github.com/stretchr/testify/require" ) diff --git a/data/block/block_test.go b/data/block/block_test.go index 2fec4f0c7..980543b24 100644 --- a/data/block/block_test.go +++ b/data/block/block_test.go @@ -5,9 +5,9 @@ import ( "reflect" "testing" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go-core/data/headerVersionData" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/data/headerVersionData" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -835,3 +835,13 @@ func TestHeader_HasScheduledMiniBlocks(t *testing.T) { h.MiniBlockHeaders = []block.MiniBlockHeader{*mbHeader} require.False(t, h.HasScheduledMiniBlocks()) } + +func TestMiniBlockHeader_GetMiniBlockHeaderReservedShouldErrWhenReservedFieldIsNil(t *testing.T) { + t.Parallel() + + mbh := &block.MiniBlockHeader{} + + mbhr, err := mbh.GetMiniBlockHeaderReserved() + assert.Nil(t, mbhr) + assert.Equal(t, data.ErrNilReservedField, err) +} diff --git a/data/block/economicsHandler.go b/data/block/economicsHandler.go index d47ba1806..9f96a6185 100644 --- a/data/block/economicsHandler.go +++ b/data/block/economicsHandler.go @@ -3,7 +3,7 @@ package block import ( "math/big" - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) // SetTotalSupply sets the total supply diff --git a/data/block/epochStartHandler.go b/data/block/epochStartHandler.go index 5c5fde24b..a96fdc217 100644 --- a/data/block/epochStartHandler.go +++ b/data/block/epochStartHandler.go @@ -1,7 +1,7 @@ package block import ( - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) // GetLastFinalizedHeaderHandlers returns the last finalized header handlers diff --git a/data/block/epochStartShardDataHandler.go b/data/block/epochStartShardDataHandler.go index 0bc329193..5d3c5392a 100644 --- a/data/block/epochStartShardDataHandler.go +++ b/data/block/epochStartShardDataHandler.go @@ -1,6 +1,6 @@ package block -import "github.com/ElrondNetwork/elrond-go-core/data" +import "github.com/multiversx/mx-chain-core-go/data" // GetPendingMiniBlockHeaderHandlers returns the pending miniBlock header handlers func (essd *EpochStartShardData) GetPendingMiniBlockHeaderHandlers() []data.MiniBlockHeaderHandler { diff --git a/data/block/metaBlock.go b/data/block/metaBlock.go index 041dc9010..ebaf8da89 100644 --- a/data/block/metaBlock.go +++ b/data/block/metaBlock.go @@ -1,13 +1,14 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. metaBlock.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. metaBlock.proto package block import ( + "fmt" "math/big" "sort" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/headerVersionData" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/headerVersionData" ) // don't break the interface @@ -523,3 +524,45 @@ func (m *MetaBlock) GetAdditionalData() headerVersionData.HeaderAdditionalData { // no extra data for the initial version of meta block header return nil } + +// CheckFieldsForNil checks a predefined set of fields for nil values +func (m *MetaBlock) CheckFieldsForNil() error { + if m == nil { + return data.ErrNilPointerReceiver + } + if m.PrevHash == nil { + return fmt.Errorf("%w in MetaBlock.PrevHash", data.ErrNilValue) + } + if m.PrevRandSeed == nil { + return fmt.Errorf("%w in MetaBlock.PrevRandSeed", data.ErrNilValue) + } + if m.RandSeed == nil { + return fmt.Errorf("%w in MetaBlock.RandSeed", data.ErrNilValue) + } + if m.RootHash == nil { + return fmt.Errorf("%w in MetaBlock.RootHash", data.ErrNilValue) + } + if m.ValidatorStatsRootHash == nil { + return fmt.Errorf("%w in MetaBlock.ValidatorStatsRootHash", data.ErrNilValue) + } + if m.ChainID == nil { + return fmt.Errorf("%w in MetaBlock.ChainID", data.ErrNilValue) + } + if m.SoftwareVersion == nil { + return fmt.Errorf("%w in MetaBlock.SoftwareVersion", data.ErrNilValue) + } + if m.AccumulatedFees == nil { + return fmt.Errorf("%w in MetaBlock.AccumulatedFees", data.ErrNilValue) + } + if m.AccumulatedFeesInEpoch == nil { + return fmt.Errorf("%w in MetaBlock.AccumulatedFeesInEpoch", data.ErrNilValue) + } + if m.DeveloperFees == nil { + return fmt.Errorf("%w in MetaBlock.DeveloperFees", data.ErrNilValue) + } + if m.DevFeesInEpoch == nil { + return fmt.Errorf("%w in MetaBlock.DevFeesInEpoch", data.ErrNilValue) + } + + return nil +} diff --git a/data/block/metaBlock.pb.go b/data/block/metaBlock.pb.go index bce26ae0a..a86de4855 100644 --- a/data/block/metaBlock.pb.go +++ b/data/block/metaBlock.pb.go @@ -6,9 +6,9 @@ package block import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" io "io" math "math" math_big "math/big" @@ -77,7 +77,7 @@ type PeerData struct { PublicKey []byte `protobuf:"bytes,2,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"` Action PeerAction `protobuf:"varint,3,opt,name=Action,proto3,enum=proto.PeerAction" json:"Action,omitempty"` TimeStamp uint64 `protobuf:"varint,4,opt,name=TimeStamp,proto3" json:"TimeStamp,omitempty"` - ValueChange *math_big.Int `protobuf:"bytes,5,opt,name=ValueChange,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"ValueChange,omitempty"` + ValueChange *math_big.Int `protobuf:"bytes,5,opt,name=ValueChange,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"ValueChange,omitempty"` } func (m *PeerData) Reset() { *m = PeerData{} } @@ -153,8 +153,8 @@ type ShardData struct { Round uint64 `protobuf:"varint,8,opt,name=Round,proto3" json:"Round,omitempty"` PrevHash []byte `protobuf:"bytes,9,opt,name=PrevHash,proto3" json:"PrevHash,omitempty"` Nonce uint64 `protobuf:"varint,10,opt,name=Nonce,proto3" json:"Nonce,omitempty"` - AccumulatedFees *math_big.Int `protobuf:"bytes,12,opt,name=AccumulatedFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"AccumulatedFees,omitempty"` - DeveloperFees *math_big.Int `protobuf:"bytes,14,opt,name=DeveloperFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"DeveloperFees,omitempty"` + AccumulatedFees *math_big.Int `protobuf:"bytes,12,opt,name=AccumulatedFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"AccumulatedFees,omitempty"` + DeveloperFees *math_big.Int `protobuf:"bytes,14,opt,name=DeveloperFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"DeveloperFees,omitempty"` NumPendingMiniBlocks uint32 `protobuf:"varint,11,opt,name=NumPendingMiniBlocks,proto3" json:"NumPendingMiniBlocks,omitempty"` LastIncludedMetaNonce uint64 `protobuf:"varint,13,opt,name=LastIncludedMetaNonce,proto3" json:"LastIncludedMetaNonce,omitempty"` ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"ShardID,omitempty"` @@ -401,12 +401,12 @@ func (m *EpochStartShardData) GetPendingMiniBlockHeaders() []MiniBlockHeader { // Economics holds the block information for total supply and rewards type Economics struct { - TotalSupply *math_big.Int `protobuf:"bytes,1,opt,name=TotalSupply,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"TotalSupply,omitempty"` - TotalToDistribute *math_big.Int `protobuf:"bytes,2,opt,name=TotalToDistribute,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"TotalToDistribute,omitempty"` - TotalNewlyMinted *math_big.Int `protobuf:"bytes,3,opt,name=TotalNewlyMinted,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"TotalNewlyMinted,omitempty"` - RewardsPerBlock *math_big.Int `protobuf:"bytes,4,opt,name=RewardsPerBlock,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"RewardsPerBlock,omitempty"` - RewardsForProtocolSustainability *math_big.Int `protobuf:"bytes,5,opt,name=RewardsForProtocolSustainability,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"RewardsForProtocolSustainability,omitempty"` - NodePrice *math_big.Int `protobuf:"bytes,6,opt,name=NodePrice,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"NodePrice,omitempty"` + TotalSupply *math_big.Int `protobuf:"bytes,1,opt,name=TotalSupply,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"TotalSupply,omitempty"` + TotalToDistribute *math_big.Int `protobuf:"bytes,2,opt,name=TotalToDistribute,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"TotalToDistribute,omitempty"` + TotalNewlyMinted *math_big.Int `protobuf:"bytes,3,opt,name=TotalNewlyMinted,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"TotalNewlyMinted,omitempty"` + RewardsPerBlock *math_big.Int `protobuf:"bytes,4,opt,name=RewardsPerBlock,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"RewardsPerBlock,omitempty"` + RewardsForProtocolSustainability *math_big.Int `protobuf:"bytes,5,opt,name=RewardsForProtocolSustainability,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"RewardsForProtocolSustainability,omitempty"` + NodePrice *math_big.Int `protobuf:"bytes,6,opt,name=NodePrice,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"NodePrice,omitempty"` PrevEpochStartRound uint64 `protobuf:"varint,7,opt,name=PrevEpochStartRound,proto3" json:"PrevEpochStartRound,omitempty"` PrevEpochStartHash []byte `protobuf:"bytes,8,opt,name=PrevEpochStartHash,proto3" json:"PrevEpochStartHash,omitempty"` } @@ -564,10 +564,10 @@ type MetaBlock struct { EpochStart EpochStart `protobuf:"bytes,18,opt,name=EpochStart,proto3" json:"EpochStart"` ChainID []byte `protobuf:"bytes,19,opt,name=ChainID,proto3" json:"ChainID,omitempty"` SoftwareVersion []byte `protobuf:"bytes,20,opt,name=SoftwareVersion,proto3" json:"SoftwareVersion,omitempty"` - AccumulatedFees *math_big.Int `protobuf:"bytes,21,opt,name=AccumulatedFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"AccumulatedFees,omitempty"` - AccumulatedFeesInEpoch *math_big.Int `protobuf:"bytes,22,opt,name=AccumulatedFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"AccumulatedFeesInEpoch,omitempty"` - DeveloperFees *math_big.Int `protobuf:"bytes,23,opt,name=DeveloperFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"DeveloperFees,omitempty"` - DevFeesInEpoch *math_big.Int `protobuf:"bytes,24,opt,name=DevFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"DevFeesInEpoch,omitempty"` + AccumulatedFees *math_big.Int `protobuf:"bytes,21,opt,name=AccumulatedFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"AccumulatedFees,omitempty"` + AccumulatedFeesInEpoch *math_big.Int `protobuf:"bytes,22,opt,name=AccumulatedFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"AccumulatedFeesInEpoch,omitempty"` + DeveloperFees *math_big.Int `protobuf:"bytes,23,opt,name=DeveloperFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"DeveloperFees,omitempty"` + DevFeesInEpoch *math_big.Int `protobuf:"bytes,24,opt,name=DevFeesInEpoch,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"DevFeesInEpoch,omitempty"` TxCount uint32 `protobuf:"varint,25,opt,name=TxCount,proto3" json:"TxCount,omitempty"` Reserved []byte `protobuf:"bytes,26,opt,name=Reserved,proto3" json:"Reserved,omitempty"` } @@ -788,88 +788,87 @@ func init() { func init() { proto.RegisterFile("metaBlock.proto", fileDescriptor_87b91ab531130b2b) } var fileDescriptor_87b91ab531130b2b = []byte{ - // 1281 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xbf, 0x6f, 0xdb, 0xc6, - 0x17, 0x17, 0x23, 0xcb, 0xb6, 0x9e, 0x2c, 0x9b, 0xbe, 0x38, 0x0e, 0xbf, 0xc6, 0x17, 0x8c, 0x21, - 0x74, 0x70, 0x8b, 0xc6, 0x6e, 0xdd, 0xa0, 0x1d, 0x3a, 0x14, 0xb1, 0x1d, 0x23, 0xca, 0x0f, 0x43, - 0xa0, 0x5c, 0x0f, 0xdd, 0x4e, 0xe4, 0x8b, 0x74, 0x30, 0xc5, 0x13, 0x8e, 0x47, 0x3b, 0xee, 0x54, - 0xf4, 0x2f, 0xe8, 0x54, 0x74, 0xeb, 0xd2, 0xa1, 0xe8, 0xde, 0x7f, 0xa1, 0xc8, 0x98, 0x31, 0x53, - 0xdb, 0x28, 0x4b, 0xc7, 0x0c, 0x5d, 0xba, 0x15,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0xf9, 0x82, 0x07, - 0xde, 0x11, 0xca, 0x73, 0x2e, 0x4e, 0x77, 0x50, 0x49, 0xb7, 0xfb, 0xfc, 0xb6, 0xcb, 0x05, 0xee, - 0x78, 0x54, 0xd2, 0xed, 0x3d, 0xd6, 0x6f, 0x07, 0x72, 0x9f, 0x86, 0x12, 0x85, 0x93, 0x3f, 0xbe, - 0xf5, 0x6b, 0x0d, 0xea, 0xdd, 0x01, 0x15, 0x9e, 0xba, 0xbc, 0x0d, 0x70, 0x1f, 0xa9, 0x87, 0xe2, - 0x3e, 0x0d, 0x07, 0xc9, 0x1d, 0x73, 0x08, 0x71, 0xe0, 0x86, 0x32, 0x7e, 0xcc, 0x02, 0xa6, 0x8a, - 0xa0, 0x75, 0xa1, 0x55, 0xdd, 0xac, 0x6e, 0x35, 0x76, 0xd7, 0x93, 0x3b, 0x17, 0xd4, 0x7b, 0x73, - 0xcf, 0x7e, 0xbf, 0x55, 0x71, 0xca, 0x5d, 0x49, 0x0b, 0x96, 0x3a, 0x02, 0xcf, 0x1c, 0x1a, 0x78, - 0x5d, 0x44, 0x4f, 0x25, 0x64, 0xc9, 0xb9, 0x84, 0x91, 0xf7, 0xa0, 0xd9, 0x89, 0x7a, 0x0f, 0xf1, - 0x22, 0xdc, 0x63, 0x72, 0x48, 0x47, 0x3a, 0x2b, 0xce, 0x65, 0x30, 0xce, 0x6b, 0x97, 0xf5, 0x03, - 0x2a, 0x23, 0x81, 0xd6, 0xbc, 0x2e, 0xd0, 0x04, 0x20, 0x6b, 0x50, 0x73, 0x78, 0x14, 0x78, 0xd6, - 0xa2, 0xca, 0xb8, 0x16, 0xc8, 0x06, 0x2c, 0xc6, 0x91, 0xd4, 0x7d, 0xeb, 0xca, 0x65, 0x22, 0xc7, - 0x1e, 0x47, 0x3c, 0x70, 0xd1, 0x02, 0xed, 0xa1, 0x04, 0x22, 0x61, 0xe5, 0xae, 0xeb, 0x46, 0xc3, - 0xc8, 0xa7, 0x12, 0xbd, 0x43, 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, 0x02, 0x8d, 0x18, 0xe9, 0xfa, 0x34, 0xe6, 0x73, 0xe6, 0x7c, 0x0a, 0x38, 0xf1, 0xb6, 0x3c, - 0x45, 0x73, 0x61, 0xef, 0x8b, 0xe7, 0x2f, 0xed, 0xca, 0x8b, 0x97, 0x76, 0xe5, 0xf5, 0x4b, 0xdb, - 0xf8, 0x66, 0x6c, 0x1b, 0x3f, 0x8f, 0x6d, 0xe3, 0xd9, 0xd8, 0x36, 0x9e, 0x8f, 0x6d, 0xe3, 0xc5, - 0xd8, 0x36, 0xfe, 0x1c, 0xdb, 0xc6, 0x5f, 0x63, 0xbb, 0xf2, 0x7a, 0x6c, 0x1b, 0xdf, 0xbd, 0xb2, - 0x2b, 0xcf, 0x5f, 0xd9, 0x95, 0x17, 0xaf, 0xec, 0xca, 0x57, 0x35, 0xf5, 0x79, 0xdc, 0x9b, 0x57, - 0x63, 0xf6, 0xc9, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2f, 0x10, 0x9d, 0x19, 0x75, 0x0f, 0x00, - 0x00, + // 1280 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x31, 0x73, 0x1b, 0x45, + 0x14, 0xd6, 0x45, 0x96, 0x6d, 0x3d, 0x59, 0xb6, 0xbc, 0x71, 0x9c, 0xc3, 0xc3, 0x5c, 0x3c, 0x1a, + 0x0a, 0xc3, 0x60, 0x1b, 0x4c, 0x06, 0x0a, 0x0a, 0x26, 0xb6, 0xe3, 0x89, 0x48, 0xe2, 0xd1, 0x9c, + 0x8c, 0x0b, 0xba, 0xd5, 0xdd, 0x8b, 0xb4, 0xe3, 0xd3, 0xad, 0xb8, 0xdb, 0xb3, 0x63, 0x2a, 0xf8, + 0x07, 0x34, 0xcc, 0xd0, 0xd1, 0x50, 0x30, 0xb4, 0xfc, 0x01, 0xca, 0x94, 0x29, 0x53, 0x01, 0x51, + 0x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81, + 0x17, 0x53, 0xa3, 0xd8, 0x99, 0x9c, 0xfe, 0x11, 0xf3, 0x59, 0xd8, 0xd7, 0x07, 0xac, 0xb3, 0x34, + 0x57, 0x8a, 0x9d, 0xe4, 0x14, 0x6e, 0xe7, 0x1b, 0x99, 0x70, 0x7a, 0xfe, 0x0d, 0x38, 0x7d, 0x5d, + 0x72, 0xf3, 0x8f, 0x79, 0xa8, 0xde, 0x77, 0xb8, 0xcf, 0x07, 0xcc, 0x09, 0xe5, 0x48, 0x3b, 0xe1, + 0x82, 0x7a, 0x9d, 0x68, 0x38, 0xf4, 0x2e, 0xf5, 0x5c, 0x9d, 0xe9, 0x48, 0xcb, 0xac, 0x4e, 0x2e, + 0x60, 0x55, 0x99, 0x27, 0xfc, 0x90, 0x85, 0x22, 0x60, 0xdd, 0x48, 0xa0, 0xee, 0xd7, 0x2c, 0x4b, + 0x4e, 0xd7, 0x20, 0x11, 0x34, 0x14, 0x78, 0x8c, 0x17, 0xde, 0xe5, 0x63, 0xe6, 0x0b, 0x74, 0xf5, + 0x4d, 0x98, 0x65, 0xdd, 0xa9, 0x12, 0x72, 0x20, 0xd9, 0x78, 0x41, 0x03, 0x37, 0x6c, 0x63, 0x90, + 0xb9, 0x28, 0x33, 0x1d, 0x48, 0xb9, 0x0a, 0xe4, 0x47, 0x03, 0x36, 0x63, 0xec, 0x88, 0x07, 0x6d, + 0x79, 0x45, 0x1c, 0xee, 0x75, 0xa2, 0x50, 0x50, 0xe6, 0xd3, 0x2e, 0xf3, 0x98, 0xb8, 0x9c, 0xfd, + 0xd3, 0xf5, 0xda, 0x92, 0xa4, 0x07, 0xd5, 0x63, 0xee, 0x62, 0x3b, 0x60, 0x4e, 0xfc, 0x06, 0xcc, + 0xb2, 0x7e, 0xba, 0x36, 0xf9, 0x08, 0x6e, 0xca, 0x87, 0x22, 0x9d, 0x42, 0xd9, 0x41, 0x52, 0xe4, + 0x22, 0x3b, 0x40, 0x26, 0x61, 0x35, 0x05, 0x16, 0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 0xba, 0x8d, 0x39, 0xd2, 0x80, 0x25, 0x9d, 0x1a, 0x23, 0x15, + 0xb2, 0x02, 0x35, 0x89, 0x74, 0x3c, 0x2a, 0x55, 0x5c, 0x63, 0x3e, 0x01, 0x6c, 0x39, 0x29, 0xcf, + 0xb0, 0xb1, 0xb0, 0xff, 0xc5, 0xf3, 0x97, 0x56, 0xe9, 0xc5, 0x4b, 0xab, 0x74, 0xf5, 0xd2, 0x32, + 0xbe, 0x1b, 0x59, 0xc6, 0xaf, 0x23, 0xcb, 0x78, 0x36, 0xb2, 0x8c, 0xe7, 0x23, 0xcb, 0x78, 0x31, + 0xb2, 0x8c, 0xbf, 0x47, 0x96, 0xf1, 0xcf, 0xc8, 0x2a, 0x5d, 0x8d, 0x2c, 0xe3, 0x87, 0x57, 0x56, + 0xe9, 0xf9, 0x2b, 0xab, 0xf4, 0xe2, 0x95, 0x55, 0xfa, 0xba, 0xa2, 0xbe, 0x88, 0xbb, 0xf3, 0x8a, + 0x62, 0x9f, 0xfc, 0x17, 0x00, 0x00, 0xff, 0xff, 0xda, 0x60, 0xe6, 0xc3, 0x68, 0x0f, 0x00, 0x00, } func (x PeerAction) String() string { @@ -911,7 +910,7 @@ func (this *PeerData) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.ValueChange, that1.ValueChange) { return false } @@ -967,13 +966,13 @@ func (this *ShardData) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.AccumulatedFees, that1.AccumulatedFees) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.DeveloperFees, that1.DeveloperFees) { return false } @@ -1068,37 +1067,37 @@ func (this *Economics) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.TotalSupply, that1.TotalSupply) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.TotalToDistribute, that1.TotalToDistribute) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.TotalNewlyMinted, that1.TotalNewlyMinted) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.RewardsPerBlock, that1.RewardsPerBlock) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.RewardsForProtocolSustainability, that1.RewardsForProtocolSustainability) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.NodePrice, that1.NodePrice) { return false } @@ -1235,25 +1234,25 @@ func (this *MetaBlock) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.AccumulatedFees, that1.AccumulatedFees) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.AccumulatedFeesInEpoch, that1.AccumulatedFeesInEpoch) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.DeveloperFees, that1.DeveloperFees) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.DevFeesInEpoch, that1.DevFeesInEpoch) { return false } @@ -1449,7 +1448,7 @@ func (m *PeerData) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.ValueChange) i -= size if _, err := __caster.MarshalTo(m.ValueChange, dAtA[i:]); err != nil { @@ -1507,7 +1506,7 @@ func (m *ShardData) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.DeveloperFees) i -= size if _, err := __caster.MarshalTo(m.DeveloperFees, dAtA[i:]); err != nil { @@ -1523,7 +1522,7 @@ func (m *ShardData) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x68 } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.AccumulatedFees) i -= size if _, err := __caster.MarshalTo(m.AccumulatedFees, dAtA[i:]); err != nil { @@ -1735,7 +1734,7 @@ func (m *Economics) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x38 } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.NodePrice) i -= size if _, err := __caster.MarshalTo(m.NodePrice, dAtA[i:]); err != nil { @@ -1746,7 +1745,7 @@ func (m *Economics) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x32 { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.RewardsForProtocolSustainability) i -= size if _, err := __caster.MarshalTo(m.RewardsForProtocolSustainability, dAtA[i:]); err != nil { @@ -1757,7 +1756,7 @@ func (m *Economics) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x2a { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.RewardsPerBlock) i -= size if _, err := __caster.MarshalTo(m.RewardsPerBlock, dAtA[i:]); err != nil { @@ -1768,7 +1767,7 @@ func (m *Economics) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.TotalNewlyMinted) i -= size if _, err := __caster.MarshalTo(m.TotalNewlyMinted, dAtA[i:]); err != nil { @@ -1779,7 +1778,7 @@ func (m *Economics) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.TotalToDistribute) i -= size if _, err := __caster.MarshalTo(m.TotalToDistribute, dAtA[i:]); err != nil { @@ -1790,7 +1789,7 @@ func (m *Economics) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.TotalSupply) i -= size if _, err := __caster.MarshalTo(m.TotalSupply, dAtA[i:]); err != nil { @@ -1887,7 +1886,7 @@ func (m *MetaBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0xc8 } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.DevFeesInEpoch) i -= size if _, err := __caster.MarshalTo(m.DevFeesInEpoch, dAtA[i:]); err != nil { @@ -1900,7 +1899,7 @@ func (m *MetaBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0xc2 { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.DeveloperFees) i -= size if _, err := __caster.MarshalTo(m.DeveloperFees, dAtA[i:]); err != nil { @@ -1913,7 +1912,7 @@ func (m *MetaBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0xba { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.AccumulatedFeesInEpoch) i -= size if _, err := __caster.MarshalTo(m.AccumulatedFeesInEpoch, dAtA[i:]); err != nil { @@ -1926,7 +1925,7 @@ func (m *MetaBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0xb2 { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.AccumulatedFees) i -= size if _, err := __caster.MarshalTo(m.AccumulatedFees, dAtA[i:]); err != nil { @@ -2132,7 +2131,7 @@ func (m *PeerData) Size() (n int) { n += 1 + sovMetaBlock(uint64(m.TimeStamp)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.ValueChange) n += 1 + l + sovMetaBlock(uint64(l)) } @@ -2187,7 +2186,7 @@ func (m *ShardData) Size() (n int) { n += 1 + sovMetaBlock(uint64(m.NumPendingMiniBlocks)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.AccumulatedFees) n += 1 + l + sovMetaBlock(uint64(l)) } @@ -2195,7 +2194,7 @@ func (m *ShardData) Size() (n int) { n += 1 + sovMetaBlock(uint64(m.LastIncludedMetaNonce)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.DeveloperFees) n += 1 + l + sovMetaBlock(uint64(l)) } @@ -2256,32 +2255,32 @@ func (m *Economics) Size() (n int) { var l int _ = l { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.TotalSupply) n += 1 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.TotalToDistribute) n += 1 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.TotalNewlyMinted) n += 1 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.RewardsPerBlock) n += 1 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.RewardsForProtocolSustainability) n += 1 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.NodePrice) n += 1 + l + sovMetaBlock(uint64(l)) } @@ -2395,22 +2394,22 @@ func (m *MetaBlock) Size() (n int) { n += 2 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.AccumulatedFees) n += 2 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.AccumulatedFeesInEpoch) n += 2 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.DeveloperFees) n += 2 + l + sovMetaBlock(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.DevFeesInEpoch) n += 2 + l + sovMetaBlock(uint64(l)) } @@ -2751,7 +2750,7 @@ func (m *PeerData) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3141,7 +3140,7 @@ func (m *ShardData) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3198,7 +3197,7 @@ func (m *ShardData) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3622,7 +3621,7 @@ func (m *Economics) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3660,7 +3659,7 @@ func (m *Economics) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3698,7 +3697,7 @@ func (m *Economics) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3736,7 +3735,7 @@ func (m *Economics) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3774,7 +3773,7 @@ func (m *Economics) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -3812,7 +3811,7 @@ func (m *Economics) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -4661,7 +4660,7 @@ func (m *MetaBlock) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -4699,7 +4698,7 @@ func (m *MetaBlock) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -4737,7 +4736,7 @@ func (m *MetaBlock) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -4775,7 +4774,7 @@ func (m *MetaBlock) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { diff --git a/data/block/metaBlock.proto b/data/block/metaBlock.proto index c90c2d2f8..5b1055e96 100644 --- a/data/block/metaBlock.proto +++ b/data/block/metaBlock.proto @@ -31,7 +31,7 @@ message PeerData { bytes PublicKey = 2; PeerAction Action = 3; uint64 TimeStamp = 4; - bytes ValueChange = 5 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes ValueChange = 5 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; } // ShardData holds the block information sent by the shards to the metachain @@ -44,8 +44,8 @@ message ShardData { uint64 Round = 8; bytes PrevHash = 9; uint64 Nonce = 10; - bytes AccumulatedFees = 12 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes DeveloperFees = 14 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes AccumulatedFees = 12 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DeveloperFees = 14 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; uint32 NumPendingMiniBlocks = 11; uint64 LastIncludedMetaNonce = 13; uint32 ShardID = 1; @@ -68,12 +68,12 @@ message EpochStartShardData { // Economics holds the block information for total supply and rewards message Economics { - bytes TotalSupply = 1 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes TotalToDistribute = 2 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes TotalNewlyMinted = 3 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes RewardsPerBlock = 4 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes RewardsForProtocolSustainability = 5 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes NodePrice = 6 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes TotalSupply = 1 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes TotalToDistribute = 2 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes TotalNewlyMinted = 3 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes RewardsPerBlock = 4 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes RewardsForProtocolSustainability = 5 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes NodePrice = 6 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; uint64 PrevEpochStartRound = 7; bytes PrevEpochStartHash = 8; } @@ -105,10 +105,10 @@ message MetaBlock { EpochStart EpochStart = 18 [(gogoproto.nullable) = false]; bytes ChainID = 19; bytes SoftwareVersion = 20; - bytes AccumulatedFees = 21 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes AccumulatedFeesInEpoch = 22 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes DeveloperFees = 23 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes DevFeesInEpoch = 24 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes AccumulatedFees = 21 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes AccumulatedFeesInEpoch = 22 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DeveloperFees = 23 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DevFeesInEpoch = 24 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; uint32 TxCount = 25; bytes Reserved = 26; } diff --git a/data/block/metaBlockChecks_test.go b/data/block/metaBlockChecks_test.go new file mode 100644 index 000000000..befb3377a --- /dev/null +++ b/data/block/metaBlockChecks_test.go @@ -0,0 +1,59 @@ +package block + +import ( + "fmt" + "testing" + + "github.com/multiversx/mx-chain-core-go/data" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var metablockExceptionFields = []string{ + "ShardInfo", + "PeerInfo", + "EpochStart", + "Signature", + "LeaderSignature", + "PubKeysBitmap", + "ReceiptsHash", + "Reserved", +} + +func TestMetaBlockHeader_Checks(t *testing.T) { + t.Parallel() + + t.Run("nil pointer receiver", func(t *testing.T) { + t.Parallel() + + var objectToTest *MetaBlock + err := objectToTest.CheckFieldsForNil() + require.NotNil(t, err) + assert.ErrorIs(t, err, data.ErrNilPointerReceiver) + }) + t.Run("test all fields when set", func(t *testing.T) { + t.Parallel() + + objectToTest := &MetaBlock{} + + fields := prepareFieldsList(objectToTest, headerV1ExceptionFields...) + assert.NotEmpty(t, fields) + }) + t.Run("test all fields when one is unset", func(t *testing.T) { + t.Parallel() + + objectToTest := &MetaBlock{} + + fields := prepareFieldsList(objectToTest, metablockExceptionFields...) + assert.NotEmpty(t, fields) + + populateFieldsWithRandomValue(t, objectToTest, fields) + err := objectToTest.CheckFieldsForNil() + require.Nil(t, err) + + fmt.Printf("fields tests on %T\n", objectToTest) + for i := 0; i < len(fields); i++ { + testField(t, objectToTest, fields, i) + } + }) +} diff --git a/data/block/metaBlock_test.go b/data/block/metaBlock_test.go index 3ed724b60..1eca12602 100644 --- a/data/block/metaBlock_test.go +++ b/data/block/metaBlock_test.go @@ -3,10 +3,10 @@ package block_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go-core/data/headerVersionData" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/data/headerVersionData" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/data/block/miniBlockHeader.go b/data/block/miniBlockHeader.go index e210f530b..44b06a7ce 100644 --- a/data/block/miniBlockHeader.go +++ b/data/block/miniBlockHeader.go @@ -1,6 +1,6 @@ package block -import "github.com/ElrondNetwork/elrond-go-core/data" +import "github.com/multiversx/mx-chain-core-go/data" // GetTypeInt32 gets the miniBlock type func (m *MiniBlockHeader) GetTypeInt32() int32 { @@ -145,7 +145,7 @@ func (m *MiniBlockHeader) getMiniBlockHeaderReserved() (*MiniBlockHeaderReserved return mbhr, nil } - return nil, nil + return nil, data.ErrNilReservedField } // SetMiniBlockHeaderReserved sets the Reserved field for the miniBlock header with the given parameter diff --git a/data/block/miniBlockHeader_test.go b/data/block/miniBlockHeader_test.go index dbc6b2726..02a671ae1 100644 --- a/data/block/miniBlockHeader_test.go +++ b/data/block/miniBlockHeader_test.go @@ -4,7 +4,7 @@ import ( "math" "testing" - "github.com/ElrondNetwork/elrond-go-core/data/block" + "github.com/multiversx/mx-chain-core-go/data/block" "github.com/stretchr/testify/require" ) diff --git a/data/block/peerBlock.go b/data/block/peerBlock.go index 3b5e2e3ff..115131523 100644 --- a/data/block/peerBlock.go +++ b/data/block/peerBlock.go @@ -1,6 +1,6 @@ package block -import "github.com/ElrondNetwork/elrond-go-core/data" +import "github.com/multiversx/mx-chain-core-go/data" // SetPubKey - setter for public key func (pc *PeerChange) SetPubKey(pubKey []byte) error { diff --git a/data/block/shardDataHandler.go b/data/block/shardDataHandler.go index dce41b421..2599d0c19 100644 --- a/data/block/shardDataHandler.go +++ b/data/block/shardDataHandler.go @@ -3,7 +3,7 @@ package block import ( "math/big" - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) // GetShardMiniBlockHeaderHandlers returns the shard miniBlockHeaders as MiniBlockHeaderHandlers diff --git a/data/block/trigger.go b/data/block/trigger.go index 2a9a6dacf..c8b511e37 100644 --- a/data/block/trigger.go +++ b/data/block/trigger.go @@ -1,7 +1,7 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. trigger.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. trigger.proto package block -import "github.com/ElrondNetwork/elrond-go-core/data" +import "github.com/multiversx/mx-chain-core-go/data" // GetEpochStartHeaderHandler returns the epoch start headerHandler func (str *ShardTriggerRegistry) GetEpochStartHeaderHandler() data.HeaderHandler { diff --git a/data/block/trigger_test.go b/data/block/trigger_test.go index 854c76ae6..f0b7c785d 100644 --- a/data/block/trigger_test.go +++ b/data/block/trigger_test.go @@ -3,7 +3,7 @@ package block import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" "github.com/stretchr/testify/require" ) diff --git a/data/errors.go b/data/errors.go index 048aeac46..bd20054a2 100644 --- a/data/errors.go +++ b/data/errors.go @@ -78,3 +78,6 @@ var ErrScheduledRootHashNotSupported = errors.New("scheduled root hash is not su // ErrWrongTransactionsTypeSize signals that size of transactions type buffer from mini block reserved field is wrong var ErrWrongTransactionsTypeSize = errors.New("wrong transactions type size") + +// ErrNilReservedField signals that a nil reserved field was provided +var ErrNilReservedField = errors.New("reserved field is nil") diff --git a/data/esdt/esdt.go b/data/esdt/esdt.go index c3563ec8b..955dac063 100644 --- a/data/esdt/esdt.go +++ b/data/esdt/esdt.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=proto -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. esdt.proto +//go:generate protoc -I=proto -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. esdt.proto package esdt import "math/big" diff --git a/data/esdt/esdt.pb.go b/data/esdt/esdt.pb.go index 9345669f5..92cb3ffa0 100644 --- a/data/esdt/esdt.pb.go +++ b/data/esdt/esdt.pb.go @@ -6,9 +6,9 @@ package esdt import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" io "io" math "math" math_big "math/big" @@ -28,10 +28,10 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// ESDigitalToken holds the data for a Elrond standard digital token transaction +// ESDigitalToken holds the data for a Electronic standard digital token transaction type ESDigitalToken struct { Type uint32 `protobuf:"varint,1,opt,name=Type,proto3" json:"Type"` - Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"Value"` + Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"Value"` Properties []byte `protobuf:"bytes,3,opt,name=Properties,proto3" json:"Properties"` TokenMetaData *MetaData `protobuf:"bytes,4,opt,name=TokenMetaData,proto3" json:"MetaData"` Reserved []byte `protobuf:"bytes,5,opt,name=Reserved,proto3" json:"Reserved"` @@ -237,39 +237,40 @@ func init() { func init() { proto.RegisterFile("esdt.proto", fileDescriptor_e413e402abc6a34c) } var fileDescriptor_e413e402abc6a34c = []byte{ - // 512 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0xc1, 0x8b, 0xda, 0x4e, - 0x14, 0xce, 0xb8, 0xba, 0xab, 0xb3, 0xba, 0x87, 0xc0, 0x0f, 0xc2, 0x8f, 0x32, 0x11, 0xa1, 0x20, - 0xb4, 0x46, 0x68, 0x8f, 0x85, 0x42, 0xb3, 0xba, 0xd4, 0x43, 0xa5, 0x8c, 0xb6, 0x87, 0xde, 0x46, - 0x9d, 0xc6, 0x61, 0x63, 0x46, 0x26, 0x93, 0x96, 0xbd, 0xf5, 0xda, 0x5b, 0xff, 0x8c, 0xd2, 0xbf, - 0x64, 0x8f, 0x1e, 0x3d, 0xa5, 0x35, 0x5e, 0x4a, 0x4e, 0xfb, 0x27, 0x94, 0x79, 0xd9, 0xac, 0x16, - 0x7a, 0x79, 0xf9, 0xbe, 0x6f, 0x1e, 0xf3, 0xe6, 0x7d, 0x1f, 0xc1, 0x98, 0xc7, 0x0b, 0xed, 0xad, - 0x95, 0xd4, 0xd2, 0xfe, 0x0f, 0x3e, 0x7e, 0x22, 0x42, 0x3d, 0x8a, 0xae, 0x92, 0x68, 0xae, 0x85, - 0x8c, 0xe2, 0xff, 0x7b, 0x81, 0xd0, 0xcb, 0x64, 0xe6, 0xcd, 0xe5, 0xaa, 0x1f, 0xc8, 0x40, 0xf6, - 0xa1, 0x6d, 0x96, 0x7c, 0x04, 0x06, 0x04, 0x50, 0x71, 0x4b, 0xe7, 0xb6, 0x82, 0x2f, 0x86, 0x93, - 0x81, 0x08, 0x84, 0x66, 0xe1, 0x54, 0x5e, 0xf3, 0xc8, 0x7e, 0x84, 0xab, 0xd3, 0x9b, 0x35, 0x77, - 0x50, 0x1b, 0x75, 0x5b, 0x7e, 0x3d, 0x4f, 0x5d, 0xe0, 0x14, 0xaa, 0x2d, 0x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x3e, 0x26, 0x93, 0x31, 0x5b, 0x95, 0xa6, 0x43, 0x26, 0x86, 0x53, 0xa8, 0xf6, 0x63, - 0x7c, 0x76, 0xa9, 0x38, 0xd3, 0x52, 0xdd, 0xbb, 0x74, 0x9e, 0xa7, 0x6e, 0x29, 0xd1, 0x12, 0xd8, - 0x4f, 0x70, 0x83, 0xca, 0x1b, 0x16, 0x82, 0x9d, 0x55, 0x48, 0xb7, 0x95, 0xa7, 0xee, 0x41, 0xa4, - 0x07, 0x68, 0x26, 0xbe, 0x66, 0xf1, 0xf2, 0x7e, 0x67, 0x98, 0x68, 0x38, 0x85, 0x6a, 0x4e, 0xdf, - 0xd1, 0x51, 0xec, 0x9c, 0xc2, 0x76, 0x70, 0x6a, 0x38, 0x85, 0x6a, 0x82, 0x7b, 0xa5, 0xb5, 0x12, - 0xb3, 0x44, 0xf3, 0xd8, 0x39, 0x3b, 0x04, 0x77, 0x50, 0xe9, 0x11, 0xf6, 0x5f, 0x6e, 0x76, 0xc4, - 0xda, 0xee, 0x88, 0x75, 0xb7, 0x23, 0xe8, 0x4b, 0x46, 0xd0, 0xf7, 0x8c, 0xa0, 0xdb, 0x8c, 0xa0, - 0x4d, 0x46, 0xd0, 0x36, 0x23, 0xe8, 0x57, 0x46, 0xd0, 0xef, 0x8c, 0x58, 0x77, 0x19, 0x41, 0xdf, - 0xf6, 0xc4, 0xda, 0xec, 0x89, 0xb5, 0xdd, 0x13, 0xeb, 0x43, 0xd5, 0xfc, 0x10, 0xb3, 0x53, 0x08, - 0xf8, 0xf9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x30, 0x1c, 0xe3, 0x1f, 0x03, 0x00, 0x00, + // 513 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xce, 0x74, 0xdb, 0xdd, 0x76, 0xb6, 0x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a, 0xaf, 0x59, 0x08, 0x76, 0x56, 0x21, 0xdc, 0x56, 0x9e, 0xba, 0x7b, + 0x91, 0xee, 0xa1, 0x99, 0xf8, 0x86, 0xc5, 0x8b, 0xdb, 0x9d, 0x61, 0xa2, 0xe1, 0x14, 0xaa, 0x39, + 0x7d, 0x4f, 0x47, 0xb1, 0x73, 0x0c, 0xdb, 0xc1, 0xa9, 0xe1, 0x14, 0xaa, 0x09, 0xee, 0x95, 0xd6, + 0x4a, 0x4c, 0x13, 0xcd, 0x63, 0xe7, 0x64, 0x1f, 0xdc, 0x5e, 0xa5, 0x07, 0xd8, 0x7f, 0xb9, 0xde, + 0x12, 0x6b, 0xb3, 0x25, 0xd6, 0xcd, 0x96, 0xa0, 0x2f, 0x19, 0x41, 0xdf, 0x33, 0x82, 0x7e, 0x65, + 0x04, 0xad, 0x33, 0x82, 0x36, 0x19, 0x41, 0x7f, 0x32, 0x82, 0xfe, 0x66, 0xc4, 0xba, 0xc9, 0x08, + 0xfa, 0xb6, 0x23, 0xd6, 0x7a, 0x47, 0xac, 0xcd, 0x8e, 0x58, 0x1f, 0xab, 0xe6, 0x7f, 0x98, 0x1e, + 0x43, 0xc0, 0xcf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x8c, 0x59, 0x17, 0x1e, 0x03, 0x00, + 0x00, } func (this *ESDigitalToken) Equal(that interface{}) bool { @@ -295,7 +296,7 @@ func (this *ESDigitalToken) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.Value, that1.Value) { return false } @@ -484,7 +485,7 @@ func (m *ESDigitalToken) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.Value) i -= size if _, err := __caster.MarshalTo(m.Value, dAtA[i:]); err != nil { @@ -625,7 +626,7 @@ func (m *ESDigitalToken) Size() (n int) { n += 1 + sovEsdt(uint64(m.Type)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.Value) n += 1 + l + sovEsdt(uint64(l)) } @@ -828,7 +829,7 @@ func (m *ESDigitalToken) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { diff --git a/data/esdt/proto/esdt.proto b/data/esdt/proto/esdt.proto index 48d99570b..861b79bca 100644 --- a/data/esdt/proto/esdt.proto +++ b/data/esdt/proto/esdt.proto @@ -8,10 +8,10 @@ option (gogoproto.stable_marshaler_all) = true; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; -// ESDigitalToken holds the data for a Elrond standard digital token transaction +// ESDigitalToken holds the data for a Electronic standard digital token transaction message ESDigitalToken { uint32 Type = 1 [(gogoproto.jsontag) = "Type"]; - bytes Value = 2 [(gogoproto.jsontag) = "Value", (gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes Value = 2 [(gogoproto.jsontag) = "Value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes Properties = 3 [(gogoproto.jsontag) = "Properties"]; MetaData TokenMetaData = 4 [(gogoproto.jsontag) = "MetaData"]; bytes Reserved = 5 [(gogoproto.jsontag) = "Reserved"]; diff --git a/data/generatedCode.md b/data/generatedCode.md index 3a58b00b0..fa499220b 100644 --- a/data/generatedCode.md +++ b/data/generatedCode.md @@ -19,14 +19,14 @@ Contains the protobuf message definition (with gogo/protobuf extensions) Should contain the go generate directive ``` -//go:generate protoc -I=proto -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. message.proto +//go:generate protoc -I=proto -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. message.proto ``` And any necessary methods that are not generated. #### Generating code #### -Check [gogo protobuf geting started](https://github.com/ElrondNetwork/protobuf#getting-started) for initial setup. +Check [gogo protobuf geting started](https://github.com/multiversx/protobuf#getting-started) for initial setup. To regenerate all the data structures run: ``` diff --git a/data/guardians/guardians.go b/data/guardians/guardians.go index 9960da059..87f684ec6 100644 --- a/data/guardians/guardians.go +++ b/data/guardians/guardians.go @@ -1,2 +1,2 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. guardians.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. guardians.proto package guardians diff --git a/data/indexer/dtos.go b/data/indexer/dtos.go deleted file mode 100644 index 3699edc5b..000000000 --- a/data/indexer/dtos.go +++ /dev/null @@ -1,71 +0,0 @@ -package indexer - -import ( - "time" - - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/esdt" -) - -// AccountTokenData holds the data needed for indexing a token of an altered account -type AccountTokenData struct { - Identifier string `json:"identifier"` - Balance string `json:"balance"` - Nonce uint64 `json:"nonce"` - Properties string `json:"properties"` - MetaData *esdt.MetaData `json:"metadata"` -} - -// AlteredAccount holds the data needed of an altered account in a block -type AlteredAccount struct { - Address string `json:"address"` - Balance string `json:"balance,omitempty"` - Nonce uint64 `json:"nonce"` - Tokens []*AccountTokenData `json:"tokens"` -} - -// ArgsSaveBlockData will contains all information that are needed to save block data -type ArgsSaveBlockData struct { - HeaderHash []byte - Body data.BodyHandler - Header data.HeaderHandler - SignersIndexes []uint64 - NotarizedHeadersHashes []string - HeaderGasConsumption HeaderGasConsumption - TransactionsPool *Pool - AlteredAccounts map[string]*AlteredAccount -} - -// HeaderGasConsumption holds the data needed to save the gas consumption of a header -type HeaderGasConsumption struct { - GasProvided uint64 - GasRefunded uint64 - GasPenalized uint64 - MaxGasPerBlock uint64 -} - -// Pool will holds all types of transaction -type Pool struct { - Txs map[string]data.TransactionHandler - Scrs map[string]data.TransactionHandler - Rewards map[string]data.TransactionHandler - Invalid map[string]data.TransactionHandler - Receipts map[string]data.TransactionHandler - Logs []*data.LogData -} - -// ValidatorRatingInfo is a structure containing validator rating information -type ValidatorRatingInfo struct { - PublicKey string - Rating float32 -} - -// RoundInfo is a structure containing block signers and shard id -type RoundInfo struct { - Index uint64 - SignersIndexes []uint64 - BlockWasProposed bool - ShardId uint32 - Epoch uint32 - Timestamp time.Duration -} diff --git a/data/interface.go b/data/interface.go index 0d45ef287..8d4fed919 100644 --- a/data/interface.go +++ b/data/interface.go @@ -3,7 +3,7 @@ package data import ( "math/big" - "github.com/ElrondNetwork/elrond-go-core/data/headerVersionData" + "github.com/multiversx/mx-chain-core-go/data/headerVersionData" ) // TriggerRegistryHandler defines getters and setters for the trigger registry @@ -82,6 +82,7 @@ type HeaderHandler interface { SetAdditionalData(headerVersionData headerVersionData.HeaderAdditionalData) error IsStartOfEpochBlock() bool ShallowClone() HeaderHandler + CheckFieldsForNil() error IsInterfaceNil() bool } @@ -280,6 +281,21 @@ type TransactionHandler interface { CheckIntegrity() error } +// TransactionHandlerWithGasUsedAndFee extends TransactionHandler by also including used gas and fee +type TransactionHandlerWithGasUsedAndFee interface { + TransactionHandler + + SetInitialPaidFee(fee *big.Int) + SetGasUsed(gasUsed uint64) + SetFee(fee *big.Int) + GetInitialPaidFee() *big.Int + GetGasUsed() uint64 + GetFee() *big.Int + GetTxHandler() TransactionHandler + SetExecutionOrder(order int) + GetExecutionOrder() int +} + // LogHandler defines the type for a log resulted from executing a transaction or smart contract call type LogHandler interface { // GetAddress returns the address of the sc that was originally called by the user @@ -348,10 +364,10 @@ type MiniBlockInfo struct { // SyncStatisticsHandler defines the methods for a component able to store the sync statistics for a trie type SyncStatisticsHandler interface { Reset() - AddNumReceived(value int) + AddNumProcessed(value int) AddNumLarge(value int) SetNumMissing(rootHash []byte, value int) - NumReceived() int + NumProcessed() int NumLarge() int NumMissing() int IsInterfaceNil() bool @@ -368,7 +384,7 @@ type TransactionWithFeeHandler interface { // UserAccountHandler models a user account type UserAccountHandler interface { - RetrieveValueFromDataTrieTracker(key []byte) ([]byte, error) + RetrieveValue(key []byte) ([]byte, uint32, error) GetBalance() *big.Int GetNonce() uint64 AddressBytes() []byte diff --git a/data/metrics/metrics.go b/data/metrics/metrics.go index 50bd26191..aa4ce4b6c 100644 --- a/data/metrics/metrics.go +++ b/data/metrics/metrics.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. metrics.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. metrics.proto package metrics // ListFromMap returns a list of values from the provided map diff --git a/data/mock/shardCoordinatorMock.go b/data/mock/shardCoordinatorMock.go index 610ddc20d..ed6bd5539 100644 --- a/data/mock/shardCoordinatorMock.go +++ b/data/mock/shardCoordinatorMock.go @@ -1,42 +1,42 @@ package mock import ( - "github.com/ElrondNetwork/elrond-go-core/core" + "github.com/multiversx/mx-chain-core-go/core" ) // ShardCoordinatorMock - type ShardCoordinatorMock struct { - SelfID uint32 - NrOfShards uint32 + SelfID uint32 + NumOfShards uint32 } // NumberOfShards - -func (scm ShardCoordinatorMock) NumberOfShards() uint32 { - return scm.NrOfShards +func (scm *ShardCoordinatorMock) NumberOfShards() uint32 { + return scm.NumOfShards } // ComputeId - -func (scm ShardCoordinatorMock) ComputeId(_ []byte) uint32 { +func (scm *ShardCoordinatorMock) ComputeId(_ []byte) uint32 { panic("implement me") } // SetSelfId - -func (scm ShardCoordinatorMock) SetSelfId(_ uint32) error { +func (scm *ShardCoordinatorMock) SetSelfId(_ uint32) error { panic("implement me") } // SelfId - -func (scm ShardCoordinatorMock) SelfId() uint32 { +func (scm *ShardCoordinatorMock) SelfId() uint32 { return scm.SelfID } // SameShard - -func (scm ShardCoordinatorMock) SameShard(_, _ []byte) bool { +func (scm *ShardCoordinatorMock) SameShard(_, _ []byte) bool { return true } // CommunicationIdentifier - -func (scm ShardCoordinatorMock) CommunicationIdentifier(destShardID uint32) string { +func (scm *ShardCoordinatorMock) CommunicationIdentifier(destShardID uint32) string { if destShardID == core.MetachainShardId { return "_0_META" } diff --git a/data/outport/dtos.go b/data/outport/dtos.go new file mode 100644 index 000000000..69641f648 --- /dev/null +++ b/data/outport/dtos.go @@ -0,0 +1,101 @@ +package outport + +import ( + "time" + + "github.com/multiversx/mx-chain-core-go/data" +) + +// TokenMetaData is the api metaData struct for tokens +type TokenMetaData struct { + Nonce uint64 `json:"nonce"` + Name string `json:"name"` + Creator string `json:"creator"` + Royalties uint32 `json:"royalties"` + Hash []byte `json:"hash"` + URIs [][]byte `json:"uris"` + Attributes []byte `json:"attributes"` +} + +// AccountTokenData holds the data needed for indexing a token of an altered account +type AccountTokenData struct { + Nonce uint64 `json:"nonce"` + Identifier string `json:"identifier"` + Balance string `json:"balance"` + Properties string `json:"properties"` + MetaData *TokenMetaData `json:"metadata,omitempty"` + AdditionalData *AdditionalAccountTokenData `json:"additionalData,omitempty"` +} + +// AlteredAccount holds the data needed of an altered account in a block +type AlteredAccount struct { + Nonce uint64 `json:"nonce"` + Address string `json:"address"` + Balance string `json:"balance,omitempty"` + Tokens []*AccountTokenData `json:"tokens"` + AdditionalData *AdditionalAccountData `json:"additionalData,omitempty"` +} + +// AdditionalAccountData holds the additional data for an altered account +type AdditionalAccountData struct { + IsSender bool `json:"isSender,omitempty"` + BalanceChanged bool `json:"balanceChanged,omitempty"` + CurrentOwner string `json:"currentOwner,omitempty"` + UserName string `json:"userName,omitempty"` + DeveloperRewards string `json:"developerRewards,omitempty"` +} + +// AdditionalAccountTokenData holds the additional data for indexing a token of an altered account +type AdditionalAccountTokenData struct { + IsNFTCreate bool `json:"isNFTCreate,omitempty"` +} + +// ArgsSaveBlockData will contain all information that are needed to save block data +type ArgsSaveBlockData struct { + HeaderHash []byte + Body data.BodyHandler + Header data.HeaderHandler + SignersIndexes []uint64 + NotarizedHeadersHashes []string + HeaderGasConsumption HeaderGasConsumption + TransactionsPool *Pool + AlteredAccounts map[string]*AlteredAccount + NumberOfShards uint32 + IsImportDB bool +} + +// HeaderGasConsumption holds the data needed to save the gas consumption of a header +type HeaderGasConsumption struct { + GasProvided uint64 + GasRefunded uint64 + GasPenalized uint64 + MaxGasPerBlock uint64 +} + +// Pool will hold all types of transaction +type Pool struct { + Txs map[string]data.TransactionHandlerWithGasUsedAndFee + Scrs map[string]data.TransactionHandlerWithGasUsedAndFee + Rewards map[string]data.TransactionHandlerWithGasUsedAndFee + Invalid map[string]data.TransactionHandlerWithGasUsedAndFee + Receipts map[string]data.TransactionHandlerWithGasUsedAndFee + Logs []*data.LogData + ScheduledExecutedSCRSHashesPrevBlock []string + ScheduledExecutedInvalidTxsHashesPrevBlock []string +} + +// ValidatorRatingInfo is a structure containing validator rating information +type ValidatorRatingInfo struct { + PublicKey string + Rating float32 +} + +// RoundInfo is a structure containing block signers and shard id +type RoundInfo struct { + Index uint64 + SignersIndexes []uint64 + BlockWasProposed bool + ShardId uint32 + Epoch uint32 + Timestamp time.Duration +} diff --git a/data/outport/txWithFee.go b/data/outport/txWithFee.go new file mode 100644 index 000000000..c515d1a82 --- /dev/null +++ b/data/outport/txWithFee.go @@ -0,0 +1,87 @@ +package outport + +import ( + "math/big" + + "github.com/multiversx/mx-chain-core-go/data" +) + +// FeeInfo holds information about the fee and gas used +type FeeInfo struct { + GasUsed uint64 + Fee *big.Int + InitialPaidFee *big.Int +} + +// TransactionHandlerWithGasAndFee holds a data.TransactionHandler and information about fee and gas used +type TransactionHandlerWithGasAndFee struct { + data.TransactionHandler + FeeInfo + ExecutionOrder int +} + +// NewTransactionHandlerWithGasAndFee returns a new instance of transactionHandlerWithGasAndFee which matches the interface +func NewTransactionHandlerWithGasAndFee(txHandler data.TransactionHandler, gasUsed uint64, fee *big.Int) data.TransactionHandlerWithGasUsedAndFee { + return &TransactionHandlerWithGasAndFee{ + TransactionHandler: txHandler, + FeeInfo: FeeInfo{ + GasUsed: gasUsed, + Fee: fee, + }, + } +} + +// SetInitialPaidFee will set the initial paid fee +func (t *TransactionHandlerWithGasAndFee) SetInitialPaidFee(fee *big.Int) { + t.InitialPaidFee = fee +} + +// GetInitialPaidFee returns the initial paid fee of the transactions +func (t *TransactionHandlerWithGasAndFee) GetInitialPaidFee() *big.Int { + return t.InitialPaidFee +} + +// SetGasUsed sets the used gas internally +func (t *TransactionHandlerWithGasAndFee) SetGasUsed(gasUsed uint64) { + t.GasUsed = gasUsed +} + +// GetGasUsed returns the used gas of the transaction +func (t *TransactionHandlerWithGasAndFee) GetGasUsed() uint64 { + return t.GasUsed +} + +// SetFee sets the fee internally +func (t *TransactionHandlerWithGasAndFee) SetFee(fee *big.Int) { + t.Fee = fee +} + +// GetFee returns the fee of the transaction +func (t *TransactionHandlerWithGasAndFee) GetFee() *big.Int { + return t.Fee +} + +// GetTxHandler will return the TransactionHandler +func (t *TransactionHandlerWithGasAndFee) GetTxHandler() data.TransactionHandler { + return t.TransactionHandler +} + +// SetExecutionOrder will set the execution order of the TransactionHandler +func (t *TransactionHandlerWithGasAndFee) SetExecutionOrder(order int) { + t.ExecutionOrder = order +} + +// GetExecutionOrder will return the execution order of the TransactionHandler +func (t *TransactionHandlerWithGasAndFee) GetExecutionOrder() int { + return t.ExecutionOrder +} + +// WrapTxsMap will wrap the provided transactions map in a map fo transactions with fee and gas used +func WrapTxsMap(txs map[string]data.TransactionHandler) map[string]data.TransactionHandlerWithGasUsedAndFee { + newMap := make(map[string]data.TransactionHandlerWithGasUsedAndFee, len(txs)) + for txHash, tx := range txs { + newMap[txHash] = NewTransactionHandlerWithGasAndFee(tx, 0, big.NewInt(0)) + } + + return newMap +} diff --git a/data/outport/txWithFee_test.go b/data/outport/txWithFee_test.go new file mode 100644 index 000000000..d24724455 --- /dev/null +++ b/data/outport/txWithFee_test.go @@ -0,0 +1,22 @@ +package outport + +import ( + "math/big" + "testing" + + "github.com/multiversx/mx-chain-core-go/data/transaction" + "github.com/stretchr/testify/require" +) + +func TestNewTransactionWithFee(t *testing.T) { + t.Parallel() + + txWithFee := NewTransactionHandlerWithGasAndFee(&transaction.Transaction{ + Nonce: 1, + }, 100, big.NewInt(1000)) + txWithFee.SetInitialPaidFee(big.NewInt(2000)) + + require.Equal(t, uint64(100), txWithFee.GetGasUsed()) + require.Equal(t, big.NewInt(1000), txWithFee.GetFee()) + require.Equal(t, big.NewInt(2000), txWithFee.GetInitialPaidFee()) +} diff --git a/data/receipt/receipt.go b/data/receipt/receipt.go index d96bef783..decc94d8f 100644 --- a/data/receipt/receipt.go +++ b/data/receipt/receipt.go @@ -1,10 +1,10 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. receipt.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. receipt.proto package receipt import ( "math/big" - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) var _ = data.TransactionHandler(&Receipt{}) diff --git a/data/receipt/receipt.pb.go b/data/receipt/receipt.pb.go index 93238c104..9c235d0cf 100644 --- a/data/receipt/receipt.pb.go +++ b/data/receipt/receipt.pb.go @@ -6,9 +6,9 @@ package receipt import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" io "io" math "math" math_big "math/big" @@ -30,7 +30,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Receipt holds all the data needed for a transaction receipt type Receipt struct { - Value *math_big.Int `protobuf:"bytes,1,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"value"` + Value *math_big.Int `protobuf:"bytes,1,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"value"` SndAddr []byte `protobuf:"bytes,2,opt,name=SndAddr,proto3" json:"sender"` Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"data,omitempty"` TxHash []byte `protobuf:"bytes,4,opt,name=TxHash,proto3" json:"txHash"` @@ -99,27 +99,27 @@ func init() { func init() { proto.RegisterFile("receipt.proto", fileDescriptor_ace1d6eb38fad2c8) } var fileDescriptor_ace1d6eb38fad2c8 = []byte{ - // 318 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x50, 0xbd, 0x4e, 0x33, 0x31, - 0x10, 0x3c, 0x7f, 0x5f, 0x7e, 0x24, 0x0b, 0x28, 0x5c, 0x9d, 0x28, 0xf6, 0x50, 0x84, 0x10, 0x05, - 0xb9, 0x2b, 0x28, 0xa9, 0x12, 0x7e, 0x44, 0x1a, 0x8a, 0x0b, 0xa2, 0xa0, 0xf3, 0xc5, 0xc6, 0xb1, - 0xc8, 0x9d, 0x23, 0x67, 0xc3, 0x4f, 0xc7, 0x23, 0xf0, 0x18, 0x88, 0x27, 0xa1, 0x4c, 0x99, 0x2a, - 0x10, 0x47, 0x42, 0x28, 0x55, 0x1e, 0x01, 0xc5, 0x09, 0x82, 0x6a, 0x77, 0x66, 0x76, 0x67, 0xa4, - 0xa1, 0x9b, 0x56, 0x76, 0xa4, 0xee, 0x63, 0xdc, 0xb7, 0x06, 0x0d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73, - 0x40, 0x46, 0x0e, 0xc8, 0xd8, 0x01, 0xf9, 0x70, 0x40, 0xbe, 0x1c, 0x04, 0x0b, 0x07, 0xe4, 0x79, - 0x06, 0xc1, 0x68, 0x06, 0xc1, 0x78, 0x06, 0xc1, 0x75, 0x75, 0xdd, 0x73, 0x56, 0xf1, 0x95, 0x1d, - 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0x65, 0xec, 0xc7, 0x7c, 0x79, 0x01, 0x00, 0x00, + // 317 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x50, 0xbb, 0x4e, 0xc3, 0x40, + 0x10, 0xf4, 0x41, 0x1e, 0xd2, 0x09, 0x28, 0x5c, 0x59, 0x14, 0x6b, 0x14, 0x21, 0x44, 0x81, 0xed, + 0x82, 0x92, 0x2a, 0x01, 0x24, 0xd2, 0x1a, 0x44, 0x41, 0x77, 0xb6, 0x0f, 0xfb, 0xa4, 0x9c, 0x2f, + 0x3a, 0xaf, 0xa3, 0xd0, 0xf1, 0x09, 0x7c, 0x06, 0xe2, 0x4b, 0x28, 0x53, 0xa6, 0x0a, 0xe4, 0x22, + 0x24, 0x94, 0x2a, 0x9f, 0x80, 0x72, 0x09, 0x82, 0x6a, 0x77, 0x66, 0x76, 0x67, 0xa4, 0xa1, 0xfb, + 0x9a, 0xa7, 0x5c, 0x0c, 0x31, 0x1c, 0x6a, 0x85, 0xca, 0x6d, 0xda, 0x71, 0x18, 0xe4, 0x02, 0x8b, + 0x3a, 0x09, 0x53, 0x25, 0xa3, 0x5c, 0xe5, 0x2a, 0xb2, 0x74, 0x52, 0x3f, 0x5a, 0x64, 0x81, 0xdd, + 0x36, 0x5f, 0x9d, 0x2f, 0x42, 0xdb, 0xf1, 0xc6, 0xc7, 0x2d, 0x68, 0xf3, 0x9e, 0x0d, 0x6a, 0xee, + 0x91, 0x23, 0x72, 0xba, 0xd7, 0x8b, 0x97, 0x33, 0xbf, 0x39, 0x5a, 0x13, 0x6f, 0x1f, 0xfe, 0xb5, + 0x64, 0x58, 0x44, 0x89, 0xc8, 0xc3, 0x7e, 0x89, 0x17, 0xff, 0x32, 0x64, 0x3d, 0x40, 0x31, 0xe2, + 0xba, 0x1a, 0x47, 0x72, 0x1c, 0xa4, 0x05, 0x13, 0x65, 0x90, 0x2a, 0xcd, 0x83, 0x5c, 0x45, 0x19, + 0x43, 0x16, 0xf6, 0x44, 0xde, 0x2f, 0xf1, 0x92, 0x55, 0xc8, 0x75, 0xbc, 0x09, 0x70, 0x8f, 0x69, + 0xfb, 0xb6, 0xcc, 0xba, 0x59, 0xa6, 0xbd, 0x1d, 0x9b, 0x45, 0x97, 0x33, 0xbf, 0x55, 0xf1, 0x32, + 0xe3, 0x3a, 0xfe, 0x95, 0xdc, 0x13, 0xda, 0xb8, 0x62, 0xc8, 0xbc, 0x5d, 0x7b, 0xe2, 0x2e, 0x67, + 0xfe, 0xc1, 0xda, 0xf1, 0x4c, 0x49, 0x81, 0x5c, 0x0e, 0xf1, 0x29, 0xb6, 0xba, 0xdb, 0xa1, 0xad, + 0xbb, 0xf1, 0x0d, 0xab, 0x0a, 0xaf, 0xf1, 0x67, 0x86, 0x96, 0x89, 0xb7, 0x4a, 0xaf, 0x3b, 0x99, + 0x83, 0x33, 0x9d, 0x83, 0xb3, 0x9a, 0x03, 0x79, 0x36, 0x40, 0x5e, 0x0d, 0x90, 0x77, 0x03, 0x64, + 0x62, 0x80, 0x4c, 0x0d, 0x90, 0x4f, 0x03, 0xe4, 0xdb, 0x80, 0xb3, 0x32, 0x40, 0x5e, 0x16, 0xe0, + 0x4c, 0x16, 0xe0, 0x4c, 0x17, 0xe0, 0x3c, 0xb4, 0xb7, 0x35, 0x27, 0x2d, 0xdb, 0xd8, 0xf9, 0x4f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xfd, 0xfd, 0x03, 0xf6, 0x78, 0x01, 0x00, 0x00, } func (this *Receipt) Equal(that interface{}) bool { @@ -142,7 +142,7 @@ func (this *Receipt) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.Value, that1.Value) { return false } @@ -221,7 +221,7 @@ func (m *Receipt) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.Value) i -= size if _, err := __caster.MarshalTo(m.Value, dAtA[i:]); err != nil { @@ -252,7 +252,7 @@ func (m *Receipt) Size() (n int) { var l int _ = l { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.Value) n += 1 + l + sovReceipt(uint64(l)) } @@ -357,7 +357,7 @@ func (m *Receipt) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { diff --git a/data/receipt/receipt.proto b/data/receipt/receipt.proto index 15158bdd1..0fbe44c12 100644 --- a/data/receipt/receipt.proto +++ b/data/receipt/receipt.proto @@ -10,7 +10,7 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto"; // Receipt holds all the data needed for a transaction receipt message Receipt { - bytes Value = 1 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes Value = 1 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes SndAddr = 2 [(gogoproto.jsontag) = "sender"]; bytes Data = 3 [(gogoproto.jsontag) = "data,omitempty"]; bytes TxHash = 4 [(gogoproto.jsontag) = "txHash"]; diff --git a/data/receipt/receipt_test.go b/data/receipt/receipt_test.go index 8cc17375a..84f689413 100644 --- a/data/receipt/receipt_test.go +++ b/data/receipt/receipt_test.go @@ -4,7 +4,7 @@ import ( "math/big" "testing" - "github.com/ElrondNetwork/elrond-go-core/data/receipt" + "github.com/multiversx/mx-chain-core-go/data/receipt" "github.com/stretchr/testify/assert" ) diff --git a/data/rewardTx/rewardTx.go b/data/rewardTx/rewardTx.go index 024fc4fcf..0e4a3ed43 100644 --- a/data/rewardTx/rewardTx.go +++ b/data/rewardTx/rewardTx.go @@ -1,10 +1,10 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. rewardTx.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. rewardTx.proto package rewardTx import ( "math/big" - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) var _ = data.TransactionHandler(&RewardTx{}) diff --git a/data/rewardTx/rewardTx.pb.go b/data/rewardTx/rewardTx.pb.go index 7eae9cabf..ab1910274 100644 --- a/data/rewardTx/rewardTx.pb.go +++ b/data/rewardTx/rewardTx.pb.go @@ -6,9 +6,9 @@ package rewardTx import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" io "io" math "math" math_big "math/big" @@ -71,7 +71,7 @@ func (Type) EnumDescriptor() ([]byte, []int) { // RewardTx holds the data for a reward transaction type RewardTx struct { Round uint64 `protobuf:"varint,1,opt,name=Round,proto3" json:"round"` - Value *math_big.Int `protobuf:"bytes,3,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"value"` + Value *math_big.Int `protobuf:"bytes,3,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"value"` RcvAddr []byte `protobuf:"bytes,4,opt,name=RcvAddr,proto3" json:"receiver"` Epoch uint32 `protobuf:"varint,2,opt,name=Epoch,proto3" json:"epoch"` } @@ -141,32 +141,32 @@ func init() { proto.RegisterFile("rewardTx.proto", fileDescriptor_25dbfb608d6bad var fileDescriptor_25dbfb608d6baddf = []byte{ // 409 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xc1, 0x8a, 0xd3, 0x40, - 0x1c, 0xc6, 0x33, 0xbb, 0xc9, 0x9a, 0x1d, 0x5a, 0x89, 0x03, 0x42, 0x10, 0x99, 0x14, 0x0f, 0x52, - 0x84, 0x26, 0x07, 0x8f, 0x9e, 0x8c, 0xec, 0xc2, 0x82, 0x8a, 0x64, 0xa3, 0x07, 0x6f, 0x93, 0x64, - 0x4c, 0x87, 0xcd, 0xce, 0x94, 0xe9, 0xa4, 0xcd, 0xde, 0xc4, 0x27, 0xf0, 0x31, 0xc4, 0x27, 0xf1, - 0xd8, 0x63, 0x4f, 0xbb, 0x76, 0x7a, 0x91, 0x9e, 0xfa, 0x08, 0x92, 0x49, 0x03, 0x3d, 0x25, 0xdf, - 0xef, 0x9b, 0x8f, 0xff, 0xc7, 0xff, 0x0f, 0x1f, 0x4b, 0xba, 0x24, 0xb2, 0x48, 0x9b, 0x70, 0x26, - 0x85, 0x12, 0x68, 0x68, 0x3e, 0xc9, 0x01, 0x3e, 0x9b, 0x94, 0x4c, 0x4d, 0xeb, 0x2c, 0xcc, 0xc5, - 0x6d, 0x54, 0x8a, 0x52, 0x44, 0xc6, 0xce, 0xea, 0x6f, 0x46, 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 0xbf, 0xf8, 0x01, 0xe0, 0x20, 0xbe, 0x5e, 0x31, 0x34, 0x81, 0xe7, + 0x9f, 0xc4, 0x37, 0x21, 0xaf, 0x44, 0x6c, 0x7c, 0x0f, 0x8d, 0xe1, 0xe8, 0x1d, 0xa3, 0x19, 0x53, + 0xb1, 0xf1, 0x01, 0x82, 0xf0, 0x2c, 0x6a, 0x94, 0x53, 0x4e, 0xd0, 0x53, 0x18, 0x7c, 0x70, 0xb3, + 0x49, 0x65, 0xf9, 0xb1, 0xa9, 0x35, 0xe5, 0x82, 0x26, 0xbc, 0xe4, 0xfa, 0x3a, 0x36, 0xfe, 0x29, + 0x7a, 0x0c, 0x1f, 0xf5, 0x6a, 0x37, 0xb7, 0x3a, 0x36, 0xfe, 0xe0, 0xd8, 0x74, 0x8f, 0xdf, 0x4a, + 0xf5, 0x9e, 0x69, 0x1a, 0x1b, 0x7f, 0x18, 0x45, 0x9b, 0x3d, 0xf6, 0xb6, 0x7b, 0xec, 0xdd, 0xee, + 0x31, 0xf8, 0x6e, 0x31, 0xf8, 0x65, 0x31, 0xf8, 0x63, 0x31, 0xd8, 0x58, 0x0c, 0xb6, 0x16, 0x83, + 0x7f, 0x16, 0x83, 0xff, 0x16, 0x7b, 0xb7, 0x16, 0x83, 0x9f, 0x07, 0xec, 0x6d, 0x0e, 0xd8, 0xdb, + 0x1e, 0xb0, 0xf7, 0x65, 0xd4, 0x6f, 0x3b, 0x39, 0x6b, 0x17, 0xf6, 0xf2, 0x2e, 0x00, 0x00, 0xff, + 0xff, 0x42, 0x42, 0x5b, 0x64, 0x00, 0x02, 0x00, 0x00, } func (x Type) String() string { @@ -199,7 +199,7 @@ func (this *RewardTx) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.Value, that1.Value) { return false } @@ -261,7 +261,7 @@ func (m *RewardTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x22 } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.Value) i -= size if _, err := __caster.MarshalTo(m.Value, dAtA[i:]); err != nil { @@ -308,7 +308,7 @@ func (m *RewardTx) Size() (n int) { n += 1 + sovRewardTx(uint64(m.Epoch)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.Value) n += 1 + l + sovRewardTx(uint64(l)) } @@ -443,7 +443,7 @@ func (m *RewardTx) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { diff --git a/data/rewardTx/rewardTx.proto b/data/rewardTx/rewardTx.proto index 6d7cbf82b..f74966c79 100644 --- a/data/rewardTx/rewardTx.proto +++ b/data/rewardTx/rewardTx.proto @@ -27,7 +27,7 @@ enum Type { // RewardTx holds the data for a reward transaction message RewardTx { uint64 Round = 1 [(gogoproto.jsontag) = "round"]; - bytes Value = 3 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes Value = 3 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes RcvAddr = 4 [(gogoproto.jsontag) = "receiver"]; uint32 Epoch = 2 [(gogoproto.jsontag) = "epoch"]; } diff --git a/data/rewardTx/rewardTx_test.go b/data/rewardTx/rewardTx_test.go index 7db4df9ea..2f8680e26 100644 --- a/data/rewardTx/rewardTx_test.go +++ b/data/rewardTx/rewardTx_test.go @@ -4,8 +4,8 @@ import ( "math/big" "testing" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/rewardTx" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/rewardTx" "github.com/stretchr/testify/assert" ) diff --git a/data/scheduled/scheduled.go b/data/scheduled/scheduled.go index f830132c3..9f8e95142 100644 --- a/data/scheduled/scheduled.go +++ b/data/scheduled/scheduled.go @@ -1,11 +1,11 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. scheduled.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. scheduled.proto package scheduled import ( - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go-core/data/smartContractResult" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/data/smartContractResult" + "github.com/multiversx/mx-chain-core-go/data/transaction" ) // GetTransactionHandlersMap returns the smart contract results as a map of transaction handlers diff --git a/data/scheduled/scheduled.pb.go b/data/scheduled/scheduled.pb.go index 040e5e0b2..6cf07afbb 100644 --- a/data/scheduled/scheduled.pb.go +++ b/data/scheduled/scheduled.pb.go @@ -6,12 +6,12 @@ package scheduled import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" - block "github.com/ElrondNetwork/elrond-go-core/data/block" - smartContractResult "github.com/ElrondNetwork/elrond-go-core/data/smartContractResult" - transaction "github.com/ElrondNetwork/elrond-go-core/data/transaction" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" + block "github.com/multiversx/mx-chain-core-go/data/block" + smartContractResult "github.com/multiversx/mx-chain-core-go/data/smartContractResult" + transaction "github.com/multiversx/mx-chain-core-go/data/transaction" io "io" math "math" math_big "math/big" @@ -32,8 +32,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GasAndFees struct { - AccumulatedFees *math_big.Int `protobuf:"bytes,1,opt,name=AccumulatedFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"AccumulatedFees,omitempty"` - DeveloperFees *math_big.Int `protobuf:"bytes,2,opt,name=DeveloperFees,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"DeveloperFees,omitempty"` + AccumulatedFees *math_big.Int `protobuf:"bytes,1,opt,name=AccumulatedFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"AccumulatedFees,omitempty"` + DeveloperFees *math_big.Int `protobuf:"bytes,2,opt,name=DeveloperFees,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"DeveloperFees,omitempty"` GasProvided uint64 `protobuf:"varint,3,opt,name=GasProvided,proto3" json:"GasProvided,omitempty"` GasPenalized uint64 `protobuf:"varint,4,opt,name=GasPenalized,proto3" json:"GasPenalized,omitempty"` GasRefunded uint64 `protobuf:"varint,5,opt,name=GasRefunded,proto3" json:"GasRefunded,omitempty"` @@ -182,37 +182,37 @@ func init() { proto.RegisterFile("scheduled.proto", fileDescriptor_f80076f37bd30 var fileDescriptor_f80076f37bd30c16 = []byte{ // 491 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x53, 0x41, 0x6f, 0xd3, 0x30, - 0x18, 0x8d, 0xdb, 0x0e, 0x81, 0xbb, 0x69, 0xe0, 0x5d, 0xa2, 0x1e, 0x4c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0x0a, 0x0c, 0x96, 0x05, + 0x06, 0xbf, 0x0a, 0x0c, 0x7e, 0x17, 0xd8, 0xbb, 0x2e, 0x30, 0xf8, 0xbc, 0xc6, 0xde, 0x62, 0x8d, + 0xbd, 0xe5, 0x1a, 0x7b, 0xef, 0x1f, 0xd4, 0x27, 0x08, 0xef, 0xb9, 0x16, 0x4f, 0xff, 0x04, 0x00, + 0x00, 0xff, 0xff, 0x81, 0x81, 0x3b, 0xd5, 0xf1, 0x03, 0x00, 0x00, } func (this *GasAndFees) Equal(that interface{}) bool { @@ -235,13 +235,13 @@ func (this *GasAndFees) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.AccumulatedFees, that1.AccumulatedFees) { return false } } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.DeveloperFees, that1.DeveloperFees) { return false } @@ -388,7 +388,7 @@ func (m *GasAndFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x18 } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.DeveloperFees) i -= size if _, err := __caster.MarshalTo(m.DeveloperFees, dAtA[i:]); err != nil { @@ -399,7 +399,7 @@ func (m *GasAndFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.AccumulatedFees) i -= size if _, err := __caster.MarshalTo(m.AccumulatedFees, dAtA[i:]); err != nil { @@ -514,12 +514,12 @@ func (m *GasAndFees) Size() (n int) { var l int _ = l { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.AccumulatedFees) n += 1 + l + sovScheduled(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.DeveloperFees) n += 1 + l + sovScheduled(uint64(l)) } @@ -686,7 +686,7 @@ func (m *GasAndFees) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -724,7 +724,7 @@ func (m *GasAndFees) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { diff --git a/data/scheduled/scheduled.proto b/data/scheduled/scheduled.proto index 65ef42d9b..2949edb80 100644 --- a/data/scheduled/scheduled.proto +++ b/data/scheduled/scheduled.proto @@ -6,13 +6,13 @@ option go_package = "scheduled"; option (gogoproto.stable_marshaler_all) = true; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; -import "github.com/ElrondNetwork/elrond-go-core/data/smartContractResult/smartContractResult.proto"; -import "github.com/ElrondNetwork/elrond-go-core/data/block/block.proto"; -import "github.com/ElrondNetwork/elrond-go-core/data/transaction/transaction.proto"; +import "github.com/multiversx/mx-chain-core-go/data/smartContractResult/smartContractResult.proto"; +import "github.com/multiversx/mx-chain-core-go/data/block/block.proto"; +import "github.com/multiversx/mx-chain-core-go/data/transaction/transaction.proto"; message GasAndFees { - bytes AccumulatedFees = 1 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; - bytes DeveloperFees = 2 [(gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes AccumulatedFees = 1 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DeveloperFees = 2 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; uint64 GasProvided = 3; uint64 GasPenalized = 4; uint64 GasRefunded = 5; diff --git a/data/scheduled/scheduled_test.go b/data/scheduled/scheduled_test.go index 84ec12f7a..81c952109 100644 --- a/data/scheduled/scheduled_test.go +++ b/data/scheduled/scheduled_test.go @@ -3,11 +3,11 @@ package scheduled_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go-core/data/scheduled" - "github.com/ElrondNetwork/elrond-go-core/data/smartContractResult" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/data/scheduled" + "github.com/multiversx/mx-chain-core-go/data/smartContractResult" + "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/stretchr/testify/require" ) diff --git a/data/smartContractResult/smartContractResult.go b/data/smartContractResult/smartContractResult.go index 22ca32668..c6ab0f8a6 100644 --- a/data/smartContractResult/smartContractResult.go +++ b/data/smartContractResult/smartContractResult.go @@ -1,10 +1,10 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. smartContractResult.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. smartContractResult.proto package smartContractResult import ( "math/big" - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) var _ = data.TransactionHandler(&SmartContractResult{}) diff --git a/data/smartContractResult/smartContractResult.pb.go b/data/smartContractResult/smartContractResult.pb.go index 7d21b11ea..45422ffd6 100644 --- a/data/smartContractResult/smartContractResult.pb.go +++ b/data/smartContractResult/smartContractResult.pb.go @@ -6,10 +6,10 @@ package smartContractResult import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" - github_com_ElrondNetwork_elrond_go_core_data_vm "github.com/ElrondNetwork/elrond-go-core/data/vm" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" + github_com_multiversx_mx_chain_core_go_data_vm "github.com/multiversx/mx-chain-core-go/data/vm" io "io" math "math" math_big "math/big" @@ -30,22 +30,22 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type SmartContractResult struct { - Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` - Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"value"` - RcvAddr []byte `protobuf:"bytes,3,opt,name=RcvAddr,proto3" json:"receiver"` - SndAddr []byte `protobuf:"bytes,4,opt,name=SndAddr,proto3" json:"sender"` - RelayerAddr []byte `protobuf:"bytes,5,opt,name=RelayerAddr,proto3" json:"relayer"` - RelayedValue *math_big.Int `protobuf:"bytes,6,opt,name=RelayedValue,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"relayedValue"` - Code []byte `protobuf:"bytes,7,opt,name=Code,proto3" json:"code,omitempty"` - Data []byte `protobuf:"bytes,8,opt,name=Data,proto3" json:"data,omitempty"` - PrevTxHash []byte `protobuf:"bytes,9,opt,name=PrevTxHash,proto3" json:"prevTxHash"` - OriginalTxHash []byte `protobuf:"bytes,10,opt,name=OriginalTxHash,proto3" json:"originalTxHash"` - GasLimit uint64 `protobuf:"varint,11,opt,name=GasLimit,proto3" json:"gasLimit"` - GasPrice uint64 `protobuf:"varint,12,opt,name=GasPrice,proto3" json:"gasPrice"` - CallType github_com_ElrondNetwork_elrond_go_core_data_vm.CallType `protobuf:"varint,13,opt,name=CallType,proto3,casttype=github.com/ElrondNetwork/elrond-go-core/data/vm.CallType" json:"callType"` - CodeMetadata []byte `protobuf:"bytes,14,opt,name=CodeMetadata,proto3" json:"codeMetadata,omitempty"` - ReturnMessage []byte `protobuf:"bytes,15,opt,name=ReturnMessage,proto3" json:"returnMessage,omitempty"` - OriginalSender []byte `protobuf:"bytes,16,opt,name=OriginalSender,proto3" json:"originalSender,omitempty"` + Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` + Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"value"` + RcvAddr []byte `protobuf:"bytes,3,opt,name=RcvAddr,proto3" json:"receiver"` + SndAddr []byte `protobuf:"bytes,4,opt,name=SndAddr,proto3" json:"sender"` + RelayerAddr []byte `protobuf:"bytes,5,opt,name=RelayerAddr,proto3" json:"relayer"` + RelayedValue *math_big.Int `protobuf:"bytes,6,opt,name=RelayedValue,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"relayedValue"` + Code []byte `protobuf:"bytes,7,opt,name=Code,proto3" json:"code,omitempty"` + Data []byte `protobuf:"bytes,8,opt,name=Data,proto3" json:"data,omitempty"` + PrevTxHash []byte `protobuf:"bytes,9,opt,name=PrevTxHash,proto3" json:"prevTxHash"` + OriginalTxHash []byte `protobuf:"bytes,10,opt,name=OriginalTxHash,proto3" json:"originalTxHash"` + GasLimit uint64 `protobuf:"varint,11,opt,name=GasLimit,proto3" json:"gasLimit"` + GasPrice uint64 `protobuf:"varint,12,opt,name=GasPrice,proto3" json:"gasPrice"` + CallType github_com_multiversx_mx_chain_core_go_data_vm.CallType `protobuf:"varint,13,opt,name=CallType,proto3,casttype=github.com/multiversx/mx-chain-core-go/data/vm.CallType" json:"callType"` + CodeMetadata []byte `protobuf:"bytes,14,opt,name=CodeMetadata,proto3" json:"codeMetadata,omitempty"` + ReturnMessage []byte `protobuf:"bytes,15,opt,name=ReturnMessage,proto3" json:"returnMessage,omitempty"` + OriginalSender []byte `protobuf:"bytes,16,opt,name=OriginalSender,proto3" json:"originalSender,omitempty"` } func (m *SmartContractResult) Reset() { *m = SmartContractResult{} } @@ -160,7 +160,7 @@ func (m *SmartContractResult) GetGasPrice() uint64 { return 0 } -func (m *SmartContractResult) GetCallType() github_com_ElrondNetwork_elrond_go_core_data_vm.CallType { +func (m *SmartContractResult) GetCallType() github_com_multiversx_mx_chain_core_go_data_vm.CallType { if m != nil { return m.CallType } @@ -195,46 +195,46 @@ func init() { func init() { proto.RegisterFile("smartContractResult.proto", fileDescriptor_edc1605de0d3d805) } var fileDescriptor_edc1605de0d3d805 = []byte{ - // 610 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x6b, 0xb6, 0xae, 0x9d, 0xd7, 0x15, 0xe4, 0x49, 0x60, 0x06, 0xb2, 0x27, 0x84, 0xa6, - 0x1e, 0x68, 0x72, 0xe0, 0x82, 0x40, 0x42, 0x5a, 0x3b, 0x60, 0x93, 0xd8, 0x98, 0xdc, 0x89, 0xc3, - 0x6e, 0x6e, 0x62, 0xb2, 0x88, 0x24, 0xae, 0x1c, 0xb7, 0xb0, 0x0b, 0xe2, 0x23, 0xf0, 0x31, 0x10, - 0x9f, 0x84, 0xe3, 0x8e, 0xbb, 0x10, 0x58, 0x76, 0x41, 0x39, 0xed, 0xcc, 0x09, 0xc5, 0xe9,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97, 0xd7, 0x40, 0x67, 0xae, - 0xb7, 0x95, 0x93, 0xce, 0x54, 0xfb, 0x95, 0xd0, 0x47, 0xff, 0xb2, 0x7a, 0x7b, 0x12, 0x5a, 0x17, - 0x79, 0x6c, 0x96, 0x8c, 0x9e, 0xc2, 0x56, 0xbe, 0xd5, 0x1d, 0xa1, 0x79, 0x4e, 0xe1, 0xb6, 0x39, - 0xf3, 0x6a, 0x96, 0xd0, 0x9b, 0x4e, 0x49, 0x2f, 0x6d, 0xb7, 0xc2, 0xa3, 0x0d, 0xb8, 0xcc, 0x84, - 0x1e, 0xab, 0x68, 0x47, 0xc4, 0x31, 0xf7, 0x04, 0xbe, 0x6e, 0x02, 0xee, 0x64, 0x09, 0xbd, 0xa5, - 0xca, 0x46, 0x29, 0xa1, 0xda, 0x81, 0x36, 0x2f, 0x17, 0x3f, 0x30, 0x57, 0x18, 0xdf, 0x30, 0x19, - 0x77, 0xb3, 0x84, 0x62, 0x59, 0x71, 0x4a, 0x21, 0x57, 0x7a, 0x7a, 0x3b, 0xc7, 0xa7, 0xa4, 0x76, - 0x72, 0x4a, 0x6a, 0xe7, 0xa7, 0x04, 0x7c, 0x4c, 0x09, 0xf8, 0x9c, 0x12, 0xf0, 0x35, 0x25, 0xe0, - 0x38, 0x25, 0xe0, 0x24, 0x25, 0xe0, 0x47, 0x4a, 0xc0, 0xcf, 0x94, 0xd4, 0xce, 0x53, 0x02, 0x3e, - 0x9d, 0x91, 0xda, 0xf1, 0x19, 0xa9, 0x9d, 0x9c, 0x91, 0xda, 0xc1, 0xca, 0x5f, 0x9e, 0x9a, 0xe1, - 0x82, 0x79, 0x35, 0x1e, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xb4, 0x81, 0x4c, 0xd3, 0x88, 0x04, - 0x00, 0x00, + // 613 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6f,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0x27, 0x29, 0x01, 0xa7, 0x29, 0x01, 0xdf, 0x53, 0x02, 0x7e, 0xa4, 0xa4, 0x76, 0x91, + 0x12, 0xf0, 0xf1, 0x9c, 0xd4, 0x4e, 0xce, 0x49, 0xed, 0xf4, 0x9c, 0xd4, 0xde, 0xae, 0xfd, 0xe1, + 0x9e, 0x19, 0x2d, 0xd9, 0x2b, 0xe3, 0xe1, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xee, 0x08, 0xc4, + 0x90, 0x85, 0x04, 0x00, 0x00, } func (this *SmartContractResult) Equal(that interface{}) bool { @@ -260,7 +260,7 @@ func (this *SmartContractResult) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.Value, that1.Value) { return false } @@ -275,7 +275,7 @@ func (this *SmartContractResult) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.RelayedValue, that1.RelayedValue) { return false } @@ -432,7 +432,7 @@ func (m *SmartContractResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x3a } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.RelayedValue) i -= size if _, err := __caster.MarshalTo(m.RelayedValue, dAtA[i:]); err != nil { @@ -464,7 +464,7 @@ func (m *SmartContractResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.Value) i -= size if _, err := __caster.MarshalTo(m.Value, dAtA[i:]); err != nil { @@ -503,7 +503,7 @@ func (m *SmartContractResult) Size() (n int) { n += 1 + sovSmartContractResult(uint64(m.Nonce)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.Value) n += 1 + l + sovSmartContractResult(uint64(l)) } @@ -520,7 +520,7 @@ func (m *SmartContractResult) Size() (n int) { n += 1 + l + sovSmartContractResult(uint64(l)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.RelayedValue) n += 1 + l + sovSmartContractResult(uint64(l)) } @@ -681,7 +681,7 @@ func (m *SmartContractResult) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -821,7 +821,7 @@ func (m *SmartContractResult) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { @@ -1017,7 +1017,7 @@ func (m *SmartContractResult) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CallType |= github_com_ElrondNetwork_elrond_go_core_data_vm.CallType(b&0x7F) << shift + m.CallType |= github_com_multiversx_mx_chain_core_go_data_vm.CallType(b&0x7F) << shift if b < 0x80 { break } diff --git a/data/smartContractResult/smartContractResult.proto b/data/smartContractResult/smartContractResult.proto index 0827559eb..4f074fc73 100644 --- a/data/smartContractResult/smartContractResult.proto +++ b/data/smartContractResult/smartContractResult.proto @@ -10,18 +10,18 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto"; message SmartContractResult { uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; - bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes RcvAddr = 3 [(gogoproto.jsontag) = "receiver"]; bytes SndAddr = 4 [(gogoproto.jsontag) = "sender"]; bytes RelayerAddr = 5 [(gogoproto.jsontag) = "relayer"]; - bytes RelayedValue = 6 [(gogoproto.jsontag) = "relayedValue", (gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes RelayedValue = 6 [(gogoproto.jsontag) = "relayedValue", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes Code = 7 [(gogoproto.jsontag) = "code,omitempty"]; bytes Data = 8 [(gogoproto.jsontag) = "data,omitempty"]; bytes PrevTxHash = 9 [(gogoproto.jsontag) = "prevTxHash"]; bytes OriginalTxHash = 10 [(gogoproto.jsontag) = "originalTxHash"]; uint64 GasLimit = 11 [(gogoproto.jsontag) = "gasLimit"]; uint64 GasPrice = 12 [(gogoproto.jsontag) = "gasPrice"]; - int64 CallType = 13 [(gogoproto.jsontag) = "callType", (gogoproto.casttype) = "github.com/ElrondNetwork/elrond-go-core/data/vm.CallType"]; + int64 CallType = 13 [(gogoproto.jsontag) = "callType", (gogoproto.casttype) = "github.com/multiversx/mx-chain-core-go/data/vm.CallType"]; bytes CodeMetadata = 14 [(gogoproto.jsontag) = "codeMetadata,omitempty"]; bytes ReturnMessage = 15 [(gogoproto.jsontag) = "returnMessage,omitempty"]; bytes OriginalSender = 16 [(gogoproto.jsontag) = "originalSender,omitempty"]; diff --git a/data/smartContractResult/smartContractResult_test.go b/data/smartContractResult/smartContractResult_test.go index 4e02e9a21..75eba8287 100644 --- a/data/smartContractResult/smartContractResult_test.go +++ b/data/smartContractResult/smartContractResult_test.go @@ -4,8 +4,8 @@ import ( "math/big" "testing" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/smartContractResult" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/smartContractResult" "github.com/stretchr/testify/assert" ) diff --git a/data/transaction/apiTransactionResult.go b/data/transaction/apiTransactionResult.go index f8e41235b..20bdfcfa4 100644 --- a/data/transaction/apiTransactionResult.go +++ b/data/transaction/apiTransactionResult.go @@ -3,8 +3,8 @@ package transaction import ( "math/big" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/vm" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/vm" ) // ApiTransactionResult is the data transfer object which will be returned on the get transaction by hash endpoint @@ -25,6 +25,7 @@ type ApiTransactionResult struct { ReceiverUsername []byte `json:"receiverUsername,omitempty"` GasPrice uint64 `json:"gasPrice,omitempty"` GasLimit uint64 `json:"gasLimit,omitempty"` + GasUsed uint64 `json:"gasUsed,omitempty"` Data []byte `json:"data,omitempty"` CodeMetadata []byte `json:"codeMetadata,omitempty"` Code string `json:"code,omitempty"` @@ -57,8 +58,15 @@ type ApiTransactionResult struct { Operation string `json:"operation,omitempty"` Function string `json:"function,omitempty"` InitiallyPaidFee string `json:"initiallyPaidFee,omitempty"` + Fee string `json:"fee,omitempty"` IsRelayed bool `json:"isRelayed,omitempty"` IsRefund bool `json:"isRefund,omitempty"` + CallType string `json:"callType,omitempty"` + RelayerAddress string `json:"relayerAddress,omitempty"` + RelayedValue string `json:"relayedValue,omitempty"` + ChainID string `json:"chainID,omitempty"` + Version uint32 `json:"version,omitempty"` + Options uint32 `json:"options"` } // ApiSmartContractResult represents a smart contract result with changed fields' types in order to make it friendly for API's json diff --git a/data/transaction/interface.go b/data/transaction/interface.go index 879444676..0d24c06c6 100644 --- a/data/transaction/interface.go +++ b/data/transaction/interface.go @@ -1,6 +1,6 @@ package transaction -import "github.com/ElrondNetwork/elrond-go-core/data/block" +import "github.com/multiversx/mx-chain-core-go/data/block" // Encoder represents a byte slice to string encoder type Encoder interface { diff --git a/data/transaction/log.go b/data/transaction/log.go index 2bd9b6d17..3f917c0f3 100644 --- a/data/transaction/log.go +++ b/data/transaction/log.go @@ -1,8 +1,8 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. log.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. log.proto package transaction import ( - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/data" ) // GetLogEvents returns the interface for the underlying events of the log structure diff --git a/data/transaction/log_test.go b/data/transaction/log_test.go index 148892e9a..34f88c687 100644 --- a/data/transaction/log_test.go +++ b/data/transaction/log_test.go @@ -3,8 +3,8 @@ package transaction_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/stretchr/testify/require" ) diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 951b10cf8..e0daa67e7 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -1,12 +1,12 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. transaction.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. transaction.proto package transaction import ( "math/big" - "github.com/ElrondNetwork/elrond-go-core/core" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data" ) var _ = data.TransactionHandler(&Transaction{}) diff --git a/data/transaction/transaction.pb.go b/data/transaction/transaction.pb.go index 199cb8d35..02d7eab4d 100644 --- a/data/transaction/transaction.pb.go +++ b/data/transaction/transaction.pb.go @@ -6,9 +6,9 @@ package transaction import ( bytes "bytes" fmt "fmt" - github_com_ElrondNetwork_elrond_go_core_data "github.com/ElrondNetwork/elrond-go-core/data" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" io "io" math "math" math_big "math/big" @@ -31,7 +31,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Transaction holds all the data needed for a value transfer or SC call type Transaction struct { Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` - Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster" json:"value"` + Value *math_big.Int `protobuf:"bytes,2,opt,name=Value,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"value"` RcvAddr []byte `protobuf:"bytes,3,opt,name=RcvAddr,proto3" json:"receiver"` RcvUserName []byte `protobuf:"bytes,4,opt,name=RcvUserName,proto3" json:"rcvUserName,omitempty"` SndAddr []byte `protobuf:"bytes,5,opt,name=SndAddr,proto3" json:"sender"` @@ -171,40 +171,40 @@ func init() { func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) } var fileDescriptor_2cc4e03d2c28c490 = []byte{ - // 516 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x93, 0xb1, 0x8e, 0xd3, 0x30, - 0x1c, 0xc6, 0x63, 0x68, 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56, 0x68, 0x17, 0x4c, 0x25, 0x5c, 0x0a, 0xb7, 0xd5, 0x01, 0xdd, 0x83, 0x52, 0x5b, 0x94, - 0xc8, 0xdf, 0xcd, 0xd0, 0x33, 0xd8, 0x1c, 0xf3, 0x48, 0x50, 0x3d, 0x57, 0xcc, 0x6d, 0x9b, 0xfd, - 0xee, 0xe6, 0x29, 0xb9, 0x9d, 0xec, 0x60, 0xa5, 0x7f, 0x6f, 0x22, 0x0f, 0x3a, 0xaf, 0x67, 0xc5, - 0x93, 0x4b, 0xdc, 0x03, 0xb3, 0xfb, 0x51, 0x9e, 0x92, 0x43, 0x59, 0xa2, 0x4a, 0x64, 0x67, 0x0d, - 0xce, 0x97, 0x6b, 0x6c, 0xad, 0xd6, 0xd8, 0xba, 0x5a, 0x63, 0xf0, 0x25, 0xc3, 0xe0, 0x7b, 0x86, - 0xc1, 0xcf, 0x0c, 0x83, 0x65, 0x86, 0xc1, 0x2a, 0xc3, 0xe0, 0x77, 0x86, 0xc1, 0x9f, 0x0c, 0x5b, - 0x57, 0x19, 0x06, 0x5f, 0x37, 0xd8, 0x5a, 0x6e, 0xb0, 0xb5, 0xda, 0x60, 0xeb, 0x7d, 0xab, 0xf2, - 0xb1, 0x4c, 0xea, 0xe6, 0xdd, 0x3f, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xec, 0xb4, 0x83, 0x7f, - 0x42, 0x03, 0x00, 0x00, + // 519 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x93, 0x41, 0x6f, 0xd3, 0x3c, + 0x1c, 0xc6, 0xe3, 0xf7, 0x5d, 0x96, 0xd6, 0xed, 0x90, 0x66, 0x34, 0x30, 0x1c, 0xec, 0x0a, 0xc1, + 0xd4, 0x03, 0x6d, 0x24, 0x10, 0xa7, 0x9d, 0xe8, 0x36, 0xa1, 0x4a, 0x68, 0xa0, 0x14, 0x76, 0xe0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, 0x33, 0xd3, 0x1c, + 0xb7, 0xed, 0xbc, 0xfb, 0x45, 0x46, 0xef, 0xa6, 0x5b, 0x58, 0xeb, 0xdf, 0x39, 0x91, 0x0f, 0xbd, + 0x37, 0xd3, 0xf2, 0xc6, 0xa5, 0xf8, 0xc0, 0x4e, 0x3f, 0x2a, 0x32, 0x7a, 0xa8, 0x2a, 0x54, 0x8b, + 0x6c, 0x5d, 0x83, 0xf3, 0xc5, 0x8a, 0x38, 0xcb, 0x15, 0x71, 0x6e, 0x56, 0x04, 0x7c, 0xce, 0x09, + 0xf8, 0x96, 0x13, 0xf0, 0x23, 0x27, 0x60, 0x91, 0x13, 0xb0, 0xcc, 0x09, 0xf8, 0x95, 0x13, 0xf0, + 0x3b, 0x27, 0xce, 0x4d, 0x4e, 0xc0, 0x97, 0x35, 0x71, 0x16, 0x6b, 0xe2, 0x2c, 0xd7, 0xc4, 0xf9, + 0xd0, 0xaa, 0xfd, 0x2b, 0xe3, 0x7d, 0x7b, 0xed, 0x9f, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x5c, + 0x0e, 0xf2, 0xfb, 0x41, 0x03, 0x00, 0x00, } func (this *Transaction) Equal(that interface{}) bool { @@ -230,7 +230,7 @@ func (this *Transaction) Equal(that interface{}) bool { return false } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if !__caster.Equal(this.Value, that1.Value) { return false } @@ -390,7 +390,7 @@ func (m *Transaction) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} size := __caster.Size(m.Value) i -= size if _, err := __caster.MarshalTo(m.Value, dAtA[i:]); err != nil { @@ -429,7 +429,7 @@ func (m *Transaction) Size() (n int) { n += 1 + sovTransaction(uint64(m.Nonce)) } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} l = __caster.Size(m.Value) n += 1 + l + sovTransaction(uint64(l)) } @@ -590,7 +590,7 @@ func (m *Transaction) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } { - __caster := &github_com_ElrondNetwork_elrond_go_core_data.BigIntCaster{} + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } else { diff --git a/data/transaction/transaction.proto b/data/transaction/transaction.proto index 80ff195e5..409c43f76 100644 --- a/data/transaction/transaction.proto +++ b/data/transaction/transaction.proto @@ -16,7 +16,7 @@ import "github.com/gogo/protobuf/gogoproto/gogo.proto"; // Transaction holds all the data needed for a value transfer or SC call message Transaction { uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; - bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/ElrondNetwork/elrond-go-core/data.BigIntCaster"]; + bytes Value = 2 [(gogoproto.jsontag) = "value", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; bytes RcvAddr = 3 [(gogoproto.jsontag) = "receiver"]; bytes RcvUserName = 4 [(gogoproto.jsontag) = "rcvUserName,omitempty"]; bytes SndAddr = 5 [(gogoproto.jsontag) = "sender"]; diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index 1e20e9c78..9df081bce 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -6,10 +6,10 @@ import ( "math/big" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data" - "github.com/ElrondNetwork/elrond-go-core/data/mock" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/mock" + "github.com/multiversx/mx-chain-core-go/data/transaction" "github.com/stretchr/testify/assert" ) diff --git a/data/typeConverters/uint64ByteSlice/bigEndianConverter.go b/data/typeConverters/uint64ByteSlice/bigEndianConverter.go index dac99af0f..fcca54cf9 100644 --- a/data/typeConverters/uint64ByteSlice/bigEndianConverter.go +++ b/data/typeConverters/uint64ByteSlice/bigEndianConverter.go @@ -3,7 +3,7 @@ package uint64ByteSlice import ( "encoding/binary" - "github.com/ElrondNetwork/elrond-go-core/data/typeConverters" + "github.com/multiversx/mx-chain-core-go/data/typeConverters" ) type bigEndianConverter struct { diff --git a/data/typeConverters/uint64ByteSlice/bigEndianConverter_test.go b/data/typeConverters/uint64ByteSlice/bigEndianConverter_test.go index f05dcf9bf..20b6c1bcf 100644 --- a/data/typeConverters/uint64ByteSlice/bigEndianConverter_test.go +++ b/data/typeConverters/uint64ByteSlice/bigEndianConverter_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/data/typeConverters" - "github.com/ElrondNetwork/elrond-go-core/data/typeConverters/uint64ByteSlice" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data/typeConverters" + "github.com/multiversx/mx-chain-core-go/data/typeConverters/uint64ByteSlice" "github.com/stretchr/testify/assert" ) diff --git a/data/vm/callType.go b/data/vm/callType.go index a38c2a0a8..6bf249000 100644 --- a/data/vm/callType.go +++ b/data/vm/callType.go @@ -23,3 +23,29 @@ const ( // another smart contract but the caller is from the previous caller ExecOnDestByCaller ) + +const ( + DirectCallStr = "directCall" + AsynchronousCallStr = "asynchronousCall" + AsynchronousCallBackStr = "asynchronousCallBack" + ESDTTransferAndExecuteStr = "esdtTransferAndExecute" + ExecOnDestByCallerStr = "execOnDestByCaller" + UnknownStr = "unknown" +) + +func (ct CallType) ToString() string { + switch ct { + case DirectCall: + return DirectCallStr + case AsynchronousCall: + return AsynchronousCallStr + case AsynchronousCallBack: + return AsynchronousCallBackStr + case ESDTTransferAndExecute: + return ESDTTransferAndExecuteStr + case ExecOnDestByCaller: + return ExecOnDestByCallerStr + default: + return UnknownStr + } +} diff --git a/data/vm/callType_test.go b/data/vm/callType_test.go new file mode 100644 index 000000000..f203cdc8a --- /dev/null +++ b/data/vm/callType_test.go @@ -0,0 +1,27 @@ +package vm + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestCallType_ToString(t *testing.T) { + callType := DirectCall + require.Equal(t, DirectCallStr, callType.ToString()) + + callType = AsynchronousCall + require.Equal(t, AsynchronousCallStr, callType.ToString()) + + callType = AsynchronousCallBack + require.Equal(t, AsynchronousCallBackStr, callType.ToString()) + + callType = ESDTTransferAndExecute + require.Equal(t, ESDTTransferAndExecuteStr, callType.ToString()) + + callType = ExecOnDestByCaller + require.Equal(t, ExecOnDestByCallerStr, callType.ToString()) + + callType = CallType(9999) + require.Equal(t, UnknownStr, callType.ToString()) +} diff --git a/display/placeholders_test.go b/display/placeholders_test.go index b0d0d2772..f176fd058 100644 --- a/display/placeholders_test.go +++ b/display/placeholders_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/ElrondNetwork/elrond-go-core/display" + "github.com/multiversx/mx-chain-core-go/display" "github.com/stretchr/testify/assert" ) diff --git a/go.mod b/go.mod index a3d50b95f..75abb36b0 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,28 @@ -module github.com/ElrondNetwork/elrond-go-core +module github.com/multiversx/mx-chain-core-go -go 1.13 +go 1.17 require ( - github.com/btcsuite/btcutil v1.0.2 + github.com/btcsuite/btcd/btcutil v1.1.3 github.com/denisbrodbeck/machineid v1.0.1 github.com/gogo/protobuf v1.3.2 github.com/golang/protobuf v1.5.2 + github.com/gorilla/mux v1.8.0 + github.com/gorilla/websocket v1.4.2 github.com/hashicorp/golang-lru v0.5.4 github.com/mr-tron/base58 v1.2.0 github.com/pelletier/go-toml v1.9.3 github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 - golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 + golang.org/x/crypto v0.3.0 ) -replace github.com/gogo/protobuf => github.com/ElrondNetwork/protobuf v1.3.2 +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + golang.org/x/sys v0.2.0 // indirect + google.golang.org/protobuf v1.26.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +) + +replace github.com/gogo/protobuf => github.com/multiversx/protobuf v1.3.2 diff --git a/go.sum b/go.sum index 598c86962..c3c008783 100644 --- a/go.sum +++ b/go.sum @@ -1,41 +1,78 @@ -github.com/ElrondNetwork/protobuf v1.3.2 h1:qoCSYiO+8GtXBEZWEjw0WPcZfM3g7QuuJrwpN+y6Mvg= -github.com/ElrondNetwork/protobuf v1.3.2/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= +github.com/btcsuite/btcd v0.22.0-beta.0.20220111032746-97732e52810c/go.mod h1:tjmYdS6MLJ5/s0Fj4DbLgSbDHbEqLJrtnHecBFkdz5M= +github.com/btcsuite/btcd v0.23.0 h1:V2/ZgjfDFIygAX3ZapeigkVBoVUtOJKSwrhZdlpSvaA= +github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= +github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA= +github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A= +github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= +github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= +github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.2 h1:9iZ1Terx9fMIOtq1VrwdqfsATL9MC2l8ZrUY6YZ2uts= -github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY= +github.com/btcsuite/goleveldb v1.0.0/go.mod h1:QiK9vBlgftBg6rWQIj6wFzbPfRjiykIEhBH4obrXJ/I= github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= +github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMSRhl4D7AQ= github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= 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/protobuf v1.3.2 h1:RaNkxvGTGbA0lMcnHAN24qE1G1i+Xs5yHA6MDvQ4mSM= +github.com/multiversx/protobuf v1.3.2/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -45,28 +82,64 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= +golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= @@ -75,5 +148,7 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/hashing/blake2b/blake2b.go b/hashing/blake2b/blake2b.go index 270a3c6c9..2a6b843ef 100644 --- a/hashing/blake2b/blake2b.go +++ b/hashing/blake2b/blake2b.go @@ -3,7 +3,7 @@ package blake2b import ( "hash" - "github.com/ElrondNetwork/elrond-go-core/hashing" + "github.com/multiversx/mx-chain-core-go/hashing" blake2bLib "golang.org/x/crypto/blake2b" ) diff --git a/hashing/blake2b/blake2b_test.go b/hashing/blake2b/blake2b_test.go index 44bc3ce4b..cd6200c69 100644 --- a/hashing/blake2b/blake2b_test.go +++ b/hashing/blake2b/blake2b_test.go @@ -3,7 +3,7 @@ package blake2b_test import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/hashing/blake2b" + "github.com/multiversx/mx-chain-core-go/hashing/blake2b" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" blake2bLib "golang.org/x/crypto/blake2b" diff --git a/hashing/factory/hasherFactory.go b/hashing/factory/hasherFactory.go index e6b188a83..64b5d63ad 100644 --- a/hashing/factory/hasherFactory.go +++ b/hashing/factory/hasherFactory.go @@ -1,10 +1,10 @@ package factory import ( - "github.com/ElrondNetwork/elrond-go-core/hashing" - "github.com/ElrondNetwork/elrond-go-core/hashing/blake2b" - "github.com/ElrondNetwork/elrond-go-core/hashing/keccak" - "github.com/ElrondNetwork/elrond-go-core/hashing/sha256" + "github.com/multiversx/mx-chain-core-go/hashing" + "github.com/multiversx/mx-chain-core-go/hashing/blake2b" + "github.com/multiversx/mx-chain-core-go/hashing/keccak" + "github.com/multiversx/mx-chain-core-go/hashing/sha256" ) // NewHasher will return a new instance of hasher based on the value stored in config diff --git a/hashing/factory/hasherFactory_test.go b/hashing/factory/hasherFactory_test.go index 8a70838dd..6ea9fa90a 100644 --- a/hashing/factory/hasherFactory_test.go +++ b/hashing/factory/hasherFactory_test.go @@ -3,9 +3,9 @@ package factory import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/hashing" - "github.com/ElrondNetwork/elrond-go-core/hashing/blake2b" - "github.com/ElrondNetwork/elrond-go-core/hashing/sha256" + "github.com/multiversx/mx-chain-core-go/hashing" + "github.com/multiversx/mx-chain-core-go/hashing/blake2b" + "github.com/multiversx/mx-chain-core-go/hashing/sha256" "github.com/stretchr/testify/assert" ) diff --git a/hashing/fnv/fnv.go b/hashing/fnv/fnv.go index 300007c29..9361095d9 100644 --- a/hashing/fnv/fnv.go +++ b/hashing/fnv/fnv.go @@ -3,7 +3,7 @@ package fnv import ( fnvLib "hash/fnv" - "github.com/ElrondNetwork/elrond-go-core/hashing" + "github.com/multiversx/mx-chain-core-go/hashing" ) var _ hashing.Hasher = (*fnv)(nil) diff --git a/hashing/hasher_test.go b/hashing/hasher_test.go index 746fab8c2..ec7245b10 100644 --- a/hashing/hasher_test.go +++ b/hashing/hasher_test.go @@ -4,11 +4,11 @@ import ( "sync" "testing" - "github.com/ElrondNetwork/elrond-go-core/hashing" - "github.com/ElrondNetwork/elrond-go-core/hashing/blake2b" - "github.com/ElrondNetwork/elrond-go-core/hashing/fnv" - "github.com/ElrondNetwork/elrond-go-core/hashing/keccak" - "github.com/ElrondNetwork/elrond-go-core/hashing/sha256" + "github.com/multiversx/mx-chain-core-go/hashing" + "github.com/multiversx/mx-chain-core-go/hashing/blake2b" + "github.com/multiversx/mx-chain-core-go/hashing/fnv" + "github.com/multiversx/mx-chain-core-go/hashing/keccak" + "github.com/multiversx/mx-chain-core-go/hashing/sha256" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/hashing/keccak/keccak.go b/hashing/keccak/keccak.go index 1712f8ca2..c39920d2b 100644 --- a/hashing/keccak/keccak.go +++ b/hashing/keccak/keccak.go @@ -1,7 +1,7 @@ package keccak import ( - "github.com/ElrondNetwork/elrond-go-core/hashing" + "github.com/multiversx/mx-chain-core-go/hashing" "golang.org/x/crypto/sha3" ) diff --git a/hashing/sha256/sha256.go b/hashing/sha256/sha256.go index 9517ead9e..079782e8b 100644 --- a/hashing/sha256/sha256.go +++ b/hashing/sha256/sha256.go @@ -3,7 +3,7 @@ package sha256 import ( sha256Lib "crypto/sha256" - "github.com/ElrondNetwork/elrond-go-core/hashing" + "github.com/multiversx/mx-chain-core-go/hashing" ) var _ hashing.Hasher = (*sha256)(nil) diff --git a/marshal/benchmarks_test.go b/marshal/benchmarks_test.go index 4f1b6b829..78405c328 100644 --- a/marshal/benchmarks_test.go +++ b/marshal/benchmarks_test.go @@ -6,9 +6,9 @@ import ( "math/rand" "testing" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go-core/data/transaction" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/data/transaction" + "github.com/multiversx/mx-chain-core-go/marshal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/marshal/factory/marshalizerFactory.go b/marshal/factory/marshalizerFactory.go index a27ab8cce..4f8387475 100644 --- a/marshal/factory/marshalizerFactory.go +++ b/marshal/factory/marshalizerFactory.go @@ -3,7 +3,7 @@ package factory import ( "fmt" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/marshal" ) // JsonMarshalizer is the name reserved for the json marshalizer diff --git a/marshal/factory/marshalizerFactory_test.go b/marshal/factory/marshalizerFactory_test.go index 0b9e94ec7..1c8e9a091 100644 --- a/marshal/factory/marshalizerFactory_test.go +++ b/marshal/factory/marshalizerFactory_test.go @@ -4,8 +4,8 @@ import ( "errors" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/marshal" "github.com/stretchr/testify/assert" ) diff --git a/marshal/gogoProtoMarshalizer_test.go b/marshal/gogoProtoMarshalizer_test.go index 8f2b08fba..2ceb9f423 100644 --- a/marshal/gogoProtoMarshalizer_test.go +++ b/marshal/gogoProtoMarshalizer_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - "github.com/ElrondNetwork/elrond-go-core/data/block" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/marshal" "github.com/stretchr/testify/assert" ) @@ -49,7 +49,7 @@ func TestGogoProtoMarshalizer_Marshal(t *testing.T) { func TestGogoProtoMarshalizer_MarshalWrongObj(t *testing.T) { - obj := "elrond" + obj := "multiversx" encNode, err := recovedMarshal(obj) assert.Nil(t, encNode) assert.NotNil(t, err) diff --git a/marshal/marshalizer_test.go b/marshal/marshalizer_test.go index 7fce104e7..5ae9b8fde 100644 --- a/marshal/marshalizer_test.go +++ b/marshal/marshalizer_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/marshal" "github.com/stretchr/testify/assert" ) diff --git a/marshal/testSizeCheckUnmarshal/testStructs_test.go b/marshal/testSizeCheckUnmarshal/testStructs_test.go index fbe2a92c2..cac76ae93 100644 --- a/marshal/testSizeCheckUnmarshal/testStructs_test.go +++ b/marshal/testSizeCheckUnmarshal/testStructs_test.go @@ -1,11 +1,11 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/ElrondNetwork/protobuf/protobuf --gogoslick_out=. testStruct.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. testStruct.proto package testSizeCheckUnmarshal import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/marshal" + "github.com/multiversx/mx-chain-core-go/marshal" "github.com/stretchr/testify/assert" ) diff --git a/storage/lrucache/capacity/capacityLRUCache.go b/storage/lrucache/capacity/capacityLRUCache.go index cbb5f476e..275a440d6 100644 --- a/storage/lrucache/capacity/capacityLRUCache.go +++ b/storage/lrucache/capacity/capacityLRUCache.go @@ -4,7 +4,7 @@ import ( "container/list" "sync" - "github.com/ElrondNetwork/elrond-go-core/storage" + "github.com/multiversx/mx-chain-core-go/storage" ) // capacityLRU implements a non thread safe LRU Cache with a max capacity size diff --git a/storage/lrucache/capacity/capacityLRUCache_test.go b/storage/lrucache/capacity/capacityLRUCache_test.go index b9a6bf070..c59d4877e 100644 --- a/storage/lrucache/capacity/capacityLRUCache_test.go +++ b/storage/lrucache/capacity/capacityLRUCache_test.go @@ -3,8 +3,8 @@ package capacity import ( "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/storage" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/storage" "github.com/stretchr/testify/assert" ) diff --git a/storage/lrucache/lrucache.go b/storage/lrucache/lrucache.go index b8d0c44ba..93a8d767c 100644 --- a/storage/lrucache/lrucache.go +++ b/storage/lrucache/lrucache.go @@ -3,9 +3,9 @@ package lrucache import ( "sync" - "github.com/ElrondNetwork/elrond-go-core/storage" - "github.com/ElrondNetwork/elrond-go-core/storage/lrucache/capacity" lru "github.com/hashicorp/golang-lru" + "github.com/multiversx/mx-chain-core-go/storage" + "github.com/multiversx/mx-chain-core-go/storage/lrucache/capacity" ) var _ storage.Cacher = (*lruCache)(nil) diff --git a/storage/lrucache/lrucache_test.go b/storage/lrucache/lrucache_test.go index 7e34bdcaa..8265b00cf 100644 --- a/storage/lrucache/lrucache_test.go +++ b/storage/lrucache/lrucache_test.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/ElrondNetwork/elrond-go-core/core/check" - "github.com/ElrondNetwork/elrond-go-core/storage" - "github.com/ElrondNetwork/elrond-go-core/storage/lrucache" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/storage" + "github.com/multiversx/mx-chain-core-go/storage/lrucache" "github.com/stretchr/testify/assert" ) diff --git a/storage/lrucache/simpleLRUCacheAdapter.go b/storage/lrucache/simpleLRUCacheAdapter.go index 6affa266b..82b481bd3 100644 --- a/storage/lrucache/simpleLRUCacheAdapter.go +++ b/storage/lrucache/simpleLRUCacheAdapter.go @@ -1,6 +1,6 @@ package lrucache -import "github.com/ElrondNetwork/elrond-go-core/storage" +import "github.com/multiversx/mx-chain-core-go/storage" // simpleLRUCacheAdapter provides an adapter between LRUCacheHandler and SizeLRUCacheHandler type simpleLRUCacheAdapter struct { diff --git a/websocketOutportDriver/data/errors.go b/websocketOutportDriver/data/errors.go new file mode 100644 index 000000000..41dee246b --- /dev/null +++ b/websocketOutportDriver/data/errors.go @@ -0,0 +1,36 @@ +package data + +import "errors" + +// ErrNilHttpServer signals that a nil http server has been provided +var ErrNilHttpServer = errors.New("nil http server") + +// ErrNilUint64ByteSliceConverter signals that a nil uint64 byte slice converter has been provided +var ErrNilUint64ByteSliceConverter = errors.New("nil uint64 byte slice converter") + +// ErrNilLogger signals that a nil instance of logger has been provided +var ErrNilLogger = errors.New("nil logger") + +// ErrEmptyDataToSend signals that the data that should be sent via websocket is empty +var ErrEmptyDataToSend = errors.New("empty data to send") + +// ErrNoClientToSendTo signals that the list of clients listening to messages is empty +var ErrNoClientToSendTo = errors.New("no client to send to") + +// ErrServerIsClosed represents the error thrown by the server's ListenAndServe() function when the server is closed +var ErrServerIsClosed = errors.New("http: Server closed") + +// ErrNilMarshaller signals that a nil marshaller has been provided +var ErrNilMarshaller = errors.New("nil marshaller") + +// ErrNilWebSocketSender signals that a nil web socket sender has been provided +var ErrNilWebSocketSender = errors.New("nil sender sender") + +// ErrWebSocketServerIsClosed signals that the web socket server was closed while trying to perform actions +var ErrWebSocketServerIsClosed = errors.New("server is closed") + +// ErrWebSocketClientNotFound signals that the provided websocket client was not found +var ErrWebSocketClientNotFound = errors.New("websocket client not found") + +// ErrNilWebSocketClient signals that a nil websocket client has been provided +var ErrNilWebSocketClient = errors.New("nil websocket client") diff --git a/websocketOutportDriver/data/interface.go b/websocketOutportDriver/data/interface.go new file mode 100644 index 000000000..b53850a66 --- /dev/null +++ b/websocketOutportDriver/data/interface.go @@ -0,0 +1,10 @@ +package data + +import "io" + +// WSConn defines what a sender shall do +type WSConn interface { + io.Closer + ReadMessage() (messageType int, payload []byte, err error) + WriteMessage(messageType int, data []byte) error +} diff --git a/websocketOutportDriver/data/operations.go b/websocketOutportDriver/data/operations.go new file mode 100644 index 000000000..893b392b9 --- /dev/null +++ b/websocketOutportDriver/data/operations.go @@ -0,0 +1,64 @@ +package data + +const ( + // WSRoute is the route which data will be sent over websocket + WSRoute = "/save" +) + +// WebSocketConfig holds the configuration needed for instantiating a new web socket server +type WebSocketConfig struct { + URL string + WithAcknowledge bool +} + +// OperationType defines the type to be used to group web socket operations +type OperationType uint8 + +// OperationTypeFromUint64 returns the operation type based on the provided uint64 value +func OperationTypeFromUint64(value uint64) OperationType { + return OperationType(uint8(value)) +} + +// String will return the string representation of the operation +func (ot OperationType) String() string { + switch ot { + case 0: + return "SaveBlock" + case 1: + return "RevertIndexedBlock" + case 2: + return "SaveRoundsInfo" + case 3: + return "SaveValidatorsPubKeys" + case 4: + return "SaveValidatorsRating" + case 5: + return "SaveAccounts" + case 6: + return "FinalizedBlock" + default: + return "Unknown" + } +} + +// Uint32 will return the uint32 representation of the operation +func (ot OperationType) Uint32() uint32 { + return uint32(ot) +} + +const ( + // OperationSaveBlock is the operation that triggers a block saving + OperationSaveBlock OperationType = 0 + // OperationRevertIndexedBlock is the operation that triggers a reverting of an indexed block + OperationRevertIndexedBlock OperationType = 1 + // OperationSaveRoundsInfo is the operation that triggers the saving of rounds info + OperationSaveRoundsInfo OperationType = 2 + // OperationSaveValidatorsPubKeys is the operation that triggers the saving of validators' public keys + OperationSaveValidatorsPubKeys OperationType = 3 + // OperationSaveValidatorsRating is the operation that triggers the saving of the validators' rating + OperationSaveValidatorsRating OperationType = 4 + // OperationSaveAccounts is the operation that triggers the saving of accounts + OperationSaveAccounts OperationType = 5 + // OperationFinalizedBlock is the operation that triggers the handling of a finalized block + OperationFinalizedBlock OperationType = 6 +) diff --git a/websocketOutportDriver/data/shared.go b/websocketOutportDriver/data/shared.go new file mode 100644 index 000000000..414a98cf2 --- /dev/null +++ b/websocketOutportDriver/data/shared.go @@ -0,0 +1,54 @@ +package data + +import ( + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/outport" +) + +// WsSendArgs holds the arguments needed for performing a web socket request +type WsSendArgs struct { + Payload []byte +} + +// ArgsRevertIndexedBlock holds the driver's arguments needed for reverting an indexed block +type ArgsRevertIndexedBlock struct { + HeaderType core.HeaderType + Header data.HeaderHandler + Body data.BodyHandler +} + +// ArgsSaveRoundsInfo holds the driver's arguments needed for indexing rounds info +type ArgsSaveRoundsInfo struct { + RoundsInfos []*outport.RoundInfo +} + +// ArgsSaveValidatorsPubKeys holds the driver's arguments needed for indexing validator public keys +type ArgsSaveValidatorsPubKeys struct { + ValidatorsPubKeys map[uint32][][]byte + Epoch uint32 +} + +// ArgsSaveValidatorsRating holds the driver's arguments needed for indexing validators' rating +type ArgsSaveValidatorsRating struct { + IndexID string + InfoRating []*outport.ValidatorRatingInfo +} + +// ArgsSaveAccounts holds the driver's arguments needed for indexing accounts +type ArgsSaveAccounts struct { + ShardID uint32 + BlockTimestamp uint64 + Acc map[string]*outport.AlteredAccount +} + +// ArgsFinalizedBlock holds the driver's arguments needed for handling a finalized block +type ArgsFinalizedBlock struct { + HeaderHash []byte +} + +// ArgsSaveBlock holds the driver's arguments needed for handling a save block +type ArgsSaveBlock struct { + HeaderType core.HeaderType + outport.ArgsSaveBlockData +} diff --git a/websocketOutportDriver/factory/factory.go b/websocketOutportDriver/factory/factory.go new file mode 100644 index 000000000..2bdf8a8dd --- /dev/null +++ b/websocketOutportDriver/factory/factory.go @@ -0,0 +1,126 @@ +package factory + +import ( + "net/http" + + "github.com/gorilla/mux" + "github.com/gorilla/websocket" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver" + outportData "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/sender" +) + +// OutportDriverWebSocketSenderFactoryArgs holds the arguments needed for creating a outportDriverWebSocketSenderFactory +type OutportDriverWebSocketSenderFactoryArgs struct { + WebSocketConfig outportData.WebSocketConfig + Marshaller marshal.Marshalizer + Uint64ByteSliceConverter websocketOutportDriver.Uint64ByteSliceConverter + Log core.Logger + WithAcknowledge bool +} + +type outportDriverWebSocketSenderFactory struct { + webSocketConfig outportData.WebSocketConfig + marshaller marshal.Marshalizer + uint64ByteSliceConverter websocketOutportDriver.Uint64ByteSliceConverter + log core.Logger + withAcknowledge bool +} + +// NewOutportDriverWebSocketSenderFactory will return a new instance of outportDriverWebSocketSenderFactory +func NewOutportDriverWebSocketSenderFactory(args OutportDriverWebSocketSenderFactoryArgs) (*outportDriverWebSocketSenderFactory, error) { + if check.IfNil(args.Marshaller) { + return nil, outportData.ErrNilMarshaller + } + if check.IfNil(args.Uint64ByteSliceConverter) { + return nil, outportData.ErrNilUint64ByteSliceConverter + } + if check.IfNil(args.Log) { + return nil, outportData.ErrNilLogger + } + return &outportDriverWebSocketSenderFactory{ + webSocketConfig: args.WebSocketConfig, + marshaller: args.Marshaller, + uint64ByteSliceConverter: args.Uint64ByteSliceConverter, + withAcknowledge: args.WithAcknowledge, + log: args.Log, + }, nil +} + +// Create will handle the creation of all the components needed to create an outport driver that sends data over +// web socket and return it afterwards +func (o *outportDriverWebSocketSenderFactory) Create() (websocketOutportDriver.Driver, error) { + webSocketSender, err := o.createWebSocketSender() + if err != nil { + return nil, err + } + + return websocketOutportDriver.NewWebsocketOutportDriverNodePart( + websocketOutportDriver.WebsocketOutportDriverNodePartArgs{ + Enabled: false, + Marshaller: o.marshaller, + WebsocketSender: webSocketSender, + WebSocketConfig: outportData.WebSocketConfig{}, + Uint64ByteSliceConverter: o.uint64ByteSliceConverter, + Log: o.log, + }, + ) +} + +func (o *outportDriverWebSocketSenderFactory) createWebSocketSender() (websocketOutportDriver.WebSocketSenderHandler, error) { + router := mux.NewRouter() + server := &http.Server{ + Addr: o.webSocketConfig.URL, + Handler: router, + } + + webSocketSenderArgs := sender.WebSocketSenderArgs{ + Server: server, + Uint64ByteSliceConverter: o.uint64ByteSliceConverter, + WithAcknowledge: o.withAcknowledge, + Log: o.log, + } + webSocketSender, err := sender.NewWebSocketSender(webSocketSenderArgs) + if err != nil { + return nil, err + } + + err = o.registerRoute(router, webSocketSender, outportData.WSRoute) + if err != nil { + return nil, err + } + + return webSocketSender, nil +} + +func (o *outportDriverWebSocketSenderFactory) registerRoute(router *mux.Router, webSocketHandler websocketOutportDriver.WebSocketSenderHandler, path string) error { + var upgrader = websocket.Upgrader{ + ReadBufferSize: 1024, + WriteBufferSize: 1024, + } + + routeSendData := router.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { + o.log.Info("new connection", "route", path, "remote address", r.RemoteAddr) + + upgrader.CheckOrigin = func(r *http.Request) bool { return true } + + ws, errUpgrade := upgrader.Upgrade(w, r, nil) + if errUpgrade != nil { + o.log.Warn("could not update websocket connection", "remote address", r.RemoteAddr, "error", errUpgrade) + return + } + + webSocketHandler.AddClient(ws, ws.RemoteAddr().String()) + }) + + if routeSendData.GetError() != nil { + o.log.Error("sender router failed to handle send data", + "route", routeSendData.GetName(), + "error", routeSendData.GetError()) + } + + return nil +} diff --git a/websocketOutportDriver/interface.go b/websocketOutportDriver/interface.go new file mode 100644 index 000000000..10c31c76f --- /dev/null +++ b/websocketOutportDriver/interface.go @@ -0,0 +1,36 @@ +package websocketOutportDriver + +import ( + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/outport" + outportSenderData "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" +) + +// Driver is an interface for saving node specific data to other storage. +// This could be an elastic search index, a MySql database or any other external services. +type Driver interface { + SaveBlock(args *outport.ArgsSaveBlockData) error + RevertIndexedBlock(header data.HeaderHandler, body data.BodyHandler) error + SaveRoundsInfo(roundsInfos []*outport.RoundInfo) error + SaveValidatorsPubKeys(validatorsPubKeys map[uint32][][]byte, epoch uint32) error + SaveValidatorsRating(indexID string, infoRating []*outport.ValidatorRatingInfo) error + SaveAccounts(blockTimestamp uint64, acc map[string]*outport.AlteredAccount, shardID uint32) error + FinalizedBlock(headerHash []byte) error + Close() error + IsInterfaceNil() bool +} + +// WebSocketSenderHandler defines what the actions that a web socket sender should do +type WebSocketSenderHandler interface { + Send(args outportSenderData.WsSendArgs) error + AddClient(wss outportSenderData.WSConn, remoteAddr string) + Close() error + IsInterfaceNil() bool +} + +// Uint64ByteSliceConverter converts byte slice to/from uint64 +type Uint64ByteSliceConverter interface { + ToByteSlice(uint64) []byte + ToUint64([]byte) (uint64, error) + IsInterfaceNil() bool +} diff --git a/websocketOutportDriver/mock/httpServerHandlerStub.go b/websocketOutportDriver/mock/httpServerHandlerStub.go new file mode 100644 index 000000000..e9786ec0a --- /dev/null +++ b/websocketOutportDriver/mock/httpServerHandlerStub.go @@ -0,0 +1,27 @@ +package mock + +import "context" + +// HttpServerStub - +type HttpServerStub struct { + ListenAndServeCalled func() error + ShutdownCalled func(ctx context.Context) error +} + +// ListenAndServe - +func (h *HttpServerStub) ListenAndServe() error { + if h.ListenAndServeCalled != nil { + return h.ListenAndServeCalled() + } + + return nil +} + +//Shutdown - +func (h *HttpServerStub) Shutdown(ctx context.Context) error { + if h.ShutdownCalled != nil { + return h.ShutdownCalled(ctx) + } + + return nil +} diff --git a/websocketOutportDriver/mock/uint64ByteSliceConverterStub.go b/websocketOutportDriver/mock/uint64ByteSliceConverterStub.go new file mode 100644 index 000000000..43886ecb8 --- /dev/null +++ b/websocketOutportDriver/mock/uint64ByteSliceConverterStub.go @@ -0,0 +1,30 @@ +package mock + +// Uint64ByteSliceConverterStub - +type Uint64ByteSliceConverterStub struct { + ToByteSliceCalled func(u2 uint64) []byte + ToUint64Called func(bytes []byte) (uint64, error) +} + +// ToByteSlice - +func (u *Uint64ByteSliceConverterStub) ToByteSlice(u2 uint64) []byte { + if u.ToByteSliceCalled != nil { + return u.ToByteSliceCalled(u2) + } + + return nil +} + +// ToUint64 - +func (u *Uint64ByteSliceConverterStub) ToUint64(bytes []byte) (uint64, error) { + if u.ToUint64Called != nil { + return u.ToUint64Called(bytes) + } + + return 0, nil +} + +// IsInterfaceNil - +func (u *Uint64ByteSliceConverterStub) IsInterfaceNil() bool { + return u == nil +} diff --git a/websocketOutportDriver/mock/webSocketSenderStub.go b/websocketOutportDriver/mock/webSocketSenderStub.go new file mode 100644 index 000000000..e475245d6 --- /dev/null +++ b/websocketOutportDriver/mock/webSocketSenderStub.go @@ -0,0 +1,42 @@ +package mock + +import ( + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" +) + +// WebSocketSenderStub - +type WebSocketSenderStub struct { + SendOnRouteCalled func(args data.WsSendArgs) error + AddClientCalled func(wss data.WSConn, remoteAddr string) + CloseCalled func() error +} + +// AddClient - +func (w *WebSocketSenderStub) AddClient(wss data.WSConn, remoteAddr string) { + if w.AddClientCalled != nil { + w.AddClientCalled(wss, remoteAddr) + } +} + +// Send - +func (w *WebSocketSenderStub) Send(args data.WsSendArgs) error { + if w.SendOnRouteCalled != nil { + return w.SendOnRouteCalled(args) + } + + return nil +} + +// Close - +func (w *WebSocketSenderStub) Close() error { + if w.CloseCalled != nil { + return w.CloseCalled() + } + + return nil +} + +// IsInterfaceNil - +func (w *WebSocketSenderStub) IsInterfaceNil() bool { + return w == nil +} diff --git a/websocketOutportDriver/mock/websocketConnectionStub.go b/websocketOutportDriver/mock/websocketConnectionStub.go new file mode 100644 index 000000000..1862e63a3 --- /dev/null +++ b/websocketOutportDriver/mock/websocketConnectionStub.go @@ -0,0 +1,35 @@ +package mock + +// WebsocketConnectionStub - +type WebsocketConnectionStub struct { + ReadMessageCalled func() (messageType int, payload []byte, err error) + WriteMessageCalled func(messageType int, data []byte) error + CloseCalled func() error +} + +// ReadMessage - +func (w *WebsocketConnectionStub) ReadMessage() (messageType int, payload []byte, err error) { + if w.ReadMessageCalled != nil { + return w.ReadMessageCalled() + } + + return 0, nil, err +} + +// WriteMessage - +func (w *WebsocketConnectionStub) WriteMessage(messageType int, data []byte) error { + if w.WriteMessageCalled != nil { + return w.WriteMessageCalled(messageType, data) + } + + return nil +} + +// Close - +func (w *WebsocketConnectionStub) Close() error { + if w.CloseCalled != nil { + return w.CloseCalled() + } + + return nil +} diff --git a/websocketOutportDriver/payloadParser.go b/websocketOutportDriver/payloadParser.go new file mode 100644 index 000000000..43f682243 --- /dev/null +++ b/websocketOutportDriver/payloadParser.go @@ -0,0 +1,154 @@ +package websocketOutportDriver + +import ( + "bytes" + "encoding/hex" + "fmt" + + "github.com/multiversx/mx-chain-core-go/core/check" + dataCore "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/outport" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" +) + +const ( + withAcknowledgeNumBytes = 1 + uint64NumBytes = 8 + uint32NumBytes = 4 +) + +var ( + minBytesForCorrectPayload = withAcknowledgeNumBytes + uint64NumBytes + uint32NumBytes + uint32NumBytes +) + +// PayloadData holds the arguments that should be parsed from a websocket payload +type PayloadData struct { + WithAcknowledge bool + Counter uint64 + OperationType data.OperationType + Payload []byte +} + +type websocketPayloadParser struct { + uint64ByteSliceConverter Uint64ByteSliceConverter +} + +// NewWebSocketPayloadParser returns a new instance of websocketPayloadParser +func NewWebSocketPayloadParser(uint64ByteSliceConverter Uint64ByteSliceConverter) (*websocketPayloadParser, error) { + if check.IfNil(uint64ByteSliceConverter) { + return nil, data.ErrNilUint64ByteSliceConverter + } + + return &websocketPayloadParser{ + uint64ByteSliceConverter: uint64ByteSliceConverter, + }, nil +} + +// ExtractPayloadData will extract the data from the received payload +// It should have the following form: +// first byte - with acknowledge or not +// next 8 bytes - counter (uint64 big endian) +// next 4 bytes - operation type (uint32 big endian) +// next 4 bytes - message length (uint32 big endian) +// next X bytes - the actual data to parse +func (wpp *websocketPayloadParser) ExtractPayloadData(payload []byte) (*PayloadData, error) { + if len(payload) < minBytesForCorrectPayload { + return nil, fmt.Errorf("invalid payload. minimum required length is %d bytes, but only provided %d", + minBytesForCorrectPayload, + len(payload)) + } + + var err error + payloadData := &PayloadData{ + WithAcknowledge: false, + } + + if payload[0] == byte(1) { + payloadData.WithAcknowledge = true + } + payload = payload[withAcknowledgeNumBytes:] + + counterBytes := payload[:uint64NumBytes] + payloadData.Counter, err = wpp.uint64ByteSliceConverter.ToUint64(counterBytes) + if err != nil { + return nil, fmt.Errorf("%w while extracting the counter from the payload", err) + } + payload = payload[uint64NumBytes:] + + operationTypeBytes := payload[:uint32NumBytes] + var operationTypeUint64 uint64 + operationTypeUint64, err = wpp.uint64ByteSliceConverter.ToUint64(padUint32ByteSlice(operationTypeBytes)) + if err != nil { + return nil, fmt.Errorf("%w while extracting the counter from the payload", err) + } + payloadData.OperationType = data.OperationTypeFromUint64(operationTypeUint64) + payload = payload[uint32NumBytes:] + + var messageLen uint64 + messageLen, err = wpp.uint64ByteSliceConverter.ToUint64(padUint32ByteSlice(payload[:uint32NumBytes])) + if err != nil { + return nil, fmt.Errorf("%w while extracting the message length", err) + } + payload = payload[uint32NumBytes:] + + if messageLen != uint64(len(payload)) { + return nil, fmt.Errorf("message counter is not equal to the actual payload. provided: %d, actual: %d", + messageLen, len(payload)) + } + + payloadData.Payload = payload + + return payloadData, nil +} + +func padUint32ByteSlice(initial []byte) []byte { + padding := bytes.Repeat([]byte{0}, 4) + return append(padding, initial...) +} + +// PrepareArgsSaveBlock will prepare save block data +func PrepareArgsSaveBlock(args outport.ArgsSaveBlockData) outport.ArgsSaveBlockData { + var pool *outport.Pool + if args.TransactionsPool != nil { + pool = &outport.Pool{ + Txs: prepareTxs(args.TransactionsPool.Txs), + Scrs: prepareTxs(args.TransactionsPool.Scrs), + Rewards: prepareTxs(args.TransactionsPool.Rewards), + Invalid: prepareTxs(args.TransactionsPool.Invalid), + Receipts: prepareTxs(args.TransactionsPool.Receipts), + Logs: prepareLogs(args.TransactionsPool.Logs), + } + } + + return outport.ArgsSaveBlockData{ + HeaderHash: args.HeaderHash, + Body: args.Body, + Header: args.Header, + SignersIndexes: args.SignersIndexes, + NotarizedHeadersHashes: args.NotarizedHeadersHashes, + HeaderGasConsumption: args.HeaderGasConsumption, + TransactionsPool: pool, + AlteredAccounts: args.AlteredAccounts, + NumberOfShards: args.NumberOfShards, + IsImportDB: args.IsImportDB, + } +} + +func prepareLogs(initial []*dataCore.LogData) []*dataCore.LogData { + res := make([]*dataCore.LogData, 0, len(initial)) + for _, logHandler := range initial { + res = append(res, &dataCore.LogData{ + LogHandler: logHandler.LogHandler, + TxHash: hex.EncodeToString([]byte(logHandler.TxHash)), + }) + } + return res +} + +func prepareTxs(initial map[string]dataCore.TransactionHandlerWithGasUsedAndFee) map[string]dataCore.TransactionHandlerWithGasUsedAndFee { + res := make(map[string]dataCore.TransactionHandlerWithGasUsedAndFee) + for txHash, tx := range initial { + res[hex.EncodeToString([]byte(txHash))] = tx + } + return res +} diff --git a/websocketOutportDriver/payloadParser_test.go b/websocketOutportDriver/payloadParser_test.go new file mode 100644 index 000000000..7a97ca7d6 --- /dev/null +++ b/websocketOutportDriver/payloadParser_test.go @@ -0,0 +1,148 @@ +package websocketOutportDriver + +import ( + "bytes" + "errors" + "strings" + "testing" + + "github.com/multiversx/mx-chain-core-go/data/typeConverters/uint64ByteSlice" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/mock" + "github.com/stretchr/testify/require" +) + +var uint64ByteSliceConv = uint64ByteSlice.NewBigEndianConverter() + +func TestNewWebSocketPayloadParser(t *testing.T) { + t.Parallel() + + t.Run("nil uint64 byte slice converter", func(t *testing.T) { + wpp, err := NewWebSocketPayloadParser(nil) + require.Equal(t, data.ErrNilUint64ByteSliceConverter, err) + require.Nil(t, wpp) + }) + + t.Run("constructor should work", func(t *testing.T) { + wpp, err := NewWebSocketPayloadParser(uint64ByteSliceConv) + require.NoError(t, err) + require.NotNil(t, wpp) + }) +} + +func TestWebsocketPayloadParser_ExtractPayloadData(t *testing.T) { + t.Run("invalid payload length", testExtractPayloadDataInvalidLength) + t.Run("invalid counter byte slice", testExtractPayloadDataInvalidCounterByteSlice) + t.Run("invalid operation type byte slice", testExtractPayloadDataInvalidOperationTypeByteSlice) + t.Run("invalid message counter byte slice", testExtractPayloadDataInvalidMessageCounterByteSlice) + t.Run("invalid payload - message counter vs actual payload size", testExtractPayloadDataMessageCounterDoesNotMatchActualPayloadSize) + t.Run("should work", testExtractPayloadDataShouldWork) +} + +func testExtractPayloadDataInvalidLength(t *testing.T) { + parser, _ := NewWebSocketPayloadParser(uint64ByteSliceConv) + res, err := parser.ExtractPayloadData([]byte("invalid")) + require.Nil(t, res) + require.Error(t, err) + require.True(t, strings.Contains(err.Error(), "invalid payload")) +} + +func testExtractPayloadDataInvalidCounterByteSlice(t *testing.T) { + localErr := errors.New("local error") + uint64ConvStub := &mock.Uint64ByteSliceConverterStub{ + ToUint64Called: func(_ []byte) (uint64, error) { + return 0, localErr + }, + } + parser, _ := NewWebSocketPayloadParser(uint64ConvStub) + res, err := parser.ExtractPayloadData(bytes.Repeat([]byte{0}, minBytesForCorrectPayload)) + require.Nil(t, res) + require.Error(t, err) + require.True(t, errors.Is(err, localErr)) +} + +func testExtractPayloadDataInvalidOperationTypeByteSlice(t *testing.T) { + localErr := errors.New("local error") + numCalled := 0 + uint64ConvStub := &mock.Uint64ByteSliceConverterStub{ + ToUint64Called: func(_ []byte) (uint64, error) { + numCalled++ + if numCalled == 2 { + return 0, localErr + } + + return 0, nil + }, + } + parser, _ := NewWebSocketPayloadParser(uint64ConvStub) + res, err := parser.ExtractPayloadData(bytes.Repeat([]byte{0}, minBytesForCorrectPayload)) + require.Nil(t, res) + require.Error(t, err) + require.True(t, errors.Is(err, localErr)) +} + +func testExtractPayloadDataInvalidMessageCounterByteSlice(t *testing.T) { + localErr := errors.New("local error") + numCalled := 0 + uint64ConvStub := &mock.Uint64ByteSliceConverterStub{ + ToUint64Called: func(_ []byte) (uint64, error) { + numCalled++ + if numCalled == 3 { + return 0, localErr + } + + return 0, nil + }, + } + parser, _ := NewWebSocketPayloadParser(uint64ConvStub) + res, err := parser.ExtractPayloadData(bytes.Repeat([]byte{0}, minBytesForCorrectPayload)) + require.Nil(t, res) + require.Error(t, err) + require.True(t, errors.Is(err, localErr)) +} + +func testExtractPayloadDataMessageCounterDoesNotMatchActualPayloadSize(t *testing.T) { + uint64ConvStub := &mock.Uint64ByteSliceConverterStub{ + ToUint64Called: func(_ []byte) (uint64, error) { + return 0, nil + }, + } + parser, _ := NewWebSocketPayloadParser(uint64ConvStub) + res, err := parser.ExtractPayloadData(bytes.Repeat([]byte{0}, minBytesForCorrectPayload+2)) + require.Nil(t, res) + require.Error(t, err) + require.True(t, strings.Contains(err.Error(), "message counter is not equal")) +} + +func testExtractPayloadDataShouldWork(t *testing.T) { + parser, _ := NewWebSocketPayloadParser(uint64ByteSliceConv) + + expectedCounter := uint64(9) + expectedOperation := data.OperationSaveAccounts + expectedPayload := []byte("actual payload data") + + payload := make([]byte, 1) + payload[0] = byte(1) // with ack + + counterBytes := bytes.Repeat([]byte{0}, uint64NumBytes) + counterBytes[uint64NumBytes-1] = byte(expectedCounter) + payload = append(payload, counterBytes...) + + operationBytes := bytes.Repeat([]byte{0}, uint32NumBytes) + operationBytes[uint32NumBytes-1] = byte(expectedOperation.Uint32()) + payload = append(payload, operationBytes...) + + messageLenBytes := bytes.Repeat([]byte{0}, uint32NumBytes) + messageLenBytes[uint32NumBytes-1] = byte(len(expectedPayload)) + payload = append(payload, messageLenBytes...) + + payload = append(payload, expectedPayload...) + + res, err := parser.ExtractPayloadData(payload) + require.NoError(t, err) + require.NotNil(t, res) + require.True(t, res.WithAcknowledge) + require.Equal(t, expectedCounter, res.Counter) + require.Equal(t, expectedOperation, res.OperationType) + require.Equal(t, expectedPayload, res.Payload) +} diff --git a/websocketOutportDriver/sender/acknowledgesHolder.go b/websocketOutportDriver/sender/acknowledgesHolder.go new file mode 100644 index 000000000..f4b5221c0 --- /dev/null +++ b/websocketOutportDriver/sender/acknowledgesHolder.go @@ -0,0 +1,52 @@ +package sender + +import "sync" + +type acknowledgesHolder struct { + acknowledges map[string]*websocketClientAcknowledgesHolder + mut sync.Mutex +} + +// NewAcknowledgesHolder returns a new instance of acknowledgesHolder +func NewAcknowledgesHolder() *acknowledgesHolder { + return &acknowledgesHolder{ + acknowledges: make(map[string]*websocketClientAcknowledgesHolder), + } +} + +// AddEntry will add the client to the inner map +func (ah *acknowledgesHolder) AddEntry(remoteAddr string) { + ah.mut.Lock() + ah.acknowledges[remoteAddr] = NewWebsocketClientAcknowledgesHolder() + ah.mut.Unlock() +} + +// GetAcknowledgesOfAddress will return the acknowledges for the specified address, if any +func (ah *acknowledgesHolder) GetAcknowledgesOfAddress(remoteAddr string) (*websocketClientAcknowledgesHolder, bool) { + ah.mut.Lock() + defer ah.mut.Unlock() + + acks, found := ah.acknowledges[remoteAddr] + return acks, found +} + +// RemoveEntryForAddress will remove the provided address from the internal map +func (ah *acknowledgesHolder) RemoveEntryForAddress(remoteAddr string) { + ah.mut.Lock() + delete(ah.acknowledges, remoteAddr) + ah.mut.Unlock() +} + +// AddReceivedAcknowledge will add the received acknowledge as a counter for the given address +func (ah *acknowledgesHolder) AddReceivedAcknowledge(remoteAddr string, counter uint64) bool { + ah.mut.Lock() + defer ah.mut.Unlock() + + acks, found := ah.acknowledges[remoteAddr] + if !found { + return false + } + + acks.Add(counter) + return true +} diff --git a/websocketOutportDriver/sender/acknowledgesHolder_test.go b/websocketOutportDriver/sender/acknowledgesHolder_test.go new file mode 100644 index 000000000..929ecfb67 --- /dev/null +++ b/websocketOutportDriver/sender/acknowledgesHolder_test.go @@ -0,0 +1,130 @@ +package sender + +import ( + "sync" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestNewAcknowledgesHolder(t *testing.T) { + t.Parallel() + + ah := NewAcknowledgesHolder() + require.NotNil(t, ah) +} + +func TestAcknowledgesHolder_AddEntry(t *testing.T) { + t.Parallel() + + remAddr := "test address" + ah := NewAcknowledgesHolder() + ah.AddEntry(remAddr) + + ah.mut.Lock() + res, found := ah.acknowledges[remAddr] + ah.mut.Unlock() + + require.True(t, found) + require.NotNil(t, res) +} + +func TestAcknowledgesHolder_AddReceivedAcknowledge(t *testing.T) { + t.Parallel() + + remAddr := "test address" + counter := uint64(37) + ah := NewAcknowledgesHolder() + ah.AddEntry(remAddr) + + ah.AddReceivedAcknowledge(remAddr, counter) + + ah.mut.Lock() + found := ah.acknowledges[remAddr].ProcessAcknowledged(counter) + ah.mut.Unlock() + + require.True(t, found) +} + +func TestAcknowledgesHolder_GetAcknowledgesOfAddress(t *testing.T) { + t.Parallel() + + t.Run("GetAcknowledgesOfAddress: not found", func(t *testing.T) { + t.Parallel() + + ah := NewAcknowledgesHolder() + + res, found := ah.GetAcknowledgesOfAddress("new addr") + require.False(t, found) + require.Nil(t, res) + }) + + t.Run("GetAcknowledgesOfAddress: should work", func(t *testing.T) { + t.Parallel() + + remAddr := "test address" + counter0, counter1 := uint64(37), uint64(38) + ah := NewAcknowledgesHolder() + ah.AddEntry(remAddr) + + ah.AddReceivedAcknowledge(remAddr, counter0) + ah.AddReceivedAcknowledge(remAddr, counter1) + + acks, found := ah.GetAcknowledgesOfAddress(remAddr) + require.True(t, found) + + found0 := acks.ProcessAcknowledged(counter0) + found1 := acks.ProcessAcknowledged(counter1) + + require.True(t, found0) + require.True(t, found1) + }) +} + +func TestAcknowledgesHolder_RemoveEntryForAddress(t *testing.T) { + t.Parallel() + + remAddr := "remote addr" + + ah := NewAcknowledgesHolder() + + ah.AddEntry(remAddr) + ah.RemoveEntryForAddress(remAddr) + + ah.mut.Lock() + _, found := ah.acknowledges[remAddr] + ah.mut.Unlock() + + require.False(t, found) +} + +func TestAcknowledgesHolder_ConcurrentOperations(t *testing.T) { + t.Parallel() + + ah := NewAcknowledgesHolder() + + defer func() { + r := recover() + require.Nil(t, r) + }() + + wg := sync.WaitGroup{} + wg.Add(100) + + for i := uint64(0); i < 100; i++ { + go func(index uint64) { + switch index % 4 { + case 0: + ah.AddReceivedAcknowledge("addr", index) + case 1: + _, _ = ah.GetAcknowledgesOfAddress("addr") + case 2: + ah.RemoveEntryForAddress("addr") + case 3: + ah.AddEntry("addr") + } + wg.Done() + }(i) + } + wg.Wait() +} diff --git a/websocketOutportDriver/sender/interface.go b/websocketOutportDriver/sender/interface.go new file mode 100644 index 000000000..9403b0a0b --- /dev/null +++ b/websocketOutportDriver/sender/interface.go @@ -0,0 +1,16 @@ +package sender + +import "context" + +// Uint64ByteSliceConverter converts byte slice to/from uint64 +type Uint64ByteSliceConverter interface { + ToByteSlice(uint64) []byte + ToUint64([]byte) (uint64, error) + IsInterfaceNil() bool +} + +// HttpServerHandler defines the minimum behaviour of a http server +type HttpServerHandler interface { + ListenAndServe() error + Shutdown(ctx context.Context) error +} diff --git a/websocketOutportDriver/sender/webSocketSender.go b/websocketOutportDriver/sender/webSocketSender.go new file mode 100644 index 000000000..9bbfd2730 --- /dev/null +++ b/websocketOutportDriver/sender/webSocketSender.go @@ -0,0 +1,249 @@ +package sender + +import ( + "context" + "fmt" + "strings" + "sync/atomic" + "time" + + "github.com/gorilla/websocket" + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/check" + outportData "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" +) + +var ( + prefixWithAck = []byte{1} + prefixWithoutAck = []byte{0} +) + +type webSocketClient struct { + conn outportData.WSConn + remoteAddr string +} + +type webSocketSender struct { + log core.Logger + // TODO: use an interface for http server (or simply provide the URL only) in order to make this component easy testable + server HttpServerHandler + counter uint64 + uint64ByteSliceConverter Uint64ByteSliceConverter + // TODO: use interfaces instead of direct instances + analyze returning pointers vs values on exported functions + clientsHolder *websocketClientsHolder + acknowledges *acknowledgesHolder + withAcknowledge bool +} + +// WebSocketSenderArgs holds the arguments needed for creating a new instance of webSocketSender +type WebSocketSenderArgs struct { + Server HttpServerHandler + Uint64ByteSliceConverter Uint64ByteSliceConverter + WithAcknowledge bool + Log core.Logger +} + +// NewWebSocketSender returns a new instance of webSocketSender +func NewWebSocketSender(args WebSocketSenderArgs) (*webSocketSender, error) { + if args.Server == nil { + return nil, outportData.ErrNilHttpServer + } + if check.IfNil(args.Uint64ByteSliceConverter) { + return nil, outportData.ErrNilUint64ByteSliceConverter + } + if check.IfNil(args.Log) { + return nil, outportData.ErrNilLogger + } + + ws := &webSocketSender{ + log: args.Log, + server: args.Server, + counter: 0, + uint64ByteSliceConverter: args.Uint64ByteSliceConverter, + clientsHolder: NewWebsocketClientsHolder(), + acknowledges: NewAcknowledgesHolder(), + withAcknowledge: args.WithAcknowledge, + } + + go ws.start() + + return ws, nil +} + +// AddClient will add the client to internal maps and will also start +func (w *webSocketSender) AddClient(wss outportData.WSConn, remoteAddr string) { + if wss == nil { + w.log.Warn("nil ws connection provider", "remote addr", remoteAddr) + return + } + + client := &webSocketClient{ + conn: wss, + remoteAddr: remoteAddr, + } + + err := w.clientsHolder.AddClient(client) + if err != nil { + w.log.Warn("cannot AddClient", "error", err) + return + } + + // TODO: maybe multiple clients types could be supported: some require ack, while some don't require ack + if !w.withAcknowledge { + return + } + + w.acknowledges.AddEntry(remoteAddr) + + go w.handleReceiveAck(client) +} + +func (w *webSocketSender) handleReceiveAck(client *webSocketClient) { + for { + mType, message, err := client.conn.ReadMessage() + if err != nil { + w.log.Error("cannot read message", "remote addr", client.remoteAddr, "error", err) + + err = w.clientsHolder.CloseAndRemove(client.remoteAddr) + w.log.LogIfError(err) + + w.acknowledges.RemoveEntryForAddress(client.remoteAddr) + + break + } + + if mType != websocket.BinaryMessage { + w.log.Warn("received message is not binary message", "remote addr", client.remoteAddr, "message type", mType) + continue + } + + w.log.Trace("received ack", "remote addr", client.remoteAddr, "message", message) + counter, err := w.uint64ByteSliceConverter.ToUint64(message) + if err != nil { + w.log.Warn("cannot decode counter: bytes to uint64", + "remote addr", client.remoteAddr, + "counter bytes", message, + "error", err, + ) + continue + } + + w.acknowledges.AddReceivedAcknowledge(client.remoteAddr, counter) + } +} + +func (w *webSocketSender) start() { + err := w.server.ListenAndServe() + if err != nil && !strings.Contains(err.Error(), outportData.ErrServerIsClosed.Error()) { + w.log.Error("could not initialize webserver", "error", err) + } +} + +func (w *webSocketSender) sendDataToClients( + data []byte, + counter uint64, +) error { + numSent := 0 + var err error + + clients := w.clientsHolder.GetAll() + if len(clients) == 0 { + return outportData.ErrNoClientToSendTo + } + + for _, client := range w.clientsHolder.GetAll() { + err = w.sendData(data, *client, counter) + if err != nil { + w.log.Error("couldn't send data to client", "error", err) + continue + } + + numSent++ + } + + if numSent == 0 { + return fmt.Errorf("data wasn't sent to any client. last known error: %w", err) + } + + return nil +} + +func (w *webSocketSender) sendData( + data []byte, + client webSocketClient, + counter uint64, +) error { + if len(data) == 0 { + return outportData.ErrEmptyDataToSend + } + + errSend := client.conn.WriteMessage(websocket.BinaryMessage, data) + if errSend != nil { + // TODO: test if this is a situation when the client connection should be dropped + w.log.Warn("could not send data to client", "remote addr", client.remoteAddr, "error", errSend) + return fmt.Errorf("%w while writing message to client %s", errSend, client.remoteAddr) + } + + if !w.withAcknowledge { + return nil + } + + // TODO: might refactor this (send to each clients, then wait for all VS send to one client, wait for it, move to next) + w.waitForAck(client.remoteAddr, counter) + + return nil +} + +func (w *webSocketSender) waitForAck(remoteAddr string, counter uint64) { + for { + acksForAddress, ok := w.acknowledges.GetAcknowledgesOfAddress(remoteAddr) + if !ok { + w.log.Warn("waiting acknowledge for an address that isn't present anymore in clients map", "remote addr", remoteAddr) + return + } + + ok = acksForAddress.ProcessAcknowledged(counter) + if ok { + return + } + + time.Sleep(time.Millisecond) + } +} + +// Send will make the request accordingly to the received arguments +func (w *webSocketSender) Send(args outportData.WsSendArgs) error { + assignedCounter := atomic.AddUint64(&w.counter, 1) + ackData := prefixWithoutAck + if w.withAcknowledge { + ackData = prefixWithAck + } + + newPayload := append(ackData, w.uint64ByteSliceConverter.ToByteSlice(assignedCounter)...) + newPayload = append(newPayload, args.Payload...) + + return w.sendDataToClients(newPayload, assignedCounter) +} + +// Close will close the server and the connections with the clients +func (w *webSocketSender) Close() error { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + err := w.server.Shutdown(ctx) + if err != nil { + w.log.Error("cannot close the server", "error", err) + } + + for _, client := range w.clientsHolder.GetAll() { + err = client.conn.Close() + w.log.LogIfError(err) + } + + return nil +} + +// IsInterfaceNil returns true if there is no value under the interface +func (w *webSocketSender) IsInterfaceNil() bool { + return w == nil +} diff --git a/websocketOutportDriver/sender/webSocketSender_test.go b/websocketOutportDriver/sender/webSocketSender_test.go new file mode 100644 index 000000000..b150f733c --- /dev/null +++ b/websocketOutportDriver/sender/webSocketSender_test.go @@ -0,0 +1,213 @@ +package sender + +import ( + "errors" + "testing" + "time" + + "github.com/gorilla/websocket" + coreMock "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/mock" + "github.com/stretchr/testify/require" +) + +func TestNewWebSocketSender(t *testing.T) { + t.Parallel() + + t.Run("nil server", func(t *testing.T) { + t.Parallel() + + args := getMockWebSocketSender() + args.Server = nil + + wss, err := NewWebSocketSender(args) + require.Nil(t, wss) + require.Equal(t, data.ErrNilHttpServer, err) + }) + + t.Run("nil uint64 byte slice converter", func(t *testing.T) { + t.Parallel() + + args := getMockWebSocketSender() + args.Uint64ByteSliceConverter = nil + + wss, err := NewWebSocketSender(args) + require.Nil(t, wss) + require.Equal(t, data.ErrNilUint64ByteSliceConverter, err) + }) + + t.Run("nil logger", func(t *testing.T) { + t.Parallel() + + args := getMockWebSocketSender() + args.Log = nil + + wss, err := NewWebSocketSender(args) + require.Nil(t, wss) + require.Equal(t, data.ErrNilLogger, err) + require.True(t, wss.IsInterfaceNil()) + }) + + t.Run("should work", func(t *testing.T) { + t.Parallel() + + args := getMockWebSocketSender() + + wss, err := NewWebSocketSender(args) + require.NoError(t, err) + require.NotNil(t, wss) + require.False(t, wss.IsInterfaceNil()) + }) +} + +func TestWebSocketSender_AddClient(t *testing.T) { + t.Parallel() + + t.Run("nil client", func(t *testing.T) { + t.Parallel() + + wss, _ := NewWebSocketSender(getMockWebSocketSender()) + + wss.AddClient(nil, "remote addr") + require.Equal(t, 0, len(wss.clientsHolder.GetAll())) + }) + + t.Run("should work - without acknowledge", func(t *testing.T) { + t.Parallel() + + wss, _ := NewWebSocketSender(getMockWebSocketSender()) + + wss.AddClient(&mock.WebsocketConnectionStub{}, "remote addr") + + clients := wss.clientsHolder.GetAll() + require.NotNil(t, clients["remote addr"]) + + wss.acknowledges.mut.Lock() + acksForAddress := wss.acknowledges.acknowledges["remote addr"] + wss.acknowledges.mut.Unlock() + + require.Nil(t, acksForAddress) + }) + + t.Run("should work - with acknowledge", func(t *testing.T) { + t.Parallel() + + args := getMockWebSocketSender() + args.WithAcknowledge = true + + wss, _ := NewWebSocketSender(args) + + wss.AddClient(&mock.WebsocketConnectionStub{ + ReadMessageCalled: func() (_ int, _ []byte, err error) { + err = errors.New("early exit - close the go routine") + return + }, + }, "remote addr") + + clients := wss.clientsHolder.GetAll() + require.NotNil(t, clients["remote addr"]) + + wss.acknowledges.mut.Lock() + acksForAddress := wss.acknowledges.acknowledges["remote addr"] + wss.acknowledges.mut.Unlock() + + require.NotNil(t, acksForAddress) + }) +} + +func TestWebSocketSender_Send(t *testing.T) { + t.Parallel() + + t.Run("should error because no clients exist", func(t *testing.T) { + t.Parallel() + + wss, _ := NewWebSocketSender(getMockWebSocketSender()) + + err := wss.Send(data.WsSendArgs{ + Payload: []byte("payload"), + }) + require.Equal(t, data.ErrNoClientToSendTo, err) + }) + + t.Run("should work - without acknowledge", func(t *testing.T) { + t.Parallel() + + wss, _ := NewWebSocketSender(getMockWebSocketSender()) + + wss.AddClient(&mock.WebsocketConnectionStub{ + ReadMessageCalled: func() (_ int, _ []byte, err error) { + err = errors.New("early exit - close the go routine") + return + }, + }, "remote addr") + + err := wss.Send(data.WsSendArgs{ + Payload: []byte("payload"), + }) + require.NoError(t, err) + }) + + t.Run("should work - with acknowledge", func(t *testing.T) { + t.Parallel() + + args := getMockWebSocketSender() + args.WithAcknowledge = true + wss, _ := NewWebSocketSender(args) + + var ack []byte + + chClientAck := make(chan bool) + wasMsgProcessed := false + + wss.AddClient(&mock.WebsocketConnectionStub{ + ReadMessageCalled: func() (msgType int, payload []byte, err error) { + if wasMsgProcessed { + time.Sleep(100 * time.Millisecond) + msgType = websocket.BinaryMessage + err = errors.New("end") + return + } + + <-chClientAck + + time.Sleep(100 * time.Millisecond) + + msgType = websocket.BinaryMessage + payload = ack + err = nil + wasMsgProcessed = true + + return + }, + WriteMessageCalled: func(_ int, data []byte) error { + ack = data[1:3] + chClientAck <- true + + return nil + }, + }, "remote addr") + + err := wss.Send(data.WsSendArgs{ + Payload: []byte("payload"), + }) + require.NoError(t, err) + }) +} + +func TestWebSocketSender_Close(t *testing.T) { + t.Parallel() + + wss, _ := NewWebSocketSender(getMockWebSocketSender()) + + err := wss.Close() + require.NoError(t, err) +} + +func getMockWebSocketSender() WebSocketSenderArgs { + return WebSocketSenderArgs{ + Server: &mock.HttpServerStub{}, + Uint64ByteSliceConverter: &mock.Uint64ByteSliceConverterStub{}, + Log: coreMock.LoggerMock{}, + } +} diff --git a/websocketOutportDriver/sender/websocketClientAcknowledgesHolder.go b/websocketOutportDriver/sender/websocketClientAcknowledgesHolder.go new file mode 100644 index 000000000..d4e7a9e3d --- /dev/null +++ b/websocketOutportDriver/sender/websocketClientAcknowledgesHolder.go @@ -0,0 +1,37 @@ +package sender + +import "sync" + +type websocketClientAcknowledgesHolder struct { + acks map[uint64]struct{} + mutAcks sync.Mutex +} + +// NewWebsocketClientAcknowledgesHolder will return a new instance of websocketAcknowledgesHolder +func NewWebsocketClientAcknowledgesHolder() *websocketClientAcknowledgesHolder { + return &websocketClientAcknowledgesHolder{ + acks: make(map[uint64]struct{}), + } +} + +// Add will add an element +func (wah *websocketClientAcknowledgesHolder) Add(counter uint64) { + wah.mutAcks.Lock() + wah.acks[counter] = struct{}{} + wah.mutAcks.Unlock() +} + +// ProcessAcknowledged will process the acknowledgment for the given counter. If found, the element will also be +// removed from the inner map +func (wah *websocketClientAcknowledgesHolder) ProcessAcknowledged(counter uint64) bool { + wah.mutAcks.Lock() + defer wah.mutAcks.Unlock() + + _, exists := wah.acks[counter] + if !exists { + return false + } + + delete(wah.acks, counter) + return true +} diff --git a/websocketOutportDriver/sender/websocketClientAcknowledgesHolder_test.go b/websocketOutportDriver/sender/websocketClientAcknowledgesHolder_test.go new file mode 100644 index 000000000..f78523ed7 --- /dev/null +++ b/websocketOutportDriver/sender/websocketClientAcknowledgesHolder_test.go @@ -0,0 +1,84 @@ +package sender + +import ( + "sync" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestNewWebsocketClientAcknowledgesHolder(t *testing.T) { + t.Parallel() + + wcah := NewWebsocketClientAcknowledgesHolder() + require.NotNil(t, wcah) +} + +func TestWebsocketClientAcknowledgesHolder_Add(t *testing.T) { + t.Parallel() + + counter := uint64(37) + wcah := NewWebsocketClientAcknowledgesHolder() + wcah.Add(counter) + + wcah.mutAcks.Lock() + res, found := wcah.acks[counter] + wcah.mutAcks.Unlock() + + require.True(t, found) + require.NotNil(t, res) +} + +func TestWebsocketClientAcknowledgesHolder_ProcessAcknowledged(t *testing.T) { + t.Parallel() + + t.Run("ProcessAcknowledged: should not find", func(t *testing.T) { + t.Parallel() + + wcah := NewWebsocketClientAcknowledgesHolder() + res := wcah.ProcessAcknowledged(5) + require.False(t, res) + }) + + t.Run("ProcessAcknowledged: should find and remove from inner map", func(t *testing.T) { + t.Parallel() + + counter := uint64(37) + wcah := NewWebsocketClientAcknowledgesHolder() + wcah.Add(counter) + + res := wcah.ProcessAcknowledged(counter) + require.True(t, res) + + wcah.mutAcks.Lock() + require.Equal(t, 0, len(wcah.acks)) + wcah.mutAcks.Unlock() + }) +} + +func TestWebsocketClientAcknowledgesHolder_ConcurrentOperations(t *testing.T) { + t.Parallel() + + wcah := NewWebsocketClientAcknowledgesHolder() + + defer func() { + r := recover() + require.Nil(t, r) + }() + + wg := sync.WaitGroup{} + wg.Add(100) + + for i := uint64(0); i < 100; i++ { + go func(index uint64) { + switch index % 2 { + case 0: + wcah.Add(index) + case 1: + wcah.ProcessAcknowledged(index) + } + wg.Done() + }(i) + } + wg.Wait() +} diff --git a/websocketOutportDriver/sender/websocketClientsHolder.go b/websocketOutportDriver/sender/websocketClientsHolder.go new file mode 100644 index 000000000..2e2060087 --- /dev/null +++ b/websocketOutportDriver/sender/websocketClientsHolder.go @@ -0,0 +1,60 @@ +package sender + +import ( + "sync" + + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" +) + +type websocketClientsHolder struct { + clients map[string]*webSocketClient + mut sync.RWMutex +} + +// NewWebsocketClientsHolder will return a new instance of websocketClientsHolder +func NewWebsocketClientsHolder() *websocketClientsHolder { + return &websocketClientsHolder{ + clients: make(map[string]*webSocketClient), + } +} + +// AddClient will add the provided client to the internal members +func (wch *websocketClientsHolder) AddClient(client *webSocketClient) error { + if client == nil { + return data.ErrNilWebSocketClient + } + + wch.mut.Lock() + wch.clients[client.remoteAddr] = client + wch.mut.Unlock() + + return nil +} + +// GetAll will return all the clients +func (wch *websocketClientsHolder) GetAll() map[string]*webSocketClient { + wch.mut.RLock() + defer wch.mut.RUnlock() + + clientsMap := make(map[string]*webSocketClient, len(wch.clients)) + for remoteAddr, client := range wch.clients { + clientsMap[remoteAddr] = client + } + + return clientsMap +} + +// CloseAndRemove will handle the closing of the connection and the deletion from the internal map +func (wch *websocketClientsHolder) CloseAndRemove(remoteAddr string) error { + wch.mut.Lock() + defer wch.mut.Unlock() + + client, ok := wch.clients[remoteAddr] + if !ok { + return data.ErrWebSocketClientNotFound + } + + delete(wch.clients, remoteAddr) + + return client.conn.Close() +} diff --git a/websocketOutportDriver/sender/websocketClientsHolder_test.go b/websocketOutportDriver/sender/websocketClientsHolder_test.go new file mode 100644 index 000000000..8c06f4e3f --- /dev/null +++ b/websocketOutportDriver/sender/websocketClientsHolder_test.go @@ -0,0 +1,84 @@ +package sender + +import ( + "testing" + + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/mock" + "github.com/stretchr/testify/require" +) + +func TestNewWebsocketClientsHolder(t *testing.T) { + t.Parallel() + + wch := NewWebsocketClientsHolder() + require.NotNil(t, wch) +} + +func TestWebsocketClientsHolder_AddClient(t *testing.T) { + t.Parallel() + + t.Run("nil web socket client", func(t *testing.T) { + t.Parallel() + + wch := NewWebsocketClientsHolder() + err := wch.AddClient(nil) + require.Equal(t, data.ErrNilWebSocketClient, err) + }) + + t.Run("should work", func(t *testing.T) { + t.Parallel() + + cl := &webSocketClient{} + wch := NewWebsocketClientsHolder() + err := wch.AddClient(cl) + require.NoError(t, err) + }) +} + +func TestWebsocketClientsHolder_GetAll(t *testing.T) { + t.Parallel() + + cl0 := &webSocketClient{remoteAddr: "cl0"} + cl1 := &webSocketClient{remoteAddr: "cl1"} + + wch := NewWebsocketClientsHolder() + + _ = wch.AddClient(cl0) + _ = wch.AddClient(cl1) + + clients := wch.GetAll() + require.Equal(t, cl0, clients["cl0"]) + require.Equal(t, cl1, clients["cl1"]) + require.Equal(t, 2, len(clients)) +} + +func TestWebsocketClientsHolder_CloseAndRemove(t *testing.T) { + t.Parallel() + + t.Run("CloseAndRemove should error because the client is not found", func(t *testing.T) { + t.Parallel() + + wch := NewWebsocketClientsHolder() + + err := wch.CloseAndRemove("new address") + require.Equal(t, data.ErrWebSocketClientNotFound, err) + }) + t.Run("CloseAndRemove should work", func(t *testing.T) { + t.Parallel() + + wch := NewWebsocketClientsHolder() + closeWasCalled := false + _ = wch.AddClient(&webSocketClient{remoteAddr: "cl", conn: &mock.WebsocketConnectionStub{ + CloseCalled: func() error { + closeWasCalled = true + return nil + }, + }}) + + err := wch.CloseAndRemove("cl") + require.NoError(t, err) + require.True(t, closeWasCalled) + }) + +} diff --git a/websocketOutportDriver/tests/realtest/README.md b/websocketOutportDriver/tests/realtest/README.md new file mode 100644 index 000000000..6af98a7c9 --- /dev/null +++ b/websocketOutportDriver/tests/realtest/README.md @@ -0,0 +1,15 @@ +# About +This directory contains test server and client applications. + +The server and client apps use `127.0.0.1:21111` for communicating via websockets. Combined, the server +sends requests continuously, and the clients will process them and send acknowledge for all processed requests. + +# How to use +1. go to `server` directory +2. `go build` +3. `./server` +4. from another terminal go to `client` directory +5. `go build` +6. `./bin` + +Step number 6 might be executed again in other terminal, as to simulate multiple clients diff --git a/websocketOutportDriver/tests/realtest/client/bin/main.go b/websocketOutportDriver/tests/realtest/client/bin/main.go new file mode 100644 index 000000000..b77f2ebb7 --- /dev/null +++ b/websocketOutportDriver/tests/realtest/client/bin/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "flag" + "log" + + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/tests/realtest/client" +) + +var ( + addr = flag.String("name", "client 0", "-") + port = flag.Int("port", 21112, "-") +) + +func main() { + tc, err := client.NewTempClient(*addr, &marshal.JsonMarshalizer{}) + if err != nil { + log.Fatal(err.Error()) + } + + defer tc.Stop() + + tc.Run(*port) +} diff --git a/websocketOutportDriver/tests/realtest/client/client.go b/websocketOutportDriver/tests/realtest/client/client.go new file mode 100644 index 000000000..730502f63 --- /dev/null +++ b/websocketOutportDriver/tests/realtest/client/client.go @@ -0,0 +1,155 @@ +package client + +import ( + "errors" + "fmt" + "io" + "net/url" + "os" + "os/signal" + "time" + + "github.com/gorilla/websocket" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/data/outport" + "github.com/multiversx/mx-chain-core-go/data/typeConverters/uint64ByteSlice" + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" +) + +// WSConn defines what a sender shall do +type WSConn interface { + io.Closer + ReadMessage() (messageType int, p []byte, err error) + WriteMessage(messageType int, data []byte) error +} + +var ( + log = &mock.LoggerMock{} + errNilMarshaller = errors.New("nil marshaller") + uint64ByteSliceConverter = uint64ByteSlice.NewBigEndianConverter() +) + +type tempClient struct { + name string + marshaller marshal.Marshalizer + chanStop chan bool +} + +// NewTempClient will return a new instance of tempClient +func NewTempClient(name string, marshaller marshal.Marshalizer) (*tempClient, error) { + if check.IfNil(marshaller) { + return nil, errNilMarshaller + } + + return &tempClient{ + name: name, + marshaller: marshaller, + chanStop: make(chan bool), + }, nil +} + +// Run will start the client on the provided port +func (tc *tempClient) Run(port int) { + interrupt := make(chan os.Signal, 1) + signal.Notify(interrupt, os.Interrupt) + + urlReceiveData := url.URL{Scheme: "ws", Host: fmt.Sprintf("127.0.0.1:%d", port), Path: "/operations"} + log.Info(tc.name+" -> connecting to", "url", urlReceiveData.String()) + wsConnection, _, err := websocket.DefaultDialer.Dial(urlReceiveData.String(), nil) + if err != nil { + log.Error(tc.name+" -> dial", "error", err) + } + defer func() { + err = wsConnection.Close() + log.LogIfError(err) + }() + + done := make(chan struct{}) + + go func() { + defer close(done) + for { + _, message, err := wsConnection.ReadMessage() + if err != nil { + log.Error(tc.name+" -> error read message", "error", err) + return + } + + tc.verifyPayloadAndSendAckIfNeeded(message, wsConnection) + } + }() + + timer := time.NewTimer(time.Second) + defer timer.Stop() + + for { + select { + case <-done: + return + case <-timer.C: + case <-interrupt: + log.Info(tc.name + " -> interrupt") + + // Cleanly close the connection by sending a close message and then + // waiting (with timeout) for the server to close the connection. + err = wsConnection.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) + if err != nil { + log.Error(tc.name+" -> write close", "error", err) + return + } + select { + case <-done: + case <-time.After(time.Second): + } + return + } + } +} + +func (tc *tempClient) verifyPayloadAndSendAckIfNeeded(payload []byte, ackHandler WSConn) { + if len(payload) == 0 { + log.Error(tc.name + " -> empty payload") + return + } + + payloadParser, _ := websocketOutportDriver.NewWebSocketPayloadParser(uint64ByteSliceConverter) + payloadData, err := payloadParser.ExtractPayloadData(payload) + if err != nil { + log.Error(tc.name + " -> error while extracting payload data: " + err.Error()) + return + } + + log.Info(tc.name+" -> processing payload", + "counter", payloadData.Counter, + "operation type", payloadData.OperationType, + "message length", len(payloadData.Payload), + "data", payloadData.Payload, + ) + + if payloadData.OperationType.Uint32() == data.OperationSaveBlock.Uint32() { + log.Debug(tc.name + " -> save block operation") + var argsBlock outport.ArgsSaveBlockData + err = tc.marshaller.Unmarshal(&argsBlock, payload) + if err != nil { + log.Error(tc.name+" -> cannot unmarshal block", "error", err) + } else { + log.Info(tc.name+" -> successfully unmarshalled block", "hash", argsBlock.HeaderHash) + } + } + + if payloadData.WithAcknowledge { + counterBytes := uint64ByteSliceConverter.ToByteSlice(payloadData.Counter) + err = ackHandler.WriteMessage(websocket.BinaryMessage, counterBytes) + if err != nil { + log.Error(tc.name + " -> " + err.Error()) + } + } +} + +// Stop - +func (tc *tempClient) Stop() { + tc.chanStop <- true +} diff --git a/websocketOutportDriver/tests/realtest/server/interface.go b/websocketOutportDriver/tests/realtest/server/interface.go new file mode 100644 index 000000000..df1393f71 --- /dev/null +++ b/websocketOutportDriver/tests/realtest/server/interface.go @@ -0,0 +1,20 @@ +package main + +import ( + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/outport" +) + +// Driver is an interface for saving node specific data to other storage. +// This could be an elastic search index, a MySql database or any other external services. +type Driver interface { + SaveBlock(args *outport.ArgsSaveBlockData) error + RevertIndexedBlock(header data.HeaderHandler, body data.BodyHandler) error + SaveRoundsInfo(roundsInfos []*outport.RoundInfo) error + SaveValidatorsPubKeys(validatorsPubKeys map[uint32][][]byte, epoch uint32) error + SaveValidatorsRating(indexID string, infoRating []*outport.ValidatorRatingInfo) error + SaveAccounts(blockTimestamp uint64, acc map[string]*outport.AlteredAccount, shardID uint32) error + FinalizedBlock(headerHash []byte) error + Close() error + IsInterfaceNil() bool +} diff --git a/websocketOutportDriver/tests/realtest/server/server.go b/websocketOutportDriver/tests/realtest/server/server.go new file mode 100644 index 000000000..29641eedb --- /dev/null +++ b/websocketOutportDriver/tests/realtest/server/server.go @@ -0,0 +1,85 @@ +package main + +import ( + "fmt" + "time" + + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/data/outport" + "github.com/multiversx/mx-chain-core-go/data/typeConverters/uint64ByteSlice" + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/factory" +) + +var jsonMarshaller = &marshal.JsonMarshalizer{} + +func main() { + server, err := createServer() + if err != nil { + fmt.Println("cannot create server: ", err.Error()) + return + } + + timeoutChan := make(chan bool) + go func(tChan chan bool) { + time.Sleep(1 * time.Minute) + tChan <- true + }(timeoutChan) + + funcCloseServer := func() { + err = server.Close() + if err != nil { + fmt.Println(err.Error()) + } + } + + for { + select { + case <-timeoutChan: + funcCloseServer() + default: + time.Sleep(2 * time.Second) + doAction(server) + } + } +} + +func doAction(server Driver) { + err := server.SaveBlock(&outport.ArgsSaveBlockData{HeaderHash: []byte("header hash")}) + if err != nil { + fmt.Println(err.Error()) + } + + err = server.SaveAccounts(1155, nil, 0) + if err != nil { + fmt.Println(err.Error()) + } + + err = server.FinalizedBlock([]byte("reverted header hash")) + if err != nil { + fmt.Println(err.Error()) + } + + err = server.SaveRoundsInfo(nil) + if err != nil { + fmt.Println(err.Error()) + } +} + +func createServer() (Driver, error) { + wsFactory, err := factory.NewOutportDriverWebSocketSenderFactory(factory.OutportDriverWebSocketSenderFactoryArgs{ + Marshaller: jsonMarshaller, + WebSocketConfig: data.WebSocketConfig{ + URL: "127.0.0.1:21112", + }, + Uint64ByteSliceConverter: uint64ByteSlice.NewBigEndianConverter(), + Log: &mock.LoggerMock{}, + WithAcknowledge: true, + }) + if err != nil { + return nil, err + } + + return wsFactory.Create() +} diff --git a/websocketOutportDriver/websocketOutportDriverNodePart.go b/websocketOutportDriver/websocketOutportDriverNodePart.go new file mode 100644 index 000000000..dd374fd63 --- /dev/null +++ b/websocketOutportDriver/websocketOutportDriverNodePart.go @@ -0,0 +1,177 @@ +package websocketOutportDriver + +import ( + "fmt" + + "github.com/multiversx/mx-chain-core-go/core" + "github.com/multiversx/mx-chain-core-go/core/atomic" + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/outport" + "github.com/multiversx/mx-chain-core-go/marshal" + outportSenderData "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" +) + +// WebsocketOutportDriverNodePartArgs holds the arguments needed for creating a new websocketOutportDriverNodePart +type WebsocketOutportDriverNodePartArgs struct { + Enabled bool + Marshaller marshal.Marshalizer + WebsocketSender WebSocketSenderHandler + WebSocketConfig outportSenderData.WebSocketConfig + Uint64ByteSliceConverter Uint64ByteSliceConverter + Log core.Logger +} + +type websocketOutportDriverNodePart struct { + marshalizer marshal.Marshalizer + log core.Logger + uint64ByteSliceConverter Uint64ByteSliceConverter + webSocketSender WebSocketSenderHandler + isClosed atomic.Flag +} + +// NewWebsocketOutportDriverNodePart will create a new instance of websocketOutportDriverNodePart +func NewWebsocketOutportDriverNodePart(args WebsocketOutportDriverNodePartArgs) (*websocketOutportDriverNodePart, error) { + if check.IfNil(args.Marshaller) { + return nil, outportSenderData.ErrNilMarshaller + } + if check.IfNil(args.WebsocketSender) { + return nil, outportSenderData.ErrNilWebSocketSender + } + if check.IfNil(args.Uint64ByteSliceConverter) { + return nil, outportSenderData.ErrNilUint64ByteSliceConverter + } + if check.IfNil(args.Log) { + return nil, outportSenderData.ErrNilLogger + } + + isClosedFlag := atomic.Flag{} + isClosedFlag.SetValue(false) + + return &websocketOutportDriverNodePart{ + marshalizer: args.Marshaller, + webSocketSender: args.WebsocketSender, + uint64ByteSliceConverter: args.Uint64ByteSliceConverter, + log: args.Log, + isClosed: isClosedFlag, + }, nil +} + +// SaveBlock will send the provided block saving arguments within the websocket +func (o *websocketOutportDriverNodePart) SaveBlock(args *outport.ArgsSaveBlockData) error { + argsSaveBlock := outportSenderData.ArgsSaveBlock{ + HeaderType: core.GetHeaderType(args.Header), + ArgsSaveBlockData: PrepareArgsSaveBlock(*args), + } + + return o.handleAction(argsSaveBlock, outportSenderData.OperationSaveBlock) +} + +// RevertIndexedBlock will handle the action of reverting the indexed block +func (o *websocketOutportDriverNodePart) RevertIndexedBlock(header data.HeaderHandler, body data.BodyHandler) error { + args := outportSenderData.ArgsRevertIndexedBlock{ + Header: header, + Body: body, + HeaderType: core.GetHeaderType(header), + } + + return o.handleAction(args, outportSenderData.OperationRevertIndexedBlock) +} + +// SaveRoundsInfo will handle the saving of rounds +func (o *websocketOutportDriverNodePart) SaveRoundsInfo(roundsInfos []*outport.RoundInfo) error { + args := outportSenderData.ArgsSaveRoundsInfo{ + RoundsInfos: roundsInfos, + } + + return o.handleAction(args, outportSenderData.OperationSaveRoundsInfo) +} + +// SaveValidatorsPubKeys will handle the saving of the validators' public keys +func (o *websocketOutportDriverNodePart) SaveValidatorsPubKeys(validatorsPubKeys map[uint32][][]byte, epoch uint32) error { + args := outportSenderData.ArgsSaveValidatorsPubKeys{ + ValidatorsPubKeys: validatorsPubKeys, + Epoch: epoch, + } + + return o.handleAction(args, outportSenderData.OperationSaveValidatorsPubKeys) +} + +// SaveValidatorsRating will handle the saving of the validators' rating +func (o *websocketOutportDriverNodePart) SaveValidatorsRating(indexID string, infoRating []*outport.ValidatorRatingInfo) error { + args := outportSenderData.ArgsSaveValidatorsRating{ + IndexID: indexID, + InfoRating: infoRating, + } + + return o.handleAction(args, outportSenderData.OperationSaveValidatorsRating) +} + +// SaveAccounts will handle the accounts' saving +func (o *websocketOutportDriverNodePart) SaveAccounts(blockTimestamp uint64, acc map[string]*outport.AlteredAccount, shardID uint32) error { + args := outportSenderData.ArgsSaveAccounts{ + BlockTimestamp: blockTimestamp, + Acc: acc, + ShardID: shardID, + } + + return o.handleAction(args, outportSenderData.OperationSaveAccounts) +} + +// FinalizedBlock will handle the finalized block +func (o *websocketOutportDriverNodePart) FinalizedBlock(headerHash []byte) error { + args := outportSenderData.ArgsFinalizedBlock{ + HeaderHash: headerHash, + } + + return o.handleAction(args, outportSenderData.OperationFinalizedBlock) +} + +// Close will handle the closing of the outport driver web socket sender +func (o *websocketOutportDriverNodePart) Close() error { + o.isClosed.SetValue(true) + return o.webSocketSender.Close() +} + +// IsInterfaceNil returns true if there is no value under the interface +func (o *websocketOutportDriverNodePart) IsInterfaceNil() bool { + return o == nil +} + +func (o *websocketOutportDriverNodePart) handleAction(args interface{}, operation outportSenderData.OperationType) error { + if o.isClosed.IsSet() { + return outportSenderData.ErrWebSocketServerIsClosed + } + + marshaledBlock, err := o.marshalizer.Marshal(args) + if err != nil { + o.log.Error("cannot marshal block", "operation", operation.String(), "error", err) + return fmt.Errorf("%w while marshaling block for operation %s", err, operation.String()) + } + + payload := o.preparePayload(operation, marshaledBlock) + + err = o.webSocketSender.Send(outportSenderData.WsSendArgs{ + Payload: payload, + }) + if err != nil { + o.log.Error("cannot send on route", "operation", operation.String(), "error", err) + return fmt.Errorf("%w while sending data on route for operation %s", err, operation.String()) + } + + return nil +} + +func (o *websocketOutportDriverNodePart) preparePayload(operation outportSenderData.OperationType, data []byte) []byte { + opBytes := o.uint64ByteSliceConverter.ToByteSlice(uint64(operation.Uint32())) + opBytes = opBytes[uint32NumBytes:] + + messageLength := uint64(len(data)) + messageLengthBytes := o.uint64ByteSliceConverter.ToByteSlice(messageLength) + messageLengthBytes = messageLengthBytes[uint32NumBytes:] + + payload := append(opBytes, messageLengthBytes...) + payload = append(payload, data...) + + return payload +} diff --git a/websocketOutportDriver/websocketOutportDriverNodePart_test.go b/websocketOutportDriver/websocketOutportDriverNodePart_test.go new file mode 100644 index 000000000..441f84934 --- /dev/null +++ b/websocketOutportDriver/websocketOutportDriverNodePart_test.go @@ -0,0 +1,369 @@ +package websocketOutportDriver + +import ( + "errors" + "testing" + + "github.com/multiversx/mx-chain-core-go/core" + coreMock "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/data/outport" + "github.com/multiversx/mx-chain-core-go/data/typeConverters/uint64ByteSlice" + "github.com/multiversx/mx-chain-core-go/marshal" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/data" + "github.com/multiversx/mx-chain-core-go/websocketOutportDriver/mock" + "github.com/stretchr/testify/require" +) + +var cannotSendOnRouteErr = errors.New("cannot send on route") + +func getMockArgs() WebsocketOutportDriverNodePartArgs { + return WebsocketOutportDriverNodePartArgs{ + Enabled: true, + Marshaller: &marshal.JsonMarshalizer{}, + WebSocketConfig: data.WebSocketConfig{ + URL: "localhost:5555", + }, + WebsocketSender: &mock.WebSocketSenderStub{}, + Log: &coreMock.LoggerMock{}, + Uint64ByteSliceConverter: uint64ByteSlice.NewBigEndianConverter(), + } +} + +func TestNewWebsocketOutportDriverNodePart(t *testing.T) { + t.Parallel() + + t.Run("nil marshaller", func(t *testing.T) { + t.Parallel() + + args := getMockArgs() + args.Marshaller = nil + + o, err := NewWebsocketOutportDriverNodePart(args) + require.Nil(t, o) + require.Equal(t, data.ErrNilMarshaller, err) + }) + + t.Run("nil uint64 byte slice converter", func(t *testing.T) { + t.Parallel() + + args := getMockArgs() + args.Uint64ByteSliceConverter = nil + + o, err := NewWebsocketOutportDriverNodePart(args) + require.Nil(t, o) + require.Equal(t, data.ErrNilUint64ByteSliceConverter, err) + }) + + t.Run("nil uint64 byte slice converter", func(t *testing.T) { + t.Parallel() + + args := getMockArgs() + args.Uint64ByteSliceConverter = nil + + o, err := NewWebsocketOutportDriverNodePart(args) + require.Nil(t, o) + require.Equal(t, data.ErrNilUint64ByteSliceConverter, err) + }) + + t.Run("nil logger", func(t *testing.T) { + t.Parallel() + + args := getMockArgs() + args.Log = nil + + o, err := NewWebsocketOutportDriverNodePart(args) + require.Nil(t, o) + require.Equal(t, data.ErrNilLogger, err) + }) + + t.Run("should work", func(t *testing.T) { + t.Parallel() + + args := getMockArgs() + + o, err := NewWebsocketOutportDriverNodePart(args) + require.NotNil(t, o) + require.NoError(t, err) + require.False(t, o.IsInterfaceNil()) + }) +} + +func TestWebsocketOutportDriverNodePart_SaveBlock(t *testing.T) { + t.Parallel() + + t.Run("SaveBlock - should error", func(t *testing.T) { + t.Parallel() + + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return cannotSendOnRouteErr + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveBlock(&outport.ArgsSaveBlockData{}) + require.True(t, errors.Is(err, cannotSendOnRouteErr)) + }) + + t.Run("SaveBlock - should work", func(t *testing.T) { + t.Parallel() + + defer func() { + r := recover() + require.Nil(t, r) + }() + args := getMockArgs() + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveBlock(&outport.ArgsSaveBlockData{}) + require.NoError(t, err) + }) +} + +func TestWebsocketOutportDriverNodePart_FinalizedBlock(t *testing.T) { + t.Parallel() + + t.Run("Finalized block - should error", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return cannotSendOnRouteErr + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.FinalizedBlock([]byte("header hash")) + require.True(t, errors.Is(err, cannotSendOnRouteErr)) + }) + + t.Run("Finalized block - should work", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return nil + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.FinalizedBlock([]byte("header hash")) + require.NoError(t, err) + }) +} + +func TestWebsocketOutportDriverNodePart_RevertIndexedBlock(t *testing.T) { + t.Parallel() + + t.Run("RevertIndexedBlock - should error", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return cannotSendOnRouteErr + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.RevertIndexedBlock(nil, nil) + require.True(t, errors.Is(err, cannotSendOnRouteErr)) + }) + + t.Run("RevertIndexedBlock block - should work", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return nil + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.RevertIndexedBlock(nil, nil) + require.NoError(t, err) + }) +} + +func TestWebsocketOutportDriverNodePart_SaveAccounts(t *testing.T) { + t.Parallel() + + t.Run("SaveAccounts - should error", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return cannotSendOnRouteErr + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveAccounts(0, nil, 0) + require.True(t, errors.Is(err, cannotSendOnRouteErr)) + }) + + t.Run("SaveAccounts block - should work", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return nil + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveAccounts(0, nil, 0) + require.NoError(t, err) + }) +} + +func TestWebsocketOutportDriverNodePart_SaveRoundsInfo(t *testing.T) { + t.Parallel() + + t.Run("SaveRoundsInfo - should error", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return cannotSendOnRouteErr + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveRoundsInfo(nil) + require.True(t, errors.Is(err, cannotSendOnRouteErr)) + }) + + t.Run("SaveRoundsInfo block - should work", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return nil + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveRoundsInfo(nil) + require.NoError(t, err) + }) +} + +func TestWebsocketOutportDriverNodePart_SaveValidatorsPubKeys(t *testing.T) { + t.Parallel() + + t.Run("SaveValidatorsPubKeys - should error", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return cannotSendOnRouteErr + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveValidatorsPubKeys(nil, 0) + require.True(t, errors.Is(err, cannotSendOnRouteErr)) + }) + + t.Run("SaveValidatorsPubKeys block - should work", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return nil + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveValidatorsPubKeys(nil, 0) + require.NoError(t, err) + }) +} + +func TestWebsocketOutportDriverNodePart_SaveValidatorsRating(t *testing.T) { + t.Parallel() + + t.Run("SaveValidatorsRating - should error", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return cannotSendOnRouteErr + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveValidatorsRating("", nil) + require.True(t, errors.Is(err, cannotSendOnRouteErr)) + }) + + t.Run("SaveValidatorsRating block - should work", func(t *testing.T) { + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(_ data.WsSendArgs) error { + return nil + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveValidatorsRating("", nil) + require.NoError(t, err) + }) +} + +func TestWebsocketOutportDriverNodePart_SaveBlock_PayloadCheck(t *testing.T) { + t.Parallel() + + args := getMockArgs() + + marshaledData, err := args.Marshaller.Marshal(&data.ArgsSaveBlock{ + HeaderType: core.MetaHeader, + ArgsSaveBlockData: outport.ArgsSaveBlockData{ + Header: &block.MetaBlock{}, + }, + }) + require.Nil(t, err) + + args.WebsocketSender = &mock.WebSocketSenderStub{ + SendOnRouteCalled: func(args data.WsSendArgs) error { + expectedOpBytes := []byte{0, 0, 0, 0} + expectedLengthBytes := []byte{0, 0, 1, 156} + expectedPayload := append(expectedOpBytes, expectedLengthBytes...) + expectedPayload = append(expectedPayload, marshaledData...) + + require.Equal(t, expectedPayload, args.Payload) + + return nil + }, + } + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.SaveBlock(&outport.ArgsSaveBlockData{Header: &block.MetaBlock{}}) + require.NoError(t, err) +} + +func TestWebsocketOutportDriverNodePart_Close(t *testing.T) { + t.Parallel() + + closedWasCalled := false + args := getMockArgs() + args.WebsocketSender = &mock.WebSocketSenderStub{ + CloseCalled: func() error { + closedWasCalled = true + return nil + }, + } + + o, err := NewWebsocketOutportDriverNodePart(args) + require.NoError(t, err) + + err = o.Close() + require.NoError(t, err) + require.True(t, closedWasCalled) +}