diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 000000000..36a081986 --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,37 @@ +name: golangci-lint +on: + push: + branches: + - main + pull_request: + branches: [ main, feat/*, rc/* ] + +permissions: + contents: read + +jobs: + golangci: + name: golangci linter + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.20.7 + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.53.2 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + args: --timeout 10m0s --max-issues-per-linter 0 --max-same-issues 0 --print-issued-lines + + # Optional: show only new issues if it's a pull request. The default value is `false`. + only-new-issues: true + + # Optional: if set to true then the action will use pre-installed Go + # skip-go-installation: true diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index 1b089f87f..266bf171f 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -1,20 +1,21 @@ name: Tests on: - push: - branches: [ main, development, feat/*, rc/* ] pull_request: - branches: [ main, development, feat/*, rc/* ] + branches: [ main, rc/*, feat/* ] + types: [ opened, ready_for_review ] + push: + workflow_dispatch: jobs: test: name: Unit runs-on: ubuntu-latest steps: - - name: Set up Go 1.17.6 + - name: Set up Go 1.20.7 uses: actions/setup-go@v3 with: - go-version: 1.17.6 + go-version: 1.20.7 id: go - name: Check out code diff --git a/.gitignore b/.gitignore index 66a5f9d21..944efcc8b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,10 @@ # Dependency directories /vendor +# IDE files +.idea/ + # Go workspace file go.work + +.idea diff --git a/Makefile b/Makefile index 2521da73c..d18369270 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,15 @@ test: @echo " > Running unit tests" go test -cover -race -coverprofile=coverage.txt -covermode=atomic -v ./... + +lint-install: +ifeq (,$(wildcard test -f bin/golangci-lint)) + @echo "Installing golint" + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s +endif + +run-lint: + @echo "Running golint" + bin/golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 --timeout=2m + +lint: lint-install run-lint diff --git a/core/check/ifHrp.go b/core/check/ifHrp.go new file mode 100644 index 000000000..4fc9c2077 --- /dev/null +++ b/core/check/ifHrp.go @@ -0,0 +1,15 @@ +package check + +// IfHrp tests if the provided string is human readable - does contain only alphabetic characters +func IfHrp(s string) bool { + if s == "" { + return false + } + + for _, r := range s { + if (r < 'a' || r > 'z') && (r < 'A' || r > 'Z') { + return false + } + } + return true +} diff --git a/core/check/ifHrp_test.go b/core/check/ifHrp_test.go new file mode 100644 index 000000000..6524cf111 --- /dev/null +++ b/core/check/ifHrp_test.go @@ -0,0 +1,25 @@ +package check_test + +import ( + "testing" + + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/stretchr/testify/assert" +) + +func TestCheckIfHRP_ShouldWork(t *testing.T) { + t.Parallel() + + assert.True(t, check.IfHrp("abc")) + assert.True(t, check.IfHrp("Abc")) + assert.False(t, check.IfHrp("abc1")) + assert.False(t, check.IfHrp("abc/")) + assert.False(t, check.IfHrp("/t")) + assert.False(t, check.IfHrp("!t")) + assert.False(t, check.IfHrp(".t")) + assert.False(t, check.IfHrp("`t")) + assert.False(t, check.IfHrp("")) + assert.False(t, check.IfHrp("123()")) + assert.False(t, check.IfHrp(" ")) + assert.False(t, check.IfHrp(" ")) +} diff --git a/core/constants.go b/core/constants.go index d47e28dfc..bff20dd6f 100644 --- a/core/constants.go +++ b/core/constants.go @@ -40,6 +40,9 @@ const AllShardId = uint32(0xFFFFFFF0) // MegabyteSize represents the size in bytes of a megabyte const MegabyteSize = 1024 * 1024 +// MaxMachineIDLen is the maximum machine ID length +const MaxMachineIDLen = 10 + // BuiltInFunctionClaimDeveloperRewards is the key for the claim developer rewards built-in function const BuiltInFunctionClaimDeveloperRewards = "ClaimDeveloperRewards" @@ -126,6 +129,9 @@ const BuiltInFunctionGuardAccount = "GuardAccount" // BuiltInFunctionUnGuardAccount is the built-in function key for un-guarding an account const BuiltInFunctionUnGuardAccount = "UnGuardAccount" +// BuiltInFunctionMigrateDataTrie is the built-in function key for migrating the data trie +const BuiltInFunctionMigrateDataTrie = "MigrateDataTrie" + // ESDTRoleLocalMint is the constant string for the local role of mint for ESDT tokens const ESDTRoleLocalMint = "ESDTRoleLocalMint" @@ -252,8 +258,17 @@ 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" +// InternalVMErrorsOperation is the identifier for the log that is generated when the execution of a smart contract generates an interval vm error +const InternalVMErrorsOperation = "internalVMErrors" + // GasRefundForRelayerMessage is the return message for to the smart contract result with refund for the relayer const GasRefundForRelayerMessage = "gas refund for relayer" // InitialVersionOfTransaction defines the initial version for a transaction const InitialVersionOfTransaction = uint32(1) + +// DefaultAddressPrefix is the default hrp of MultiversX/Elrond +const DefaultAddressPrefix = "erd" + +// TopicRequestSuffix represents the topic name suffix for requests +const TopicRequestSuffix = "_REQUEST" diff --git a/core/errorHandling.go b/core/errorHandling.go new file mode 100644 index 000000000..970609d41 --- /dev/null +++ b/core/errorHandling.go @@ -0,0 +1,46 @@ +package core + +import ( + "errors" + "strings" +) + +// IsGetNodeFromDBError returns true if the provided error is of type getNodeFromDB +func IsGetNodeFromDBError(err error) bool { + if err == nil { + return false + } + + if IsClosingError(err) { + return false + } + + return strings.Contains(err.Error(), GetNodeFromDBErrorString) +} + +// IsClosingError returns true if the provided error is used whenever the node is in the closing process +func IsClosingError(err error) bool { + if err == nil { + return false + } + + errString := err.Error() + return strings.Contains(errString, ErrDBIsClosed.Error()) || + strings.Contains(errString, ErrContextClosing.Error()) +} + +// UnwrapGetNodeFromDBErr unwraps the provided error until it finds a GetNodeFromDbErrHandler +func UnwrapGetNodeFromDBErr(wrappedErr error) GetNodeFromDbErrHandler { + errWithKeyHandler, ok := wrappedErr.(GetNodeFromDbErrHandler) + for !ok { + if wrappedErr == nil { + return nil + } + + err := errors.Unwrap(wrappedErr) + errWithKeyHandler, ok = err.(GetNodeFromDbErrHandler) + wrappedErr = err + } + + return errWithKeyHandler +} diff --git a/core/errorHandling_test.go b/core/errorHandling_test.go new file mode 100644 index 000000000..9654a7562 --- /dev/null +++ b/core/errorHandling_test.go @@ -0,0 +1,80 @@ +package core + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestIsGetNodeFromDBError(t *testing.T) { + t.Parallel() + + t.Run("nil error", func(t *testing.T) { + t.Parallel() + + assert.False(t, IsGetNodeFromDBError(nil)) + }) + + t.Run("closing error", func(t *testing.T) { + t.Parallel() + + assert.False(t, IsGetNodeFromDBError(ErrContextClosing)) + assert.False(t, IsGetNodeFromDBError(ErrDBIsClosed)) + }) + + t.Run("get node from db error", func(t *testing.T) { + t.Parallel() + + assert.True(t, IsGetNodeFromDBError(fmt.Errorf("trie error: %s", GetNodeFromDBErrorString))) + }) + + t.Run("other error", func(t *testing.T) { + t.Parallel() + + assert.False(t, IsGetNodeFromDBError(fmt.Errorf("trie error: %s", "other error"))) + }) +} + +func TestIsClosingError(t *testing.T) { + t.Parallel() + + t.Run("nil error", func(t *testing.T) { + t.Parallel() + + assert.False(t, IsClosingError(nil)) + }) + + t.Run("closing error", func(t *testing.T) { + t.Parallel() + + assert.True(t, IsClosingError(ErrContextClosing)) + assert.True(t, IsClosingError(ErrDBIsClosed)) + }) + + t.Run("other error", func(t *testing.T) { + t.Parallel() + + assert.False(t, IsClosingError(fmt.Errorf("trie error: %s", "other error"))) + }) +} + +func TestUnwrapGetNodeFromDBErr(t *testing.T) { + t.Parallel() + + key := []byte("key") + identifier := "identifier" + err := fmt.Errorf("key not found") + + getNodeFromDbErr := NewGetNodeFromDBErrWithKey(key, err, identifier) + wrappedErr1 := fmt.Errorf("wrapped error 1: %w", getNodeFromDbErr) + wrappedErr2 := fmt.Errorf("wrapped error 2: %w", wrappedErr1) + wrappedErr3 := fmt.Errorf("wrapped error 3: %w", wrappedErr2) + + assert.Nil(t, UnwrapGetNodeFromDBErr(nil)) + assert.Nil(t, UnwrapGetNodeFromDBErr(err)) + assert.Equal(t, getNodeFromDbErr, UnwrapGetNodeFromDBErr(getNodeFromDbErr)) + assert.Equal(t, getNodeFromDbErr, UnwrapGetNodeFromDBErr(wrappedErr1)) + assert.Equal(t, getNodeFromDbErr, UnwrapGetNodeFromDBErr(wrappedErr2)) + assert.Equal(t, getNodeFromDbErr, UnwrapGetNodeFromDBErr(wrappedErr3)) +} diff --git a/core/errors.go b/core/errors.go index 65e1d59be..a6e64c498 100644 --- a/core/errors.go +++ b/core/errors.go @@ -109,3 +109,12 @@ var ErrNilGoRoutineProcessor = errors.New("nil go routine processor") // ErrNilPubkeyConverter signals that a nil public key converter has been provided var ErrNilPubkeyConverter = errors.New("nil pubkey converter") + +// ErrContextClosing signals that the parent context requested the closing of its children +var ErrContextClosing = errors.New("context closing") + +// ErrDBIsClosed is raised when the DB is closed +var ErrDBIsClosed = errors.New("DB is closed") + +// ErrNilEnableEpochsHandler signals that a nil enable epochs handler has been provided +var ErrNilEnableEpochsHandler = errors.New("nil enable epochs handler") diff --git a/core/file.go b/core/file.go index 2edf58a23..a7300a53b 100644 --- a/core/file.go +++ b/core/file.go @@ -1,6 +1,7 @@ package core import ( + "bytes" "encoding/json" "encoding/pem" "fmt" @@ -13,6 +14,8 @@ import ( "github.com/pelletier/go-toml" ) +const pemPkHeader = "PRIVATE KEY for " + // ArgCreateFileArgument will hold the arguments for a new file creation method call type ArgCreateFileArgument struct { Directory string @@ -48,6 +51,20 @@ func LoadTomlFile(dest interface{}, relativePath string) error { return toml.NewDecoder(f).Decode(dest) } +// SaveTomlFile will open and save data to toml file +func SaveTomlFile(src interface{}, relativePath string) error { + f, err := os.Create(relativePath) + if err != nil { + return err + } + + defer func() { + _ = f.Close() + }() + + return toml.NewEncoder(f).Encode(src) +} + // LoadTomlFileToMap opens and decodes a toml file as a map[string]interface{} func LoadTomlFileToMap(relativePath string) (map[string]interface{}, error) { f, err := OpenFile(relativePath) @@ -162,16 +179,64 @@ func LoadSkPkFromPemFile(relativePath string, skIndex int) ([]byte, string, erro } blockType := blkRecovered.Type - header := "PRIVATE KEY for " - if strings.Index(blockType, header) != 0 { - return nil, "", fmt.Errorf("%w missing '%s' in block type", ErrPemFileIsInvalid, header) + + if strings.Index(blockType, pemPkHeader) != 0 { + return nil, "", fmt.Errorf("%w missing '%s' in block type", ErrPemFileIsInvalid, pemPkHeader) } - blockTypeString := blockType[len(header):] + blockTypeString := blockType[len(pemPkHeader):] return blkRecovered.Bytes, blockTypeString, nil } +// LoadAllKeysFromPemFile loads all the secret keys and existing public key bytes stored in the file +func LoadAllKeysFromPemFile(relativePath string) ([][]byte, []string, error) { + file, err := OpenFile(relativePath) + if err != nil { + return nil, nil, err + } + + defer func() { + _ = file.Close() + }() + + buff, err := ioutil.ReadAll(file) + if err != nil { + return nil, nil, fmt.Errorf("%w while reading %s file", err, relativePath) + } + if len(buff) == 0 { + return nil, nil, fmt.Errorf("%w while reading %s file", ErrEmptyFile, relativePath) + } + + var blkRecovered *pem.Block + privateKeys := make([][]byte, 0) + publicKeys := make([]string, 0) + + for { + if len(buff) == 0 { + break + } + + blkRecovered, buff = pem.Decode(buff) + if blkRecovered == nil { + return nil, nil, fmt.Errorf("%w while reading %s file, error decoding", ErrPemFileIsInvalid, relativePath) + } + buff = bytes.TrimSpace(buff) + + blockType := blkRecovered.Type + if strings.Index(blockType, pemPkHeader) != 0 { + return nil, nil, fmt.Errorf("%w missing '%s' in block type", ErrPemFileIsInvalid, pemPkHeader) + } + + blockTypeString := blockType[len(pemPkHeader):] + + privateKeys = append(privateKeys, blkRecovered.Bytes) + publicKeys = append(publicKeys, blockTypeString) + } + + return privateKeys, publicKeys, nil +} + // SaveSkToPemFile saves secret key bytes in the file func SaveSkToPemFile(file *os.File, identifier string, skBytes []byte) error { if file == nil { diff --git a/core/file_test.go b/core/file_test.go index 8d80d9627..edaf0ead3 100644 --- a/core/file_test.go +++ b/core/file_test.go @@ -5,15 +5,17 @@ import ( "errors" "io/ioutil" "os" + "path/filepath" "strings" "testing" "github.com/multiversx/mx-chain-core-go/core" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type TestStruct struct { - a, b int + A, B int } func TestOpenFile_NoExistingFileShouldErr(t *testing.T) { @@ -68,6 +70,61 @@ func TestLoadTomlFile_FileExitsShouldPass(t *testing.T) { assert.Nil(t, err) } +func TestSaveTomlFile(t *testing.T) { + t.Parallel() + + t.Run("empty filename, should fail", func(t *testing.T) { + t.Parallel() + + cfg := &TestStruct{} + + fileName := "" + + err := core.SaveTomlFile(cfg, fileName) + require.Error(t, err) + }) + + t.Run("invalid path, should fail", func(t *testing.T) { + t.Parallel() + + cfg := &TestStruct{} + + fileName := "invalid_path" + "/testFile1" + + err := core.SaveTomlFile(cfg, fileName) + require.Error(t, err) + }) + + t.Run("should work with valid dir", func(t *testing.T) { + t.Parallel() + + cfg := &TestStruct{} + + dir := t.TempDir() + fileName := dir + "/testFile1" + + err := core.SaveTomlFile(cfg, fileName) + require.Nil(t, err) + }) + + t.Run("should work", func(t *testing.T) { + t.Parallel() + + cfg := &TestStruct{A: 10, B: 20} + dir := t.TempDir() + fileName := dir + "/testFile1" + + err := core.SaveTomlFile(cfg, fileName) + require.Nil(t, err) + + newCfg := &TestStruct{} + err = core.LoadTomlFile(newCfg, fileName) + require.Nil(t, err) + + require.Equal(t, cfg, newCfg) + }) +} + func TestLoadJSonFile_NoExistingFileShouldErr(t *testing.T) { t.Parallel() @@ -76,7 +133,6 @@ func TestLoadJSonFile_NoExistingFileShouldErr(t *testing.T) { err := core.LoadJsonFile(cfg, "file") assert.Error(t, err) - } func TestLoadJSonFile_FileExitsShouldPass(t *testing.T) { @@ -88,7 +144,7 @@ func TestLoadJSonFile_FileExitsShouldPass(t *testing.T) { file, err := os.Create(fileName) assert.Nil(t, err) - data, _ := json.MarshalIndent(TestStruct{a: 0, b: 0}, "", " ") + data, _ := json.MarshalIndent(TestStruct{A: 0, B: 0}, "", " ") _ = ioutil.WriteFile(fileName, data, 0644) @@ -103,154 +159,249 @@ func TestLoadJSonFile_FileExitsShouldPass(t *testing.T) { assert.Nil(t, err) } -func TestLoadSkPkFromPemFile_InvalidSkIndexShouldErr(t *testing.T) { +func TestLoadSkPkFromPemFile(t *testing.T) { t.Parallel() - dataSk, dataPk, err := core.LoadSkPkFromPemFile("testFile5", -1) + t.Run("invalid index should error", func(t *testing.T) { + t.Parallel() - assert.Nil(t, dataSk) - assert.Empty(t, "", dataPk) - assert.Equal(t, core.ErrInvalidIndex, err) -} + fileName := filepath.Join(t.TempDir(), "testFile") + dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, -1) -func TestLoadSkPkFromPemFile_NoExistingFileShouldErr(t *testing.T) { - t.Parallel() + assert.Nil(t, dataSk) + assert.Empty(t, "", dataPk) + assert.Equal(t, core.ErrInvalidIndex, err) + }) + t.Run("missing file should error", func(t *testing.T) { + t.Parallel() - dataSk, dataPk, err := core.LoadSkPkFromPemFile("testFile6", 0) + fileName := filepath.Join(t.TempDir(), "testFile") + dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) - assert.Nil(t, dataSk) - assert.Empty(t, dataPk) - assert.Error(t, err) -} + assert.Nil(t, dataSk) + assert.Empty(t, dataPk) + assert.Error(t, err) + }) + t.Run("empty file should error", func(t *testing.T) { + t.Parallel() -func TestLoadSkPkFromPemFile_EmptyFileShouldErr(t *testing.T) { - t.Parallel() + fileName := filepath.Join(t.TempDir(), "testFile") + _, _ = os.Create(fileName) - fileName := "testFile7" - _, _ = os.Create(fileName) + dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) - dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) - if _, errF := os.Stat(fileName); errF == nil { - _ = os.Remove(fileName) - } + assert.Nil(t, dataSk) + assert.Empty(t, dataPk) + assert.True(t, errors.Is(err, core.ErrEmptyFile)) + }) + t.Run("incorrect header should error", func(t *testing.T) { + t.Parallel() - assert.Nil(t, dataSk) - assert.Empty(t, dataPk) - assert.True(t, errors.Is(err, core.ErrEmptyFile)) -} + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) -func TestLoadSkPkFromPemFile_ShouldPass(t *testing.T) { - t.Parallel() + _, _ = file.WriteString("-----BEGIN INCORRECT HEADER ABCD-----\n") + _, _ = file.WriteString("ChQeKDI8\n") + _, _ = file.WriteString("-----END INCORRECT HEADER ABCD-----") - fileName := "testFile8" - file, err := os.Create(fileName) - assert.Nil(t, err) + dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) - skBytes := []byte{10, 20, 30, 40, 50, 60} - pkString := "ABCD" + assert.Nil(t, dataSk) + assert.Empty(t, dataPk) + assert.True(t, errors.Is(err, core.ErrPemFileIsInvalid)) + }) + t.Run("invalid pem file should error", func(t *testing.T) { + t.Parallel() - _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString + "-----\n") - _, _ = file.WriteString("ChQeKDI8\n") - _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString + "-----") + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) - dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) - if _, errF := os.Stat(fileName); errF == nil { - _ = os.Remove(fileName) - } + _, _ = file.WriteString("data") - assert.Equal(t, dataSk, skBytes) - assert.Equal(t, dataPk, pkString) - assert.Nil(t, err) -} + dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) -func TestLoadSkPkFromPemFile_IncorrectHeaderShouldErr(t *testing.T) { - t.Parallel() + assert.Nil(t, dataSk) + assert.Empty(t, dataPk) + assert.True(t, errors.Is(err, core.ErrPemFileIsInvalid)) + }) + t.Run("invalid index should error", func(t *testing.T) { + t.Parallel() - fileName := "testFile9" - file, err := os.Create(fileName) - assert.Nil(t, err) + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) - _, _ = file.WriteString("-----BEGIN INCORRECT HEADER ABCD-----\n") - _, _ = file.WriteString("ChQeKDI8\n") - _, _ = file.WriteString("-----END INCORRECT HEADER ABCD-----") + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for data-----\n") + _, _ = file.WriteString("ChQeKDI8\n") + _, _ = file.WriteString("-----END PRIVATE KEY for data-----") - dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) - if _, errF := os.Stat(fileName); errF == nil { - _ = os.Remove(fileName) - } + dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 1) - assert.Nil(t, dataSk) - assert.Empty(t, dataPk) - assert.True(t, errors.Is(err, core.ErrPemFileIsInvalid)) -} + assert.Nil(t, dataSk) + assert.Empty(t, dataPk) + assert.True(t, errors.Is(err, core.ErrInvalidIndex)) + }) + t.Run("should work", func(t *testing.T) { + t.Parallel() -func TestLoadSkPkFromPemFile_InvalidPemFileShouldErr(t *testing.T) { - t.Parallel() + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) - fileName := "testFile10" - file, err := os.Create(fileName) - assert.Nil(t, err) + skBytes := []byte{10, 20, 30, 40, 50, 60} + pkString := "ABCD" - _, _ = file.WriteString("data") + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString + "-----\n") + _, _ = file.WriteString("ChQeKDI8\n") + _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString + "-----") - dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) - if _, errF := os.Stat(fileName); errF == nil { - _ = os.Remove(fileName) - } + dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 0) - assert.Nil(t, dataSk) - assert.Empty(t, dataPk) - assert.True(t, errors.Is(err, core.ErrPemFileIsInvalid)) + assert.Equal(t, dataSk, skBytes) + assert.Equal(t, dataPk, pkString) + assert.Nil(t, err) + }) } -func TestLoadSkPkFromPemFile_InvalidIndexShouldErr(t *testing.T) { +func TestLoadAllKeysFromPemFile(t *testing.T) { t.Parallel() - fileName := "testFile11" - file, err := os.Create(fileName) - assert.Nil(t, err) - - _, _ = file.WriteString("-----BEGIN PRIVATE KEY for data-----\n") - _, _ = file.WriteString("ChQeKDI8\n") - _, _ = file.WriteString("-----END PRIVATE KEY for data-----") - - dataSk, dataPk, err := core.LoadSkPkFromPemFile(fileName, 1) - if _, errF := os.Stat(fileName); errF == nil { - _ = os.Remove(fileName) - } - - assert.Nil(t, dataSk) - assert.Empty(t, dataPk) - assert.True(t, errors.Is(err, core.ErrInvalidIndex)) + t.Run("missing file should error", func(t *testing.T) { + t.Parallel() + + fileName := filepath.Join(t.TempDir(), "testFile") + privateKeys, publicKeys, err := core.LoadAllKeysFromPemFile(fileName) + + assert.Nil(t, privateKeys) + assert.Nil(t, publicKeys) + assert.Error(t, err) + }) + t.Run("empty file should error", func(t *testing.T) { + t.Parallel() + + fileName := filepath.Join(t.TempDir(), "testFile") + _, _ = os.Create(fileName) + + privateKeys, publicKeys, err := core.LoadAllKeysFromPemFile(fileName) + + assert.Nil(t, privateKeys) + assert.Nil(t, publicKeys) + assert.True(t, errors.Is(err, core.ErrEmptyFile)) + }) + t.Run("incorrect header should error", func(t *testing.T) { + t.Parallel() + + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) + + _, _ = file.WriteString("-----BEGIN INCORRECT HEADER ABCD-----\n") + _, _ = file.WriteString("ChQeKDI8\n") + _, _ = file.WriteString("-----END INCORRECT HEADER ABCD-----") + + privateKeys, publicKeys, err := core.LoadAllKeysFromPemFile(fileName) + + assert.Nil(t, privateKeys) + assert.Empty(t, publicKeys) + assert.True(t, errors.Is(err, core.ErrPemFileIsInvalid)) + }) + t.Run("invalid pem file should error", func(t *testing.T) { + t.Parallel() + + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) + + _, _ = file.WriteString("data") + + privateKeys, publicKeys, err := core.LoadAllKeysFromPemFile(fileName) + + assert.Nil(t, privateKeys) + assert.Empty(t, publicKeys) + assert.True(t, errors.Is(err, core.ErrPemFileIsInvalid)) + }) + t.Run("should work with one key", func(t *testing.T) { + t.Parallel() + + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) + + skBytes := []byte{10, 20, 30, 40, 50, 60} + pkString := "ABCD" + + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString + "-----\n") + _, _ = file.WriteString("ChQeKDI8\n") + _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString + "-----") + _ = file.Close() + + privateKeys, publicKeys, err := core.LoadAllKeysFromPemFile(fileName) + + assert.Equal(t, [][]byte{skBytes}, privateKeys) + assert.Equal(t, []string{pkString}, publicKeys) + assert.Nil(t, err) + }) + t.Run("should work with three keys and extra spaces", func(t *testing.T) { + t.Parallel() + + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) + + skBytes1 := []byte{10, 20, 30, 40, 50, 60} + pkString1 := "ABCD1" + skBytes2 := []byte{11, 21, 31, 41, 51, 61} + pkString2 := "ABCD2" + skBytes3 := []byte{12, 22, 32, 42, 52, 62} + pkString3 := "ABCD2" + + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString1 + "-----\n") + _, _ = file.WriteString("ChQeKDI8\n") + _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString1 + "-----\n") + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString2 + "-----\n\n\n") + _, _ = file.WriteString("CxUfKTM9\n") + _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString2 + "-----\n") + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString3 + "-----\n") + _, _ = file.WriteString("DBYgKjQ+\n") + _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString3 + "-----\n\n\n\n") + _ = file.Close() + + privateKeys, publicKeys, err := core.LoadAllKeysFromPemFile(fileName) + + assert.Equal(t, [][]byte{skBytes1, skBytes2, skBytes3}, privateKeys) + assert.Equal(t, []string{pkString1, pkString2, pkString3}, publicKeys) + assert.Nil(t, err) + }) } -func TestSaveSkToPemFile_NilFileShouldErr(t *testing.T) { +func TestSaveSkToPemFile(t *testing.T) { t.Parallel() - skBytes := make([]byte, 0) - skBytes = append(skBytes, 10, 20, 30) + t.Run("nil file should error", func(t *testing.T) { + t.Parallel() - err := core.SaveSkToPemFile(nil, "data", skBytes) + skBytes := make([]byte, 0) + skBytes = append(skBytes, 10, 20, 30) - assert.Equal(t, core.ErrNilFile, err) -} + err := core.SaveSkToPemFile(nil, "data", skBytes) -func TestSaveSkToPemFile_ShouldPass(t *testing.T) { - t.Parallel() - - fileName := "testFile12" - file, err := os.Create(fileName) - assert.Nil(t, err) + assert.Equal(t, core.ErrNilFile, err) + }) + t.Run("should work", func(t *testing.T) { + t.Parallel() - skBytes := make([]byte, 0) - skBytes = append(skBytes, 10, 20, 30, 40, 50, 60) + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) - err = core.SaveSkToPemFile(file, "data", skBytes) - if _, errF := os.Stat(fileName); errF == nil { - _ = os.Remove(fileName) - } + skBytes := make([]byte, 0) + skBytes = append(skBytes, 10, 20, 30, 40, 50, 60) - assert.Nil(t, err) + err = core.SaveSkToPemFile(file, "data", skBytes) + assert.Nil(t, err) + }) } func TestCreateFile(t *testing.T) { diff --git a/core/getNodeFromDBErrWithKey.go b/core/getNodeFromDBErrWithKey.go new file mode 100644 index 000000000..b6b757c54 --- /dev/null +++ b/core/getNodeFromDBErrWithKey.go @@ -0,0 +1,50 @@ +package core + +import ( + "encoding/hex" + "fmt" +) + +// GetNodeFromDBErrorString represents the string which is returned when a getting node from DB returns an error +const GetNodeFromDBErrorString = "getNodeFromDB error" + +// getNodeFromDBErrWithKey defines a custom error for trie get node +type getNodeFromDBErrWithKey struct { + getErr error + key []byte + dbIdentifier string +} + +// NewGetNodeFromDBErrWithKey will create a new instance of GetNodeFromDBErrWithKey +func NewGetNodeFromDBErrWithKey(key []byte, err error, id string) *getNodeFromDBErrWithKey { + return &getNodeFromDBErrWithKey{ + getErr: err, + key: key, + dbIdentifier: id, + } +} + +// Error returns the error as string +func (e *getNodeFromDBErrWithKey) Error() string { + return fmt.Sprintf( + "%s: %s for key %v", + GetNodeFromDBErrorString, + e.getErr.Error(), + hex.EncodeToString(e.key), + ) +} + +// GetKey will return the key that generated the error +func (e *getNodeFromDBErrWithKey) GetKey() []byte { + return e.key +} + +// GetIdentifier will return the db identifier corresponding to the db +func (e *getNodeFromDBErrWithKey) GetIdentifier() string { + return e.dbIdentifier +} + +// IsInterfaceNil returns true if there is no value under the interface +func (e *getNodeFromDBErrWithKey) IsInterfaceNil() bool { + return e == nil +} diff --git a/core/getNodeFromDBErrWithKey_test.go b/core/getNodeFromDBErrWithKey_test.go new file mode 100644 index 000000000..93e03a80b --- /dev/null +++ b/core/getNodeFromDBErrWithKey_test.go @@ -0,0 +1,60 @@ +package core + +import ( + "encoding/hex" + "errors" + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +var testErr = errors.New("test error") +var testKey = []byte("test key") +var testId = "test id" + +func TestNewStopWatch(t *testing.T) { + t.Parallel() + + err := NewGetNodeFromDBErrWithKey(testKey, testErr, testId) + assert.Equal(t, testErr, err.getErr) + assert.Equal(t, testKey, err.key) + assert.Equal(t, testId, err.dbIdentifier) +} + +func TestGetNodeFromDBErrWithKey_Error(t *testing.T) { + t.Parallel() + + expectedResult := fmt.Sprintf( + "%s: %s for key %v", + GetNodeFromDBErrorString, + testErr.Error(), + hex.EncodeToString(testKey), + ) + err := NewGetNodeFromDBErrWithKey(testKey, testErr, testId) + assert.Equal(t, expectedResult, err.Error()) +} + +func TestGetNodeFromDBErrWithKey_GetKey(t *testing.T) { + t.Parallel() + + err := NewGetNodeFromDBErrWithKey(testKey, testErr, testId) + assert.Equal(t, testKey, err.GetKey()) +} + +func TestGetNodeFromDBErrWithKey_GetIdentifier(t *testing.T) { + t.Parallel() + + err := NewGetNodeFromDBErrWithKey(testKey, testErr, testId) + assert.Equal(t, testId, err.GetIdentifier()) +} + +func TestGetNodeFromDBErrWithKey_IsInterfaceNil(t *testing.T) { + t.Parallel() + + var err *getNodeFromDBErrWithKey + assert.True(t, err.IsInterfaceNil()) + + err = NewGetNodeFromDBErrWithKey(testKey, testErr, testId) + assert.False(t, err.IsInterfaceNil()) +} diff --git a/core/interface.go b/core/interface.go index cb9f4b9a4..8bde1c046 100644 --- a/core/interface.go +++ b/core/interface.go @@ -25,7 +25,9 @@ type ConnectedAddressesHandler interface { type PubkeyConverter interface { Len() int Decode(humanReadable string) ([]byte, error) - Encode(pkBytes []byte) string + Encode(pkBytes []byte) (string, error) + SilentEncode(pkBytes []byte, log Logger) string + EncodeSlice(pkBytesSlice [][]byte) ([]string, error) IsInterfaceNil() bool } @@ -66,7 +68,6 @@ type Throttler interface { type KeyValueHolder interface { Key() []byte Value() []byte - ValueWithoutSuffix(suffix []byte) ([]byte, error) } // EpochSubscriberHandler defines the behavior of a component that can be notified if a new epoch was confirmed @@ -126,3 +127,23 @@ type Logger interface { LogIfError(err error, args ...interface{}) IsInterfaceNil() bool } + +// GetNodeFromDbErrHandler defines the behavior of a component that can provide extra info from a missing trie node err +type GetNodeFromDbErrHandler interface { + Error() string + GetKey() []byte + GetIdentifier() string + IsInterfaceNil() bool +} + +// TrieNodeVersionVerifier defines the behavior of a component that can verify if a trie node version is valid +type TrieNodeVersionVerifier interface { + IsValidVersion(version TrieNodeVersion) bool + IsInterfaceNil() bool +} + +// EnableEpochsHandler defines the behavior of a component that can return if a feature is enabled or not +type EnableEpochsHandler interface { + IsAutoBalanceDataTriesEnabled() bool + IsInterfaceNil() bool +} diff --git a/core/keyLoader.go b/core/keyLoader.go index ec089d936..a2e493583 100644 --- a/core/keyLoader.go +++ b/core/keyLoader.go @@ -1,10 +1,25 @@ package core -// KeyLoader holds the logic for loading a key from a file and an index -type KeyLoader struct { +// keyLoader holds the logic for loading a key from a file and an index +type keyLoader struct { } -// LoadKey loads the key with the given index found in the pem file from the given relative path. -func (kl *KeyLoader) LoadKey(relativePath string, skIndex int) ([]byte, string, error) { - return LoadSkPkFromPemFile(relativePath, skIndex) +// NewKeyLoader creates a new instance of type key loader +func NewKeyLoader() *keyLoader { + return &keyLoader{} +} + +// LoadKey loads the key with the given index found in the pem file from the given path. +func (kl *keyLoader) LoadKey(path string, skIndex int) ([]byte, string, error) { + return LoadSkPkFromPemFile(path, skIndex) +} + +// LoadAllKeys loads all keys found in the pem file for the given path +func (kl *keyLoader) LoadAllKeys(path string) ([][]byte, []string, error) { + return LoadAllKeysFromPemFile(path) +} + +// IsInterfaceNil returns true if there is no value under the interface +func (kl *keyLoader) IsInterfaceNil() bool { + return kl == nil } diff --git a/core/keyLoader_test.go b/core/keyLoader_test.go new file mode 100644 index 000000000..7699180e9 --- /dev/null +++ b/core/keyLoader_test.go @@ -0,0 +1,77 @@ +package core + +import ( + "os" + "path/filepath" + "testing" + + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/stretchr/testify/assert" +) + +func TestNewKeyLoader(t *testing.T) { + t.Parallel() + + kl := NewKeyLoader() + assert.False(t, check.IfNil(kl)) +} + +func TestKeyLoader_LoadKey(t *testing.T) { + t.Parallel() + + kl := NewKeyLoader() + file, sourceData := createTestFile(t) + recoveredData := make(map[string][]byte) + for i := 0; i < 3; i++ { + sk, pk, err := kl.LoadKey(file, i) + assert.Nil(t, err) + recoveredData[pk] = sk + } + + assert.Equal(t, sourceData, recoveredData) +} + +func TestKeyLoader_LoadAllKeys(t *testing.T) { + t.Parallel() + + kl := NewKeyLoader() + file, sourceData := createTestFile(t) + + recoveredData := make(map[string][]byte) + privateKeys, publicKeys, err := kl.LoadAllKeys(file) + assert.Nil(t, err) + + for i, pk := range publicKeys { + recoveredData[pk] = privateKeys[i] + } + + assert.Equal(t, sourceData, recoveredData) +} + +func createTestFile(tb testing.TB) (string, map[string][]byte) { + fileName := filepath.Join(tb.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(tb, err) + + pkString1 := "ABCD1" + pkString2 := "ABCD2" + pkString3 := "ABCD2" + + data := make(map[string][]byte) + data[pkString1] = []byte{10, 20, 30, 40, 50, 60} + data[pkString2] = []byte{11, 21, 31, 41, 51, 61} + data[pkString3] = []byte{12, 22, 32, 42, 52, 62} + + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString1 + "-----\n") + _, _ = file.WriteString("ChQeKDI8\n") + _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString1 + "-----\n") + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString2 + "-----\n\n\n") + _, _ = file.WriteString("CxUfKTM9\n") + _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString2 + "-----\n") + _, _ = file.WriteString("-----BEGIN PRIVATE KEY for " + pkString3 + "-----\n") + _, _ = file.WriteString("DBYgKjQ+\n") + _, _ = file.WriteString("-----END PRIVATE KEY for " + pkString3 + "-----\n\n\n\n") + _ = file.Close() + + return fileName, data +} diff --git a/core/keyValStorage/keyValStorage.go b/core/keyValStorage/keyValStorage.go index b3cbc49b6..963f62457 100644 --- a/core/keyValStorage/keyValStorage.go +++ b/core/keyValStorage/keyValStorage.go @@ -1,11 +1,5 @@ package keyValStorage -import ( - "bytes" - - "github.com/multiversx/mx-chain-core-go/core" -) - // KeyValStorage holds a key and an associated value type keyValStorage struct { key []byte @@ -29,22 +23,3 @@ func (k *keyValStorage) Key() []byte { func (k *keyValStorage) Value() []byte { return k.value } - -// ValueWithoutSuffix will try to trim the suffix from the current data field -func (k *keyValStorage) ValueWithoutSuffix(suffix []byte) ([]byte, error) { - if len(suffix) == 0 { - return k.value, nil - } - - lenValue := len(k.value) - lenSuffix := len(suffix) - position := bytes.Index(k.value, suffix) - if position != lenValue-lenSuffix || position < 0 { - return nil, core.ErrSuffixNotPresentOrInIncorrectPosition - } - - newData := make([]byte, lenValue-lenSuffix) - copy(newData, k.value[:position]) - - return newData, nil -} diff --git a/core/keyValStorage/keyValStorage_test.go b/core/keyValStorage/keyValStorage_test.go index 57a4001f8..7c57cb02e 100644 --- a/core/keyValStorage/keyValStorage_test.go +++ b/core/keyValStorage/keyValStorage_test.go @@ -3,7 +3,6 @@ package keyValStorage_test import ( "testing" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-core-go/core/keyValStorage" "github.com/stretchr/testify/assert" ) @@ -19,37 +18,3 @@ func TestNewKeyValStorage_GetKeyAndVal(t *testing.T) { assert.Equal(t, key, keyVal.Key()) assert.Equal(t, value, keyVal.Value()) } - -func TestKeyValStorage_ValueWithoutSuffix(t *testing.T) { - t.Parallel() - - keyVal := keyValStorage.NewKeyValStorage([]byte("key"), []byte("val")) - trimmedData, err := keyVal.ValueWithoutSuffix([]byte("val2")) - assert.Equal(t, core.ErrSuffixNotPresentOrInIncorrectPosition, err) - assert.Nil(t, trimmedData) - - trimmedData, err = keyVal.ValueWithoutSuffix([]byte("va")) - assert.Equal(t, core.ErrSuffixNotPresentOrInIncorrectPosition, err) - assert.Nil(t, trimmedData) - - trimmedData, err = keyVal.ValueWithoutSuffix([]byte("l")) - assert.Nil(t, err) - assert.Equal(t, []byte("va"), trimmedData) - - trimmedData, err = keyVal.ValueWithoutSuffix([]byte("al")) - assert.Nil(t, err) - assert.Equal(t, []byte("v"), trimmedData) - - trimmedData, err = keyVal.ValueWithoutSuffix([]byte("val")) - assert.Nil(t, err) - assert.Equal(t, []byte(""), trimmedData) - - trimmedData, err = keyVal.ValueWithoutSuffix([]byte("")) - assert.Nil(t, err) - assert.Equal(t, []byte("val"), trimmedData) - - keyVal = keyValStorage.NewKeyValStorage([]byte(""), []byte("")) - trimmedData, err = keyVal.ValueWithoutSuffix([]byte("")) - assert.Nil(t, err) - assert.Equal(t, []byte(""), trimmedData) -} diff --git a/core/machineID.go b/core/machineID.go index d93d66ea4..7af988bf9 100644 --- a/core/machineID.go +++ b/core/machineID.go @@ -2,16 +2,14 @@ package core import "github.com/denisbrodbeck/machineid" -const maxMachineIDLen = 10 - // GetAnonymizedMachineID returns the machine ID anonymized with the provided app ID string func GetAnonymizedMachineID(appID string) string { machineID, err := machineid.ProtectedID(appID) if err != nil { machineID = "unknown machine ID" } - if len(machineID) > maxMachineIDLen { - machineID = machineID[:maxMachineIDLen] + if len(machineID) > MaxMachineIDLen { + machineID = machineID[:MaxMachineIDLen] } return machineID diff --git a/core/machineID_test.go b/core/machineID_test.go index bc9a6e8a5..5ca8b09af 100644 --- a/core/machineID_test.go +++ b/core/machineID_test.go @@ -13,6 +13,6 @@ func TestGetAnonymizedMachineID(t *testing.T) { secondVariant := GetAnonymizedMachineID("second") assert.NotEqual(t, firstVariant, secondVariant) - assert.Equal(t, maxMachineIDLen, len(firstVariant)) - assert.Equal(t, maxMachineIDLen, len(secondVariant)) + assert.Equal(t, MaxMachineIDLen, len(firstVariant)) + assert.Equal(t, MaxMachineIDLen, len(secondVariant)) } diff --git a/core/mock/enableEpochsHandlerMock.go b/core/mock/enableEpochsHandlerMock.go new file mode 100644 index 000000000..91abd5be5 --- /dev/null +++ b/core/mock/enableEpochsHandlerMock.go @@ -0,0 +1,20 @@ +package mock + +// EnableEpochsHandlerStub - +type EnableEpochsHandlerStub struct { + IsAutoBalanceDataTriesEnabledCalled func() bool +} + +// IsAutoBalanceDataTriesEnabled - +func (e *EnableEpochsHandlerStub) IsAutoBalanceDataTriesEnabled() bool { + if e.IsAutoBalanceDataTriesEnabledCalled != nil { + return e.IsAutoBalanceDataTriesEnabledCalled() + } + + return false +} + +// IsInterfaceNil returns true if there is no value under the interface +func (e *EnableEpochsHandlerStub) IsInterfaceNil() bool { + return e == nil +} diff --git a/core/nodetype/nodeTypeProvider.go b/core/nodetype/nodeTypeProvider.go index feb059bc2..6083c7f90 100644 --- a/core/nodetype/nodeTypeProvider.go +++ b/core/nodetype/nodeTypeProvider.go @@ -33,7 +33,7 @@ func (ntp *nodeTypeProvider) GetType() core.NodeType { return ntp.nodeType } -// IsInterfaceNil returns true is there is no value under the interface +// IsInterfaceNil returns true if there is no value under the interface func (ntp *nodeTypeProvider) IsInterfaceNil() bool { return ntp == nil } diff --git a/core/pubkeyConverter/bech32PubkeyConverter.go b/core/pubkeyConverter/bech32PubkeyConverter.go index 3361d007b..e77846fbf 100644 --- a/core/pubkeyConverter/bech32PubkeyConverter.go +++ b/core/pubkeyConverter/bech32PubkeyConverter.go @@ -18,7 +18,6 @@ type config struct { } var bech32Config = config{ - prefix: "erd", fromBits: byte(8), toBits: byte(5), pad: true, @@ -26,27 +25,28 @@ var bech32Config = config{ // bech32PubkeyConverter encodes or decodes provided public key as/from bech32 format type bech32PubkeyConverter struct { - log core.Logger - len int + prefix string + len int } // NewBech32PubkeyConverter returns a bech32PubkeyConverter instance -func NewBech32PubkeyConverter(addressLen int, log core.Logger) (*bech32PubkeyConverter, error) { +func NewBech32PubkeyConverter(addressLen int, prefix string) (*bech32PubkeyConverter, error) { if addressLen < 1 { - return nil, fmt.Errorf("%w when creating hex address converter, addressLen should have been greater than 0", + return nil, fmt.Errorf("%w when creating address converter, addressLen should have been greater than 0", ErrInvalidAddressLength) } if addressLen%2 == 1 { - return nil, fmt.Errorf("%w when creating hex address converter, addressLen should have been an even number", + return nil, fmt.Errorf("%w when creating address converter, addressLen should have been an even number", ErrInvalidAddressLength) } - if check.IfNil(log) { - return nil, core.ErrNilLogger + if !check.IfHrp(prefix) { + return nil, fmt.Errorf("%w when creating address converter, prefix should have been human readable", + ErrInvalidHrpPrefix) } return &bech32PubkeyConverter{ - log: log, - len: addressLen, + prefix: prefix, + len: addressLen, }, nil } @@ -61,7 +61,7 @@ func (bpc *bech32PubkeyConverter) Decode(humanReadable string) ([]byte, error) { if err != nil { return nil, err } - if decodedPrefix != bech32Config.prefix { + if decodedPrefix != bpc.prefix { return nil, ErrInvalidErdAddress } @@ -80,42 +80,52 @@ func (bpc *bech32PubkeyConverter) Decode(humanReadable string) ([]byte, error) { } // Encode converts the provided bytes in a bech32 form -func (bpc *bech32PubkeyConverter) Encode(pkBytes []byte) string { +func (bpc *bech32PubkeyConverter) Encode(pkBytes []byte) (string, error) { if len(pkBytes) != bpc.len { - bpc.log.Debug("bech32PubkeyConverter.Encode PkBytesLength", - "hex buff", hex.EncodeToString(pkBytes), - "error", ErrWrongSize, - "stack trace", string(debug.Stack()), - ) - - return "" + return "", fmt.Errorf("%w when encoding address, expected length %d, received %d", + ErrWrongSize, bpc.len, len(pkBytes)) } - //since the errors generated here are usually because of a bad config, they will be treated here conv, err := bech32.ConvertBits(pkBytes, bech32Config.fromBits, bech32Config.toBits, bech32Config.pad) if err != nil { - bpc.log.Warn("bech32PubkeyConverter.Encode ConvertBits", - "hex buff", hex.EncodeToString(pkBytes), - "error", err, - "stack trace", string(debug.Stack()), - ) + return "", fmt.Errorf("%w: %s", ErrConvertBits, err.Error()) + } - return "" + encodedBytes, err := bech32.Encode(bpc.prefix, conv) + if err != nil { + return "", fmt.Errorf("%w: %s", ErrBech32ConvertError, err.Error()) } - converted, err := bech32.Encode(bech32Config.prefix, conv) + return encodedBytes, nil +} + +// SilentEncode converts the provided bytes in a bech32 form without returning any error +func (bpc *bech32PubkeyConverter) SilentEncode(pkBytes []byte, log core.Logger) string { + encodedBytes, err := bpc.Encode(pkBytes) if err != nil { - bpc.log.Warn("bech32PubkeyConverter.Encode Encode", + log.Warn("bech32PubkeyConverter.SilentEncode", "hex buff", hex.EncodeToString(pkBytes), - "conv", hex.EncodeToString(conv), "error", err, - "stack trace", string(debug.Stack()), - ) - + "stack trace", string(debug.Stack())) return "" } - return converted + return encodedBytes +} + +// EncodeSlice converts the provided bytes slice into a slice of bech32 addresses +func (bpc *bech32PubkeyConverter) EncodeSlice(pkBytesSlice [][]byte) ([]string, error) { + encodedSlice := make([]string, 0, len(pkBytesSlice)) + + for _, item := range pkBytesSlice { + encoded, err := bpc.Encode(item) + if err != nil { + return nil, err + } + encodedSlice = append(encodedSlice, encoded) + } + + return encodedSlice, nil } // IsInterfaceNil returns true if there is no value under the interface diff --git a/core/pubkeyConverter/bech32PubkeyConverter_test.go b/core/pubkeyConverter/bech32PubkeyConverter_test.go index cb8f896b5..785baab35 100644 --- a/core/pubkeyConverter/bech32PubkeyConverter_test.go +++ b/core/pubkeyConverter/bech32PubkeyConverter_test.go @@ -1,11 +1,13 @@ package pubkeyConverter_test import ( + "encoding/hex" "errors" "fmt" "strings" "testing" + "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/core/pubkeyConverter" @@ -15,15 +17,15 @@ import ( func TestNewBech32PubkeyConverter_InvalidSizeShouldErr(t *testing.T) { t.Parallel() - bpc, err := pubkeyConverter.NewBech32PubkeyConverter(-1, &mock.LoggerMock{}) + bpc, err := pubkeyConverter.NewBech32PubkeyConverter(-1, core.DefaultAddressPrefix) assert.True(t, errors.Is(err, pubkeyConverter.ErrInvalidAddressLength)) assert.True(t, check.IfNil(bpc)) - bpc, err = pubkeyConverter.NewBech32PubkeyConverter(0, &mock.LoggerMock{}) + bpc, err = pubkeyConverter.NewBech32PubkeyConverter(0, core.DefaultAddressPrefix) assert.True(t, errors.Is(err, pubkeyConverter.ErrInvalidAddressLength)) assert.True(t, check.IfNil(bpc)) - bpc, err = pubkeyConverter.NewBech32PubkeyConverter(3, &mock.LoggerMock{}) + bpc, err = pubkeyConverter.NewBech32PubkeyConverter(3, core.DefaultAddressPrefix) assert.True(t, errors.Is(err, pubkeyConverter.ErrInvalidAddressLength)) assert.True(t, check.IfNil(bpc)) } @@ -32,7 +34,7 @@ func TestNewBech32PubkeyConverter_ShouldWork(t *testing.T) { t.Parallel() addressLen := 28 - bpc, err := pubkeyConverter.NewBech32PubkeyConverter(addressLen, &mock.LoggerMock{}) + bpc, err := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) assert.Nil(t, err) assert.False(t, check.IfNil(bpc)) @@ -43,7 +45,7 @@ func TestBech32PubkeyConverter_DecodeInvalidStringShouldErr(t *testing.T) { t.Parallel() addressLen := 32 - bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, &mock.LoggerMock{}) + bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) str, err := bpc.Decode("not a bech32 string") @@ -55,7 +57,7 @@ func TestBech32PubkeyConverter_DecodePrefixMismatchShouldErr(t *testing.T) { t.Parallel() addressLen := 32 - bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, &mock.LoggerMock{}) + bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) str, err := bpc.Decode("err1xyerxdp4xcmnswfsxyerxdp4xcmnswfsxyerxdp4xcmnswfsxyeqnyphvl") @@ -67,7 +69,7 @@ func TestBech32PubkeyConverter_DecodeWrongSizeShouldErr(t *testing.T) { t.Parallel() addressLen := 32 - bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, &mock.LoggerMock{}) + bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) str, err := bpc.Decode("erd1xyerxdp4xcmnswfsxyeqqzq40r") @@ -75,15 +77,40 @@ func TestBech32PubkeyConverter_DecodeWrongSizeShouldErr(t *testing.T) { assert.True(t, errors.Is(err, pubkeyConverter.ErrWrongSize)) } +func TestBech32PubkeyConverter_SilentEncodeShouldWork(t *testing.T) { + t.Parallel() + + addressLen := 32 + bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) + + buff := []byte("12345678901234567890123456789012") + str := bpc.SilentEncode(buff, &mock.LoggerMock{}) + + assert.Equal(t, 0, strings.Index(str, pubkeyConverter.Prefix)) +} + +func TestBech32PubkeyConverter_SilentEncodeShouldNotWork(t *testing.T) { + t.Parallel() + + addressLen := 32 + bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) + + buff := []byte("1234") + str := bpc.SilentEncode(buff, &mock.LoggerMock{}) + + assert.Equal(t, "", str) +} + func TestBech32PubkeyConverter_EncodeDecodeShouldWork(t *testing.T) { t.Parallel() addressLen := 32 - bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, &mock.LoggerMock{}) + bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) buff := []byte("12345678901234567890123456789012") - str := bpc.Encode(buff) + str, err := bpc.Encode(buff) + assert.Nil(t, err) assert.Equal(t, 0, strings.Index(str, pubkeyConverter.Prefix)) fmt.Printf("generated address: %s\n", str) @@ -95,18 +122,49 @@ func TestBech32PubkeyConverter_EncodeDecodeShouldWork(t *testing.T) { } func TestBech32PubkeyConverter_EncodeWrongLengthShouldReturnEmpty(t *testing.T) { + t.Parallel() + addressLen := 32 - bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, &mock.LoggerMock{}) + bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) buff := []byte("12345678901234567890") - str := bpc.Encode(buff) + str, err := bpc.Encode(buff) + + assert.True(t, errors.Is(err, pubkeyConverter.ErrWrongSize)) assert.Equal(t, "", str) buff = []byte{} - str = bpc.Encode(buff) + str, err = bpc.Encode(buff) + + assert.True(t, errors.Is(err, pubkeyConverter.ErrWrongSize)) assert.Equal(t, "", str) buff = []byte("1234567890123456789012345678901234567890") - str = bpc.Encode(buff) + str, err = bpc.Encode(buff) + + assert.True(t, errors.Is(err, pubkeyConverter.ErrWrongSize)) assert.Equal(t, "", str) } + +func TestBech32PubkeyConverter_EncodeSliceShouldWork(t *testing.T) { + t.Parallel() + + addressLen := 32 + sliceLen := 2 + + bpc, _ := pubkeyConverter.NewBech32PubkeyConverter(addressLen, core.DefaultAddressPrefix) + + decodedSlice := make([][]byte, 0) + + alice, _ := hex.DecodeString("0139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e1") + decodedSlice = append(decodedSlice, alice) + + bob, _ := hex.DecodeString("8049d639e5a6980d1cd2392abcce41029cda74a1563523a202f09641cc2618f8") + decodedSlice = append(decodedSlice, bob) + + str, err := bpc.EncodeSlice(decodedSlice) + assert.Nil(t, err) + assert.Equal(t, sliceLen, len(str)) + assert.Equal(t, []string{"erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th", + "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"}, str) +} diff --git a/core/pubkeyConverter/errors.go b/core/pubkeyConverter/errors.go index 8640e9ae7..5dd9db3aa 100644 --- a/core/pubkeyConverter/errors.go +++ b/core/pubkeyConverter/errors.go @@ -11,5 +11,11 @@ var ErrWrongSize = errors.New("wrong size") // ErrInvalidErdAddress signals that the provided address is not an ERD address var ErrInvalidErdAddress = errors.New("invalid ERD address") -//ErrBech32ConvertError signals that conversion the 5bit alphabet to 8bit failed +// ErrBech32ConvertError signals that conversion the 5bit alphabet to 8bit failed var ErrBech32ConvertError = errors.New("can't convert bech32 string") + +// ErrHrpPrefix signals that the prefix is not human readable or empty +var ErrInvalidHrpPrefix = errors.New("invalid hrp prefix") + +// ErrConvertBits signals that a configuration mistake has been introduced +var ErrConvertBits = errors.New("invalid fromBits or toBits when converting bits") diff --git a/core/pubkeyConverter/hexPubkeyConverter.go b/core/pubkeyConverter/hexPubkeyConverter.go index 470d05615..5ab7477cb 100644 --- a/core/pubkeyConverter/hexPubkeyConverter.go +++ b/core/pubkeyConverter/hexPubkeyConverter.go @@ -3,6 +3,8 @@ package pubkeyConverter import ( "encoding/hex" "fmt" + + "github.com/multiversx/mx-chain-core-go/core" ) // hexPubkeyConverter encodes or decodes provided public key as/from hex @@ -42,7 +44,23 @@ func (ppc *hexPubkeyConverter) Decode(humanReadable string) ([]byte, error) { } // Encode converts the provided bytes in a form that this converter can decode. In this case it will encode to hex -func (ppc *hexPubkeyConverter) Encode(pkBytes []byte) string { +func (ppc *hexPubkeyConverter) Encode(pkBytes []byte) (string, error) { + return hex.EncodeToString(pkBytes), nil +} + +// EncodeSlice converts the provided bytes slice in a form that this converter can decode. In this case it will encode to hex +func (ppc *hexPubkeyConverter) EncodeSlice(pkBytesSlice [][]byte) ([]string, error) { + encodedSlice := make([]string, 0, len(pkBytesSlice)) + + for _, item := range pkBytesSlice { + encodedSlice = append(encodedSlice, hex.EncodeToString(item)) + } + + return encodedSlice, nil +} + +// SilentEncode converts the provided bytes in a form that this converter can decode. In this case it will encode to hex +func (ppc *hexPubkeyConverter) SilentEncode(pkBytes []byte, log core.Logger) string { return hex.EncodeToString(pkBytes) } diff --git a/core/pubkeyConverter/hexPubkeyConverter_test.go b/core/pubkeyConverter/hexPubkeyConverter_test.go index 84f1b7c91..b1c813684 100644 --- a/core/pubkeyConverter/hexPubkeyConverter_test.go +++ b/core/pubkeyConverter/hexPubkeyConverter_test.go @@ -5,6 +5,7 @@ import ( "testing" "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" ) @@ -69,7 +70,18 @@ func TestHexPubkeyConverter_EncodeShouldWork(t *testing.T) { addressLen := 4 hpc, _ := pubkeyConverter.NewHexPubkeyConverter(addressLen) - str := hpc.Encode([]byte{170, 255}) + str, err := hpc.Encode([]byte{170, 255}) + assert.Nil(t, err) + assert.Equal(t, "aaff", str) +} + +func TestHexPubkeyConverter_SilentEncodeShouldWork(t *testing.T) { + t.Parallel() + + addressLen := 4 + hpc, _ := pubkeyConverter.NewHexPubkeyConverter(addressLen) + + str := hpc.SilentEncode([]byte{170, 255}, &mock.LoggerMock{}) assert.Equal(t, "aaff", str) } @@ -83,7 +95,30 @@ func TestHexPubkeyConverter_EncodeDecodeShouldWork(t *testing.T) { buff, err := hpc.Decode(value) assert.Nil(t, err) - revoveredValue := hpc.Encode(buff) + recoveredValue, err := hpc.Encode(buff) + assert.Nil(t, err) + assert.Equal(t, value, recoveredValue) +} - assert.Equal(t, value, revoveredValue) +func TestHexPubkeyConverter_EncodeSliceShouldWork(t *testing.T) { + t.Parallel() + + addressLen := 16 + sliceLen := 2 + + hpc, _ := pubkeyConverter.NewHexPubkeyConverter(addressLen) + + decodedSlice := make([][]byte, 0) + + hexPubkey1, _ := hpc.Decode("123456789012345678901234567890af") + decodedSlice = append(decodedSlice, hexPubkey1) + + hexPubkey2, _ := hpc.Decode("123456789012345678901234567890af") + decodedSlice = append(decodedSlice, hexPubkey2) + + str, err := hpc.EncodeSlice(decodedSlice) + assert.Nil(t, err) + assert.Equal(t, sliceLen, len(str)) + assert.Equal(t, []string{"123456789012345678901234567890af", + "123456789012345678901234567890af"}, str) } diff --git a/core/transaction/transactionSorter.go b/core/transaction/transactionSorter.go index 5f6267cb2..db6532517 100644 --- a/core/transaction/transactionSorter.go +++ b/core/transaction/transactionSorter.go @@ -37,23 +37,27 @@ func SortTransactionsBySenderAndNonceWithFrontRunningProtection(transactions []d // 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) { +func SortTransactionsBySenderAndNonceWithFrontRunningProtectionExtendedTransactions(transactions []data.TxWithExecutionOrderHandler, 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)) + txHandler := tx.GetTxHandler() + + xoredBytes := xorBytes(txHandler.GetSndAddr(), randSeed) + xoredAddresses[string(txHandler.GetSndAddr())] = hasher.Compute(string(xoredBytes)) } sorter := func(i, j int) bool { txI := transactions[i] txJ := transactions[j] + txIHandler := txI.GetTxHandler() + txJHandler := txJ.GetTxHandler() - delta := bytes.Compare(xoredAddresses[string(txI.GetSndAddr())], xoredAddresses[string(txJ.GetSndAddr())]) + delta := bytes.Compare(xoredAddresses[string(txIHandler.GetSndAddr())], xoredAddresses[string(txJHandler.GetSndAddr())]) if delta == 0 { - delta = int(txI.GetNonce()) - int(txJ.GetNonce()) + delta = int(txIHandler.GetNonce()) - int(txJHandler.GetNonce()) } return delta < 0 @@ -80,14 +84,16 @@ func SortTransactionsBySenderAndNonce(transactions []data.TransactionHandler) { } // SortTransactionsBySenderAndNonceExtendedTransactions - sorts the transactions by address without the front running protection -func SortTransactionsBySenderAndNonceExtendedTransactions(transactions []data.TransactionHandlerWithGasUsedAndFee) { +func SortTransactionsBySenderAndNonceExtendedTransactions(transactions []data.TxWithExecutionOrderHandler) { sorter := func(i, j int) bool { txI := transactions[i] txJ := transactions[j] + txIHandler := txI.GetTxHandler() + txJHandler := txJ.GetTxHandler() - delta := bytes.Compare(txI.GetSndAddr(), txJ.GetSndAddr()) + delta := bytes.Compare(txIHandler.GetSndAddr(), txJHandler.GetSndAddr()) if delta == 0 { - delta = int(txI.GetNonce()) - int(txJ.GetNonce()) + delta = int(txIHandler.GetNonce()) - int(txJHandler.GetNonce()) } return delta < 0 diff --git a/core/transaction/transactionSorter_test.go b/core/transaction/transactionSorter_test.go index f690f2269..4e4c64137 100644 --- a/core/transaction/transactionSorter_test.go +++ b/core/transaction/transactionSorter_test.go @@ -47,11 +47,12 @@ func Test_SortTransactionsBySenderAndNonceWithFrontRunningProtection(t *testing. &transaction.Transaction{Nonce: 3, SndAddr: senders[3]}, &transaction.Transaction{Nonce: 3, SndAddr: senders[2]}, } - wrappedTxs := make([]data.TransactionHandlerWithGasUsedAndFee, 0, len(txs)) + wrappedTxs := make([]data.TxWithExecutionOrderHandler, 0, len(txs)) for _, tx := range txs { - wrappedTxs = append(wrappedTxs, outport.NewTransactionHandlerWithGasAndFee(tx, 0, big.NewInt(0))) + wrappedTxs = append(wrappedTxs, &outport.TxInfo{ + Transaction: tx.(*transaction.Transaction), + FeeInfo: &outport.FeeInfo{Fee: big.NewInt(0)}}) } - SortTransactionsBySenderAndNonceWithFrontRunningProtection(txs, hasher, []byte(randomness)) SortTransactionsBySenderAndNonceWithFrontRunningProtectionExtendedTransactions(wrappedTxs, hasher, []byte(randomness)) @@ -69,7 +70,7 @@ func Test_SortTransactionsBySenderAndNonceWithFrontRunningProtection(t *testing. 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()))) + assert.Equal(t, expectedOutput[i], fmt.Sprintf("%d %s", wrappedTxs[i].GetTxHandler().GetNonce(), hex.EncodeToString(wrappedTxs[i].GetTxHandler().GetSndAddr()))) } } @@ -84,9 +85,11 @@ func Test_SortTransactionsBySenderAndNonceLegacy(t *testing.T) { &transaction.Transaction{Nonce: 3, SndAddr: []byte("ffff")}, &transaction.Transaction{Nonce: 3, SndAddr: []byte("eeee")}, } - wrappedTxs := make([]data.TransactionHandlerWithGasUsedAndFee, 0, len(txs)) + wrappedTxs := make([]data.TxWithExecutionOrderHandler, 0, len(txs)) for _, tx := range txs { - wrappedTxs = append(wrappedTxs, outport.NewTransactionHandlerWithGasAndFee(tx, 0, big.NewInt(0))) + wrappedTxs = append(wrappedTxs, &outport.TxInfo{ + Transaction: tx.(*transaction.Transaction), + FeeInfo: &outport.FeeInfo{Fee: big.NewInt(0)}}) } SortTransactionsBySenderAndNonce(txs) @@ -105,6 +108,6 @@ func Test_SortTransactionsBySenderAndNonceLegacy(t *testing.T) { 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()))) + assert.Equal(t, expectedOutput[i], fmt.Sprintf("%d %s", wrappedTxs[i].GetTxHandler().GetNonce(), string(wrappedTxs[i].GetTxHandler().GetSndAddr()))) } } diff --git a/core/trie.go b/core/trie.go new file mode 100644 index 000000000..de4623765 --- /dev/null +++ b/core/trie.go @@ -0,0 +1,81 @@ +package core + +import ( + "strconv" + + "github.com/multiversx/mx-chain-core-go/core/check" +) + +// TrieNodeVersion defines the version of the trie node +type TrieNodeVersion uint8 + +const ( + // NotSpecified means that the value is not populated or is not important + NotSpecified TrieNodeVersion = iota + + // AutoBalanceEnabled is used for data tries, and only after the activation of AutoBalanceDataTriesEnableEpoch flag + AutoBalanceEnabled +) + +const ( + // NotSpecifiedString is the string representation of NotSpecified trie node version + NotSpecifiedString = "not specified" + + // AutoBalanceEnabledString is the string representation of AutoBalanceEnabled trie node version + AutoBalanceEnabledString = "auto balanced" +) + +func (version TrieNodeVersion) String() string { + switch version { + case NotSpecified: + return NotSpecifiedString + case AutoBalanceEnabled: + return AutoBalanceEnabledString + default: + return "unknown: " + strconv.Itoa(int(version)) + } +} + +type trieNodeVersionVerifier struct { + enableEpochsHandler EnableEpochsHandler +} + +func NewTrieNodeVersionVerifier(enableEpochsHandler EnableEpochsHandler) (*trieNodeVersionVerifier, error) { + if check.IfNil(enableEpochsHandler) { + return nil, ErrNilEnableEpochsHandler + } + + return &trieNodeVersionVerifier{ + enableEpochsHandler: enableEpochsHandler, + }, nil +} + +// IsValidVersion returns true if the given trie node version is valid +func (vv *trieNodeVersionVerifier) IsValidVersion(version TrieNodeVersion) bool { + if vv.enableEpochsHandler.IsAutoBalanceDataTriesEnabled() { + return version <= AutoBalanceEnabled + } + + return version == NotSpecified +} + +// IsInterfaceNil returns true if there is no value under the interface +func (vv *trieNodeVersionVerifier) IsInterfaceNil() bool { + return vv == nil +} + +// GetVersionForNewData returns the trie node version that should be used for new data +func GetVersionForNewData(handler EnableEpochsHandler) TrieNodeVersion { + if handler.IsAutoBalanceDataTriesEnabled() { + return AutoBalanceEnabled + } + + return NotSpecified +} + +// TrieData holds the data that will be inserted into the trie +type TrieData struct { + Key []byte + Value []byte + Version TrieNodeVersion +} diff --git a/core/trie_test.go b/core/trie_test.go new file mode 100644 index 000000000..d5332723a --- /dev/null +++ b/core/trie_test.go @@ -0,0 +1,100 @@ +package core + +import ( + "testing" + + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/core/mock" + "github.com/stretchr/testify/assert" +) + +func TestNewTrieNodeVersionVerifier(t *testing.T) { + t.Parallel() + + t.Run("nil enableEpochsHandler", func(t *testing.T) { + t.Parallel() + + vv, err := NewTrieNodeVersionVerifier(nil) + assert.Nil(t, vv) + assert.Equal(t, ErrNilEnableEpochsHandler, err) + }) + t.Run("new trieNodeVersionVerifier", func(t *testing.T) { + t.Parallel() + + vv, err := NewTrieNodeVersionVerifier(&mock.EnableEpochsHandlerStub{}) + assert.Nil(t, err) + assert.False(t, check.IfNil(vv)) + }) +} + +func TestTrieNodeVersionVerifier_IsValidVersion(t *testing.T) { + t.Parallel() + + t.Run("auto balance enabled", func(t *testing.T) { + t.Parallel() + + vv, _ := NewTrieNodeVersionVerifier( + &mock.EnableEpochsHandlerStub{ + IsAutoBalanceDataTriesEnabledCalled: func() bool { + return true + }, + }, + ) + assert.True(t, vv.IsValidVersion(NotSpecified)) + assert.True(t, vv.IsValidVersion(AutoBalanceEnabled)) + assert.False(t, vv.IsValidVersion(AutoBalanceEnabled+1)) + }) + + t.Run("auto balance disabled", func(t *testing.T) { + t.Parallel() + + vv, _ := NewTrieNodeVersionVerifier( + &mock.EnableEpochsHandlerStub{ + IsAutoBalanceDataTriesEnabledCalled: func() bool { + return false + }, + }, + ) + assert.True(t, vv.IsValidVersion(NotSpecified)) + assert.False(t, vv.IsValidVersion(AutoBalanceEnabled)) + assert.False(t, vv.IsValidVersion(AutoBalanceEnabled+1)) + }) +} + +func TestTrieNodeVersion_String(t *testing.T) { + t.Parallel() + + assert.Equal(t, NotSpecifiedString, NotSpecified.String()) + assert.Equal(t, AutoBalanceEnabledString, AutoBalanceEnabled.String()) + assert.Equal(t, "unknown: 100", TrieNodeVersion(100).String()) +} + +func TestGetVersionForNewData(t *testing.T) { + t.Parallel() + + t.Run("auto balance enabled", func(t *testing.T) { + t.Parallel() + + getVersionForNewData := GetVersionForNewData( + &mock.EnableEpochsHandlerStub{ + IsAutoBalanceDataTriesEnabledCalled: func() bool { + return true + }, + }, + ) + assert.Equal(t, AutoBalanceEnabled, getVersionForNewData) + }) + + t.Run("auto balance disabled", func(t *testing.T) { + t.Parallel() + + getVersionForNewData := GetVersionForNewData( + &mock.EnableEpochsHandlerStub{ + IsAutoBalanceDataTriesEnabledCalled: func() bool { + return false + }, + }, + ) + assert.Equal(t, NotSpecified, getVersionForNewData) + }) +} diff --git a/data/alteredAccount/alteredAccount.go b/data/alteredAccount/alteredAccount.go new file mode 100644 index 000000000..a4f35d01e --- /dev/null +++ b/data/alteredAccount/alteredAccount.go @@ -0,0 +1,2 @@ +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src alteredAccount.proto +package alteredAccount diff --git a/data/alteredAccount/alteredAccount.pb.go b/data/alteredAccount/alteredAccount.pb.go new file mode 100644 index 000000000..231e1957f --- /dev/null +++ b/data/alteredAccount/alteredAccount.pb.go @@ -0,0 +1,2478 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: alteredAccount.proto + +package alteredAccount + +import ( + bytes "bytes" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type AlteredAccount struct { + Address string `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` + Nonce uint64 `protobuf:"varint,2,opt,name=Nonce,proto3" json:"nonce"` + Balance string `protobuf:"bytes,3,opt,name=Balance,proto3" json:"balance,omitempty"` + Tokens []*AccountTokenData `protobuf:"bytes,4,rep,name=Tokens,proto3" json:"tokens,omitempty"` + AdditionalData *AdditionalAccountData `protobuf:"bytes,5,opt,name=AdditionalData,proto3" json:"additionalAccountData,omitempty"` +} + +func (m *AlteredAccount) Reset() { *m = AlteredAccount{} } +func (*AlteredAccount) ProtoMessage() {} +func (*AlteredAccount) Descriptor() ([]byte, []int) { + return fileDescriptor_804e04a1cde31bca, []int{0} +} +func (m *AlteredAccount) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AlteredAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *AlteredAccount) XXX_Merge(src proto.Message) { + xxx_messageInfo_AlteredAccount.Merge(m, src) +} +func (m *AlteredAccount) XXX_Size() int { + return m.Size() +} +func (m *AlteredAccount) XXX_DiscardUnknown() { + xxx_messageInfo_AlteredAccount.DiscardUnknown(m) +} + +var xxx_messageInfo_AlteredAccount proto.InternalMessageInfo + +func (m *AlteredAccount) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *AlteredAccount) GetNonce() uint64 { + if m != nil { + return m.Nonce + } + return 0 +} + +func (m *AlteredAccount) GetBalance() string { + if m != nil { + return m.Balance + } + return "" +} + +func (m *AlteredAccount) GetTokens() []*AccountTokenData { + if m != nil { + return m.Tokens + } + return nil +} + +func (m *AlteredAccount) GetAdditionalData() *AdditionalAccountData { + if m != nil { + return m.AdditionalData + } + return nil +} + +type AccountTokenData struct { + Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` + Identifier string `protobuf:"bytes,2,opt,name=Identifier,proto3" json:"identifier"` + Balance string `protobuf:"bytes,3,opt,name=Balance,proto3" json:"balance"` + Properties string `protobuf:"bytes,4,opt,name=Properties,proto3" json:"properties"` + MetaData *TokenMetaData `protobuf:"bytes,5,opt,name=MetaData,proto3" json:"metaData,omitempty"` + AdditionalData *AdditionalAccountTokenData `protobuf:"bytes,6,opt,name=AdditionalData,proto3" json:"additionalData,omitempty"` +} + +func (m *AccountTokenData) Reset() { *m = AccountTokenData{} } +func (*AccountTokenData) ProtoMessage() {} +func (*AccountTokenData) Descriptor() ([]byte, []int) { + return fileDescriptor_804e04a1cde31bca, []int{1} +} +func (m *AccountTokenData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AccountTokenData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *AccountTokenData) XXX_Merge(src proto.Message) { + xxx_messageInfo_AccountTokenData.Merge(m, src) +} +func (m *AccountTokenData) XXX_Size() int { + return m.Size() +} +func (m *AccountTokenData) XXX_DiscardUnknown() { + xxx_messageInfo_AccountTokenData.DiscardUnknown(m) +} + +var xxx_messageInfo_AccountTokenData proto.InternalMessageInfo + +func (m *AccountTokenData) GetNonce() uint64 { + if m != nil { + return m.Nonce + } + return 0 +} + +func (m *AccountTokenData) GetIdentifier() string { + if m != nil { + return m.Identifier + } + return "" +} + +func (m *AccountTokenData) GetBalance() string { + if m != nil { + return m.Balance + } + return "" +} + +func (m *AccountTokenData) GetProperties() string { + if m != nil { + return m.Properties + } + return "" +} + +func (m *AccountTokenData) GetMetaData() *TokenMetaData { + if m != nil { + return m.MetaData + } + return nil +} + +func (m *AccountTokenData) GetAdditionalData() *AdditionalAccountTokenData { + if m != nil { + return m.AdditionalData + } + return nil +} + +type TokenMetaData struct { + Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` + Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"name"` + Creator string `protobuf:"bytes,3,opt,name=Creator,proto3" json:"creator"` + Royalties uint32 `protobuf:"varint,4,opt,name=Royalties,proto3" json:"royalties"` + Hash []byte `protobuf:"bytes,5,opt,name=Hash,proto3" json:"hash"` + URIs [][]byte `protobuf:"bytes,6,rep,name=URIs,proto3" json:"uris"` + Attributes []byte `protobuf:"bytes,7,opt,name=Attributes,proto3" json:"attributes"` +} + +func (m *TokenMetaData) Reset() { *m = TokenMetaData{} } +func (*TokenMetaData) ProtoMessage() {} +func (*TokenMetaData) Descriptor() ([]byte, []int) { + return fileDescriptor_804e04a1cde31bca, []int{2} +} +func (m *TokenMetaData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TokenMetaData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *TokenMetaData) XXX_Merge(src proto.Message) { + xxx_messageInfo_TokenMetaData.Merge(m, src) +} +func (m *TokenMetaData) XXX_Size() int { + return m.Size() +} +func (m *TokenMetaData) XXX_DiscardUnknown() { + xxx_messageInfo_TokenMetaData.DiscardUnknown(m) +} + +var xxx_messageInfo_TokenMetaData proto.InternalMessageInfo + +func (m *TokenMetaData) GetNonce() uint64 { + if m != nil { + return m.Nonce + } + return 0 +} + +func (m *TokenMetaData) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *TokenMetaData) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *TokenMetaData) GetRoyalties() uint32 { + if m != nil { + return m.Royalties + } + return 0 +} + +func (m *TokenMetaData) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func (m *TokenMetaData) GetURIs() [][]byte { + if m != nil { + return m.URIs + } + return nil +} + +func (m *TokenMetaData) GetAttributes() []byte { + if m != nil { + return m.Attributes + } + return nil +} + +type AdditionalAccountTokenData struct { + IsNFTCreate bool `protobuf:"varint,1,opt,name=IsNFTCreate,proto3" json:"isNFTCreate,omitempty"` +} + +func (m *AdditionalAccountTokenData) Reset() { *m = AdditionalAccountTokenData{} } +func (*AdditionalAccountTokenData) ProtoMessage() {} +func (*AdditionalAccountTokenData) Descriptor() ([]byte, []int) { + return fileDescriptor_804e04a1cde31bca, []int{3} +} +func (m *AdditionalAccountTokenData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AdditionalAccountTokenData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *AdditionalAccountTokenData) XXX_Merge(src proto.Message) { + xxx_messageInfo_AdditionalAccountTokenData.Merge(m, src) +} +func (m *AdditionalAccountTokenData) XXX_Size() int { + return m.Size() +} +func (m *AdditionalAccountTokenData) XXX_DiscardUnknown() { + xxx_messageInfo_AdditionalAccountTokenData.DiscardUnknown(m) +} + +var xxx_messageInfo_AdditionalAccountTokenData proto.InternalMessageInfo + +func (m *AdditionalAccountTokenData) GetIsNFTCreate() bool { + if m != nil { + return m.IsNFTCreate + } + return false +} + +type AdditionalAccountData struct { + IsSender bool `protobuf:"varint,1,opt,name=IsSender,proto3" json:"isSender,omitempty"` + BalanceChanged bool `protobuf:"varint,2,opt,name=BalanceChanged,proto3" json:"balanceChanged,omitempty"` + CurrentOwner string `protobuf:"bytes,3,opt,name=CurrentOwner,proto3" json:"currentOwner,omitempty"` + UserName string `protobuf:"bytes,4,opt,name=UserName,proto3" json:"userName,omitempty"` + DeveloperRewards string `protobuf:"bytes,5,opt,name=DeveloperRewards,proto3" json:"developerRewards,omitempty"` + CodeHash []byte `protobuf:"bytes,6,opt,name=CodeHash,proto3" json:"codeHash,omitempty"` + RootHash []byte `protobuf:"bytes,7,opt,name=RootHash,proto3" json:"rootHash,omitempty"` + CodeMetadata []byte `protobuf:"bytes,8,opt,name=CodeMetadata,proto3" json:"codeMetadata,omitempty"` +} + +func (m *AdditionalAccountData) Reset() { *m = AdditionalAccountData{} } +func (*AdditionalAccountData) ProtoMessage() {} +func (*AdditionalAccountData) Descriptor() ([]byte, []int) { + return fileDescriptor_804e04a1cde31bca, []int{4} +} +func (m *AdditionalAccountData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AdditionalAccountData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *AdditionalAccountData) XXX_Merge(src proto.Message) { + xxx_messageInfo_AdditionalAccountData.Merge(m, src) +} +func (m *AdditionalAccountData) XXX_Size() int { + return m.Size() +} +func (m *AdditionalAccountData) XXX_DiscardUnknown() { + xxx_messageInfo_AdditionalAccountData.DiscardUnknown(m) +} + +var xxx_messageInfo_AdditionalAccountData proto.InternalMessageInfo + +func (m *AdditionalAccountData) GetIsSender() bool { + if m != nil { + return m.IsSender + } + return false +} + +func (m *AdditionalAccountData) GetBalanceChanged() bool { + if m != nil { + return m.BalanceChanged + } + return false +} + +func (m *AdditionalAccountData) GetCurrentOwner() string { + if m != nil { + return m.CurrentOwner + } + return "" +} + +func (m *AdditionalAccountData) GetUserName() string { + if m != nil { + return m.UserName + } + return "" +} + +func (m *AdditionalAccountData) GetDeveloperRewards() string { + if m != nil { + return m.DeveloperRewards + } + return "" +} + +func (m *AdditionalAccountData) GetCodeHash() []byte { + if m != nil { + return m.CodeHash + } + return nil +} + +func (m *AdditionalAccountData) GetRootHash() []byte { + if m != nil { + return m.RootHash + } + return nil +} + +func (m *AdditionalAccountData) GetCodeMetadata() []byte { + if m != nil { + return m.CodeMetadata + } + return nil +} + +func init() { + proto.RegisterType((*AlteredAccount)(nil), "proto.AlteredAccount") + proto.RegisterType((*AccountTokenData)(nil), "proto.AccountTokenData") + proto.RegisterType((*TokenMetaData)(nil), "proto.TokenMetaData") + proto.RegisterType((*AdditionalAccountTokenData)(nil), "proto.AdditionalAccountTokenData") + proto.RegisterType((*AdditionalAccountData)(nil), "proto.AdditionalAccountData") +} + +func init() { proto.RegisterFile("alteredAccount.proto", fileDescriptor_804e04a1cde31bca) } + +var fileDescriptor_804e04a1cde31bca = []byte{ + // 810 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x95, 0xcd, 0x6a, 0xeb, 0x46, + 0x14, 0xc7, 0x2d, 0x7f, 0x7b, 0x9c, 0x98, 0x54, 0x24, 0xa9, 0x6b, 0x82, 0xe4, 0xba, 0x14, 0x0c, + 0xad, 0x6d, 0x48, 0x97, 0x81, 0x82, 0xe5, 0xb4, 0xc4, 0x85, 0xa6, 0x45, 0x4d, 0x16, 0xed, 0x6e, + 0x2c, 0x4d, 0x6c, 0x51, 0x4b, 0x63, 0x46, 0xa3, 0x7c, 0xec, 0x0a, 0xdd, 0x97, 0x3e, 0x46, 0xdf, + 0xa1, 0x2f, 0xd0, 0x65, 0x96, 0x59, 0x89, 0x46, 0xd9, 0x5c, 0x04, 0x17, 0xb2, 0xbd, 0xbb, 0xcb, + 0x1c, 0x49, 0xf6, 0x28, 0x1f, 0xf7, 0xae, 0x92, 0xf9, 0x9f, 0x73, 0xfe, 0xe7, 0xf8, 0x77, 0x66, + 0x6c, 0xb4, 0x8b, 0x97, 0x9c, 0x30, 0x62, 0x8f, 0x2d, 0x8b, 0x06, 0x1e, 0x1f, 0xae, 0x18, 0xe5, + 0x54, 0xad, 0xc0, 0x9f, 0xce, 0x60, 0xee, 0xf0, 0x45, 0x30, 0x1b, 0x5a, 0xd4, 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63, 0x52, 0xca, 0xa1, 0xa6, 0xb6, 0xa9, 0x61, 0xa9, 0x26, 0xd7, 0x64, 0x79, 0xc0, 0x89, + 0xda, 0x44, 0xbc, 0x12, 0x5b, 0x3c, 0xc7, 0x3a, 0xd4, 0x25, 0x9c, 0x24, 0x3d, 0xc7, 0x49, 0xd2, + 0x8d, 0x3f, 0x95, 0xdb, 0x7b, 0xad, 0x70, 0x77, 0xaf, 0x15, 0x1e, 0xef, 0x35, 0xe5, 0x8f, 0x48, + 0x53, 0xfe, 0x89, 0x34, 0xe5, 0xbf, 0x48, 0x53, 0x6e, 0x23, 0x4d, 0xb9, 0x8b, 0x34, 0xe5, 0xff, + 0x48, 0x53, 0xde, 0x44, 0x5a, 0xe1, 0x31, 0xd2, 0x94, 0xbf, 0x1f, 0xb4, 0xc2, 0xed, 0x83, 0x56, + 0xb8, 0x7b, 0xd0, 0x0a, 0xbf, 0x4d, 0xa5, 0xdf, 0x1f, 0x37, 0x58, 0x72, 0xe7, 0x92, 0x30, 0xff, + 0x7a, 0xe4, 0x5e, 0x0f, 0xac, 0x05, 0x76, 0xbc, 0x81, 0x45, 0x19, 0x19, 0xcc, 0xe9, 0x48, 0xf4, + 0x19, 0xe5, 0x7f, 0xc8, 0x8e, 0xf2, 0xc7, 0x59, 0x15, 0xbe, 0x3d, 0xbe, 0x79, 0x1f, 0x00, 0x00, + 0xff, 0xff, 0xf3, 0xb4, 0x64, 0x47, 0xf0, 0x06, 0x00, 0x00, +} + +func (this *AlteredAccount) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*AlteredAccount) + if !ok { + that2, ok := that.(AlteredAccount) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if this.Nonce != that1.Nonce { + return false + } + if this.Balance != that1.Balance { + return false + } + if len(this.Tokens) != len(that1.Tokens) { + return false + } + for i := range this.Tokens { + if !this.Tokens[i].Equal(that1.Tokens[i]) { + return false + } + } + if !this.AdditionalData.Equal(that1.AdditionalData) { + return false + } + return true +} +func (this *AccountTokenData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*AccountTokenData) + if !ok { + that2, ok := that.(AccountTokenData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Nonce != that1.Nonce { + return false + } + if this.Identifier != that1.Identifier { + return false + } + if this.Balance != that1.Balance { + return false + } + if this.Properties != that1.Properties { + return false + } + if !this.MetaData.Equal(that1.MetaData) { + return false + } + if !this.AdditionalData.Equal(that1.AdditionalData) { + return false + } + return true +} +func (this *TokenMetaData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*TokenMetaData) + if !ok { + that2, ok := that.(TokenMetaData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Nonce != that1.Nonce { + return false + } + if this.Name != that1.Name { + return false + } + if this.Creator != that1.Creator { + return false + } + if this.Royalties != that1.Royalties { + return false + } + if !bytes.Equal(this.Hash, that1.Hash) { + return false + } + if len(this.URIs) != len(that1.URIs) { + return false + } + for i := range this.URIs { + if !bytes.Equal(this.URIs[i], that1.URIs[i]) { + return false + } + } + if !bytes.Equal(this.Attributes, that1.Attributes) { + return false + } + return true +} +func (this *AdditionalAccountTokenData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*AdditionalAccountTokenData) + if !ok { + that2, ok := that.(AdditionalAccountTokenData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.IsNFTCreate != that1.IsNFTCreate { + return false + } + return true +} +func (this *AdditionalAccountData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*AdditionalAccountData) + if !ok { + that2, ok := that.(AdditionalAccountData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.IsSender != that1.IsSender { + return false + } + if this.BalanceChanged != that1.BalanceChanged { + return false + } + if this.CurrentOwner != that1.CurrentOwner { + return false + } + if this.UserName != that1.UserName { + return false + } + if this.DeveloperRewards != that1.DeveloperRewards { + return false + } + if !bytes.Equal(this.CodeHash, that1.CodeHash) { + return false + } + if !bytes.Equal(this.RootHash, that1.RootHash) { + return false + } + if !bytes.Equal(this.CodeMetadata, that1.CodeMetadata) { + return false + } + return true +} +func (this *AlteredAccount) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 9) + s = append(s, "&alteredAccount.AlteredAccount{") + s = append(s, "Address: "+fmt.Sprintf("%#v", this.Address)+",\n") + s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") + s = append(s, "Balance: "+fmt.Sprintf("%#v", this.Balance)+",\n") + if this.Tokens != nil { + s = append(s, "Tokens: "+fmt.Sprintf("%#v", this.Tokens)+",\n") + } + if this.AdditionalData != nil { + s = append(s, "AdditionalData: "+fmt.Sprintf("%#v", this.AdditionalData)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *AccountTokenData) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 10) + s = append(s, "&alteredAccount.AccountTokenData{") + s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") + s = append(s, "Identifier: "+fmt.Sprintf("%#v", this.Identifier)+",\n") + s = append(s, "Balance: "+fmt.Sprintf("%#v", this.Balance)+",\n") + s = append(s, "Properties: "+fmt.Sprintf("%#v", this.Properties)+",\n") + if this.MetaData != nil { + s = append(s, "MetaData: "+fmt.Sprintf("%#v", this.MetaData)+",\n") + } + if this.AdditionalData != nil { + s = append(s, "AdditionalData: "+fmt.Sprintf("%#v", this.AdditionalData)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *TokenMetaData) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 11) + s = append(s, "&alteredAccount.TokenMetaData{") + s = append(s, "Nonce: "+fmt.Sprintf("%#v", this.Nonce)+",\n") + s = append(s, "Name: "+fmt.Sprintf("%#v", this.Name)+",\n") + s = append(s, "Creator: "+fmt.Sprintf("%#v", this.Creator)+",\n") + s = append(s, "Royalties: "+fmt.Sprintf("%#v", this.Royalties)+",\n") + s = append(s, "Hash: "+fmt.Sprintf("%#v", this.Hash)+",\n") + s = append(s, "URIs: "+fmt.Sprintf("%#v", this.URIs)+",\n") + s = append(s, "Attributes: "+fmt.Sprintf("%#v", this.Attributes)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *AdditionalAccountTokenData) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&alteredAccount.AdditionalAccountTokenData{") + s = append(s, "IsNFTCreate: "+fmt.Sprintf("%#v", this.IsNFTCreate)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *AdditionalAccountData) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 12) + s = append(s, "&alteredAccount.AdditionalAccountData{") + s = append(s, "IsSender: "+fmt.Sprintf("%#v", this.IsSender)+",\n") + s = append(s, "BalanceChanged: "+fmt.Sprintf("%#v", this.BalanceChanged)+",\n") + s = append(s, "CurrentOwner: "+fmt.Sprintf("%#v", this.CurrentOwner)+",\n") + s = append(s, "UserName: "+fmt.Sprintf("%#v", this.UserName)+",\n") + s = append(s, "DeveloperRewards: "+fmt.Sprintf("%#v", this.DeveloperRewards)+",\n") + s = append(s, "CodeHash: "+fmt.Sprintf("%#v", this.CodeHash)+",\n") + s = append(s, "RootHash: "+fmt.Sprintf("%#v", this.RootHash)+",\n") + s = append(s, "CodeMetadata: "+fmt.Sprintf("%#v", this.CodeMetadata)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringAlteredAccount(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *AlteredAccount) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AlteredAccount) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AlteredAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AdditionalData != nil { + { + size, err := m.AdditionalData.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAlteredAccount(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.Tokens) > 0 { + for iNdEx := len(m.Tokens) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAlteredAccount(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Balance) > 0 { + i -= len(m.Balance) + copy(dAtA[i:], m.Balance) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Balance))) + i-- + dAtA[i] = 0x1a + } + if m.Nonce != 0 { + i = encodeVarintAlteredAccount(dAtA, i, uint64(m.Nonce)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *AccountTokenData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AccountTokenData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AccountTokenData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AdditionalData != nil { + { + size, err := m.AdditionalData.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAlteredAccount(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if m.MetaData != nil { + { + size, err := m.MetaData.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAlteredAccount(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.Properties) > 0 { + i -= len(m.Properties) + copy(dAtA[i:], m.Properties) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Properties))) + i-- + dAtA[i] = 0x22 + } + if len(m.Balance) > 0 { + i -= len(m.Balance) + copy(dAtA[i:], m.Balance) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Balance))) + i-- + dAtA[i] = 0x1a + } + if len(m.Identifier) > 0 { + i -= len(m.Identifier) + copy(dAtA[i:], m.Identifier) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Identifier))) + i-- + dAtA[i] = 0x12 + } + if m.Nonce != 0 { + i = encodeVarintAlteredAccount(dAtA, i, uint64(m.Nonce)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TokenMetaData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TokenMetaData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TokenMetaData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Attributes) > 0 { + i -= len(m.Attributes) + copy(dAtA[i:], m.Attributes) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Attributes))) + i-- + dAtA[i] = 0x3a + } + if len(m.URIs) > 0 { + for iNdEx := len(m.URIs) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.URIs[iNdEx]) + copy(dAtA[i:], m.URIs[iNdEx]) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.URIs[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x2a + } + if m.Royalties != 0 { + i = encodeVarintAlteredAccount(dAtA, i, uint64(m.Royalties)) + i-- + dAtA[i] = 0x20 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if m.Nonce != 0 { + i = encodeVarintAlteredAccount(dAtA, i, uint64(m.Nonce)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *AdditionalAccountTokenData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AdditionalAccountTokenData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AdditionalAccountTokenData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsNFTCreate { + i-- + if m.IsNFTCreate { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *AdditionalAccountData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AdditionalAccountData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AdditionalAccountData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CodeMetadata) > 0 { + i -= len(m.CodeMetadata) + copy(dAtA[i:], m.CodeMetadata) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.CodeMetadata))) + i-- + dAtA[i] = 0x42 + } + if len(m.RootHash) > 0 { + i -= len(m.RootHash) + copy(dAtA[i:], m.RootHash) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.RootHash))) + i-- + dAtA[i] = 0x3a + } + if len(m.CodeHash) > 0 { + i -= len(m.CodeHash) + copy(dAtA[i:], m.CodeHash) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.CodeHash))) + i-- + dAtA[i] = 0x32 + } + if len(m.DeveloperRewards) > 0 { + i -= len(m.DeveloperRewards) + copy(dAtA[i:], m.DeveloperRewards) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.DeveloperRewards))) + i-- + dAtA[i] = 0x2a + } + if len(m.UserName) > 0 { + i -= len(m.UserName) + copy(dAtA[i:], m.UserName) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.UserName))) + i-- + dAtA[i] = 0x22 + } + if len(m.CurrentOwner) > 0 { + i -= len(m.CurrentOwner) + copy(dAtA[i:], m.CurrentOwner) + i = encodeVarintAlteredAccount(dAtA, i, uint64(len(m.CurrentOwner))) + i-- + dAtA[i] = 0x1a + } + if m.BalanceChanged { + i-- + if m.BalanceChanged { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if m.IsSender { + i-- + if m.IsSender { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintAlteredAccount(dAtA []byte, offset int, v uint64) int { + offset -= sovAlteredAccount(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AlteredAccount) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + if m.Nonce != 0 { + n += 1 + sovAlteredAccount(uint64(m.Nonce)) + } + l = len(m.Balance) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + if len(m.Tokens) > 0 { + for _, e := range m.Tokens { + l = e.Size() + n += 1 + l + sovAlteredAccount(uint64(l)) + } + } + if m.AdditionalData != nil { + l = m.AdditionalData.Size() + n += 1 + l + sovAlteredAccount(uint64(l)) + } + return n +} + +func (m *AccountTokenData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Nonce != 0 { + n += 1 + sovAlteredAccount(uint64(m.Nonce)) + } + l = len(m.Identifier) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + l = len(m.Balance) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + l = len(m.Properties) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + if m.MetaData != nil { + l = m.MetaData.Size() + n += 1 + l + sovAlteredAccount(uint64(l)) + } + if m.AdditionalData != nil { + l = m.AdditionalData.Size() + n += 1 + l + sovAlteredAccount(uint64(l)) + } + return n +} + +func (m *TokenMetaData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Nonce != 0 { + n += 1 + sovAlteredAccount(uint64(m.Nonce)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + if m.Royalties != 0 { + n += 1 + sovAlteredAccount(uint64(m.Royalties)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + if len(m.URIs) > 0 { + for _, b := range m.URIs { + l = len(b) + n += 1 + l + sovAlteredAccount(uint64(l)) + } + } + l = len(m.Attributes) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + return n +} + +func (m *AdditionalAccountTokenData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IsNFTCreate { + n += 2 + } + return n +} + +func (m *AdditionalAccountData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IsSender { + n += 2 + } + if m.BalanceChanged { + n += 2 + } + l = len(m.CurrentOwner) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + l = len(m.UserName) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + l = len(m.DeveloperRewards) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + l = len(m.CodeHash) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + l = len(m.RootHash) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + l = len(m.CodeMetadata) + if l > 0 { + n += 1 + l + sovAlteredAccount(uint64(l)) + } + return n +} + +func sovAlteredAccount(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAlteredAccount(x uint64) (n int) { + return sovAlteredAccount(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *AlteredAccount) String() string { + if this == nil { + return "nil" + } + repeatedStringForTokens := "[]*AccountTokenData{" + for _, f := range this.Tokens { + repeatedStringForTokens += strings.Replace(f.String(), "AccountTokenData", "AccountTokenData", 1) + "," + } + repeatedStringForTokens += "}" + s := strings.Join([]string{`&AlteredAccount{`, + `Address:` + fmt.Sprintf("%v", this.Address) + `,`, + `Nonce:` + fmt.Sprintf("%v", this.Nonce) + `,`, + `Balance:` + fmt.Sprintf("%v", this.Balance) + `,`, + `Tokens:` + repeatedStringForTokens + `,`, + `AdditionalData:` + strings.Replace(this.AdditionalData.String(), "AdditionalAccountData", "AdditionalAccountData", 1) + `,`, + `}`, + }, "") + return s +} +func (this *AccountTokenData) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&AccountTokenData{`, + `Nonce:` + fmt.Sprintf("%v", this.Nonce) + `,`, + `Identifier:` + fmt.Sprintf("%v", this.Identifier) + `,`, + `Balance:` + fmt.Sprintf("%v", this.Balance) + `,`, + `Properties:` + fmt.Sprintf("%v", this.Properties) + `,`, + `MetaData:` + strings.Replace(this.MetaData.String(), "TokenMetaData", "TokenMetaData", 1) + `,`, + `AdditionalData:` + strings.Replace(this.AdditionalData.String(), "AdditionalAccountTokenData", "AdditionalAccountTokenData", 1) + `,`, + `}`, + }, "") + return s +} +func (this *TokenMetaData) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&TokenMetaData{`, + `Nonce:` + fmt.Sprintf("%v", this.Nonce) + `,`, + `Name:` + fmt.Sprintf("%v", this.Name) + `,`, + `Creator:` + fmt.Sprintf("%v", this.Creator) + `,`, + `Royalties:` + fmt.Sprintf("%v", this.Royalties) + `,`, + `Hash:` + fmt.Sprintf("%v", this.Hash) + `,`, + `URIs:` + fmt.Sprintf("%v", this.URIs) + `,`, + `Attributes:` + fmt.Sprintf("%v", this.Attributes) + `,`, + `}`, + }, "") + return s +} +func (this *AdditionalAccountTokenData) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&AdditionalAccountTokenData{`, + `IsNFTCreate:` + fmt.Sprintf("%v", this.IsNFTCreate) + `,`, + `}`, + }, "") + return s +} +func (this *AdditionalAccountData) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&AdditionalAccountData{`, + `IsSender:` + fmt.Sprintf("%v", this.IsSender) + `,`, + `BalanceChanged:` + fmt.Sprintf("%v", this.BalanceChanged) + `,`, + `CurrentOwner:` + fmt.Sprintf("%v", this.CurrentOwner) + `,`, + `UserName:` + fmt.Sprintf("%v", this.UserName) + `,`, + `DeveloperRewards:` + fmt.Sprintf("%v", this.DeveloperRewards) + `,`, + `CodeHash:` + fmt.Sprintf("%v", this.CodeHash) + `,`, + `RootHash:` + fmt.Sprintf("%v", this.RootHash) + `,`, + `CodeMetadata:` + fmt.Sprintf("%v", this.CodeMetadata) + `,`, + `}`, + }, "") + return s +} +func valueToStringAlteredAccount(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *AlteredAccount) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AlteredAccount: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AlteredAccount: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + m.Nonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Balance = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tokens", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tokens = append(m.Tokens, &AccountTokenData{}) + if err := m.Tokens[len(m.Tokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AdditionalData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AdditionalData == nil { + m.AdditionalData = &AdditionalAccountData{} + } + if err := m.AdditionalData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAlteredAccount(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AccountTokenData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AccountTokenData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AccountTokenData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + m.Nonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identifier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identifier = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Balance = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Properties", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Properties = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MetaData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.MetaData == nil { + m.MetaData = &TokenMetaData{} + } + if err := m.MetaData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AdditionalData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AdditionalData == nil { + m.AdditionalData = &AdditionalAccountTokenData{} + } + if err := m.AdditionalData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAlteredAccount(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TokenMetaData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TokenMetaData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TokenMetaData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + m.Nonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Royalties", wireType) + } + m.Royalties = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Royalties |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field URIs", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.URIs = append(m.URIs, make([]byte, postIndex-iNdEx)) + copy(m.URIs[len(m.URIs)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Attributes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Attributes = append(m.Attributes[:0], dAtA[iNdEx:postIndex]...) + if m.Attributes == nil { + m.Attributes = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAlteredAccount(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AdditionalAccountTokenData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AdditionalAccountTokenData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AdditionalAccountTokenData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsNFTCreate", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsNFTCreate = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipAlteredAccount(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AdditionalAccountData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AdditionalAccountData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AdditionalAccountData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSender", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsSender = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BalanceChanged", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BalanceChanged = bool(v != 0) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentOwner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CurrentOwner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UserName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeveloperRewards", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DeveloperRewards = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeHash = append(m.CodeHash[:0], dAtA[iNdEx:postIndex]...) + if m.CodeHash == nil { + m.CodeHash = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RootHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RootHash = append(m.RootHash[:0], dAtA[iNdEx:postIndex]...) + if m.RootHash == nil { + m.RootHash = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CodeMetadata", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAlteredAccount + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAlteredAccount + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CodeMetadata = append(m.CodeMetadata[:0], dAtA[iNdEx:postIndex]...) + if m.CodeMetadata == nil { + m.CodeMetadata = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAlteredAccount(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthAlteredAccount + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAlteredAccount(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAlteredAccount + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAlteredAccount + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAlteredAccount + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAlteredAccount + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAlteredAccount = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAlteredAccount = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAlteredAccount = fmt.Errorf("proto: unexpected end of group") +) diff --git a/data/alteredAccount/alteredAccount.proto b/data/alteredAccount/alteredAccount.proto new file mode 100644 index 000000000..08e6c0af0 --- /dev/null +++ b/data/alteredAccount/alteredAccount.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; + +package proto; + +option go_package = "github.com/multiversx/mx-chain-core-go/data/alteredAccount;alteredAccount"; +option (gogoproto.stable_marshaler_all) = true; + +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; + +message AlteredAccount { + string Address = 1 [(gogoproto.jsontag) = "address"]; + uint64 Nonce = 2 [(gogoproto.jsontag) = "nonce"]; + string Balance = 3 [(gogoproto.jsontag) = "balance,omitempty"]; + repeated AccountTokenData Tokens = 4 [(gogoproto.jsontag) = "tokens,omitempty"]; + AdditionalAccountData AdditionalData = 5 [(gogoproto.jsontag) = "additionalAccountData,omitempty"]; +} + +message AccountTokenData { + uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; + string Identifier = 2 [(gogoproto.jsontag) = "identifier"]; + string Balance = 3 [(gogoproto.jsontag) = "balance"]; + string Properties = 4 [(gogoproto.jsontag) = "properties"]; + TokenMetaData MetaData = 5 [(gogoproto.jsontag) = "metaData,omitempty"]; + AdditionalAccountTokenData AdditionalData = 6 [(gogoproto.jsontag) = "additionalData,omitempty"]; +} + +message TokenMetaData { + uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; + string Name = 2 [(gogoproto.jsontag) = "name"]; + string Creator = 3 [(gogoproto.jsontag) = "creator"]; + uint32 Royalties = 4 [(gogoproto.jsontag) = "royalties"]; + bytes Hash = 5 [(gogoproto.jsontag) = "hash"]; + repeated bytes URIs = 6 [(gogoproto.jsontag) = "uris"]; + bytes Attributes = 7 [(gogoproto.jsontag) = "attributes"]; +} + +message AdditionalAccountTokenData { + bool IsNFTCreate = 1 [(gogoproto.jsontag) = "isNFTCreate,omitempty"]; +} + +message AdditionalAccountData { + bool IsSender = 1 [(gogoproto.jsontag) = "isSender,omitempty"]; + bool BalanceChanged = 2 [(gogoproto.jsontag) = "balanceChanged,omitempty"]; + string CurrentOwner = 3 [(gogoproto.jsontag) = "currentOwner,omitempty"]; + string UserName = 4 [(gogoproto.jsontag) = "userName,omitempty"]; + string DeveloperRewards = 5 [(gogoproto.jsontag) = "developerRewards,omitempty"]; + bytes CodeHash = 6 [(gogoproto.jsontag) = "codeHash,omitempty"]; + bytes RootHash = 7 [(gogoproto.jsontag) = "rootHash,omitempty"]; + bytes CodeMetadata = 8 [(gogoproto.jsontag) = "codeMetadata,omitempty"]; +} diff --git a/data/api/apiBlock.go b/data/api/apiBlock.go index 5387c1099..4ee57b77e 100644 --- a/data/api/apiBlock.go +++ b/data/api/apiBlock.go @@ -4,7 +4,7 @@ import ( "math/big" "time" - "github.com/multiversx/mx-chain-core-go/data/outport" + "github.com/multiversx/mx-chain-core-go/data/alteredAccount" "github.com/multiversx/mx-chain-core-go/data/transaction" ) @@ -25,6 +25,13 @@ type Block struct { Status string `json:"status,omitempty"` RandSeed string `json:"randSeed,omitempty"` PrevRandSeed string `json:"prevRandSeed,omitempty"` + PubKeyBitmap string `json:"pubKeyBitmap"` + Signature string `json:"signature,omitempty"` + LeaderSignature string `json:"leaderSignature,omitempty"` + ChainID string `json:"chainID,omitempty"` + SoftwareVersion string `json:"softwareVersion,omitempty"` + ReceiptsHash string `json:"receiptsHash,omitempty"` + Reserved []byte `json:"reserved,omitempty"` Timestamp time.Duration `json:"timestamp,omitempty"` NotarizedBlocks []*NotarizedBlock `json:"notarizedBlocks,omitempty"` MiniBlocks []*MiniBlock `json:"miniBlocks,omitempty"` @@ -57,13 +64,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"` - RootHash string `json:"rootHash"` - MiniBlockHashes []string `json:"miniBlockHashes,omitempty"` - AlteredAccounts []*outport.AlteredAccount `json:"alteredAccounts,omitempty"` + 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 []*alteredAccount.AlteredAccount `json:"alteredAccounts,omitempty"` } // EpochStartShardData is a structure that holds data about the epoch start shard data diff --git a/data/api/apiESDTSupply.go b/data/api/apiESDTSupply.go index 9488f7b98..4033e9263 100644 --- a/data/api/apiESDTSupply.go +++ b/data/api/apiESDTSupply.go @@ -2,8 +2,9 @@ package api // ESDTSupply represents the structure for esdt supply that is returned by api routes type ESDTSupply struct { - InitialMinted string `json:"initialMinted"` - Supply string `json:"supply"` - Burned string `json:"burned"` - Minted string `json:"minted"` + InitialMinted string `json:"initialMinted"` + Supply string `json:"supply"` + Burned string `json:"burned"` + Minted string `json:"minted"` + RecomputedSupply bool `json:"recomputedSupply"` } diff --git a/data/api/guardianData.go b/data/api/guardianData.go index 135a36cb2..dda348abf 100644 --- a/data/api/guardianData.go +++ b/data/api/guardianData.go @@ -11,5 +11,5 @@ type Guardian struct { type GuardianData struct { ActiveGuardian *Guardian `json:"activeGuardian,omitempty"` PendingGuardian *Guardian `json:"pendingGuardian,omitempty"` - Guarded bool `json:"guarded,omitempty"` + Guarded bool `json:"guarded"` } diff --git a/data/block/block.go b/data/block/block.go index cc8a1fd8a..0ac8fd2aa 100644 --- a/data/block/block.go +++ b/data/block/block.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. block.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src block.proto package block import ( diff --git a/data/block/block.pb.go b/data/block/block.pb.go index 880b6eee5..fc69abd77 100644 --- a/data/block/block.pb.go +++ b/data/block/block.pb.go @@ -115,11 +115,11 @@ func (MiniBlockState) EnumDescriptor() ([]byte, []int) { } type MiniBlock struct { - TxHashes [][]byte `protobuf:"bytes,1,rep,name=TxHashes,proto3" json:"TxHashes,omitempty"` - ReceiverShardID uint32 `protobuf:"varint,2,opt,name=ReceiverShardID,proto3" json:"ReceiverShardID,omitempty"` - SenderShardID uint32 `protobuf:"varint,3,opt,name=SenderShardID,proto3" json:"SenderShardID,omitempty"` - Type Type `protobuf:"varint,4,opt,name=Type,proto3,enum=proto.Type" json:"Type,omitempty"` - Reserved []byte `protobuf:"bytes,5,opt,name=Reserved,proto3" json:"Reserved,omitempty"` + TxHashes [][]byte `protobuf:"bytes,1,rep,name=TxHashes,proto3" json:"txHashes,omitempty"` + ReceiverShardID uint32 `protobuf:"varint,2,opt,name=ReceiverShardID,proto3" json:"receiverShardID"` + SenderShardID uint32 `protobuf:"varint,3,opt,name=SenderShardID,proto3" json:"senderShardID"` + Type Type `protobuf:"varint,4,opt,name=Type,proto3,enum=proto.Type" json:"type"` + Reserved []byte `protobuf:"bytes,5,opt,name=Reserved,proto3" json:"reserved,omitempty"` } func (m *MiniBlock) Reset() { *m = MiniBlock{} } @@ -186,12 +186,12 @@ func (m *MiniBlock) GetReserved() []byte { } type MiniBlockHeader struct { - Hash []byte `protobuf:"bytes,1,opt,name=Hash,proto3" json:"Hash,omitempty"` - SenderShardID uint32 `protobuf:"varint,2,opt,name=SenderShardID,proto3" json:"SenderShardID,omitempty"` - ReceiverShardID uint32 `protobuf:"varint,3,opt,name=ReceiverShardID,proto3" json:"ReceiverShardID,omitempty"` - TxCount uint32 `protobuf:"varint,4,opt,name=TxCount,proto3" json:"TxCount,omitempty"` - Type Type `protobuf:"varint,5,opt,name=Type,proto3,enum=proto.Type" json:"Type,omitempty"` - Reserved []byte `protobuf:"bytes,6,opt,name=Reserved,proto3" json:"Reserved,omitempty"` + Hash []byte `protobuf:"bytes,1,opt,name=Hash,proto3" json:"hash,omitempty"` + SenderShardID uint32 `protobuf:"varint,2,opt,name=SenderShardID,proto3" json:"senderShardID"` + ReceiverShardID uint32 `protobuf:"varint,3,opt,name=ReceiverShardID,proto3" json:"receiverShardID"` + TxCount uint32 `protobuf:"varint,4,opt,name=TxCount,proto3" json:"txCount"` + Type Type `protobuf:"varint,5,opt,name=Type,proto3,enum=proto.Type" json:"type"` + Reserved []byte `protobuf:"bytes,6,opt,name=Reserved,proto3" json:"reserved,omitempty"` } func (m *MiniBlockHeader) Reset() { *m = MiniBlockHeader{} } @@ -266,8 +266,8 @@ func (m *MiniBlockHeader) GetReserved() []byte { // PeerChange holds a change in one peer to shard assignation type PeerChange struct { - PubKey []byte `protobuf:"bytes,1,opt,name=PubKey,proto3" json:"PubKey,omitempty"` - ShardIdDest uint32 `protobuf:"varint,2,opt,name=ShardIdDest,proto3" json:"ShardIdDest,omitempty"` + PubKey []byte `protobuf:"bytes,1,opt,name=PubKey,proto3" json:"pubKey,omitempty"` + ShardIdDest uint32 `protobuf:"varint,2,opt,name=ShardIdDest,proto3" json:"shardIdDest"` } func (m *PeerChange) Reset() { *m = PeerChange{} } @@ -315,30 +315,30 @@ func (m *PeerChange) GetShardIdDest() uint32 { // Header holds the metadata of a block. This is the part that is being hashed and run through consensus. // The header holds the hash of the body and also the link to the previous block header hash type Header struct { - Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"Nonce,omitempty"` - PrevHash []byte `protobuf:"bytes,2,opt,name=PrevHash,proto3" json:"PrevHash,omitempty"` - PrevRandSeed []byte `protobuf:"bytes,3,opt,name=PrevRandSeed,proto3" json:"PrevRandSeed,omitempty"` - RandSeed []byte `protobuf:"bytes,4,opt,name=RandSeed,proto3" json:"RandSeed,omitempty"` - PubKeysBitmap []byte `protobuf:"bytes,5,opt,name=PubKeysBitmap,proto3" json:"PubKeysBitmap,omitempty"` - ShardID uint32 `protobuf:"varint,6,opt,name=ShardID,proto3" json:"ShardID,omitempty"` - TimeStamp uint64 `protobuf:"varint,7,opt,name=TimeStamp,proto3" json:"TimeStamp,omitempty"` - Round uint64 `protobuf:"varint,8,opt,name=Round,proto3" json:"Round,omitempty"` - Epoch uint32 `protobuf:"varint,9,opt,name=Epoch,proto3" json:"Epoch,omitempty"` - BlockBodyType Type `protobuf:"varint,10,opt,name=BlockBodyType,proto3,enum=proto.Type" json:"BlockBodyType,omitempty"` - Signature []byte `protobuf:"bytes,11,opt,name=Signature,proto3" json:"Signature,omitempty"` - LeaderSignature []byte `protobuf:"bytes,12,opt,name=LeaderSignature,proto3" json:"LeaderSignature,omitempty"` - MiniBlockHeaders []MiniBlockHeader `protobuf:"bytes,13,rep,name=MiniBlockHeaders,proto3" json:"MiniBlockHeaders"` - PeerChanges []PeerChange `protobuf:"bytes,14,rep,name=PeerChanges,proto3" json:"PeerChanges"` - RootHash []byte `protobuf:"bytes,15,opt,name=RootHash,proto3" json:"RootHash,omitempty"` - MetaBlockHashes [][]byte `protobuf:"bytes,16,rep,name=MetaBlockHashes,proto3" json:"MetaBlockHashes,omitempty"` - TxCount uint32 `protobuf:"varint,17,opt,name=TxCount,proto3" json:"TxCount,omitempty"` - EpochStartMetaHash []byte `protobuf:"bytes,18,opt,name=EpochStartMetaHash,proto3" json:"EpochStartMetaHash,omitempty"` - 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/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"` + Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` + PrevHash []byte `protobuf:"bytes,2,opt,name=PrevHash,proto3" json:"prevHash,omitempty"` + PrevRandSeed []byte `protobuf:"bytes,3,opt,name=PrevRandSeed,proto3" json:"prevRandSeed,omitempty"` + RandSeed []byte `protobuf:"bytes,4,opt,name=RandSeed,proto3" json:"randSeed,omitempty"` + PubKeysBitmap []byte `protobuf:"bytes,5,opt,name=PubKeysBitmap,proto3" json:"pubKeysBitmap,omitempty"` + ShardID uint32 `protobuf:"varint,6,opt,name=ShardID,proto3" json:"shardID"` + TimeStamp uint64 `protobuf:"varint,7,opt,name=TimeStamp,proto3" json:"timeStamp,omitempty"` + Round uint64 `protobuf:"varint,8,opt,name=Round,proto3" json:"round"` + Epoch uint32 `protobuf:"varint,9,opt,name=Epoch,proto3" json:"epoch"` + BlockBodyType Type `protobuf:"varint,10,opt,name=BlockBodyType,proto3,enum=proto.Type" json:"blockBodyType"` + Signature []byte `protobuf:"bytes,11,opt,name=Signature,proto3" json:"signature,omitempty"` + LeaderSignature []byte `protobuf:"bytes,12,opt,name=LeaderSignature,proto3" json:"leaderSignature,omitempty"` + MiniBlockHeaders []MiniBlockHeader `protobuf:"bytes,13,rep,name=MiniBlockHeaders,proto3" json:"miniBlockHeaders"` + PeerChanges []PeerChange `protobuf:"bytes,14,rep,name=PeerChanges,proto3" json:"peerChanges"` + RootHash []byte `protobuf:"bytes,15,opt,name=RootHash,proto3" json:"rootHash,omitempty"` + MetaBlockHashes [][]byte `protobuf:"bytes,16,rep,name=MetaBlockHashes,proto3" json:"metaBlockHashes,omitempty"` + TxCount uint32 `protobuf:"varint,17,opt,name=TxCount,proto3" json:"txCount"` + EpochStartMetaHash []byte `protobuf:"bytes,18,opt,name=EpochStartMetaHash,proto3" json:"epochStartMetaHash,omitempty"` + 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/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"` } func (m *Header) Reset() { *m = Header{} } @@ -538,7 +538,7 @@ func (m *Header) GetReserved() []byte { } type Body struct { - MiniBlocks []*MiniBlock `protobuf:"bytes,1,rep,name=MiniBlocks,proto3" json:"MiniBlocks,omitempty"` + MiniBlocks []*MiniBlock `protobuf:"bytes,1,rep,name=MiniBlocks,proto3" json:"miniBlocks,omitempty"` } func (m *Body) Reset() { *m = Body{} } @@ -578,8 +578,8 @@ func (m *Body) GetMiniBlocks() []*MiniBlock { // BodyHeaderPair holds a body and header hash pair type BodyHeaderPair struct { - Body []byte `protobuf:"bytes,1,opt,name=Body,proto3" json:"Body,omitempty"` - Header []byte `protobuf:"bytes,2,opt,name=Header,proto3" json:"Header,omitempty"` + Body []byte `protobuf:"bytes,1,opt,name=Body,proto3" json:"body,omitempty"` + Header []byte `protobuf:"bytes,2,opt,name=Header,proto3" json:"header,omitempty"` } func (m *BodyHeaderPair) Reset() { *m = BodyHeaderPair{} } @@ -639,68 +639,84 @@ func init() { func init() { proto.RegisterFile("block.proto", fileDescriptor_8e550b1f5926e92d) } var fileDescriptor_8e550b1f5926e92d = []byte{ - // 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, 0x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89, 0x48, 0x22, - 0x45, 0xbc, 0x6b, 0x6e, 0x66, 0xce, 0xdb, 0x29, 0xfd, 0x9b, 0x76, 0xca, 0xb9, 0x76, 0xce, 0x01, - 0xba, 0x88, 0xf2, 0x64, 0xc8, 0xa3, 0x01, 0xb2, 0x1d, 0x28, 0x77, 0x93, 0xfe, 0x57, 0x78, 0x95, - 0xb6, 0x92, 0x5a, 0xac, 0x09, 0x15, 0xc3, 0xc3, 0x3f, 0xc5, 0x58, 0xa5, 0xad, 0x2c, 0x43, 0x7b, - 0x7f, 0x6d, 0x40, 0x39, 0x9d, 0xc6, 0x13, 0x28, 0xbd, 0x12, 0x91, 0x87, 0x94, 0xa3, 0xe8, 0x1a, - 0x43, 0x93, 0xe8, 0x4a, 0x9c, 0xd0, 0x9c, 0xd6, 0x0c, 0x89, 0xcc, 0x66, 0x7b, 0x50, 0xd5, 0xdf, - 0x2e, 0x8f, 0xfc, 0x1e, 0xa2, 0x4f, 0x23, 0xa8, 0xba, 0x2b, 0x18, 0x35, 0x91, 0x9d, 0x17, 0xd3, - 0x26, 0xb2, 0xb3, 0xe7, 0x50, 0x33, 0x44, 0xe3, 0x76, 0xa0, 0x42, 0x3e, 0x4e, 0x2f, 0x6d, 0x15, - 0xd4, 0x13, 0xcc, 0x66, 0x5c, 0x36, 0x13, 0xcc, 0x66, 0xfb, 0x0c, 0x36, 0x2f, 0x83, 0x10, 0x7b, - 0x8a, 0x87, 0x63, 0x7b, 0x83, 0x58, 0x2f, 0x00, 0xdd, 0x8f, 0x2b, 0x92, 0xc8, 0xb7, 0x1f, 0x99, - 0x7e, 0xc8, 0xd0, 0xe8, 0xd9, 0x58, 0x78, 0x43, 0x7b, 0x93, 0x72, 0x19, 0x83, 0x7d, 0x08, 0x35, - 0x12, 0x46, 0x5b, 0xf8, 0x57, 0x74, 0x29, 0x70, 0xff, 0x52, 0x56, 0x3d, 0x74, 0xf1, 0x5e, 0x30, - 0x88, 0xb8, 0x4a, 0x24, 0xda, 0x15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, 0x71, 0x1c, 0x44, 0x03, 0xe2, 0x04, 0x50, 0x7e, 0x25, 0x64, 0xc8, 0x47, - 0x8d, 0x82, 0xa6, 0xd0, 0xf3, 0x86, 0xe8, 0x27, 0x23, 0xf4, 0x1b, 0x16, 0x31, 0x32, 0xce, 0xe8, - 0x37, 0xd6, 0x0e, 0x3e, 0x87, 0xfa, 0x7c, 0x24, 0xc4, 0x9c, 0x6d, 0x42, 0xe9, 0x3c, 0x88, 0x28, - 0xb4, 0xaa, 0x77, 0xa7, 0x18, 0x8b, 0x98, 0x22, 0x1f, 0xc3, 0x56, 0x97, 0x4b, 0x15, 0xf0, 0xd1, - 0xd9, 0x14, 0xbd, 0x44, 0xe9, 0xf8, 0xf6, 0x17, 0xd7, 0xb7, 0x4e, 0xe1, 0xe6, 0xd6, 0x29, 0xbc, - 0xbf, 0x75, 0xac, 0xef, 0x66, 0x8e, 0xf5, 0xd3, 0xcc, 0xb1, 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, + // 1228 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x6f, 0xdc, 0x44, + 0x14, 0x5f, 0x27, 0x9b, 0xa4, 0x99, 0xfd, 0x9b, 0x49, 0x9b, 0x9a, 0x52, 0xec, 0x28, 0x12, 0x28, + 0x54, 0x4d, 0x56, 0x04, 0xa1,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ab, 0x4b, 0xb8, 0x08, + 0xc8, 0xe8, 0xde, 0x29, 0xf5, 0xc6, 0x42, 0xf2, 0x9d, 0x1f, 0x5f, 0xbc, 0xb2, 0x2a, 0x2f, 0x5f, + 0x59, 0x95, 0x37, 0xaf, 0x2c, 0xe3, 0xa7, 0x89, 0x65, 0xfc, 0x36, 0xb1, 0x8c, 0xe7, 0x13, 0xcb, + 0x78, 0x31, 0xb1, 0x8c, 0x97, 0x13, 0xcb, 0xf8, 0x6b, 0x62, 0x19, 0x7f, 0x4f, 0xac, 0xca, 0x9b, + 0x89, 0x65, 0x3c, 0x7d, 0x6d, 0x55, 0x5e, 0xbc, 0xb6, 0x2a, 0x2f, 0x5f, 0x5b, 0x95, 0xc7, 0xb7, + 0x2e, 0xd0, 0x79, 0x1d, 0x58, 0x39, 0xb7, 0xe1, 0x6f, 0x7f, 0x19, 0x1a, 0xe3, 0xd3, 0x7f, 0x03, + 0x00, 0x00, 0xff, 0xff, 0x39, 0x62, 0xdb, 0x54, 0x6c, 0x0b, 0x00, 0x00, } func (x Type) String() string { diff --git a/data/block/block.proto b/data/block/block.proto index 0ace1958f..99d11d0bb 100644 --- a/data/block/block.proto +++ b/data/block/block.proto @@ -8,7 +8,7 @@ syntax = "proto3"; package proto; -option go_package = "block"; +option go_package = "github.com/multiversx/mx-chain-core-go/data/block;block"; option (gogoproto.stable_marshaler_all) = true; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; @@ -37,63 +37,63 @@ enum MiniBlockState{ } message MiniBlock { - repeated bytes TxHashes = 1; - uint32 ReceiverShardID = 2; - uint32 SenderShardID = 3; - Type Type = 4; - bytes Reserved = 5; + repeated bytes TxHashes = 1 [(gogoproto.jsontag) = "txHashes,omitempty"]; + uint32 ReceiverShardID = 2 [(gogoproto.jsontag) = "receiverShardID"]; + uint32 SenderShardID = 3 [(gogoproto.jsontag) = "senderShardID"]; + Type Type = 4 [(gogoproto.jsontag) = "type"]; + bytes Reserved = 5 [(gogoproto.jsontag) = "reserved,omitempty"]; } message MiniBlockHeader { - bytes Hash = 1; - uint32 SenderShardID = 2; - uint32 ReceiverShardID = 3; - uint32 TxCount = 4; - Type Type = 5; - bytes Reserved = 6; + bytes Hash = 1 [(gogoproto.jsontag) = "hash,omitempty"]; + uint32 SenderShardID = 2 [(gogoproto.jsontag) = "senderShardID"]; + uint32 ReceiverShardID = 3 [(gogoproto.jsontag) = "receiverShardID"]; + uint32 TxCount = 4 [(gogoproto.jsontag) = "txCount"]; + Type Type = 5 [(gogoproto.jsontag) = "type"]; + bytes Reserved = 6 [(gogoproto.jsontag) = "reserved,omitempty"]; } // PeerChange holds a change in one peer to shard assignation message PeerChange { - bytes PubKey = 1; - uint32 ShardIdDest = 2; + bytes PubKey = 1 [(gogoproto.jsontag) = "pubKey,omitempty"]; + uint32 ShardIdDest = 2 [(gogoproto.jsontag) = "shardIdDest"]; } // Header holds the metadata of a block. This is the part that is being hashed and run through consensus. // The header holds the hash of the body and also the link to the previous block header hash message Header { - uint64 Nonce = 1; - bytes PrevHash = 2; - bytes PrevRandSeed = 3; - bytes RandSeed = 4; - bytes PubKeysBitmap = 5; - uint32 ShardID = 6; - uint64 TimeStamp = 7; - uint64 Round = 8; - uint32 Epoch = 9; - Type BlockBodyType = 10; - bytes Signature = 11; - bytes LeaderSignature = 12; - repeated MiniBlockHeader MiniBlockHeaders = 13 [(gogoproto.nullable) = false]; - repeated PeerChange PeerChanges = 14 [(gogoproto.nullable) = false]; - bytes RootHash = 15; - repeated bytes MetaBlockHashes = 16; - uint32 TxCount = 17; - bytes EpochStartMetaHash = 18; - bytes ReceiptsHash = 19; - bytes ChainID = 20; - bytes SoftwareVersion = 21; - 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; + uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; + bytes PrevHash = 2 [(gogoproto.jsontag) = "prevHash,omitempty"]; + bytes PrevRandSeed = 3 [(gogoproto.jsontag) = "prevRandSeed,omitempty"]; + bytes RandSeed = 4 [(gogoproto.jsontag) = "randSeed,omitempty"]; + bytes PubKeysBitmap = 5 [(gogoproto.jsontag) = "pubKeysBitmap,omitempty"]; + uint32 ShardID = 6 [(gogoproto.jsontag) = "shardID"]; + uint64 TimeStamp = 7 [(gogoproto.jsontag) = "timeStamp,omitempty"]; + uint64 Round = 8 [(gogoproto.jsontag) = "round"]; + uint32 Epoch = 9 [(gogoproto.jsontag) = "epoch"]; + Type BlockBodyType = 10 [(gogoproto.jsontag) = "blockBodyType"]; + bytes Signature = 11 [(gogoproto.jsontag) = "signature,omitempty"]; + bytes LeaderSignature = 12 [(gogoproto.jsontag) = "leaderSignature,omitempty"]; + repeated MiniBlockHeader MiniBlockHeaders = 13 [(gogoproto.jsontag) = "miniBlockHeaders", (gogoproto.nullable) = false]; + repeated PeerChange PeerChanges = 14 [(gogoproto.jsontag) = "peerChanges", (gogoproto.nullable) = false]; + bytes RootHash = 15 [(gogoproto.jsontag) = "rootHash,omitempty"]; + repeated bytes MetaBlockHashes = 16 [(gogoproto.jsontag) = "metaBlockHashes,omitempty"]; + uint32 TxCount = 17 [(gogoproto.jsontag) = "txCount"]; + bytes EpochStartMetaHash = 18 [(gogoproto.jsontag) = "epochStartMetaHash,omitempty"]; + bytes ReceiptsHash = 19 [(gogoproto.jsontag) = "receiptsHash,omitempty"]; + bytes ChainID = 20 [(gogoproto.jsontag) = "chainID,omitempty"]; + bytes SoftwareVersion = 21 [(gogoproto.jsontag) = "softwareVersion,omitempty"]; + bytes AccumulatedFees = 22 [(gogoproto.jsontag) = "accumulatedFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DeveloperFees = 23 [(gogoproto.jsontag) = "developerFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes Reserved = 24 [(gogoproto.jsontag) = "reserved,omitempty"]; } message Body { - repeated MiniBlock MiniBlocks = 1; + repeated MiniBlock MiniBlocks = 1 [(gogoproto.jsontag) = "miniBlocks,omitempty"]; } // BodyHeaderPair holds a body and header hash pair message BodyHeaderPair{ - bytes Body = 1; - bytes Header = 2; + bytes Body = 1 [(gogoproto.jsontag) = "body,omitempty"]; + bytes Header = 2 [(gogoproto.jsontag) = "header,omitempty"]; } diff --git a/data/block/blockV2.pb.go b/data/block/blockV2.pb.go index fedd77586..a7a2eaca1 100644 --- a/data/block/blockV2.pb.go +++ b/data/block/blockV2.pb.go @@ -30,13 +30,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // HeaderV2 extends the Header structure with extra fields for version 2 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/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"` + 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/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"` + ScheduledGasPenalized uint64 `protobuf:"varint,6,opt,name=ScheduledGasPenalized,proto3" json:"scheduledGasPenalized"` + ScheduledGasRefunded uint64 `protobuf:"varint,7,opt,name=ScheduledGasRefunded,proto3" json:"scheduledGasRefunded"` } func (m *HeaderV2) Reset() { *m = HeaderV2{} } @@ -117,8 +117,8 @@ func (m *HeaderV2) GetScheduledGasRefunded() uint64 { } type MiniBlockReserved struct { - ExecutionType ProcessingType `protobuf:"varint,1,opt,name=ExecutionType,proto3,enum=proto.ProcessingType" json:"ExecutionType,omitempty"` - TransactionsType []byte `protobuf:"bytes,2,opt,name=TransactionsType,proto3" json:"TransactionsType,omitempty"` + ExecutionType ProcessingType `protobuf:"varint,1,opt,name=ExecutionType,proto3,enum=proto.ProcessingType" json:"executionType"` + TransactionsType []byte `protobuf:"bytes,2,opt,name=TransactionsType,proto3" json:"transactionsType"` } func (m *MiniBlockReserved) Reset() { *m = MiniBlockReserved{} } @@ -164,10 +164,10 @@ func (m *MiniBlockReserved) GetTransactionsType() []byte { } type MiniBlockHeaderReserved struct { - ExecutionType ProcessingType `protobuf:"varint,1,opt,name=ExecutionType,proto3,enum=proto.ProcessingType" json:"ExecutionType,omitempty"` - State MiniBlockState `protobuf:"varint,2,opt,name=State,proto3,enum=proto.MiniBlockState" json:"State,omitempty"` - IndexOfFirstTxProcessed int32 `protobuf:"varint,3,opt,name=IndexOfFirstTxProcessed,proto3" json:"IndexOfFirstTxProcessed,omitempty"` - IndexOfLastTxProcessed int32 `protobuf:"varint,4,opt,name=IndexOfLastTxProcessed,proto3" json:"IndexOfLastTxProcessed,omitempty"` + ExecutionType ProcessingType `protobuf:"varint,1,opt,name=ExecutionType,proto3,enum=proto.ProcessingType" json:"executionType"` + State MiniBlockState `protobuf:"varint,2,opt,name=State,proto3,enum=proto.MiniBlockState" json:"state"` + IndexOfFirstTxProcessed int32 `protobuf:"varint,3,opt,name=IndexOfFirstTxProcessed,proto3" json:"indexOfFirstTxProcessed"` + IndexOfLastTxProcessed int32 `protobuf:"varint,4,opt,name=IndexOfLastTxProcessed,proto3" json:"indexOfLastTxProcessed"` } func (m *MiniBlockHeaderReserved) Reset() { *m = MiniBlockHeaderReserved{} } @@ -235,40 +235,46 @@ func init() { func init() { proto.RegisterFile("blockV2.proto", fileDescriptor_17a3844aa051366e) } var fileDescriptor_17a3844aa051366e = []byte{ - // 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, 0xc2, 0x98, 0x31, 0x1b, 0xe4, 0xb2, 0x30, 0x76, 0x61, 0x47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x03, 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, + // 622 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xcf, 0x95, 0xba, 0xc0, 0x95, 0xa0, 0xd6, 0xea, 0x1f, 0xd3, 0x4a, 0xe7, 0x28, 0x53, 0x07, + 0x92, 0x48, 0x41, 0x62, 0xe9, 0x00, 0x18, 0x5a, 0x5a, 0xa9, 0xa5, 0xd5, 0xb5, 0x74, 0x60, 0xbb, + 0xd8, 0xaf, 0xce, 0x89, 0xd8, 0x17, 0xf9, 0xce, 0x51, 0xca, 0xc4, 0x47, 0xe0, 0x4b, 0x54, 0x42, + 0xf0, 0x45, 0x18, 0x18, 0x3a, 0x96, 0xc5, 0x50, 0x77, 0x41, 0x9e, 0xfa, 0x11, 0x50, 0xce, 0x21, + 0xfd, 0xe7, 0x8c, 0x9d, 0xfc, 0xee, 0xfd, 0xfe, 0xdc, 0x4f, 0xa7, 0xf7, 0x8c, 0xcb, 0xad, 0x8e, + 0x70, 0x3f, 0x1e, 0x34, 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, + 0x5b, 0xec, 0xea, 0xcf, 0x09, 0xbc, 0x38, 0xca, 0x99, 0x6f, 0xd3, 0x9d, 0xa5, 0x7d, 0x8e, 0x8d, + 0x3d, 0xc5, 0x54, 0x1e, 0xf1, 0xd2, 0x67, 0x74, 0xbd, 0x06, 0x9d, 0x87, 0x59, 0x62, 0x1b, 0x72, + 0x50, 0xd2, 0x9c, 0x6e, 0xbe, 0xc7, 0x8b, 0x9b, 0xa1, 0x07, 0xfd, 0x9d, 0xc3, 0x75, 0x1e, 0x49, + 0xb5, 0xdf, 0x1f, 0xde, 0x0c, 0x9e, 0x5e, 0x46, 0xc3, 0x59, 0xce, 0x12, 0x7b, 0x91, 0x17, 0x53, + 0xe8, 0x38, 0xad, 0x49, 0xf1, 0xc2, 0x10, 0xda, 0x62, 0xd7, 0x5d, 0x27, 0xb5, 0xeb, 0x52, 0x96, + 0xd8, 0x0b, 0xbc, 0x90, 0x41, 0xc7, 0x28, 0x9d, 0x17, 0x27, 0x67, 0xa4, 0x74, 0x7a, 0x46, 0x4a, + 0x17, 0x67, 0x04, 0x7d, 0x4e, 0x09, 0xfa, 0x9a, 0x12, 0xf4, 0x23, 0x25, 0xe8, 0x24, 0x25, 0xe8, + 0x34, 0x25, 0xe8, 0x4f, 0x4a, 0xd0, 0xdf, 0x94, 0x94, 0x2e, 0x52, 0x82, 0xbe, 0x9c, 0x93, 0xd2, + 0xc9, 0x39, 0x29, 0x9d, 0x9e, 0x93, 0xd2, 0x07, 0x43, 0xff, 0x19, 0x5b, 0x53, 0xfa, 0x4d, 0x9e, + 0xfd, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x2a, 0xc8, 0x73, 0x7c, 0x6e, 0x05, 0x00, 0x00, } func (this *HeaderV2) Equal(that interface{}) bool { diff --git a/data/block/blockV2.proto b/data/block/blockV2.proto index 274f179cf..0e5a4b9bb 100644 --- a/data/block/blockV2.proto +++ b/data/block/blockV2.proto @@ -11,23 +11,23 @@ import "block.proto"; // HeaderV2 extends the Header structure with extra fields for version 2 message HeaderV2 { - Header Header = 1; - bytes ScheduledRootHash = 2; - 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; + Header Header = 1 [(gogoproto.jsontag) = "header,omitempty"]; + bytes ScheduledRootHash = 2 [(gogoproto.jsontag) = "scheduledRootHash,omitempty"]; + bytes ScheduledAccumulatedFees = 3 [(gogoproto.jsontag) = "scheduledAccumulatedFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes ScheduledDeveloperFees = 4 [(gogoproto.jsontag) = "scheduledDeveloperFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + uint64 ScheduledGasProvided = 5 [(gogoproto.jsontag) = "scheduledGasProvided"]; + uint64 ScheduledGasPenalized = 6 [(gogoproto.jsontag) = "scheduledGasPenalized"]; + uint64 ScheduledGasRefunded = 7 [(gogoproto.jsontag) = "scheduledGasRefunded"]; } message MiniBlockReserved { - ProcessingType ExecutionType = 1; - bytes TransactionsType = 2; + ProcessingType ExecutionType = 1 [(gogoproto.jsontag) = "executionType"]; + bytes TransactionsType = 2 [(gogoproto.jsontag) = "transactionsType"]; } message MiniBlockHeaderReserved { - ProcessingType ExecutionType = 1; - MiniBlockState State = 2; - int32 IndexOfFirstTxProcessed = 3; - int32 IndexOfLastTxProcessed = 4; + ProcessingType ExecutionType = 1 [(gogoproto.jsontag) = "executionType"]; + MiniBlockState State = 2 [(gogoproto.jsontag) = "state"]; + int32 IndexOfFirstTxProcessed = 3 [(gogoproto.jsontag) = "indexOfFirstTxProcessed"]; + int32 IndexOfLastTxProcessed = 4 [(gogoproto.jsontag) = "indexOfLastTxProcessed"]; } diff --git a/data/block/emptyBlockCreatorsContainer.go b/data/block/emptyBlockCreatorsContainer.go new file mode 100644 index 000000000..94715fc32 --- /dev/null +++ b/data/block/emptyBlockCreatorsContainer.go @@ -0,0 +1,52 @@ +package block + +import ( + "sync" + + "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" +) + +type emptyBlockCreatorsContainer struct { + mut sync.RWMutex + blockCreators map[core.HeaderType]EmptyBlockCreator +} + +// NewEmptyBlockCreatorsContainer creates a new block creators container +func NewEmptyBlockCreatorsContainer() *emptyBlockCreatorsContainer { + return &emptyBlockCreatorsContainer{ + blockCreators: make(map[core.HeaderType]EmptyBlockCreator), + } +} + +// Add will add a new empty block creator +func (container *emptyBlockCreatorsContainer) Add(headerType core.HeaderType, creator EmptyBlockCreator) error { + if check.IfNil(creator) { + return data.ErrNilEmptyBlockCreator + } + + container.mut.Lock() + container.blockCreators[headerType] = creator + container.mut.Unlock() + + return nil +} + +// Get will try to get a new empty block creator. Errors if the empty block creator type is not found +func (container *emptyBlockCreatorsContainer) Get(headerType core.HeaderType) (EmptyBlockCreator, error) { + container.mut.RLock() + creator, ok := container.blockCreators[headerType] + container.mut.RUnlock() + + if !ok { + return nil, data.ErrInvalidHeaderType + } + + return creator, nil +} + +// IsInterfaceNil returns true if there is no value under the interface +func (container *emptyBlockCreatorsContainer) IsInterfaceNil() bool { + return container == nil +} diff --git a/data/block/emptyBlockCreatorsContainer_test.go b/data/block/emptyBlockCreatorsContainer_test.go new file mode 100644 index 000000000..18ae0fc1f --- /dev/null +++ b/data/block/emptyBlockCreatorsContainer_test.go @@ -0,0 +1,112 @@ +package block + +import ( + "fmt" + "sync" + "testing" + "time" + + "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" + "github.com/multiversx/mx-chain-core-go/marshal/factory" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewEmptyBlockCreatorsContainer(t *testing.T) { + t.Parallel() + + container := NewEmptyBlockCreatorsContainer() + require.False(t, check.IfNil(container)) + assert.Equal(t, 0, len(container.blockCreators)) +} + +func TestEmptyBlockCreatorsContainer_Add(t *testing.T) { + t.Parallel() + + t.Run("nil block creator should error", func(t *testing.T) { + container := NewEmptyBlockCreatorsContainer() + err := container.Add(core.ShardHeaderV1, nil) + assert.Equal(t, data.ErrNilEmptyBlockCreator, err) + assert.Equal(t, 0, len(container.blockCreators)) + }) + t.Run("not nil block creator should work", func(t *testing.T) { + container := NewEmptyBlockCreatorsContainer() + creator := NewEmptyHeaderCreator() + err := container.Add(core.ShardHeaderV1, creator) + assert.Nil(t, err) + assert.Equal(t, 1, len(container.blockCreators)) + }) +} + +func TestEmptyBlockCreatorsContainer_Get(t *testing.T) { + t.Parallel() + + t.Run("missing header creator should error", func(t *testing.T) { + container := NewEmptyBlockCreatorsContainer() + creator, err := container.Get(core.ShardHeaderV1) + assert.Equal(t, data.ErrInvalidHeaderType, err) + assert.True(t, check.IfNil(creator)) + }) + t.Run("existing header creator should work", func(t *testing.T) { + container := NewEmptyBlockCreatorsContainer() + creator := NewEmptyHeaderCreator() + _ = container.Add(core.ShardHeaderV1, creator) + recovered, err := container.Get(core.ShardHeaderV1) + assert.Nil(t, err) + assert.True(t, recovered == creator) // pointer testing + }) +} + +func TestEmptyBlockCreatorsContainer_ConcurrentOperations(t *testing.T) { + t.Parallel() + + container := NewEmptyBlockCreatorsContainer() + numOperations := 1000 + wg := &sync.WaitGroup{} + wg.Add(numOperations) + for i := 0; i < numOperations; i++ { + go func(idx int) { + time.Sleep(time.Millisecond * 10) + switch idx { + case 0: + _ = container.Add(core.ShardHeaderV1, NewEmptyHeaderCreator()) + case 1: + _, _ = container.Get(core.ShardHeaderV1) + default: + require.Nil(t, fmt.Sprintf("invalid index %d", idx)) + } + + wg.Done() + }(i % 2) + } + + wg.Wait() +} + +func TestSemiIntegrationUnmarshal(t *testing.T) { + t.Parallel() + + // setup part + container := NewEmptyBlockCreatorsContainer() + err := container.Add(core.ShardHeaderV1, NewEmptyHeaderCreator()) + require.Nil(t, err) + err = container.Add(core.ShardHeaderV2, NewEmptyHeaderV2Creator()) + require.Nil(t, err) + err = container.Add(core.MetaHeader, NewEmptyMetaBlockCreator()) + require.Nil(t, err) + + marshaller, _ := factory.NewMarshalizer(factory.GogoProtobuf) + headerV1 := &Header{Nonce: 1} + hBytes, _ := marshaller.Marshal(headerV1) + + //usage part + creator, err := container.Get(core.ShardHeaderV1) + require.Nil(t, err) + + recoveredHeader, err := GetHeaderFromBytes(marshaller, creator, hBytes) + assert.Nil(t, err) + assert.Equal(t, headerV1, recoveredHeader) + assert.False(t, headerV1 == recoveredHeader) // pointer testing, different objects +} diff --git a/data/block/emptyHeaderCreator.go b/data/block/emptyHeaderCreator.go new file mode 100644 index 000000000..91717df6e --- /dev/null +++ b/data/block/emptyHeaderCreator.go @@ -0,0 +1,20 @@ +package block + +import "github.com/multiversx/mx-chain-core-go/data" + +type emptyHeaderCreator struct{} + +// NewEmptyHeaderCreator is able to create empty header v1 instances +func NewEmptyHeaderCreator() *emptyHeaderCreator { + return &emptyHeaderCreator{} +} + +// CreateNewHeader creates a new empty header v1 +func (creator *emptyHeaderCreator) CreateNewHeader() data.HeaderHandler { + return &Header{} +} + +// IsInterfaceNil returns true if there is no value under the interface +func (creator *emptyHeaderCreator) IsInterfaceNil() bool { + return creator == nil +} diff --git a/data/block/emptyHeaderCreator_test.go b/data/block/emptyHeaderCreator_test.go new file mode 100644 index 000000000..908aa499d --- /dev/null +++ b/data/block/emptyHeaderCreator_test.go @@ -0,0 +1,26 @@ +package block + +import ( + "fmt" + "testing" + + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewEmptyHeaderCreator(t *testing.T) { + t.Parallel() + + creator := NewEmptyHeaderCreator() + require.False(t, check.IfNil(creator)) +} + +func TestEmptyHeaderCreator_CreateNewHeader(t *testing.T) { + t.Parallel() + + creator := NewEmptyHeaderCreator() + header := creator.CreateNewHeader() + require.False(t, check.IfNil(header)) + assert.Equal(t, "*block.Header", fmt.Sprintf("%T", header)) +} diff --git a/data/block/emptyHeaderV2Creator.go b/data/block/emptyHeaderV2Creator.go new file mode 100644 index 000000000..b94b28f92 --- /dev/null +++ b/data/block/emptyHeaderV2Creator.go @@ -0,0 +1,22 @@ +package block + +import "github.com/multiversx/mx-chain-core-go/data" + +type emptyHeaderV2Creator struct{} + +// NewEmptyHeaderV2Creator is able to create empty header v2 instances +func NewEmptyHeaderV2Creator() *emptyHeaderV2Creator { + return &emptyHeaderV2Creator{} +} + +// CreateNewHeader creates a new empty header v2 +func (creator *emptyHeaderV2Creator) CreateNewHeader() data.HeaderHandler { + return &HeaderV2{ + Header: &Header{}, + } +} + +// IsInterfaceNil returns true if there is no value under the interface +func (creator *emptyHeaderV2Creator) IsInterfaceNil() bool { + return creator == nil +} diff --git a/data/block/emptyHeaderV2Creator_test.go b/data/block/emptyHeaderV2Creator_test.go new file mode 100644 index 000000000..8fabd6676 --- /dev/null +++ b/data/block/emptyHeaderV2Creator_test.go @@ -0,0 +1,28 @@ +package block + +import ( + "fmt" + "testing" + + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewEmptyHeaderV2Creator(t *testing.T) { + t.Parallel() + + creator := NewEmptyHeaderV2Creator() + require.False(t, check.IfNil(creator)) +} + +func TestEmptyHeaderV2Creator_CreateNewHeader(t *testing.T) { + t.Parallel() + + creator := NewEmptyHeaderV2Creator() + header := creator.CreateNewHeader() + require.False(t, check.IfNil(header)) + require.False(t, check.IfNil(header.(*HeaderV2))) + require.False(t, check.IfNil(header.(*HeaderV2).Header)) + assert.Equal(t, "*block.HeaderV2", fmt.Sprintf("%T", header)) +} diff --git a/data/block/emptyMetablockCreator.go b/data/block/emptyMetablockCreator.go new file mode 100644 index 000000000..aa11ea5b1 --- /dev/null +++ b/data/block/emptyMetablockCreator.go @@ -0,0 +1,20 @@ +package block + +import "github.com/multiversx/mx-chain-core-go/data" + +type emptyMetaBlockCreator struct{} + +// NewEmptyMetaBlockCreator is able to create empty metablock instances +func NewEmptyMetaBlockCreator() *emptyMetaBlockCreator { + return &emptyMetaBlockCreator{} +} + +// CreateNewHeader creates a new empty metablock +func (creator *emptyMetaBlockCreator) CreateNewHeader() data.HeaderHandler { + return &MetaBlock{} +} + +// IsInterfaceNil returns true if there is no value under the interface +func (creator *emptyMetaBlockCreator) IsInterfaceNil() bool { + return creator == nil +} diff --git a/data/block/emptyMetablockCreator_test.go b/data/block/emptyMetablockCreator_test.go new file mode 100644 index 000000000..3e3ca92d9 --- /dev/null +++ b/data/block/emptyMetablockCreator_test.go @@ -0,0 +1,26 @@ +package block + +import ( + "fmt" + "testing" + + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewEmptyMetaBlockCreator(t *testing.T) { + t.Parallel() + + creator := NewEmptyMetaBlockCreator() + require.False(t, check.IfNil(creator)) +} + +func TestEmptyMetaBlockCreator_CreateNewHeader(t *testing.T) { + t.Parallel() + + creator := NewEmptyMetaBlockCreator() + header := creator.CreateNewHeader() + require.False(t, check.IfNil(header)) + assert.Equal(t, "*block.MetaBlock", fmt.Sprintf("%T", header)) +} diff --git a/data/block/interface.go b/data/block/interface.go new file mode 100644 index 000000000..8603de78f --- /dev/null +++ b/data/block/interface.go @@ -0,0 +1,9 @@ +package block + +import "github.com/multiversx/mx-chain-core-go/data" + +// EmptyBlockCreator is able to create empty block instances +type EmptyBlockCreator interface { + CreateNewHeader() data.HeaderHandler + IsInterfaceNil() bool +} diff --git a/data/block/metaBlock.pb.go b/data/block/metaBlock.pb.go index a86de4855..9595a0edd 100644 --- a/data/block/metaBlock.pb.go +++ b/data/block/metaBlock.pb.go @@ -73,11 +73,11 @@ func (PeerAction) EnumDescriptor() ([]byte, []int) { // - a peer can register with an amount to become a validator // - a peer can choose to deregister and get back the deposited value type PeerData struct { - Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"Address,omitempty"` - 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/multiversx/mx-chain-core-go/data.BigIntCaster" json:"ValueChange,omitempty"` + Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"address,omitempty"` + 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"` + 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/multiversx/mx-chain-core-go/data.BigIntCaster" json:"valueChange,omitempty"` } func (m *PeerData) Reset() { *m = PeerData{} } @@ -145,20 +145,20 @@ func (m *PeerData) GetValueChange() *math_big.Int { // ShardData holds the block information sent by the shards to the metachain type ShardData struct { - HeaderHash []byte `protobuf:"bytes,2,opt,name=HeaderHash,proto3" json:"HeaderHash,omitempty"` - ShardMiniBlockHeaders []MiniBlockHeader `protobuf:"bytes,3,rep,name=ShardMiniBlockHeaders,proto3" json:"ShardMiniBlockHeaders"` - PrevRandSeed []byte `protobuf:"bytes,4,opt,name=PrevRandSeed,proto3" json:"PrevRandSeed,omitempty"` - PubKeysBitmap []byte `protobuf:"bytes,5,opt,name=PubKeysBitmap,proto3" json:"PubKeysBitmap,omitempty"` - Signature []byte `protobuf:"bytes,6,opt,name=Signature,proto3" json:"Signature,omitempty"` - 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/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"` - TxCount uint32 `protobuf:"varint,7,opt,name=TxCount,proto3" json:"TxCount,omitempty"` + HeaderHash []byte `protobuf:"bytes,2,opt,name=HeaderHash,proto3" json:"headerHash,omitempty"` + ShardMiniBlockHeaders []MiniBlockHeader `protobuf:"bytes,3,rep,name=ShardMiniBlockHeaders,proto3" json:"shardMiniBlockHeaders"` + PrevRandSeed []byte `protobuf:"bytes,4,opt,name=PrevRandSeed,proto3" json:"prevRandSeed,omitempty"` + PubKeysBitmap []byte `protobuf:"bytes,5,opt,name=PubKeysBitmap,proto3" json:"pubKeysBitmap,omitempty"` + Signature []byte `protobuf:"bytes,6,opt,name=Signature,proto3" json:"signature,omitempty"` + Round uint64 `protobuf:"varint,8,opt,name=Round,proto3" json:"round"` + PrevHash []byte `protobuf:"bytes,9,opt,name=PrevHash,proto3" json:"prevHash,omitempty"` + Nonce uint64 `protobuf:"varint,10,opt,name=Nonce,proto3" json:"nonce"` + 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"` + LastIncludedMetaNonce uint64 `protobuf:"varint,13,opt,name=LastIncludedMetaNonce,proto3" json:"lastIncludedMetaNonce"` + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + TxCount uint32 `protobuf:"varint,7,opt,name=TxCount,proto3" json:"txCount"` } func (m *ShardData) Reset() { *m = ShardData{} } @@ -289,16 +289,16 @@ func (m *ShardData) GetTxCount() uint32 { // EpochStartShardData hold the last finalized headers hash and state root hash type EpochStartShardData struct { - ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"ShardID,omitempty"` - Epoch uint32 `protobuf:"varint,9,opt,name=Epoch,proto3" json:"Epoch,omitempty"` - Round uint64 `protobuf:"varint,7,opt,name=Round,proto3" json:"Round,omitempty"` - Nonce uint64 `protobuf:"varint,8,opt,name=Nonce,proto3" json:"Nonce,omitempty"` - HeaderHash []byte `protobuf:"bytes,2,opt,name=HeaderHash,proto3" json:"HeaderHash,omitempty"` - RootHash []byte `protobuf:"bytes,3,opt,name=RootHash,proto3" json:"RootHash,omitempty"` - ScheduledRootHash []byte `protobuf:"bytes,10,opt,name=ScheduledRootHash,proto3" json:"ScheduledRootHash,omitempty"` - FirstPendingMetaBlock []byte `protobuf:"bytes,4,opt,name=FirstPendingMetaBlock,proto3" json:"FirstPendingMetaBlock,omitempty"` - LastFinishedMetaBlock []byte `protobuf:"bytes,5,opt,name=LastFinishedMetaBlock,proto3" json:"LastFinishedMetaBlock,omitempty"` - PendingMiniBlockHeaders []MiniBlockHeader `protobuf:"bytes,6,rep,name=PendingMiniBlockHeaders,proto3" json:"PendingMiniBlockHeaders"` + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + Epoch uint32 `protobuf:"varint,9,opt,name=Epoch,proto3" json:"epoch"` + Round uint64 `protobuf:"varint,7,opt,name=Round,proto3" json:"round"` + Nonce uint64 `protobuf:"varint,8,opt,name=Nonce,proto3" json:"nonce"` + HeaderHash []byte `protobuf:"bytes,2,opt,name=HeaderHash,proto3" json:"headerHash,omitempty"` + RootHash []byte `protobuf:"bytes,3,opt,name=RootHash,proto3" json:"rootHash,omitempty"` + ScheduledRootHash []byte `protobuf:"bytes,10,opt,name=ScheduledRootHash,proto3" json:"scheduledRootHash,omitempty"` + FirstPendingMetaBlock []byte `protobuf:"bytes,4,opt,name=FirstPendingMetaBlock,proto3" json:"firstPendingMetaBlock,omitempty"` + LastFinishedMetaBlock []byte `protobuf:"bytes,5,opt,name=LastFinishedMetaBlock,proto3" json:"lastFinishedMetaBlock,omitempty"` + PendingMiniBlockHeaders []MiniBlockHeader `protobuf:"bytes,6,rep,name=PendingMiniBlockHeaders,proto3" json:"pendingMiniBlockHeaders"` } func (m *EpochStartShardData) Reset() { *m = EpochStartShardData{} } @@ -401,14 +401,14 @@ 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/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"` + 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"` + PrevEpochStartHash []byte `protobuf:"bytes,8,opt,name=PrevEpochStartHash,proto3" json:"prevEpochStartHash,omitempty"` } func (m *Economics) Reset() { *m = Economics{} } @@ -497,8 +497,8 @@ func (m *Economics) GetPrevEpochStartHash() []byte { // EpochStart holds the block information for end-of-epoch type EpochStart struct { - LastFinalizedHeaders []EpochStartShardData `protobuf:"bytes,1,rep,name=LastFinalizedHeaders,proto3" json:"LastFinalizedHeaders"` - Economics Economics `protobuf:"bytes,2,opt,name=Economics,proto3" json:"Economics"` + LastFinalizedHeaders []EpochStartShardData `protobuf:"bytes,1,rep,name=LastFinalizedHeaders,proto3" json:"lastFinalizedHeaders"` + Economics Economics `protobuf:"bytes,2,opt,name=Economics,proto3" json:"economics"` } func (m *EpochStart) Reset() { *m = EpochStart{} } @@ -545,31 +545,31 @@ func (m *EpochStart) GetEconomics() Economics { // MetaBlock holds the data that will be saved to the metachain each round type MetaBlock struct { - Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"Nonce,omitempty"` - Epoch uint32 `protobuf:"varint,2,opt,name=Epoch,proto3" json:"Epoch,omitempty"` - Round uint64 `protobuf:"varint,3,opt,name=Round,proto3" json:"Round,omitempty"` - TimeStamp uint64 `protobuf:"varint,4,opt,name=TimeStamp,proto3" json:"TimeStamp,omitempty"` - ShardInfo []ShardData `protobuf:"bytes,5,rep,name=ShardInfo,proto3" json:"ShardInfo"` - PeerInfo []PeerData `protobuf:"bytes,6,rep,name=PeerInfo,proto3" json:"PeerInfo"` - Signature []byte `protobuf:"bytes,7,opt,name=Signature,proto3" json:"Signature,omitempty"` - LeaderSignature []byte `protobuf:"bytes,8,opt,name=LeaderSignature,proto3" json:"LeaderSignature,omitempty"` - PubKeysBitmap []byte `protobuf:"bytes,9,opt,name=PubKeysBitmap,proto3" json:"PubKeysBitmap,omitempty"` - PrevHash []byte `protobuf:"bytes,10,opt,name=PrevHash,proto3" json:"PrevHash,omitempty"` - PrevRandSeed []byte `protobuf:"bytes,11,opt,name=PrevRandSeed,proto3" json:"PrevRandSeed,omitempty"` - RandSeed []byte `protobuf:"bytes,12,opt,name=RandSeed,proto3" json:"RandSeed,omitempty"` - RootHash []byte `protobuf:"bytes,13,opt,name=RootHash,proto3" json:"RootHash,omitempty"` - ValidatorStatsRootHash []byte `protobuf:"bytes,14,opt,name=ValidatorStatsRootHash,proto3" json:"ValidatorStatsRootHash,omitempty"` - MiniBlockHeaders []MiniBlockHeader `protobuf:"bytes,16,rep,name=MiniBlockHeaders,proto3" json:"MiniBlockHeaders"` - ReceiptsHash []byte `protobuf:"bytes,17,opt,name=ReceiptsHash,proto3" json:"ReceiptsHash,omitempty"` - 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/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"` + Nonce uint64 `protobuf:"varint,1,opt,name=Nonce,proto3" json:"nonce"` + Epoch uint32 `protobuf:"varint,2,opt,name=Epoch,proto3" json:"epoch"` + Round uint64 `protobuf:"varint,3,opt,name=Round,proto3" json:"round"` + TimeStamp uint64 `protobuf:"varint,4,opt,name=TimeStamp,proto3" json:"timeStamp,omitempty"` + ShardInfo []ShardData `protobuf:"bytes,5,rep,name=ShardInfo,proto3" json:"shardInfo"` + PeerInfo []PeerData `protobuf:"bytes,6,rep,name=PeerInfo,proto3" json:"peerInfo"` + Signature []byte `protobuf:"bytes,7,opt,name=Signature,proto3" json:"signature,omitempty"` + LeaderSignature []byte `protobuf:"bytes,8,opt,name=LeaderSignature,proto3" json:"leaderSignature,omitempty"` + PubKeysBitmap []byte `protobuf:"bytes,9,opt,name=PubKeysBitmap,proto3" json:"pubKeysBitmap,omitempty"` + PrevHash []byte `protobuf:"bytes,10,opt,name=PrevHash,proto3" json:"prevHash,omitempty"` + PrevRandSeed []byte `protobuf:"bytes,11,opt,name=PrevRandSeed,proto3" json:"prevRandSeed,omitempty"` + RandSeed []byte `protobuf:"bytes,12,opt,name=RandSeed,proto3" json:"randSeed,omitempty"` + RootHash []byte `protobuf:"bytes,13,opt,name=RootHash,proto3" json:"rootHash,omitempty"` + ValidatorStatsRootHash []byte `protobuf:"bytes,14,opt,name=ValidatorStatsRootHash,proto3" json:"validatorStatsRootHash,omitempty"` + MiniBlockHeaders []MiniBlockHeader `protobuf:"bytes,16,rep,name=MiniBlockHeaders,proto3" json:"miniBlockHeaders"` + ReceiptsHash []byte `protobuf:"bytes,17,opt,name=ReceiptsHash,proto3" json:"receiptsHash,omitempty"` + EpochStart EpochStart `protobuf:"bytes,18,opt,name=EpochStart,proto3" json:"epochStart,omitempty"` + 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/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"` + Reserved []byte `protobuf:"bytes,26,opt,name=Reserved,proto3" json:"reserved,omitempty"` } func (m *MetaBlock) Reset() { *m = MetaBlock{} } @@ -788,87 +788,111 @@ func init() { func init() { proto.RegisterFile("metaBlock.proto", fileDescriptor_87b91ab531130b2b) } var fileDescriptor_87b91ab531130b2b = []byte{ - // 1280 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0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 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, 0x15, 0x3b, 0x0b, 0x3c, 0xcd, 0x9f, 0x0c, 0x80, - 0x14, 0x22, 0x27, 0xb0, 0x16, 0x53, 0x98, 0x7a, 0xec, 0x5b, 0x74, 0x13, 0x9a, 0x1a, 0x8a, 0xa6, - 0x1b, 0x31, 0x4d, 0x0b, 0xa6, 0x62, 0x4c, 0xd5, 0xc2, 0x6c, 0x72, 0x37, 0x43, 0x53, 0x45, 0x92, - 0xda, 0x5e, 0x23, 0x59, 0x2a, 0xc1, 0xe3, 0x05, 0xd2, 0xc0, 0xe6, 0x55, 0x15, 0xaa, 0xe9, 0x0c, - 0x19, 0xcf, 0x4b, 0x23, 0x3b, 0x2f, 0xc7, 0x13, 0xf7, 0x46, 0xe1, 0xc4, 0x2d, 0x67, 0x27, 0xee, - 0xff, 0x0b, 0xa2, 0xbb, 0xb1, 0x44, 0x69, 0xf9, 0x4f, 0xb8, 0x59, 0x51, 0xdb, 0x4d, 0x7e, 0x63, - 0x7e, 0x93, 0x69, 0x20, 0xf9, 0x58, 0x6b, 0x3a, 0x95, 0xa4, 0x47, 0xd9, 0x4a, 0x46, 0x91, 0x65, - 0x72, 0xc6, 0x61, 0x93, 0x02, 0x62, 0x21, 0x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0x67, 0x42, 0x56, - 0x2a, 0xd6, 0x60, 0x88, 0xc1, 0x39, 0xba, 0xe6, 0x46, 0xcc, 0x9a, 0xd8, 0xfe, 0xe0, 0x17, 0x03, - 0x20, 0xfd, 0x94, 0x23, 0xab, 0x50, 0x6f, 0xf9, 0xe7, 0x92, 0x28, 0x1a, 0x68, 0x94, 0xc8, 0x1a, - 0x34, 0x64, 0x80, 0x8d, 0x3d, 0x29, 0x09, 0xa8, 0x42, 0x0d, 0x19, 0x28, 0xd1, 0xaf, 0xfc, 0x50, - 0xd0, 0x33, 0xe6, 0xf7, 0x1a, 0x37, 0xc8, 0x3a, 0x10, 0x35, 0x82, 0x30, 0xc8, 0x86, 0x96, 0xc9, - 0xb2, 0xae, 0xf0, 0x25, 0x65, 0x1e, 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, + // 1651 bytes of a gzipped FileDescriptorProto + 0x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0x4a, 0xb0, 0x1b, 0x54, 0x03, 0x1d, 0x16, 0x4e, 0x22, 0xa5, 0xd1, 0x14, 0xe0, 0x77, 0x02, 0x28, + 0x33, 0xf4, 0x10, 0x9f, 0x69, 0xe7, 0x07, 0xc4, 0xa0, 0x58, 0x8d, 0x4a, 0xbc, 0xe3, 0x7b, 0xd2, + 0x2a, 0x1d, 0x92, 0x4d, 0x22, 0xad, 0x91, 0x04, 0x58, 0x63, 0x91, 0xf1, 0x19, 0xb2, 0x55, 0xa7, + 0x89, 0x6d, 0xbe, 0xce, 0x59, 0x63, 0xb1, 0x07, 0x45, 0x13, 0x69, 0x2c, 0x43, 0xe1, 0xe1, 0xef, + 0x02, 0xa8, 0x45, 0xd8, 0xbe, 0x69, 0x37, 0x83, 0xa2, 0x55, 0x4c, 0xad, 0xe5, 0x3a, 0x14, 0x11, + 0x03, 0xb5, 0x89, 0x46, 0xe8, 0x79, 0x74, 0x61, 0xce, 0x7c, 0x4f, 0xba, 0x6e, 0xbf, 0x44, 0x77, + 0x12, 0x49, 0xbf, 0x34, 0x41, 0xf8, 0x05, 0x28, 0x1c, 0x9a, 0x2a, 0x6e, 0xda, 0x44, 0x89, 0xc7, + 0x8b, 0x4f, 0x83, 0xf1, 0xc2, 0x88, 0xc1, 0x49, 0xa4, 0x95, 0x84, 0x84, 0x0d, 0xb0, 0x10, 0x8c, + 0x17, 0x49, 0x9f, 0xe0, 0x29, 0x3d, 0x1c, 0xa6, 0x47, 0xc5, 0x72, 0x9a, 0x0d, 0x6c, 0x02, 0x38, + 0x08, 0x33, 0x82, 0xcd, 0xb3, 0x67, 0xaa, 0xf9, 0x9e, 0x74, 0xd5, 0x1a, 0x91, 0x72, 0x7c, 0x95, + 0x62, 0xbb, 0xf6, 0xab, 0x00, 0x40, 0x02, 0x41, 0x0d, 0x2c, 0x46, 0xa4, 0x86, 0x34, 0xf2, 0x39, + 0x56, 0x63, 0xe2, 0x12, 0x18, 0x71, 0xad, 0x46, 0xc4, 0x95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 0xb4, 0x5b, + 0x14, 0x51, 0xa7, 0xef, 0x21, 0x1c, 0xe6, 0xff, 0xeb, 0x7b, 0x52, 0xed, 0x34, 0x55, 0x83, 0xf3, + 0x37, 0xc6, 0x07, 0xbc, 0x0f, 0xca, 0x23, 0xc3, 0x48, 0xf9, 0x85, 0xc3, 0x88, 0x18, 0x95, 0x52, + 0x59, 0x1f, 0x9e, 0x42, 0xca, 0x69, 0x3b, 0xa4, 0x8c, 0x15, 0x4c, 0x2c, 0xea, 0xb0, 0x8c, 0x2b, + 0xc9, 0x19, 0xdb, 0x1c, 0xce, 0x9f, 0x31, 0xaf, 0x0f, 0xef, 0xf2, 0x1c, 0x24, 0x42, 0x46, 0x04, + 0x95, 0x11, 0xae, 0x49, 0x28, 0x06, 0xf7, 0x31, 0x7e, 0x76, 0xe5, 0x68, 0x6c, 0x0b, 0xe4, 0x76, + 0x03, 0x82, 0x6e, 0xec, 0x89, 0x0b, 0xc9, 0x67, 0x0e, 0x25, 0x84, 0xf8, 0xcf, 0x1c, 0x91, 0x56, + 0x50, 0xe5, 0x2d, 0xf3, 0x98, 0x9e, 0x21, 0x1b, 0xdf, 0xc3, 0xb6, 0x43, 0x4c, 0x43, 0x5c, 0x4c, + 0xaa, 0xdc, 0x19, 0x14, 0xf1, 0x55, 0x3e, 0x64, 0x95, 0xba, 0x1e, 0x2e, 0xbd, 0xd9, 0xf5, 0xf0, + 0x47, 0x01, 0x2c, 0x0f, 0x61, 0x0d, 0x23, 0x64, 0xc1, 0x65, 0x96, 0x99, 0x1e, 0x94, 0x16, 0x4a, + 0xd5, 0x98, 0x44, 0x82, 0x63, 0x92, 0x49, 0x59, 0x63, 0x57, 0xde, 0xdc, 0x1a, 0xfb, 0xad, 0x00, + 0xe6, 0xf6, 0xf0, 0x29, 0x7f, 0x58, 0x22, 0xcb, 0x06, 0xfb, 0x9e, 0x24, 0xaa, 0x03, 0x92, 0x49, + 0xa4, 0x33, 0x14, 0x9c, 0x5f, 0x48, 0x2f, 0x8f, 0x5f, 0x48, 0x19, 0xf3, 0x60, 0x07, 0xdb, 0xa7, + 0x58, 0x15, 0x57, 0x39, 0xe6, 0x89, 0xb0, 0x01, 0xe6, 0x89, 0xb0, 0xeb, 0x3f, 0x08, 0x00, 0x24, + 0xdf, 0xe5, 0x60, 0x05, 0x94, 0x1a, 0x06, 0x23, 0x9a, 0x10, 0x28, 0x67, 0xe0, 0x22, 0x28, 0x07, + 0x0a, 0x32, 0xee, 0x04, 0x43, 0x34, 0x62, 0xa8, 0x10, 0x28, 0x06, 0xe8, 0x47, 0x86, 0x43, 0xd1, + 0x09, 0x31, 0x3a, 0xe5, 0x29, 0xb8, 0x0c, 0x20, 0xeb, 0x45, 0xd8, 0xe6, 0x55, 0xa7, 0xe1, 0x5c, + 0x18, 0xe1, 0x43, 0x44, 0x34, 0xac, 0x96, 0x2f, 0xc1, 0x32, 0x98, 0x0d, 0x4d, 0x23, 0x24, 0x0b, + 0xe7, 0x41, 0x31, 0x40, 0x5a, 0x1a, 0x0a, 0x96, 0xa9, 0xf2, 0x4c, 0x0c, 0xc8, 0x41, 0xff, 0x3c, + 0xc1, 0xe5, 0x5c, 0xfd, 0xfd, 0xc7, 0x4f, 0xab, 0x99, 0x27, 0x4f, 0xab, 0x99, 0xe7, 0x4f, 0xab, + 0xc2, 0x97, 0xbd, 0xaa, 0xf0, 0x53, 0xaf, 0x2a, 0x3c, 0xea, 0x55, 0x85, 0xc7, 0xbd, 0xaa, 0xf0, + 0xa4, 0x57, 0x15, 0xfe, 0xec, 0x55, 0x85, 0xbf, 0x7b, 0xd5, 0xcc, 0xf3, 0x5e, 0x55, 0x78, 0xf8, + 0xac, 0x9a, 0x79, 0xfc, 0xac, 0x9a, 0x79, 0xf2, 0xac, 0x9a, 0xf9, 0x24, 0xcb, 0x3e, 0x87, 0xb6, + 0x67, 0x18, 0xa1, 0xbc, 0xf5, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6d, 0x22, 0xba, 0x7e, 0x65, + 0x15, 0x00, 0x00, } func (x PeerAction) String() string { diff --git a/data/block/metaBlock.proto b/data/block/metaBlock.proto index 5b1055e96..db3a9bc3c 100644 --- a/data/block/metaBlock.proto +++ b/data/block/metaBlock.proto @@ -27,88 +27,88 @@ enum PeerAction { // - a peer can register with an amount to become a validator // - a peer can choose to deregister and get back the deposited value message PeerData { - bytes Address = 1; - bytes PublicKey = 2; - PeerAction Action = 3; - uint64 TimeStamp = 4; - bytes ValueChange = 5 [(gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes Address = 1 [(gogoproto.jsontag) = "address,omitempty"]; + bytes PublicKey = 2 [(gogoproto.jsontag) = "publicKey,omitempty"]; + PeerAction Action = 3 [(gogoproto.jsontag) = "action"]; + uint64 TimeStamp = 4 [(gogoproto.jsontag) = "timeStamp,omitempty"]; + bytes ValueChange = 5 [(gogoproto.jsontag) = "valueChange,omitempty", (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 message ShardData { - bytes HeaderHash = 2; - repeated MiniBlockHeader ShardMiniBlockHeaders = 3 [(gogoproto.nullable) = false]; - bytes PrevRandSeed = 4; - bytes PubKeysBitmap = 5; - bytes Signature = 6; - uint64 Round = 8; - bytes PrevHash = 9; - uint64 Nonce = 10; - 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; - uint32 TxCount = 7; + bytes HeaderHash = 2 [(gogoproto.jsontag) = "headerHash,omitempty"]; + repeated MiniBlockHeader ShardMiniBlockHeaders = 3 [(gogoproto.jsontag) = "shardMiniBlockHeaders", (gogoproto.nullable) = false]; + bytes PrevRandSeed = 4 [(gogoproto.jsontag) = "prevRandSeed,omitempty"]; + bytes PubKeysBitmap = 5 [(gogoproto.jsontag) = "pubKeysBitmap,omitempty"]; + bytes Signature = 6 [(gogoproto.jsontag) = "signature,omitempty"]; + uint64 Round = 8 [(gogoproto.jsontag) = "round"]; + bytes PrevHash = 9 [(gogoproto.jsontag) = "prevHash,omitempty"]; + uint64 Nonce = 10 [(gogoproto.jsontag) = "nonce"]; + bytes AccumulatedFees = 12 [(gogoproto.jsontag) = "accumulatedFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DeveloperFees = 14 [(gogoproto.jsontag) = "developerFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + uint32 NumPendingMiniBlocks = 11 [(gogoproto.jsontag) = "numPendingMiniBlocks"]; + uint64 LastIncludedMetaNonce = 13 [(gogoproto.jsontag) = "lastIncludedMetaNonce"]; + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + uint32 TxCount = 7 [(gogoproto.jsontag) = "txCount"]; } // EpochStartShardData hold the last finalized headers hash and state root hash message EpochStartShardData { - uint32 ShardID = 1; - uint32 Epoch = 9; - uint64 Round = 7; - uint64 Nonce = 8; - bytes HeaderHash = 2; - bytes RootHash = 3; - bytes ScheduledRootHash = 10; - bytes FirstPendingMetaBlock = 4; - bytes LastFinishedMetaBlock = 5; - repeated MiniBlockHeader PendingMiniBlockHeaders = 6 [(gogoproto.nullable) = false]; + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + uint32 Epoch = 9 [(gogoproto.jsontag) = "epoch"]; + uint64 Round = 7 [(gogoproto.jsontag) = "round"]; + uint64 Nonce = 8 [(gogoproto.jsontag) = "nonce"]; + bytes HeaderHash = 2 [(gogoproto.jsontag) = "headerHash,omitempty"]; + bytes RootHash = 3 [(gogoproto.jsontag) = "rootHash,omitempty"]; + bytes ScheduledRootHash = 10 [(gogoproto.jsontag) = "scheduledRootHash,omitempty"]; + bytes FirstPendingMetaBlock = 4 [(gogoproto.jsontag) = "firstPendingMetaBlock,omitempty"]; + bytes LastFinishedMetaBlock = 5 [(gogoproto.jsontag) = "lastFinishedMetaBlock,omitempty"]; + repeated MiniBlockHeader PendingMiniBlockHeaders = 6 [(gogoproto.jsontag) = "pendingMiniBlockHeaders", (gogoproto.nullable) = false]; } // Economics holds the block information for total supply and rewards message Economics { - 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; + bytes TotalSupply = 1 [(gogoproto.jsontag) = "totalSupply,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes TotalToDistribute = 2 [(gogoproto.jsontag) = "totalToDistribute,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes TotalNewlyMinted = 3 [(gogoproto.jsontag) = "totalNewlyMinted,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes RewardsPerBlock = 4 [(gogoproto.jsontag) = "rewardsPerBlock,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes RewardsForProtocolSustainability = 5 [(gogoproto.jsontag) = "rewardsForProtocolSustainability,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes NodePrice = 6 [(gogoproto.jsontag) = "nodePrice,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + uint64 PrevEpochStartRound = 7 [(gogoproto.jsontag) = "prevEpochStartRound"]; + bytes PrevEpochStartHash = 8 [(gogoproto.jsontag) = "prevEpochStartHash,omitempty"]; } // EpochStart holds the block information for end-of-epoch message EpochStart { - repeated EpochStartShardData LastFinalizedHeaders = 1 [(gogoproto.nullable) = false]; - Economics Economics = 2 [(gogoproto.nullable) = false]; + repeated EpochStartShardData LastFinalizedHeaders = 1 [(gogoproto.jsontag) = "lastFinalizedHeaders", (gogoproto.nullable) = false]; + Economics Economics = 2 [(gogoproto.jsontag) = "economics", (gogoproto.nullable) = false]; } // MetaBlock holds the data that will be saved to the metachain each round message MetaBlock { - uint64 Nonce = 1; - uint32 Epoch = 2; - uint64 Round = 3; - uint64 TimeStamp = 4; - repeated ShardData ShardInfo = 5 [(gogoproto.nullable) = false]; - repeated PeerData PeerInfo = 6 [(gogoproto.nullable) = false]; - bytes Signature = 7; - bytes LeaderSignature = 8; - bytes PubKeysBitmap = 9; - bytes PrevHash = 10; - bytes PrevRandSeed = 11; - bytes RandSeed = 12; - bytes RootHash = 13; - bytes ValidatorStatsRootHash = 14; - repeated MiniBlockHeader MiniBlockHeaders = 16 [(gogoproto.nullable) = false]; - bytes ReceiptsHash = 17; - EpochStart EpochStart = 18 [(gogoproto.nullable) = false]; - bytes ChainID = 19; - bytes SoftwareVersion = 20; - 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; + uint64 Nonce = 1 [(gogoproto.jsontag) = "nonce"]; + uint32 Epoch = 2 [(gogoproto.jsontag) = "epoch"]; + uint64 Round = 3 [(gogoproto.jsontag) = "round"]; + uint64 TimeStamp = 4 [(gogoproto.jsontag) = "timeStamp,omitempty"]; + repeated ShardData ShardInfo = 5 [(gogoproto.jsontag) = "shardInfo", (gogoproto.nullable) = false]; + repeated PeerData PeerInfo = 6 [(gogoproto.jsontag) = "peerInfo", (gogoproto.nullable) = false]; + bytes Signature = 7 [(gogoproto.jsontag) = "signature,omitempty"]; + bytes LeaderSignature = 8 [(gogoproto.jsontag) = "leaderSignature,omitempty"]; + bytes PubKeysBitmap = 9 [(gogoproto.jsontag) = "pubKeysBitmap,omitempty"]; + bytes PrevHash = 10 [(gogoproto.jsontag) = "prevHash,omitempty"]; + bytes PrevRandSeed = 11 [(gogoproto.jsontag) = "prevRandSeed,omitempty"]; + bytes RandSeed = 12 [(gogoproto.jsontag) = "randSeed,omitempty"]; + bytes RootHash = 13 [(gogoproto.jsontag) = "rootHash,omitempty"]; + bytes ValidatorStatsRootHash = 14 [(gogoproto.jsontag) = "validatorStatsRootHash,omitempty"]; + repeated MiniBlockHeader MiniBlockHeaders = 16 [(gogoproto.jsontag) = "miniBlockHeaders", (gogoproto.nullable) = false]; + bytes ReceiptsHash = 17 [(gogoproto.jsontag) = "receiptsHash,omitempty"]; + EpochStart EpochStart = 18 [(gogoproto.jsontag) = "epochStart,omitempty", (gogoproto.nullable) = false]; + bytes ChainID = 19 [(gogoproto.jsontag) = "chainID,omitempty"]; + bytes SoftwareVersion = 20 [(gogoproto.jsontag) = "softwareVersion,omitempty"]; + bytes AccumulatedFees = 21 [(gogoproto.jsontag) = "accumulatedFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes AccumulatedFeesInEpoch = 22 [(gogoproto.jsontag) = "accumulatedFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DeveloperFees = 23 [(gogoproto.jsontag) = "developerFees,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes DevFeesInEpoch = 24 [(gogoproto.jsontag) = "devFeesInEpoch,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + uint32 TxCount = 25 [(gogoproto.jsontag) = "txCount"]; + bytes Reserved = 26 [(gogoproto.jsontag) = "reserved,omitempty"]; } diff --git a/data/block/unmarshal.go b/data/block/unmarshal.go new file mode 100644 index 000000000..4c5813f2c --- /dev/null +++ b/data/block/unmarshal.go @@ -0,0 +1,25 @@ +package block + +import ( + "github.com/multiversx/mx-chain-core-go/core/check" + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/marshal" +) + +// GetHeaderFromBytes will unmarshal the header bytes based on the header type +func GetHeaderFromBytes(marshaller marshal.Marshalizer, creator EmptyBlockCreator, headerBytes []byte) (data.HeaderHandler, error) { + if check.IfNil(marshaller) { + return nil, data.ErrNilMarshalizer + } + if check.IfNil(creator) { + return nil, data.ErrNilEmptyBlockCreator + } + + header := creator.CreateNewHeader() + err := marshaller.Unmarshal(header, headerBytes) + if err != nil { + return nil, err + } + + return header, nil +} diff --git a/data/block/unmarshal_test.go b/data/block/unmarshal_test.go new file mode 100644 index 000000000..fc89eebf3 --- /dev/null +++ b/data/block/unmarshal_test.go @@ -0,0 +1,58 @@ +package block + +import ( + "testing" + + "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/marshal/factory" + "github.com/stretchr/testify/require" +) + +func TestGetHeaderFromBytes(t *testing.T) { + t.Parallel() + + marshaller, _ := factory.NewMarshalizer(factory.GogoProtobuf) + headerV1 := &Header{Nonce: 1} + hBytes, _ := marshaller.Marshal(headerV1) + emptyBlockCreator := &mock.EmptyBlockCreatorStub{ + CreateNewHeaderCalled: func() data.HeaderHandler { + return &Header{} + }, + } + + t.Run("should return error when nil marshaller", func(t *testing.T) { + header, err := GetHeaderFromBytes(nil, emptyBlockCreator, hBytes) + require.True(t, check.IfNil(header)) + require.Equal(t, data.ErrNilMarshalizer, err) + }) + t.Run("should return error when nil empty block creator", func(t *testing.T) { + header, err := GetHeaderFromBytes(marshaller, nil, hBytes) + require.True(t, check.IfNil(header)) + require.Equal(t, data.ErrNilEmptyBlockCreator, err) + }) + t.Run("wrong bytes should return error", func(t *testing.T) { + header, err := GetHeaderFromBytes(marshaller, emptyBlockCreator, []byte("wrong bytes")) + require.True(t, check.IfNil(header)) + require.NotNil(t, err) + }) + t.Run("nil bytes should return empty header", func(t *testing.T) { + header, err := GetHeaderFromBytes(marshaller, emptyBlockCreator, nil) + require.False(t, check.IfNil(header)) + require.Nil(t, err) + require.Equal(t, uint64(0), header.GetNonce()) + }) + t.Run("empty bytes should return empty header", func(t *testing.T) { + header, err := GetHeaderFromBytes(marshaller, emptyBlockCreator, make([]byte, 0)) + require.False(t, check.IfNil(header)) + require.Nil(t, err) + require.Equal(t, uint64(0), header.GetNonce()) + }) + t.Run("should work with correct bytes", func(t *testing.T) { + header, err := GetHeaderFromBytes(marshaller, emptyBlockCreator, hBytes) + require.False(t, check.IfNil(header)) + require.Nil(t, err) + require.Equal(t, uint64(1), header.GetNonce()) + }) +} diff --git a/data/errors.go b/data/errors.go index bd20054a2..ab2dae17c 100644 --- a/data/errors.go +++ b/data/errors.go @@ -22,6 +22,9 @@ var ErrNilShardCoordinator = errors.New("nil shard coordinator") // ErrNilMarshalizer is raised when the NewTrie() function is called, but a marshalizer isn't provided var ErrNilMarshalizer = errors.New("no marshalizer provided") +// ErrNilEmptyBlockCreator is raised when attempting to work with a nil empty block creator +var ErrNilEmptyBlockCreator = errors.New("nil empty block creator") + // ErrNilDatabase is raised when a database operation is called, but no database is provided var ErrNilDatabase = errors.New("no database provided") diff --git a/data/interface.go b/data/interface.go index 9c293edc4..80b039da2 100644 --- a/data/interface.go +++ b/data/interface.go @@ -281,24 +281,15 @@ 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 +type TxWithExecutionOrderHandler interface { + SetExecutionOrder(order uint32) + GetExecutionOrder() uint32 GetTxHandler() TransactionHandler - SetExecutionOrder(order int) - GetExecutionOrder() int } // Encoder represents a byte slice to string encoder type Encoder interface { - Encode(buff []byte) string + Encode(buff []byte) (string, error) IsInterfaceNil() bool } diff --git a/data/mock/emptyBlockCreatorStub.go b/data/mock/emptyBlockCreatorStub.go new file mode 100644 index 000000000..277ac7270 --- /dev/null +++ b/data/mock/emptyBlockCreatorStub.go @@ -0,0 +1,21 @@ +package mock + +import "github.com/multiversx/mx-chain-core-go/data" + +// EmptyBlockCreatorStub - +type EmptyBlockCreatorStub struct { + CreateNewHeaderCalled func() data.HeaderHandler +} + +// CreateNewHeader - +func (e *EmptyBlockCreatorStub) CreateNewHeader() data.HeaderHandler { + if e.CreateNewHeaderCalled != nil { + return e.CreateNewHeaderCalled() + } + return nil +} + +// IsInterfaceNil - +func (e *EmptyBlockCreatorStub) IsInterfaceNil() bool { + return e == nil +} diff --git a/data/mock/pubkeyConverterStub.go b/data/mock/pubkeyConverterStub.go index f8ef55072..0a40905b6 100644 --- a/data/mock/pubkeyConverterStub.go +++ b/data/mock/pubkeyConverterStub.go @@ -1,10 +1,14 @@ package mock +import "github.com/multiversx/mx-chain-core-go/core" + // PubkeyConverterStub - type PubkeyConverterStub struct { - LenCalled func() int - DecodeCalled func(humanReadable string) ([]byte, error) - EncodeCalled func(pkBytes []byte) string + LenCalled func() int + DecodeCalled func(humanReadable string) ([]byte, error) + EncodeCalled func(pkBytes []byte) (string, error) + EncodeSliceCalled func(pkBytesSlice [][]byte) ([]string, error) + SilentEncodeCalled func(pkBytes []byte, log core.Logger) string } // Len - @@ -26,11 +30,29 @@ func (pcs *PubkeyConverterStub) Decode(humanReadable string) ([]byte, error) { } // Encode - -func (pcs *PubkeyConverterStub) Encode(pkBytes []byte) string { +func (pcs *PubkeyConverterStub) Encode(pkBytes []byte) (string, error) { if pcs.EncodeCalled != nil { return pcs.EncodeCalled(pkBytes) } + return "", nil +} + +// EncodeSlice - +func (pcs *PubkeyConverterStub) EncodeSlice(pkBytesSlice [][]byte) ([]string, error) { + if pcs.EncodeSliceCalled != nil { + return pcs.EncodeSliceCalled(pkBytesSlice) + } + + return make([]string, 0), nil +} + +// SilentEncode - +func (pcs *PubkeyConverterStub) SilentEncode(pkBytes []byte, log core.Logger) string { + if pcs.SilentEncodeCalled != nil { + return pcs.SilentEncodeCalled(pkBytes, log) + } + return "" } diff --git a/data/outport/common.go b/data/outport/common.go new file mode 100644 index 000000000..825485116 --- /dev/null +++ b/data/outport/common.go @@ -0,0 +1,59 @@ +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src config.proto + +package outport + +import ( + "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" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/multiversx/mx-chain-core-go/marshal" +) + +// GetHeaderBytesAndType returns the marshalled header bytes along with header type, if known +func GetHeaderBytesAndType(marshaller marshal.Marshalizer, headerHandler data.HeaderHandler) ([]byte, core.HeaderType, error) { + if check.IfNil(marshaller) { + return nil, "", core.ErrNilMarshalizer + } + + var headerType core.HeaderType + + switch headerHandler.(type) { + case *block.HeaderV2: + headerType = core.ShardHeaderV2 + case *block.MetaBlock: + headerType = core.MetaHeader + case *block.Header: + headerType = core.ShardHeaderV1 + default: + return nil, "", errInvalidHeaderType + } + + headerBytes, err := marshaller.Marshal(headerHandler) + return headerBytes, headerType, err +} + +// GetBody converts the BodyHandler interface to Body struct +func GetBody(bodyHandler data.BodyHandler) (*block.Body, error) { + if check.IfNil(bodyHandler) { + return nil, errNilBodyHandler + } + + body, castOk := bodyHandler.(*block.Body) + if !castOk { + return nil, errCannotCastBlockBody + } + + return body, nil +} + +// ConvertPubKeys converts a map into a map +func ConvertPubKeys(validatorsPubKeys map[uint32][][]byte) map[uint32]*PubKeys { + ret := make(map[uint32]*PubKeys, len(validatorsPubKeys)) + + for shard, validators := range validatorsPubKeys { + ret[shard] = &PubKeys{Keys: validators} + } + + return ret +} diff --git a/data/outport/common_test.go b/data/outport/common_test.go new file mode 100644 index 000000000..555657ca1 --- /dev/null +++ b/data/outport/common_test.go @@ -0,0 +1,77 @@ +package outport + +import ( + "testing" + + "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" + "github.com/multiversx/mx-chain-core-go/data/block" + "github.com/stretchr/testify/require" +) + +func TestGetHeaderBytesAndType(t *testing.T) { + t.Parallel() + + headerBytes, headerType, err := GetHeaderBytesAndType(nil, nil) + require.Nil(t, headerBytes) + require.Empty(t, headerType) + require.Equal(t, core.ErrNilMarshalizer, err) + + marshaller := &mock.MarshalizerMock{} + headerBytes, headerType, err = GetHeaderBytesAndType(marshaller, nil) + require.Nil(t, headerBytes) + require.Empty(t, headerType) + require.Equal(t, errInvalidHeaderType, err) + + var header data.HeaderHandler + + header = &block.Header{} + headerBytes, headerType, err = GetHeaderBytesAndType(marshaller, header) + expectedHeaderBytes, _ := marshaller.Marshal(header) + require.Equal(t, expectedHeaderBytes, headerBytes) + require.Equal(t, core.ShardHeaderV1, headerType) + require.Nil(t, err) + + header = &block.HeaderV2{} + headerBytes, headerType, err = GetHeaderBytesAndType(marshaller, header) + expectedHeaderBytes, _ = marshaller.Marshal(header) + require.Equal(t, expectedHeaderBytes, headerBytes) + require.Equal(t, core.ShardHeaderV2, headerType) + require.Nil(t, err) + + header = &block.MetaBlock{} + headerBytes, headerType, err = GetHeaderBytesAndType(marshaller, header) + expectedHeaderBytes, _ = marshaller.Marshal(header) + require.Equal(t, expectedHeaderBytes, headerBytes) + require.Equal(t, core.MetaHeader, headerType) + require.Nil(t, err) +} + +func TestGetBody(t *testing.T) { + t.Parallel() + + receivedBody, err := GetBody(nil) + require.Nil(t, receivedBody) + require.Equal(t, errNilBodyHandler, err) + + var body data.BodyHandler = &block.Body{} + receivedBody, err = GetBody(body) + require.Nil(t, err) + require.Equal(t, body, receivedBody) +} + +func TestConvertPubKeys(t *testing.T) { + t.Parallel() + + validatorsPubKeys := map[uint32][][]byte{ + 0: {[]byte("pubKey1"), []byte("pubKey2")}, + core.MetachainShardId: {[]byte("pubKey3")}, + } + + ret := ConvertPubKeys(validatorsPubKeys) + require.Equal(t, map[uint32]*PubKeys{ + 0: {Keys: validatorsPubKeys[0]}, + core.MetachainShardId: {Keys: validatorsPubKeys[core.MetachainShardId]}, + }, ret) +} diff --git a/data/outport/config.pb.go b/data/outport/config.pb.go new file mode 100644 index 000000000..3836b1d11 --- /dev/null +++ b/data/outport/config.pb.go @@ -0,0 +1,412 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: config.proto + +package outport + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type OutportConfig struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + IsInImportDBMode bool `protobuf:"varint,2,opt,name=IsInImportDBMode,proto3" json:"isInImportDBMode"` +} + +func (m *OutportConfig) Reset() { *m = OutportConfig{} } +func (*OutportConfig) ProtoMessage() {} +func (*OutportConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_3eaf2c85e69e9ea4, []int{0} +} +func (m *OutportConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OutportConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *OutportConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_OutportConfig.Merge(m, src) +} +func (m *OutportConfig) XXX_Size() int { + return m.Size() +} +func (m *OutportConfig) XXX_DiscardUnknown() { + xxx_messageInfo_OutportConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_OutportConfig proto.InternalMessageInfo + +func (m *OutportConfig) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *OutportConfig) GetIsInImportDBMode() bool { + if m != nil { + return m.IsInImportDBMode + } + return false +} + +func init() { + proto.RegisterType((*OutportConfig)(nil), "proto.OutportConfig") +} + +func init() { proto.RegisterFile("config.proto", fileDescriptor_3eaf2c85e69e9ea4) } + +var fileDescriptor_3eaf2c85e69e9ea4 = []byte{ + // 261 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0xce, 0xcf, 0x4b, + 0xcb, 0x4c, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x52, 0xba, 0xe9, 0x99, + 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xe9, 0xf9, 0xe9, 0xf9, 0xfa, 0x60, 0xe1, + 0xa4, 0xd2, 0x34, 0x30, 0x0f, 0xcc, 0x01, 0xb3, 0x20, 0xba, 0x94, 0x2a, 0xb8, 0x78, 0xfd, 0x4b, + 0x4b, 0x0a, 0xf2, 0x8b, 0x4a, 0x9c, 0xc1, 0x86, 0x09, 0xa9, 0x72, 0xb1, 0x07, 0x67, 0x24, 0x16, + 0xa5, 0x78, 0xba, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x3a, 0x71, 0xbf, 0xba, 0x27, 0xcf, 0x5e, + 0x0c, 0x11, 0x0a, 0x82, 0xc9, 0x09, 0x39, 0x70, 0x09, 0x78, 0x16, 0x7b, 0xe6, 0x79, 0xe6, 0x82, + 0xb4, 0xba, 0x38, 0xf9, 0xe6, 0xa7, 0xa4, 0x4a, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x38, 0x89, 0xbc, + 0xba, 0x27, 0x2f, 0x90, 0x89, 0x26, 0x17, 0x84, 0xa1, 0xda, 0xa9, 0xf4, 0xc2, 0x43, 0x39, 0x86, + 0x1b, 0x0f, 0xe5, 0x18, 0x3e, 0x3c, 0x94, 0x63, 0x6c, 0x78, 0x24, 0xc7, 0xb8, 0xe2, 0x91, 0x1c, + 0xe3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0xde, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, + 0x1c, 0xe3, 0x8b, 0x47, 0x72, 0x0c, 0x1f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, + 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xd6, 0x48, 0x5e, 0xcc, 0x2d, 0xcd, 0x29, 0xc9, + 0x2c, 0x4b, 0x2d, 0x2a, 0xae, 0xd0, 0xcf, 0xad, 0xd0, 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x4d, + 0xce, 0x2f, 0x4a, 0xd5, 0x4d, 0xcf, 0xd7, 0x4f, 0x49, 0x2c, 0x49, 0xd4, 0xcf, 0x87, 0xf8, 0xce, + 0x1a, 0x4a, 0x27, 0xb1, 0x81, 0xfd, 0x6d, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x62, 0x13, 0x75, + 0x71, 0x3d, 0x01, 0x00, 0x00, +} + +func (this *OutportConfig) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OutportConfig) + if !ok { + that2, ok := that.(OutportConfig) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if this.IsInImportDBMode != that1.IsInImportDBMode { + return false + } + return true +} +func (this *OutportConfig) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&outport.OutportConfig{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + s = append(s, "IsInImportDBMode: "+fmt.Sprintf("%#v", this.IsInImportDBMode)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringConfig(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *OutportConfig) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OutportConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OutportConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsInImportDBMode { + i-- + if m.IsInImportDBMode { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if m.ShardID != 0 { + i = encodeVarintConfig(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintConfig(dAtA []byte, offset int, v uint64) int { + offset -= sovConfig(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *OutportConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovConfig(uint64(m.ShardID)) + } + if m.IsInImportDBMode { + n += 2 + } + return n +} + +func sovConfig(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozConfig(x uint64) (n int) { + return sovConfig(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *OutportConfig) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&OutportConfig{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `IsInImportDBMode:` + fmt.Sprintf("%v", this.IsInImportDBMode) + `,`, + `}`, + }, "") + return s +} +func valueToStringConfig(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *OutportConfig) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OutportConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OutportConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsInImportDBMode", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowConfig + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsInImportDBMode = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipConfig(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthConfig + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipConfig(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowConfig + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthConfig + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupConfig + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthConfig + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthConfig = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowConfig = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupConfig = fmt.Errorf("proto: unexpected end of group") +) diff --git a/data/outport/config.proto b/data/outport/config.proto new file mode 100644 index 000000000..68f70f3f6 --- /dev/null +++ b/data/outport/config.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package proto; + +option go_package = "github.com/multiversx/mx-chain-core-go/data/outport;outport"; +option (gogoproto.stable_marshaler_all) = true; + +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; + +message OutportConfig { + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + bool IsInImportDBMode = 2 [(gogoproto.jsontag) = "isInImportDBMode"]; +} diff --git a/data/outport/consts.go b/data/outport/consts.go new file mode 100644 index 000000000..ee1790267 --- /dev/null +++ b/data/outport/consts.go @@ -0,0 +1,20 @@ +package outport + +const ( + // TopicSaveBlock is the topic that triggers a block saving + TopicSaveBlock = "SaveBlock" + // TopicRevertIndexedBlock is the topic that triggers a reverting of an indexed block + TopicRevertIndexedBlock = "RevertIndexedBlock" + // TopicSaveRoundsInfo is the topic that triggers the saving of rounds info + TopicSaveRoundsInfo = "SaveRoundsInfo" + // TopicSaveValidatorsPubKeys is the topic that triggers the saving of validators' public keys + TopicSaveValidatorsPubKeys = "SaveValidatorsPubKeys" + // TopicSaveValidatorsRating is the topic that triggers the saving of the validators' rating + TopicSaveValidatorsRating = "SaveValidatorsRating" + // TopicSaveAccounts is the topic that triggers the saving of accounts + TopicSaveAccounts = "SaveAccounts" + // TopicFinalizedBlock is the topic that triggers the handling of a finalized block + TopicFinalizedBlock = "FinalizedBlock" + // TopicSettings is the topic that triggers the sending of node settings + TopicSettings = "Settings" +) diff --git a/data/outport/dtos.go b/data/outport/dtos.go deleted file mode 100644 index 69641f648..000000000 --- a/data/outport/dtos.go +++ /dev/null @@ -1,101 +0,0 @@ -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/errors.go b/data/outport/errors.go new file mode 100644 index 000000000..5479d75f9 --- /dev/null +++ b/data/outport/errors.go @@ -0,0 +1,9 @@ +package outport + +import "errors" + +var errInvalidHeaderType = errors.New("received invalid/unknown header type") + +var errNilBodyHandler = errors.New("nil body handler") + +var errCannotCastBlockBody = errors.New("cannot cast block body") diff --git a/data/outport/feeInfo.go b/data/outport/feeInfo.go new file mode 100644 index 000000000..3741fa022 --- /dev/null +++ b/data/outport/feeInfo.go @@ -0,0 +1,18 @@ +package outport + +import "math/big" + +// SetInitialPaidFee sets the initial paid fee +func (f *FeeInfo) SetInitialPaidFee(fee *big.Int) { + f.InitialPaidFee = fee +} + +// SetGasUsed sets the used gas +func (f *FeeInfo) SetGasUsed(gasUsed uint64) { + f.GasUsed = gasUsed +} + +// SetFee sets the fee +func (f *FeeInfo) SetFee(fee *big.Int) { + f.Fee = fee +} diff --git a/data/outport/outportBlock.go b/data/outport/outportBlock.go new file mode 100644 index 000000000..d66839919 --- /dev/null +++ b/data/outport/outportBlock.go @@ -0,0 +1,58 @@ +//go:generate protoc -I=. -I=$GOPATH/src/github.com/multiversx/mx-chain-core-go/data/block -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src outportBlock.proto + +package outport + +import ( + "github.com/multiversx/mx-chain-core-go/data" + "github.com/multiversx/mx-chain-core-go/data/block" +) + +// OutportBlockWithHeader will extend the OutportBlock structure +type OutportBlockWithHeader struct { + *OutportBlock + Header data.HeaderHandler +} + +// HeaderDataWithBody holds header and body data +type HeaderDataWithBody struct { + Body data.BodyHandler + Header data.HeaderHandler + IntraShardMiniBlocks []*block.MiniBlock + HeaderHash []byte +} + +// OutportBlockWithHeaderAndBody is a wrapper for OutportBlock used for outport handler +type OutportBlockWithHeaderAndBody struct { + *OutportBlock + HeaderDataWithBody *HeaderDataWithBody +} + +// SetExecutionOrder sets execution order +func (t *TxInfo) SetExecutionOrder(order uint32) { + t.ExecutionOrder = order +} + +// GetTxHandler returns tx handler +func (t *TxInfo) GetTxHandler() data.TransactionHandler { + return t.Transaction +} + +// SetExecutionOrder sets execution order +func (s *SCRInfo) SetExecutionOrder(order uint32) { + s.ExecutionOrder = order +} + +// GetTxHandler returns tx handler +func (s *SCRInfo) GetTxHandler() data.TransactionHandler { + return s.SmartContractResult +} + +// SetExecutionOrder sets execution order +func (r *RewardInfo) SetExecutionOrder(order uint32) { + r.ExecutionOrder = order +} + +// GetTxHandler returns tx handler +func (r *RewardInfo) GetTxHandler() data.TransactionHandler { + return r.Reward +} diff --git a/data/outport/outportBlock.pb.go b/data/outport/outportBlock.pb.go new file mode 100644 index 000000000..f7020b56c --- /dev/null +++ b/data/outport/outportBlock.pb.go @@ -0,0 +1,7892 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: outportBlock.proto + +package outport + +import ( + bytes "bytes" + encoding_binary "encoding/binary" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_sortkeys "github.com/gogo/protobuf/sortkeys" + github_com_multiversx_mx_chain_core_go_data "github.com/multiversx/mx-chain-core-go/data" + alteredAccount "github.com/multiversx/mx-chain-core-go/data/alteredAccount" + block "github.com/multiversx/mx-chain-core-go/data/block" + receipt "github.com/multiversx/mx-chain-core-go/data/receipt" + rewardTx "github.com/multiversx/mx-chain-core-go/data/rewardTx" + 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" + math_bits "math/bits" + reflect "reflect" + strings "strings" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type OutportBlock struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID,omitempty"` + BlockData *BlockData `protobuf:"bytes,2,opt,name=BlockData,proto3" json:"blockData,omitempty"` + TransactionPool *TransactionPool `protobuf:"bytes,3,opt,name=TransactionPool,proto3" json:"transactionPool,omitempty"` + HeaderGasConsumption *HeaderGasConsumption `protobuf:"bytes,4,opt,name=HeaderGasConsumption,proto3" json:"headerGasConsumption,omitempty"` + AlteredAccounts map[string]*alteredAccount.AlteredAccount `protobuf:"bytes,5,rep,name=AlteredAccounts,proto3" json:"alteredAccounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + NotarizedHeadersHashes []string `protobuf:"bytes,6,rep,name=NotarizedHeadersHashes,proto3" json:"notarizedHeadersHashes,omitempty"` + NumberOfShards uint32 `protobuf:"varint,7,opt,name=NumberOfShards,proto3" json:"numberOfShards"` + SignersIndexes []uint64 `protobuf:"varint,8,rep,packed,name=SignersIndexes,proto3" json:"signersIndexes,omitempty"` + HighestFinalBlockNonce uint64 `protobuf:"varint,9,opt,name=HighestFinalBlockNonce,proto3" json:"highestFinalBlockNonce"` + HighestFinalBlockHash []byte `protobuf:"bytes,10,opt,name=HighestFinalBlockHash,proto3" json:"highestFinalBlockHash,omitempty"` +} + +func (m *OutportBlock) Reset() { *m = OutportBlock{} } +func (*OutportBlock) ProtoMessage() {} +func (*OutportBlock) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{0} +} +func (m *OutportBlock) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *OutportBlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *OutportBlock) XXX_Merge(src proto.Message) { + xxx_messageInfo_OutportBlock.Merge(m, src) +} +func (m *OutportBlock) XXX_Size() int { + return m.Size() +} +func (m *OutportBlock) XXX_DiscardUnknown() { + xxx_messageInfo_OutportBlock.DiscardUnknown(m) +} + +var xxx_messageInfo_OutportBlock proto.InternalMessageInfo + +func (m *OutportBlock) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *OutportBlock) GetBlockData() *BlockData { + if m != nil { + return m.BlockData + } + return nil +} + +func (m *OutportBlock) GetTransactionPool() *TransactionPool { + if m != nil { + return m.TransactionPool + } + return nil +} + +func (m *OutportBlock) GetHeaderGasConsumption() *HeaderGasConsumption { + if m != nil { + return m.HeaderGasConsumption + } + return nil +} + +func (m *OutportBlock) GetAlteredAccounts() map[string]*alteredAccount.AlteredAccount { + if m != nil { + return m.AlteredAccounts + } + return nil +} + +func (m *OutportBlock) GetNotarizedHeadersHashes() []string { + if m != nil { + return m.NotarizedHeadersHashes + } + return nil +} + +func (m *OutportBlock) GetNumberOfShards() uint32 { + if m != nil { + return m.NumberOfShards + } + return 0 +} + +func (m *OutportBlock) GetSignersIndexes() []uint64 { + if m != nil { + return m.SignersIndexes + } + return nil +} + +func (m *OutportBlock) GetHighestFinalBlockNonce() uint64 { + if m != nil { + return m.HighestFinalBlockNonce + } + return 0 +} + +func (m *OutportBlock) GetHighestFinalBlockHash() []byte { + if m != nil { + return m.HighestFinalBlockHash + } + return nil +} + +type BlockData struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID,omitempty"` + HeaderBytes []byte `protobuf:"bytes,2,opt,name=HeaderBytes,proto3" json:"headerBytes,omitempty"` + HeaderType string `protobuf:"bytes,3,opt,name=HeaderType,proto3" json:"headerType,omitempty"` + HeaderHash []byte `protobuf:"bytes,4,opt,name=HeaderHash,proto3" json:"headerHash,omitempty"` + Body *block.Body `protobuf:"bytes,5,opt,name=Body,proto3" json:"body,omitempty"` + IntraShardMiniBlocks []*block.MiniBlock `protobuf:"bytes,6,rep,name=IntraShardMiniBlocks,proto3" json:"intraShardMiniBlocks,omitempty"` +} + +func (m *BlockData) Reset() { *m = BlockData{} } +func (*BlockData) ProtoMessage() {} +func (*BlockData) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{1} +} +func (m *BlockData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BlockData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *BlockData) XXX_Merge(src proto.Message) { + xxx_messageInfo_BlockData.Merge(m, src) +} +func (m *BlockData) XXX_Size() int { + return m.Size() +} +func (m *BlockData) XXX_DiscardUnknown() { + xxx_messageInfo_BlockData.DiscardUnknown(m) +} + +var xxx_messageInfo_BlockData proto.InternalMessageInfo + +func (m *BlockData) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *BlockData) GetHeaderBytes() []byte { + if m != nil { + return m.HeaderBytes + } + return nil +} + +func (m *BlockData) GetHeaderType() string { + if m != nil { + return m.HeaderType + } + return "" +} + +func (m *BlockData) GetHeaderHash() []byte { + if m != nil { + return m.HeaderHash + } + return nil +} + +func (m *BlockData) GetBody() *block.Body { + if m != nil { + return m.Body + } + return nil +} + +func (m *BlockData) GetIntraShardMiniBlocks() []*block.MiniBlock { + if m != nil { + return m.IntraShardMiniBlocks + } + return nil +} + +type TransactionPool struct { + Transactions map[string]*TxInfo `protobuf:"bytes,1,rep,name=Transactions,proto3" json:"transactions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + SmartContractResults map[string]*SCRInfo `protobuf:"bytes,2,rep,name=SmartContractResults,proto3" json:"smartContractResults,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Rewards map[string]*RewardInfo `protobuf:"bytes,3,rep,name=Rewards,proto3" json:"rewards,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Receipts map[string]*receipt.Receipt `protobuf:"bytes,4,rep,name=Receipts,proto3" json:"receipts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + InvalidTxs map[string]*TxInfo `protobuf:"bytes,5,rep,name=InvalidTxs,proto3" json:"invalidTxs,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Logs []*LogData `protobuf:"bytes,6,rep,name=Logs,proto3" json:"logs,omitempty"` + ScheduledExecutedSCRSHashesPrevBlock []string `protobuf:"bytes,7,rep,name=ScheduledExecutedSCRSHashesPrevBlock,proto3" json:"scheduledExecutedSCRSHashesPrevBlock,omitempty"` + ScheduledExecutedInvalidTxsHashesPrevBlock []string `protobuf:"bytes,8,rep,name=ScheduledExecutedInvalidTxsHashesPrevBlock,proto3" json:"scheduledExecutedInvalidTxsHashesPrevBlock,omitempty"` +} + +func (m *TransactionPool) Reset() { *m = TransactionPool{} } +func (*TransactionPool) ProtoMessage() {} +func (*TransactionPool) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{2} +} +func (m *TransactionPool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TransactionPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *TransactionPool) XXX_Merge(src proto.Message) { + xxx_messageInfo_TransactionPool.Merge(m, src) +} +func (m *TransactionPool) XXX_Size() int { + return m.Size() +} +func (m *TransactionPool) XXX_DiscardUnknown() { + xxx_messageInfo_TransactionPool.DiscardUnknown(m) +} + +var xxx_messageInfo_TransactionPool proto.InternalMessageInfo + +func (m *TransactionPool) GetTransactions() map[string]*TxInfo { + if m != nil { + return m.Transactions + } + return nil +} + +func (m *TransactionPool) GetSmartContractResults() map[string]*SCRInfo { + if m != nil { + return m.SmartContractResults + } + return nil +} + +func (m *TransactionPool) GetRewards() map[string]*RewardInfo { + if m != nil { + return m.Rewards + } + return nil +} + +func (m *TransactionPool) GetReceipts() map[string]*receipt.Receipt { + if m != nil { + return m.Receipts + } + return nil +} + +func (m *TransactionPool) GetInvalidTxs() map[string]*TxInfo { + if m != nil { + return m.InvalidTxs + } + return nil +} + +func (m *TransactionPool) GetLogs() []*LogData { + if m != nil { + return m.Logs + } + return nil +} + +func (m *TransactionPool) GetScheduledExecutedSCRSHashesPrevBlock() []string { + if m != nil { + return m.ScheduledExecutedSCRSHashesPrevBlock + } + return nil +} + +func (m *TransactionPool) GetScheduledExecutedInvalidTxsHashesPrevBlock() []string { + if m != nil { + return m.ScheduledExecutedInvalidTxsHashesPrevBlock + } + return nil +} + +type FeeInfo struct { + GasUsed uint64 `protobuf:"varint,1,opt,name=GasUsed,proto3" json:"gasUsed"` + Fee *math_big.Int `protobuf:"bytes,2,opt,name=Fee,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"fee,omitempty"` + InitialPaidFee *math_big.Int `protobuf:"bytes,3,opt,name=InitialPaidFee,proto3,casttypewith=math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster" json:"initialPaidFee,omitempty"` +} + +func (m *FeeInfo) Reset() { *m = FeeInfo{} } +func (*FeeInfo) ProtoMessage() {} +func (*FeeInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{3} +} +func (m *FeeInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FeeInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *FeeInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_FeeInfo.Merge(m, src) +} +func (m *FeeInfo) XXX_Size() int { + return m.Size() +} +func (m *FeeInfo) XXX_DiscardUnknown() { + xxx_messageInfo_FeeInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_FeeInfo proto.InternalMessageInfo + +func (m *FeeInfo) GetGasUsed() uint64 { + if m != nil { + return m.GasUsed + } + return 0 +} + +func (m *FeeInfo) GetFee() *math_big.Int { + if m != nil { + return m.Fee + } + return nil +} + +func (m *FeeInfo) GetInitialPaidFee() *math_big.Int { + if m != nil { + return m.InitialPaidFee + } + return nil +} + +type TxInfo struct { + Transaction *transaction.Transaction `protobuf:"bytes,1,opt,name=Transaction,proto3" json:"transaction,omitempty"` + FeeInfo *FeeInfo `protobuf:"bytes,2,opt,name=FeeInfo,proto3" json:"feeInfo,omitempty"` + ExecutionOrder uint32 `protobuf:"varint,3,opt,name=ExecutionOrder,proto3" json:"executionOrder"` +} + +func (m *TxInfo) Reset() { *m = TxInfo{} } +func (*TxInfo) ProtoMessage() {} +func (*TxInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{4} +} +func (m *TxInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *TxInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxInfo.Merge(m, src) +} +func (m *TxInfo) XXX_Size() int { + return m.Size() +} +func (m *TxInfo) XXX_DiscardUnknown() { + xxx_messageInfo_TxInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_TxInfo proto.InternalMessageInfo + +func (m *TxInfo) GetTransaction() *transaction.Transaction { + if m != nil { + return m.Transaction + } + return nil +} + +func (m *TxInfo) GetFeeInfo() *FeeInfo { + if m != nil { + return m.FeeInfo + } + return nil +} + +func (m *TxInfo) GetExecutionOrder() uint32 { + if m != nil { + return m.ExecutionOrder + } + return 0 +} + +type SCRInfo struct { + SmartContractResult *smartContractResult.SmartContractResult `protobuf:"bytes,1,opt,name=SmartContractResult,proto3" json:"smartContractResult,omitempty"` + FeeInfo *FeeInfo `protobuf:"bytes,2,opt,name=FeeInfo,proto3" json:"feeInfo,omitempty"` + ExecutionOrder uint32 `protobuf:"varint,3,opt,name=ExecutionOrder,proto3" json:"executionOrder"` +} + +func (m *SCRInfo) Reset() { *m = SCRInfo{} } +func (*SCRInfo) ProtoMessage() {} +func (*SCRInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{5} +} +func (m *SCRInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SCRInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *SCRInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_SCRInfo.Merge(m, src) +} +func (m *SCRInfo) XXX_Size() int { + return m.Size() +} +func (m *SCRInfo) XXX_DiscardUnknown() { + xxx_messageInfo_SCRInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_SCRInfo proto.InternalMessageInfo + +func (m *SCRInfo) GetSmartContractResult() *smartContractResult.SmartContractResult { + if m != nil { + return m.SmartContractResult + } + return nil +} + +func (m *SCRInfo) GetFeeInfo() *FeeInfo { + if m != nil { + return m.FeeInfo + } + return nil +} + +func (m *SCRInfo) GetExecutionOrder() uint32 { + if m != nil { + return m.ExecutionOrder + } + return 0 +} + +type LogData struct { + TxHash string `protobuf:"bytes,1,opt,name=TxHash,proto3" json:"txHash"` + Log *transaction.Log `protobuf:"bytes,2,opt,name=Log,proto3" json:"log"` +} + +func (m *LogData) Reset() { *m = LogData{} } +func (*LogData) ProtoMessage() {} +func (*LogData) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{6} +} +func (m *LogData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LogData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *LogData) XXX_Merge(src proto.Message) { + xxx_messageInfo_LogData.Merge(m, src) +} +func (m *LogData) XXX_Size() int { + return m.Size() +} +func (m *LogData) XXX_DiscardUnknown() { + xxx_messageInfo_LogData.DiscardUnknown(m) +} + +var xxx_messageInfo_LogData proto.InternalMessageInfo + +func (m *LogData) GetTxHash() string { + if m != nil { + return m.TxHash + } + return "" +} + +func (m *LogData) GetLog() *transaction.Log { + if m != nil { + return m.Log + } + return nil +} + +type RewardInfo struct { + Reward *rewardTx.RewardTx `protobuf:"bytes,1,opt,name=Reward,proto3" json:"reward,omitempty"` + ExecutionOrder uint32 `protobuf:"varint,2,opt,name=ExecutionOrder,proto3" json:"executionOrder"` +} + +func (m *RewardInfo) Reset() { *m = RewardInfo{} } +func (*RewardInfo) ProtoMessage() {} +func (*RewardInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{7} +} +func (m *RewardInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RewardInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *RewardInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_RewardInfo.Merge(m, src) +} +func (m *RewardInfo) XXX_Size() int { + return m.Size() +} +func (m *RewardInfo) XXX_DiscardUnknown() { + xxx_messageInfo_RewardInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_RewardInfo proto.InternalMessageInfo + +func (m *RewardInfo) GetReward() *rewardTx.RewardTx { + if m != nil { + return m.Reward + } + return nil +} + +func (m *RewardInfo) GetExecutionOrder() uint32 { + if m != nil { + return m.ExecutionOrder + } + return 0 +} + +type HeaderGasConsumption struct { + GasProvided uint64 `protobuf:"varint,1,opt,name=GasProvided,proto3" json:"gasProvided"` + GasRefunded uint64 `protobuf:"varint,2,opt,name=GasRefunded,proto3" json:"gasRefunded"` + GasPenalized uint64 `protobuf:"varint,3,opt,name=GasPenalized,proto3" json:"gasPenalized"` + MaxGasPerBlock uint64 `protobuf:"varint,4,opt,name=MaxGasPerBlock,proto3" json:"maxGasPerBlock"` +} + +func (m *HeaderGasConsumption) Reset() { *m = HeaderGasConsumption{} } +func (*HeaderGasConsumption) ProtoMessage() {} +func (*HeaderGasConsumption) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{8} +} +func (m *HeaderGasConsumption) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HeaderGasConsumption) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *HeaderGasConsumption) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeaderGasConsumption.Merge(m, src) +} +func (m *HeaderGasConsumption) XXX_Size() int { + return m.Size() +} +func (m *HeaderGasConsumption) XXX_DiscardUnknown() { + xxx_messageInfo_HeaderGasConsumption.DiscardUnknown(m) +} + +var xxx_messageInfo_HeaderGasConsumption proto.InternalMessageInfo + +func (m *HeaderGasConsumption) GetGasProvided() uint64 { + if m != nil { + return m.GasProvided + } + return 0 +} + +func (m *HeaderGasConsumption) GetGasRefunded() uint64 { + if m != nil { + return m.GasRefunded + } + return 0 +} + +func (m *HeaderGasConsumption) GetGasPenalized() uint64 { + if m != nil { + return m.GasPenalized + } + return 0 +} + +func (m *HeaderGasConsumption) GetMaxGasPerBlock() uint64 { + if m != nil { + return m.MaxGasPerBlock + } + return 0 +} + +type ValidatorRatingInfo struct { + PublicKey string `protobuf:"bytes,1,opt,name=PublicKey,proto3" json:"publicKey"` + Rating float32 `protobuf:"fixed32,2,opt,name=Rating,proto3" json:"rating"` +} + +func (m *ValidatorRatingInfo) Reset() { *m = ValidatorRatingInfo{} } +func (*ValidatorRatingInfo) ProtoMessage() {} +func (*ValidatorRatingInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{9} +} +func (m *ValidatorRatingInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorRatingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *ValidatorRatingInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorRatingInfo.Merge(m, src) +} +func (m *ValidatorRatingInfo) XXX_Size() int { + return m.Size() +} +func (m *ValidatorRatingInfo) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorRatingInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorRatingInfo proto.InternalMessageInfo + +func (m *ValidatorRatingInfo) GetPublicKey() string { + if m != nil { + return m.PublicKey + } + return "" +} + +func (m *ValidatorRatingInfo) GetRating() float32 { + if m != nil { + return m.Rating + } + return 0 +} + +type ValidatorsRating struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + Epoch uint32 `protobuf:"varint,2,opt,name=Epoch,proto3" json:"epoch"` + ValidatorsRatingInfo []*ValidatorRatingInfo `protobuf:"bytes,3,rep,name=ValidatorsRatingInfo,proto3" json:"validatorsRatingInfo,omitempty"` +} + +func (m *ValidatorsRating) Reset() { *m = ValidatorsRating{} } +func (*ValidatorsRating) ProtoMessage() {} +func (*ValidatorsRating) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{10} +} +func (m *ValidatorsRating) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorsRating) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *ValidatorsRating) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorsRating.Merge(m, src) +} +func (m *ValidatorsRating) XXX_Size() int { + return m.Size() +} +func (m *ValidatorsRating) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorsRating.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorsRating proto.InternalMessageInfo + +func (m *ValidatorsRating) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *ValidatorsRating) GetEpoch() uint32 { + if m != nil { + return m.Epoch + } + return 0 +} + +func (m *ValidatorsRating) GetValidatorsRatingInfo() []*ValidatorRatingInfo { + if m != nil { + return m.ValidatorsRatingInfo + } + return nil +} + +type RoundInfo struct { + Round uint64 `protobuf:"varint,1,opt,name=Round,proto3" json:"round"` + SignersIndexes []uint64 `protobuf:"varint,2,rep,packed,name=SignersIndexes,proto3" json:"signersIndexes"` + BlockWasProposed bool `protobuf:"varint,3,opt,name=BlockWasProposed,proto3" json:"blockWasProposed"` + ShardId uint32 `protobuf:"varint,4,opt,name=ShardId,proto3" json:"shardId"` + Epoch uint32 `protobuf:"varint,5,opt,name=Epoch,proto3" json:"epoch"` + Timestamp uint64 `protobuf:"varint,6,opt,name=Timestamp,proto3" json:"timestamp"` +} + +func (m *RoundInfo) Reset() { *m = RoundInfo{} } +func (*RoundInfo) ProtoMessage() {} +func (*RoundInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{11} +} +func (m *RoundInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RoundInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *RoundInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_RoundInfo.Merge(m, src) +} +func (m *RoundInfo) XXX_Size() int { + return m.Size() +} +func (m *RoundInfo) XXX_DiscardUnknown() { + xxx_messageInfo_RoundInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_RoundInfo proto.InternalMessageInfo + +func (m *RoundInfo) GetRound() uint64 { + if m != nil { + return m.Round + } + return 0 +} + +func (m *RoundInfo) GetSignersIndexes() []uint64 { + if m != nil { + return m.SignersIndexes + } + return nil +} + +func (m *RoundInfo) GetBlockWasProposed() bool { + if m != nil { + return m.BlockWasProposed + } + return false +} + +func (m *RoundInfo) GetShardId() uint32 { + if m != nil { + return m.ShardId + } + return 0 +} + +func (m *RoundInfo) GetEpoch() uint32 { + if m != nil { + return m.Epoch + } + return 0 +} + +func (m *RoundInfo) GetTimestamp() uint64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type RoundsInfo struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + RoundsInfo []*RoundInfo `protobuf:"bytes,2,rep,name=RoundsInfo,proto3" json:"roundsInfo,omitempty"` +} + +func (m *RoundsInfo) Reset() { *m = RoundsInfo{} } +func (*RoundsInfo) ProtoMessage() {} +func (*RoundsInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{12} +} +func (m *RoundsInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RoundsInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *RoundsInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_RoundsInfo.Merge(m, src) +} +func (m *RoundsInfo) XXX_Size() int { + return m.Size() +} +func (m *RoundsInfo) XXX_DiscardUnknown() { + xxx_messageInfo_RoundsInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_RoundsInfo proto.InternalMessageInfo + +func (m *RoundsInfo) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *RoundsInfo) GetRoundsInfo() []*RoundInfo { + if m != nil { + return m.RoundsInfo + } + return nil +} + +type PubKeys struct { + Keys [][]byte `protobuf:"bytes,1,rep,name=Keys,proto3" json:"keys,omitempty"` +} + +func (m *PubKeys) Reset() { *m = PubKeys{} } +func (*PubKeys) ProtoMessage() {} +func (*PubKeys) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{13} +} +func (m *PubKeys) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubKeys) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *PubKeys) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubKeys.Merge(m, src) +} +func (m *PubKeys) XXX_Size() int { + return m.Size() +} +func (m *PubKeys) XXX_DiscardUnknown() { + xxx_messageInfo_PubKeys.DiscardUnknown(m) +} + +var xxx_messageInfo_PubKeys proto.InternalMessageInfo + +func (m *PubKeys) GetKeys() [][]byte { + if m != nil { + return m.Keys + } + return nil +} + +type ValidatorsPubKeys struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + ShardValidatorsPubKeys map[uint32]*PubKeys `protobuf:"bytes,2,rep,name=ShardValidatorsPubKeys,proto3" json:"validatorsPubKeys,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + Epoch uint32 `protobuf:"varint,3,opt,name=Epoch,proto3" json:"epoch"` +} + +func (m *ValidatorsPubKeys) Reset() { *m = ValidatorsPubKeys{} } +func (*ValidatorsPubKeys) ProtoMessage() {} +func (*ValidatorsPubKeys) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{14} +} +func (m *ValidatorsPubKeys) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorsPubKeys) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *ValidatorsPubKeys) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorsPubKeys.Merge(m, src) +} +func (m *ValidatorsPubKeys) XXX_Size() int { + return m.Size() +} +func (m *ValidatorsPubKeys) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorsPubKeys.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorsPubKeys proto.InternalMessageInfo + +func (m *ValidatorsPubKeys) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *ValidatorsPubKeys) GetShardValidatorsPubKeys() map[uint32]*PubKeys { + if m != nil { + return m.ShardValidatorsPubKeys + } + return nil +} + +func (m *ValidatorsPubKeys) GetEpoch() uint32 { + if m != nil { + return m.Epoch + } + return 0 +} + +type Accounts struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + BlockTimestamp uint64 `protobuf:"varint,2,opt,name=BlockTimestamp,proto3" json:"blockTimestamp"` + AlteredAccounts map[string]*alteredAccount.AlteredAccount `protobuf:"bytes,3,rep,name=AlteredAccounts,proto3" json:"alteredAccounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (m *Accounts) Reset() { *m = Accounts{} } +func (*Accounts) ProtoMessage() {} +func (*Accounts) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{15} +} +func (m *Accounts) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Accounts) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *Accounts) XXX_Merge(src proto.Message) { + xxx_messageInfo_Accounts.Merge(m, src) +} +func (m *Accounts) XXX_Size() int { + return m.Size() +} +func (m *Accounts) XXX_DiscardUnknown() { + xxx_messageInfo_Accounts.DiscardUnknown(m) +} + +var xxx_messageInfo_Accounts proto.InternalMessageInfo + +func (m *Accounts) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *Accounts) GetBlockTimestamp() uint64 { + if m != nil { + return m.BlockTimestamp + } + return 0 +} + +func (m *Accounts) GetAlteredAccounts() map[string]*alteredAccount.AlteredAccount { + if m != nil { + return m.AlteredAccounts + } + return nil +} + +type FinalizedBlock struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` + HeaderHash []byte `protobuf:"bytes,2,opt,name=HeaderHash,proto3" json:"headerHash"` +} + +func (m *FinalizedBlock) Reset() { *m = FinalizedBlock{} } +func (*FinalizedBlock) ProtoMessage() {} +func (*FinalizedBlock) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{16} +} +func (m *FinalizedBlock) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FinalizedBlock) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *FinalizedBlock) XXX_Merge(src proto.Message) { + xxx_messageInfo_FinalizedBlock.Merge(m, src) +} +func (m *FinalizedBlock) XXX_Size() int { + return m.Size() +} +func (m *FinalizedBlock) XXX_DiscardUnknown() { + xxx_messageInfo_FinalizedBlock.DiscardUnknown(m) +} + +var xxx_messageInfo_FinalizedBlock proto.InternalMessageInfo + +func (m *FinalizedBlock) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func (m *FinalizedBlock) GetHeaderHash() []byte { + if m != nil { + return m.HeaderHash + } + return nil +} + +type Shard struct { + ShardID uint32 `protobuf:"varint,1,opt,name=ShardID,proto3" json:"shardID"` +} + +func (m *Shard) Reset() { *m = Shard{} } +func (*Shard) ProtoMessage() {} +func (*Shard) Descriptor() ([]byte, []int) { + return fileDescriptor_661b95cef868af95, []int{17} +} +func (m *Shard) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Shard) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil +} +func (m *Shard) XXX_Merge(src proto.Message) { + xxx_messageInfo_Shard.Merge(m, src) +} +func (m *Shard) XXX_Size() int { + return m.Size() +} +func (m *Shard) XXX_DiscardUnknown() { + xxx_messageInfo_Shard.DiscardUnknown(m) +} + +var xxx_messageInfo_Shard proto.InternalMessageInfo + +func (m *Shard) GetShardID() uint32 { + if m != nil { + return m.ShardID + } + return 0 +} + +func init() { + proto.RegisterType((*OutportBlock)(nil), "proto.OutportBlock") + proto.RegisterMapType((map[string]*alteredAccount.AlteredAccount)(nil), "proto.OutportBlock.AlteredAccountsEntry") + proto.RegisterType((*BlockData)(nil), "proto.BlockData") + proto.RegisterType((*TransactionPool)(nil), "proto.TransactionPool") + proto.RegisterMapType((map[string]*TxInfo)(nil), "proto.TransactionPool.InvalidTxsEntry") + proto.RegisterMapType((map[string]*receipt.Receipt)(nil), "proto.TransactionPool.ReceiptsEntry") + proto.RegisterMapType((map[string]*RewardInfo)(nil), "proto.TransactionPool.RewardsEntry") + proto.RegisterMapType((map[string]*SCRInfo)(nil), "proto.TransactionPool.SmartContractResultsEntry") + proto.RegisterMapType((map[string]*TxInfo)(nil), "proto.TransactionPool.TransactionsEntry") + proto.RegisterType((*FeeInfo)(nil), "proto.FeeInfo") + proto.RegisterType((*TxInfo)(nil), "proto.TxInfo") + proto.RegisterType((*SCRInfo)(nil), "proto.SCRInfo") + proto.RegisterType((*LogData)(nil), "proto.LogData") + proto.RegisterType((*RewardInfo)(nil), "proto.RewardInfo") + proto.RegisterType((*HeaderGasConsumption)(nil), "proto.HeaderGasConsumption") + proto.RegisterType((*ValidatorRatingInfo)(nil), "proto.ValidatorRatingInfo") + proto.RegisterType((*ValidatorsRating)(nil), "proto.ValidatorsRating") + proto.RegisterType((*RoundInfo)(nil), "proto.RoundInfo") + proto.RegisterType((*RoundsInfo)(nil), "proto.RoundsInfo") + proto.RegisterType((*PubKeys)(nil), "proto.PubKeys") + proto.RegisterType((*ValidatorsPubKeys)(nil), "proto.ValidatorsPubKeys") + proto.RegisterMapType((map[uint32]*PubKeys)(nil), "proto.ValidatorsPubKeys.ShardValidatorsPubKeysEntry") + proto.RegisterType((*Accounts)(nil), "proto.Accounts") + proto.RegisterMapType((map[string]*alteredAccount.AlteredAccount)(nil), "proto.Accounts.AlteredAccountsEntry") + proto.RegisterType((*FinalizedBlock)(nil), "proto.FinalizedBlock") + proto.RegisterType((*Shard)(nil), "proto.Shard") +} + +func init() { proto.RegisterFile("outportBlock.proto", fileDescriptor_661b95cef868af95) } + +var fileDescriptor_661b95cef868af95 = []byte{ + // 1931 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x59, 0x4b, 0x70, 0xe3, 0x48, + 0x19, 0x8e, 0xfc, 0x88, 0xe3, 0xdf, 0x89, 0x93, 0xe9, 0xcd, 0x04, 0x4d, 0x86, 0xb5, 0x82, 0x67, + 0x76, 0x49, 0x31, 0x8c, 0xcd, 0xce, 0x4e, 0x51, 0x53, 0x33, 0xb5, 0x05, 0xa3, 0xcc, 0xcb, 0xcc, + 0x23, 0x29, 0x25, 0xb0, 0xcc, 0x16, 0x55, 0x20, 0x5b, 0x1d, 0x59, 0x35, 0xb6, 0xda, 0x48, 0xed, + 0x60, 0x73, 0x81, 0x13, 0xcb, 0x81, 0xad, 0xe2, 0xc8, 0x8d, 0x2b, 0xc5, 0x81, 0x2b, 0x07, 0xee, + 0x14, 0x27, 0x6a, 0x4e, 0xd4, 0x9c, 0x04, 0x93, 0xb9, 0x50, 0x3a, 0x50, 0x7b, 0xe3, 0x4a, 0xa9, + 0xbb, 0x65, 0xb5, 0x64, 0x65, 0xcb, 0x59, 0xd8, 0xe2, 0x12, 0x4b, 0xff, 0xe3, 0xfb, 0xbb, 0xff, + 0x57, 0xff, 0xad, 0x00, 0x22, 0x63, 0x3a, 0x22, 0x1e, 0xd5, 0x07, 0xa4, 0xf7, 0xa2, 0x35, 0xf2, + 0x08, 0x25, 0xa8, 0xcc, 0x7e, 0xb6, 0xaf, 0xdb, 0x0e, 0xed, 0x8f, 0xbb, 0xad, 0x1e, 0x19, 0xb6, + 0x6d, 0x62, 0x93, 0x36, 0x23, 0x77, 0xc7, 0xc7, 0xec,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, 0x15, 0x53, 0xd7, 0xa9, 0x98, 0xfc, 0x3f, 0xf9, 0x1c, 0xf5, 0x45, 0x7e, 0xff, 0xb0, + 0xa1, 0xce, 0x3e, 0xb6, 0x44, 0xad, 0x9d, 0x5f, 0x53, 0x16, 0x74, 0x5f, 0x2b, 0xf5, 0x09, 0x82, + 0xcf, 0x9c, 0xf5, 0x30, 0xd0, 0x20, 0xf9, 0x04, 0x21, 0x7f, 0x78, 0x68, 0xb6, 0xa0, 0xcc, 0x54, + 0x17, 0xc4, 0xd7, 0xc7, 0x2f, 0x5f, 0x37, 0x96, 0x5e, 0xbd, 0x6e, 0x2c, 0x7d, 0xfa, 0xba, 0xa1, + 0xfc, 0xfc, 0xb4, 0xa1, 0xfc, 0xee, 0xb4, 0xa1, 0xfc, 0xe5, 0xb4, 0xa1, 0xbc, 0x3c, 0x6d, 0x28, + 0xaf, 0x4e, 0x1b, 0xca, 0x3f, 0x4e, 0x1b, 0xca, 0x3f, 0x4f, 0x1b, 0x4b, 0x9f, 0x9e, 0x36, 0x94, + 0x5f, 0xbf, 0x69, 0x2c, 0xbd, 0x7c, 0xd3, 0x58, 0x7a, 0xf5, 0xa6, 0xb1, 0xf4, 0xd1, 0x79, 0x46, + 0xca, 0xb6, 0xf8, 0x3f, 0xc0, 0x1d, 0xf1, 0xdb, 0x5d, 0x66, 0x0e, 0x7b, 0xff, 0x3f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xe1, 0x15, 0x1f, 0x1e, 0x21, 0x18, 0x00, 0x00, +} + +func (this *OutportBlock) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*OutportBlock) + if !ok { + that2, ok := that.(OutportBlock) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if !this.BlockData.Equal(that1.BlockData) { + return false + } + if !this.TransactionPool.Equal(that1.TransactionPool) { + return false + } + if !this.HeaderGasConsumption.Equal(that1.HeaderGasConsumption) { + return false + } + if len(this.AlteredAccounts) != len(that1.AlteredAccounts) { + return false + } + for i := range this.AlteredAccounts { + if !this.AlteredAccounts[i].Equal(that1.AlteredAccounts[i]) { + return false + } + } + if len(this.NotarizedHeadersHashes) != len(that1.NotarizedHeadersHashes) { + return false + } + for i := range this.NotarizedHeadersHashes { + if this.NotarizedHeadersHashes[i] != that1.NotarizedHeadersHashes[i] { + return false + } + } + if this.NumberOfShards != that1.NumberOfShards { + return false + } + if len(this.SignersIndexes) != len(that1.SignersIndexes) { + return false + } + for i := range this.SignersIndexes { + if this.SignersIndexes[i] != that1.SignersIndexes[i] { + return false + } + } + if this.HighestFinalBlockNonce != that1.HighestFinalBlockNonce { + return false + } + if !bytes.Equal(this.HighestFinalBlockHash, that1.HighestFinalBlockHash) { + return false + } + return true +} +func (this *BlockData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*BlockData) + if !ok { + that2, ok := that.(BlockData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if !bytes.Equal(this.HeaderBytes, that1.HeaderBytes) { + return false + } + if this.HeaderType != that1.HeaderType { + return false + } + if !bytes.Equal(this.HeaderHash, that1.HeaderHash) { + return false + } + if !this.Body.Equal(that1.Body) { + return false + } + if len(this.IntraShardMiniBlocks) != len(that1.IntraShardMiniBlocks) { + return false + } + for i := range this.IntraShardMiniBlocks { + if !this.IntraShardMiniBlocks[i].Equal(that1.IntraShardMiniBlocks[i]) { + return false + } + } + return true +} +func (this *TransactionPool) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*TransactionPool) + if !ok { + that2, ok := that.(TransactionPool) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Transactions) != len(that1.Transactions) { + return false + } + for i := range this.Transactions { + if !this.Transactions[i].Equal(that1.Transactions[i]) { + return false + } + } + if len(this.SmartContractResults) != len(that1.SmartContractResults) { + return false + } + for i := range this.SmartContractResults { + if !this.SmartContractResults[i].Equal(that1.SmartContractResults[i]) { + return false + } + } + if len(this.Rewards) != len(that1.Rewards) { + return false + } + for i := range this.Rewards { + if !this.Rewards[i].Equal(that1.Rewards[i]) { + return false + } + } + if len(this.Receipts) != len(that1.Receipts) { + return false + } + for i := range this.Receipts { + if !this.Receipts[i].Equal(that1.Receipts[i]) { + return false + } + } + if len(this.InvalidTxs) != len(that1.InvalidTxs) { + return false + } + for i := range this.InvalidTxs { + if !this.InvalidTxs[i].Equal(that1.InvalidTxs[i]) { + return false + } + } + if len(this.Logs) != len(that1.Logs) { + return false + } + for i := range this.Logs { + if !this.Logs[i].Equal(that1.Logs[i]) { + return false + } + } + if len(this.ScheduledExecutedSCRSHashesPrevBlock) != len(that1.ScheduledExecutedSCRSHashesPrevBlock) { + return false + } + for i := range this.ScheduledExecutedSCRSHashesPrevBlock { + if this.ScheduledExecutedSCRSHashesPrevBlock[i] != that1.ScheduledExecutedSCRSHashesPrevBlock[i] { + return false + } + } + if len(this.ScheduledExecutedInvalidTxsHashesPrevBlock) != len(that1.ScheduledExecutedInvalidTxsHashesPrevBlock) { + return false + } + for i := range this.ScheduledExecutedInvalidTxsHashesPrevBlock { + if this.ScheduledExecutedInvalidTxsHashesPrevBlock[i] != that1.ScheduledExecutedInvalidTxsHashesPrevBlock[i] { + return false + } + } + return true +} +func (this *FeeInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*FeeInfo) + if !ok { + that2, ok := that.(FeeInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.GasUsed != that1.GasUsed { + return false + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + if !__caster.Equal(this.Fee, that1.Fee) { + return false + } + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + if !__caster.Equal(this.InitialPaidFee, that1.InitialPaidFee) { + return false + } + } + return true +} +func (this *TxInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*TxInfo) + if !ok { + that2, ok := that.(TxInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Transaction.Equal(that1.Transaction) { + return false + } + if !this.FeeInfo.Equal(that1.FeeInfo) { + return false + } + if this.ExecutionOrder != that1.ExecutionOrder { + return false + } + return true +} +func (this *SCRInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*SCRInfo) + if !ok { + that2, ok := that.(SCRInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.SmartContractResult.Equal(that1.SmartContractResult) { + return false + } + if !this.FeeInfo.Equal(that1.FeeInfo) { + return false + } + if this.ExecutionOrder != that1.ExecutionOrder { + return false + } + return true +} +func (this *LogData) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*LogData) + if !ok { + that2, ok := that.(LogData) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.TxHash != that1.TxHash { + return false + } + if !this.Log.Equal(that1.Log) { + return false + } + return true +} +func (this *RewardInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RewardInfo) + if !ok { + that2, ok := that.(RewardInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Reward.Equal(that1.Reward) { + return false + } + if this.ExecutionOrder != that1.ExecutionOrder { + return false + } + return true +} +func (this *HeaderGasConsumption) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*HeaderGasConsumption) + if !ok { + that2, ok := that.(HeaderGasConsumption) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.GasProvided != that1.GasProvided { + return false + } + if this.GasRefunded != that1.GasRefunded { + return false + } + if this.GasPenalized != that1.GasPenalized { + return false + } + if this.MaxGasPerBlock != that1.MaxGasPerBlock { + return false + } + return true +} +func (this *ValidatorRatingInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorRatingInfo) + if !ok { + that2, ok := that.(ValidatorRatingInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.PublicKey != that1.PublicKey { + return false + } + if this.Rating != that1.Rating { + return false + } + return true +} +func (this *ValidatorsRating) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorsRating) + if !ok { + that2, ok := that.(ValidatorsRating) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if this.Epoch != that1.Epoch { + return false + } + if len(this.ValidatorsRatingInfo) != len(that1.ValidatorsRatingInfo) { + return false + } + for i := range this.ValidatorsRatingInfo { + if !this.ValidatorsRatingInfo[i].Equal(that1.ValidatorsRatingInfo[i]) { + return false + } + } + return true +} +func (this *RoundInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RoundInfo) + if !ok { + that2, ok := that.(RoundInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Round != that1.Round { + return false + } + if len(this.SignersIndexes) != len(that1.SignersIndexes) { + return false + } + for i := range this.SignersIndexes { + if this.SignersIndexes[i] != that1.SignersIndexes[i] { + return false + } + } + if this.BlockWasProposed != that1.BlockWasProposed { + return false + } + if this.ShardId != that1.ShardId { + return false + } + if this.Epoch != that1.Epoch { + return false + } + if this.Timestamp != that1.Timestamp { + return false + } + return true +} +func (this *RoundsInfo) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RoundsInfo) + if !ok { + that2, ok := that.(RoundsInfo) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if len(this.RoundsInfo) != len(that1.RoundsInfo) { + return false + } + for i := range this.RoundsInfo { + if !this.RoundsInfo[i].Equal(that1.RoundsInfo[i]) { + return false + } + } + return true +} +func (this *PubKeys) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PubKeys) + if !ok { + that2, ok := that.(PubKeys) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if len(this.Keys) != len(that1.Keys) { + return false + } + for i := range this.Keys { + if !bytes.Equal(this.Keys[i], that1.Keys[i]) { + return false + } + } + return true +} +func (this *ValidatorsPubKeys) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorsPubKeys) + if !ok { + that2, ok := that.(ValidatorsPubKeys) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if len(this.ShardValidatorsPubKeys) != len(that1.ShardValidatorsPubKeys) { + return false + } + for i := range this.ShardValidatorsPubKeys { + if !this.ShardValidatorsPubKeys[i].Equal(that1.ShardValidatorsPubKeys[i]) { + return false + } + } + if this.Epoch != that1.Epoch { + return false + } + return true +} +func (this *Accounts) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Accounts) + if !ok { + that2, ok := that.(Accounts) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if this.BlockTimestamp != that1.BlockTimestamp { + return false + } + if len(this.AlteredAccounts) != len(that1.AlteredAccounts) { + return false + } + for i := range this.AlteredAccounts { + if !this.AlteredAccounts[i].Equal(that1.AlteredAccounts[i]) { + return false + } + } + return true +} +func (this *FinalizedBlock) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*FinalizedBlock) + if !ok { + that2, ok := that.(FinalizedBlock) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + if !bytes.Equal(this.HeaderHash, that1.HeaderHash) { + return false + } + return true +} +func (this *Shard) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Shard) + if !ok { + that2, ok := that.(Shard) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ShardID != that1.ShardID { + return false + } + return true +} +func (this *OutportBlock) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 14) + s = append(s, "&outport.OutportBlock{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + if this.BlockData != nil { + s = append(s, "BlockData: "+fmt.Sprintf("%#v", this.BlockData)+",\n") + } + if this.TransactionPool != nil { + s = append(s, "TransactionPool: "+fmt.Sprintf("%#v", this.TransactionPool)+",\n") + } + if this.HeaderGasConsumption != nil { + s = append(s, "HeaderGasConsumption: "+fmt.Sprintf("%#v", this.HeaderGasConsumption)+",\n") + } + keysForAlteredAccounts := make([]string, 0, len(this.AlteredAccounts)) + for k, _ := range this.AlteredAccounts { + keysForAlteredAccounts = append(keysForAlteredAccounts, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForAlteredAccounts) + mapStringForAlteredAccounts := "map[string]*alteredAccount.AlteredAccount{" + for _, k := range keysForAlteredAccounts { + mapStringForAlteredAccounts += fmt.Sprintf("%#v: %#v,", k, this.AlteredAccounts[k]) + } + mapStringForAlteredAccounts += "}" + if this.AlteredAccounts != nil { + s = append(s, "AlteredAccounts: "+mapStringForAlteredAccounts+",\n") + } + s = append(s, "NotarizedHeadersHashes: "+fmt.Sprintf("%#v", this.NotarizedHeadersHashes)+",\n") + s = append(s, "NumberOfShards: "+fmt.Sprintf("%#v", this.NumberOfShards)+",\n") + s = append(s, "SignersIndexes: "+fmt.Sprintf("%#v", this.SignersIndexes)+",\n") + s = append(s, "HighestFinalBlockNonce: "+fmt.Sprintf("%#v", this.HighestFinalBlockNonce)+",\n") + s = append(s, "HighestFinalBlockHash: "+fmt.Sprintf("%#v", this.HighestFinalBlockHash)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *BlockData) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 10) + s = append(s, "&outport.BlockData{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + s = append(s, "HeaderBytes: "+fmt.Sprintf("%#v", this.HeaderBytes)+",\n") + s = append(s, "HeaderType: "+fmt.Sprintf("%#v", this.HeaderType)+",\n") + s = append(s, "HeaderHash: "+fmt.Sprintf("%#v", this.HeaderHash)+",\n") + if this.Body != nil { + s = append(s, "Body: "+fmt.Sprintf("%#v", this.Body)+",\n") + } + if this.IntraShardMiniBlocks != nil { + s = append(s, "IntraShardMiniBlocks: "+fmt.Sprintf("%#v", this.IntraShardMiniBlocks)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *TransactionPool) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 12) + s = append(s, "&outport.TransactionPool{") + keysForTransactions := make([]string, 0, len(this.Transactions)) + for k, _ := range this.Transactions { + keysForTransactions = append(keysForTransactions, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForTransactions) + mapStringForTransactions := "map[string]*TxInfo{" + for _, k := range keysForTransactions { + mapStringForTransactions += fmt.Sprintf("%#v: %#v,", k, this.Transactions[k]) + } + mapStringForTransactions += "}" + if this.Transactions != nil { + s = append(s, "Transactions: "+mapStringForTransactions+",\n") + } + keysForSmartContractResults := make([]string, 0, len(this.SmartContractResults)) + for k, _ := range this.SmartContractResults { + keysForSmartContractResults = append(keysForSmartContractResults, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForSmartContractResults) + mapStringForSmartContractResults := "map[string]*SCRInfo{" + for _, k := range keysForSmartContractResults { + mapStringForSmartContractResults += fmt.Sprintf("%#v: %#v,", k, this.SmartContractResults[k]) + } + mapStringForSmartContractResults += "}" + if this.SmartContractResults != nil { + s = append(s, "SmartContractResults: "+mapStringForSmartContractResults+",\n") + } + keysForRewards := make([]string, 0, len(this.Rewards)) + for k, _ := range this.Rewards { + keysForRewards = append(keysForRewards, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForRewards) + mapStringForRewards := "map[string]*RewardInfo{" + for _, k := range keysForRewards { + mapStringForRewards += fmt.Sprintf("%#v: %#v,", k, this.Rewards[k]) + } + mapStringForRewards += "}" + if this.Rewards != nil { + s = append(s, "Rewards: "+mapStringForRewards+",\n") + } + keysForReceipts := make([]string, 0, len(this.Receipts)) + for k, _ := range this.Receipts { + keysForReceipts = append(keysForReceipts, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForReceipts) + mapStringForReceipts := "map[string]*receipt.Receipt{" + for _, k := range keysForReceipts { + mapStringForReceipts += fmt.Sprintf("%#v: %#v,", k, this.Receipts[k]) + } + mapStringForReceipts += "}" + if this.Receipts != nil { + s = append(s, "Receipts: "+mapStringForReceipts+",\n") + } + keysForInvalidTxs := make([]string, 0, len(this.InvalidTxs)) + for k, _ := range this.InvalidTxs { + keysForInvalidTxs = append(keysForInvalidTxs, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForInvalidTxs) + mapStringForInvalidTxs := "map[string]*TxInfo{" + for _, k := range keysForInvalidTxs { + mapStringForInvalidTxs += fmt.Sprintf("%#v: %#v,", k, this.InvalidTxs[k]) + } + mapStringForInvalidTxs += "}" + if this.InvalidTxs != nil { + s = append(s, "InvalidTxs: "+mapStringForInvalidTxs+",\n") + } + if this.Logs != nil { + s = append(s, "Logs: "+fmt.Sprintf("%#v", this.Logs)+",\n") + } + s = append(s, "ScheduledExecutedSCRSHashesPrevBlock: "+fmt.Sprintf("%#v", this.ScheduledExecutedSCRSHashesPrevBlock)+",\n") + s = append(s, "ScheduledExecutedInvalidTxsHashesPrevBlock: "+fmt.Sprintf("%#v", this.ScheduledExecutedInvalidTxsHashesPrevBlock)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *FeeInfo) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&outport.FeeInfo{") + s = append(s, "GasUsed: "+fmt.Sprintf("%#v", this.GasUsed)+",\n") + s = append(s, "Fee: "+fmt.Sprintf("%#v", this.Fee)+",\n") + s = append(s, "InitialPaidFee: "+fmt.Sprintf("%#v", this.InitialPaidFee)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *TxInfo) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&outport.TxInfo{") + if this.Transaction != nil { + s = append(s, "Transaction: "+fmt.Sprintf("%#v", this.Transaction)+",\n") + } + if this.FeeInfo != nil { + s = append(s, "FeeInfo: "+fmt.Sprintf("%#v", this.FeeInfo)+",\n") + } + s = append(s, "ExecutionOrder: "+fmt.Sprintf("%#v", this.ExecutionOrder)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *SCRInfo) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&outport.SCRInfo{") + if this.SmartContractResult != nil { + s = append(s, "SmartContractResult: "+fmt.Sprintf("%#v", this.SmartContractResult)+",\n") + } + if this.FeeInfo != nil { + s = append(s, "FeeInfo: "+fmt.Sprintf("%#v", this.FeeInfo)+",\n") + } + s = append(s, "ExecutionOrder: "+fmt.Sprintf("%#v", this.ExecutionOrder)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *LogData) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&outport.LogData{") + s = append(s, "TxHash: "+fmt.Sprintf("%#v", this.TxHash)+",\n") + if this.Log != nil { + s = append(s, "Log: "+fmt.Sprintf("%#v", this.Log)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *RewardInfo) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&outport.RewardInfo{") + if this.Reward != nil { + s = append(s, "Reward: "+fmt.Sprintf("%#v", this.Reward)+",\n") + } + s = append(s, "ExecutionOrder: "+fmt.Sprintf("%#v", this.ExecutionOrder)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *HeaderGasConsumption) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 8) + s = append(s, "&outport.HeaderGasConsumption{") + s = append(s, "GasProvided: "+fmt.Sprintf("%#v", this.GasProvided)+",\n") + s = append(s, "GasRefunded: "+fmt.Sprintf("%#v", this.GasRefunded)+",\n") + s = append(s, "GasPenalized: "+fmt.Sprintf("%#v", this.GasPenalized)+",\n") + s = append(s, "MaxGasPerBlock: "+fmt.Sprintf("%#v", this.MaxGasPerBlock)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *ValidatorRatingInfo) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&outport.ValidatorRatingInfo{") + s = append(s, "PublicKey: "+fmt.Sprintf("%#v", this.PublicKey)+",\n") + s = append(s, "Rating: "+fmt.Sprintf("%#v", this.Rating)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *ValidatorsRating) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&outport.ValidatorsRating{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + s = append(s, "Epoch: "+fmt.Sprintf("%#v", this.Epoch)+",\n") + if this.ValidatorsRatingInfo != nil { + s = append(s, "ValidatorsRatingInfo: "+fmt.Sprintf("%#v", this.ValidatorsRatingInfo)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *RoundInfo) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 10) + s = append(s, "&outport.RoundInfo{") + s = append(s, "Round: "+fmt.Sprintf("%#v", this.Round)+",\n") + s = append(s, "SignersIndexes: "+fmt.Sprintf("%#v", this.SignersIndexes)+",\n") + s = append(s, "BlockWasProposed: "+fmt.Sprintf("%#v", this.BlockWasProposed)+",\n") + s = append(s, "ShardId: "+fmt.Sprintf("%#v", this.ShardId)+",\n") + s = append(s, "Epoch: "+fmt.Sprintf("%#v", this.Epoch)+",\n") + s = append(s, "Timestamp: "+fmt.Sprintf("%#v", this.Timestamp)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *RoundsInfo) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&outport.RoundsInfo{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + if this.RoundsInfo != nil { + s = append(s, "RoundsInfo: "+fmt.Sprintf("%#v", this.RoundsInfo)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *PubKeys) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&outport.PubKeys{") + s = append(s, "Keys: "+fmt.Sprintf("%#v", this.Keys)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *ValidatorsPubKeys) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&outport.ValidatorsPubKeys{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + keysForShardValidatorsPubKeys := make([]uint32, 0, len(this.ShardValidatorsPubKeys)) + for k, _ := range this.ShardValidatorsPubKeys { + keysForShardValidatorsPubKeys = append(keysForShardValidatorsPubKeys, k) + } + github_com_gogo_protobuf_sortkeys.Uint32s(keysForShardValidatorsPubKeys) + mapStringForShardValidatorsPubKeys := "map[uint32]*PubKeys{" + for _, k := range keysForShardValidatorsPubKeys { + mapStringForShardValidatorsPubKeys += fmt.Sprintf("%#v: %#v,", k, this.ShardValidatorsPubKeys[k]) + } + mapStringForShardValidatorsPubKeys += "}" + if this.ShardValidatorsPubKeys != nil { + s = append(s, "ShardValidatorsPubKeys: "+mapStringForShardValidatorsPubKeys+",\n") + } + s = append(s, "Epoch: "+fmt.Sprintf("%#v", this.Epoch)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Accounts) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 7) + s = append(s, "&outport.Accounts{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + s = append(s, "BlockTimestamp: "+fmt.Sprintf("%#v", this.BlockTimestamp)+",\n") + keysForAlteredAccounts := make([]string, 0, len(this.AlteredAccounts)) + for k, _ := range this.AlteredAccounts { + keysForAlteredAccounts = append(keysForAlteredAccounts, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForAlteredAccounts) + mapStringForAlteredAccounts := "map[string]*alteredAccount.AlteredAccount{" + for _, k := range keysForAlteredAccounts { + mapStringForAlteredAccounts += fmt.Sprintf("%#v: %#v,", k, this.AlteredAccounts[k]) + } + mapStringForAlteredAccounts += "}" + if this.AlteredAccounts != nil { + s = append(s, "AlteredAccounts: "+mapStringForAlteredAccounts+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *FinalizedBlock) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&outport.FinalizedBlock{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + s = append(s, "HeaderHash: "+fmt.Sprintf("%#v", this.HeaderHash)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Shard) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 5) + s = append(s, "&outport.Shard{") + s = append(s, "ShardID: "+fmt.Sprintf("%#v", this.ShardID)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} +func valueToGoStringOutportBlock(v interface{}, typ string) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("func(v %v) *%v { return &v } ( %#v )", typ, typ, pv) +} +func (m *OutportBlock) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *OutportBlock) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *OutportBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.HighestFinalBlockHash) > 0 { + i -= len(m.HighestFinalBlockHash) + copy(dAtA[i:], m.HighestFinalBlockHash) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.HighestFinalBlockHash))) + i-- + dAtA[i] = 0x52 + } + if m.HighestFinalBlockNonce != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.HighestFinalBlockNonce)) + i-- + dAtA[i] = 0x48 + } + if len(m.SignersIndexes) > 0 { + dAtA2 := make([]byte, len(m.SignersIndexes)*10) + var j1 int + for _, num := range m.SignersIndexes { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintOutportBlock(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x42 + } + if m.NumberOfShards != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.NumberOfShards)) + i-- + dAtA[i] = 0x38 + } + if len(m.NotarizedHeadersHashes) > 0 { + for iNdEx := len(m.NotarizedHeadersHashes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.NotarizedHeadersHashes[iNdEx]) + copy(dAtA[i:], m.NotarizedHeadersHashes[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.NotarizedHeadersHashes[iNdEx]))) + i-- + dAtA[i] = 0x32 + } + } + if len(m.AlteredAccounts) > 0 { + keysForAlteredAccounts := make([]string, 0, len(m.AlteredAccounts)) + for k := range m.AlteredAccounts { + keysForAlteredAccounts = append(keysForAlteredAccounts, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForAlteredAccounts) + for iNdEx := len(keysForAlteredAccounts) - 1; iNdEx >= 0; iNdEx-- { + v := m.AlteredAccounts[string(keysForAlteredAccounts[iNdEx])] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(keysForAlteredAccounts[iNdEx]) + copy(dAtA[i:], keysForAlteredAccounts[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(keysForAlteredAccounts[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintOutportBlock(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x2a + } + } + if m.HeaderGasConsumption != nil { + { + size, err := m.HeaderGasConsumption.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.TransactionPool != nil { + { + size, err := m.TransactionPool.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.BlockData != nil { + { + size, err := m.BlockData.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.ShardID != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BlockData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BlockData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BlockData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IntraShardMiniBlocks) > 0 { + for iNdEx := len(m.IntraShardMiniBlocks) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IntraShardMiniBlocks[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if m.Body != nil { + { + size, err := m.Body.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + if len(m.HeaderHash) > 0 { + i -= len(m.HeaderHash) + copy(dAtA[i:], m.HeaderHash) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.HeaderHash))) + i-- + dAtA[i] = 0x22 + } + if len(m.HeaderType) > 0 { + i -= len(m.HeaderType) + copy(dAtA[i:], m.HeaderType) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.HeaderType))) + i-- + dAtA[i] = 0x1a + } + if len(m.HeaderBytes) > 0 { + i -= len(m.HeaderBytes) + copy(dAtA[i:], m.HeaderBytes) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.HeaderBytes))) + i-- + dAtA[i] = 0x12 + } + if m.ShardID != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TransactionPool) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TransactionPool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TransactionPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ScheduledExecutedInvalidTxsHashesPrevBlock) > 0 { + for iNdEx := len(m.ScheduledExecutedInvalidTxsHashesPrevBlock) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ScheduledExecutedInvalidTxsHashesPrevBlock[iNdEx]) + copy(dAtA[i:], m.ScheduledExecutedInvalidTxsHashesPrevBlock[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.ScheduledExecutedInvalidTxsHashesPrevBlock[iNdEx]))) + i-- + dAtA[i] = 0x42 + } + } + if len(m.ScheduledExecutedSCRSHashesPrevBlock) > 0 { + for iNdEx := len(m.ScheduledExecutedSCRSHashesPrevBlock) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ScheduledExecutedSCRSHashesPrevBlock[iNdEx]) + copy(dAtA[i:], m.ScheduledExecutedSCRSHashesPrevBlock[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.ScheduledExecutedSCRSHashesPrevBlock[iNdEx]))) + i-- + dAtA[i] = 0x3a + } + } + if len(m.Logs) > 0 { + for iNdEx := len(m.Logs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Logs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.InvalidTxs) > 0 { + keysForInvalidTxs := make([]string, 0, len(m.InvalidTxs)) + for k := range m.InvalidTxs { + keysForInvalidTxs = append(keysForInvalidTxs, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForInvalidTxs) + for iNdEx := len(keysForInvalidTxs) - 1; iNdEx >= 0; iNdEx-- { + v := m.InvalidTxs[string(keysForInvalidTxs[iNdEx])] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(keysForInvalidTxs[iNdEx]) + copy(dAtA[i:], keysForInvalidTxs[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(keysForInvalidTxs[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintOutportBlock(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x2a + } + } + if len(m.Receipts) > 0 { + keysForReceipts := make([]string, 0, len(m.Receipts)) + for k := range m.Receipts { + keysForReceipts = append(keysForReceipts, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForReceipts) + for iNdEx := len(keysForReceipts) - 1; iNdEx >= 0; iNdEx-- { + v := m.Receipts[string(keysForReceipts[iNdEx])] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(keysForReceipts[iNdEx]) + copy(dAtA[i:], keysForReceipts[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(keysForReceipts[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintOutportBlock(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x22 + } + } + if len(m.Rewards) > 0 { + keysForRewards := make([]string, 0, len(m.Rewards)) + for k := range m.Rewards { + keysForRewards = append(keysForRewards, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForRewards) + for iNdEx := len(keysForRewards) - 1; iNdEx >= 0; iNdEx-- { + v := m.Rewards[string(keysForRewards[iNdEx])] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(keysForRewards[iNdEx]) + copy(dAtA[i:], keysForRewards[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(keysForRewards[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintOutportBlock(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if len(m.SmartContractResults) > 0 { + keysForSmartContractResults := make([]string, 0, len(m.SmartContractResults)) + for k := range m.SmartContractResults { + keysForSmartContractResults = append(keysForSmartContractResults, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForSmartContractResults) + for iNdEx := len(keysForSmartContractResults) - 1; iNdEx >= 0; iNdEx-- { + v := m.SmartContractResults[string(keysForSmartContractResults[iNdEx])] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(keysForSmartContractResults[iNdEx]) + copy(dAtA[i:], keysForSmartContractResults[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(keysForSmartContractResults[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintOutportBlock(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Transactions) > 0 { + keysForTransactions := make([]string, 0, len(m.Transactions)) + for k := range m.Transactions { + keysForTransactions = append(keysForTransactions, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForTransactions) + for iNdEx := len(keysForTransactions) - 1; iNdEx >= 0; iNdEx-- { + v := m.Transactions[string(keysForTransactions[iNdEx])] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(keysForTransactions[iNdEx]) + copy(dAtA[i:], keysForTransactions[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(keysForTransactions[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintOutportBlock(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *FeeInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FeeInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeeInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + size := __caster.Size(m.InitialPaidFee) + i -= size + if _, err := __caster.MarshalTo(m.InitialPaidFee, dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + size := __caster.Size(m.Fee) + i -= size + if _, err := __caster.MarshalTo(m.Fee, dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.GasUsed != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.GasUsed)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *TxInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TxInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecutionOrder != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ExecutionOrder)) + i-- + dAtA[i] = 0x18 + } + if m.FeeInfo != nil { + { + size, err := m.FeeInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Transaction != nil { + { + size, err := m.Transaction.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SCRInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SCRInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SCRInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecutionOrder != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ExecutionOrder)) + i-- + dAtA[i] = 0x18 + } + if m.FeeInfo != nil { + { + size, err := m.FeeInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.SmartContractResult != nil { + { + size, err := m.SmartContractResult.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *LogData) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LogData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LogData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Log != nil { + { + size, err := m.Log.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.TxHash) > 0 { + i -= len(m.TxHash) + copy(dAtA[i:], m.TxHash) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.TxHash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RewardInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RewardInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RewardInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExecutionOrder != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ExecutionOrder)) + i-- + dAtA[i] = 0x10 + } + if m.Reward != nil { + { + size, err := m.Reward.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *HeaderGasConsumption) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HeaderGasConsumption) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HeaderGasConsumption) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MaxGasPerBlock != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.MaxGasPerBlock)) + i-- + dAtA[i] = 0x20 + } + if m.GasPenalized != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.GasPenalized)) + i-- + dAtA[i] = 0x18 + } + if m.GasRefunded != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.GasRefunded)) + i-- + dAtA[i] = 0x10 + } + if m.GasProvided != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.GasProvided)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ValidatorRatingInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ValidatorRatingInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorRatingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Rating != 0 { + i -= 4 + encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(m.Rating)))) + i-- + dAtA[i] = 0x15 + } + if len(m.PublicKey) > 0 { + i -= len(m.PublicKey) + copy(dAtA[i:], m.PublicKey) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.PublicKey))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ValidatorsRating) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ValidatorsRating) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorsRating) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorsRatingInfo) > 0 { + for iNdEx := len(m.ValidatorsRatingInfo) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValidatorsRatingInfo[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Epoch != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.Epoch)) + i-- + dAtA[i] = 0x10 + } + if m.ShardID != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RoundInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RoundInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RoundInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x30 + } + if m.Epoch != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.Epoch)) + i-- + dAtA[i] = 0x28 + } + if m.ShardId != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardId)) + i-- + dAtA[i] = 0x20 + } + if m.BlockWasProposed { + i-- + if m.BlockWasProposed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.SignersIndexes) > 0 { + dAtA20 := make([]byte, len(m.SignersIndexes)*10) + var j19 int + for _, num := range m.SignersIndexes { + for num >= 1<<7 { + dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j19++ + } + dAtA20[j19] = uint8(num) + j19++ + } + i -= j19 + copy(dAtA[i:], dAtA20[:j19]) + i = encodeVarintOutportBlock(dAtA, i, uint64(j19)) + i-- + dAtA[i] = 0x12 + } + if m.Round != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.Round)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RoundsInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RoundsInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RoundsInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RoundsInfo) > 0 { + for iNdEx := len(m.RoundsInfo) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RoundsInfo[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.ShardID != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PubKeys) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PubKeys) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubKeys) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Keys) > 0 { + for iNdEx := len(m.Keys) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Keys[iNdEx]) + copy(dAtA[i:], m.Keys[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.Keys[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ValidatorsPubKeys) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ValidatorsPubKeys) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorsPubKeys) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Epoch != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.Epoch)) + i-- + dAtA[i] = 0x18 + } + if len(m.ShardValidatorsPubKeys) > 0 { + keysForShardValidatorsPubKeys := make([]uint32, 0, len(m.ShardValidatorsPubKeys)) + for k := range m.ShardValidatorsPubKeys { + keysForShardValidatorsPubKeys = append(keysForShardValidatorsPubKeys, uint32(k)) + } + github_com_gogo_protobuf_sortkeys.Uint32s(keysForShardValidatorsPubKeys) + for iNdEx := len(keysForShardValidatorsPubKeys) - 1; iNdEx >= 0; iNdEx-- { + v := m.ShardValidatorsPubKeys[uint32(keysForShardValidatorsPubKeys[iNdEx])] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i = encodeVarintOutportBlock(dAtA, i, uint64(keysForShardValidatorsPubKeys[iNdEx])) + i-- + dAtA[i] = 0x8 + i = encodeVarintOutportBlock(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if m.ShardID != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Accounts) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Accounts) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Accounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AlteredAccounts) > 0 { + keysForAlteredAccounts := make([]string, 0, len(m.AlteredAccounts)) + for k := range m.AlteredAccounts { + keysForAlteredAccounts = append(keysForAlteredAccounts, string(k)) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForAlteredAccounts) + for iNdEx := len(keysForAlteredAccounts) - 1; iNdEx >= 0; iNdEx-- { + v := m.AlteredAccounts[string(keysForAlteredAccounts[iNdEx])] + baseI := i + if v != nil { + { + size, err := v.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOutportBlock(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + i -= len(keysForAlteredAccounts[iNdEx]) + copy(dAtA[i:], keysForAlteredAccounts[iNdEx]) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(keysForAlteredAccounts[iNdEx]))) + i-- + dAtA[i] = 0xa + i = encodeVarintOutportBlock(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x1a + } + } + if m.BlockTimestamp != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.BlockTimestamp)) + i-- + dAtA[i] = 0x10 + } + if m.ShardID != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *FinalizedBlock) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FinalizedBlock) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FinalizedBlock) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.HeaderHash) > 0 { + i -= len(m.HeaderHash) + copy(dAtA[i:], m.HeaderHash) + i = encodeVarintOutportBlock(dAtA, i, uint64(len(m.HeaderHash))) + i-- + dAtA[i] = 0x12 + } + if m.ShardID != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Shard) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Shard) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Shard) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ShardID != 0 { + i = encodeVarintOutportBlock(dAtA, i, uint64(m.ShardID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintOutportBlock(dAtA []byte, offset int, v uint64) int { + offset -= sovOutportBlock(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *OutportBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardID)) + } + if m.BlockData != nil { + l = m.BlockData.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.TransactionPool != nil { + l = m.TransactionPool.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.HeaderGasConsumption != nil { + l = m.HeaderGasConsumption.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if len(m.AlteredAccounts) > 0 { + for k, v := range m.AlteredAccounts { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOutportBlock(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovOutportBlock(uint64(len(k))) + l + n += mapEntrySize + 1 + sovOutportBlock(uint64(mapEntrySize)) + } + } + if len(m.NotarizedHeadersHashes) > 0 { + for _, s := range m.NotarizedHeadersHashes { + l = len(s) + n += 1 + l + sovOutportBlock(uint64(l)) + } + } + if m.NumberOfShards != 0 { + n += 1 + sovOutportBlock(uint64(m.NumberOfShards)) + } + if len(m.SignersIndexes) > 0 { + l = 0 + for _, e := range m.SignersIndexes { + l += sovOutportBlock(uint64(e)) + } + n += 1 + sovOutportBlock(uint64(l)) + l + } + if m.HighestFinalBlockNonce != 0 { + n += 1 + sovOutportBlock(uint64(m.HighestFinalBlockNonce)) + } + l = len(m.HighestFinalBlockHash) + if l > 0 { + n += 1 + l + sovOutportBlock(uint64(l)) + } + return n +} + +func (m *BlockData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardID)) + } + l = len(m.HeaderBytes) + if l > 0 { + n += 1 + l + sovOutportBlock(uint64(l)) + } + l = len(m.HeaderType) + if l > 0 { + n += 1 + l + sovOutportBlock(uint64(l)) + } + l = len(m.HeaderHash) + if l > 0 { + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.Body != nil { + l = m.Body.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if len(m.IntraShardMiniBlocks) > 0 { + for _, e := range m.IntraShardMiniBlocks { + l = e.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + } + return n +} + +func (m *TransactionPool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Transactions) > 0 { + for k, v := range m.Transactions { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOutportBlock(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovOutportBlock(uint64(len(k))) + l + n += mapEntrySize + 1 + sovOutportBlock(uint64(mapEntrySize)) + } + } + if len(m.SmartContractResults) > 0 { + for k, v := range m.SmartContractResults { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOutportBlock(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovOutportBlock(uint64(len(k))) + l + n += mapEntrySize + 1 + sovOutportBlock(uint64(mapEntrySize)) + } + } + if len(m.Rewards) > 0 { + for k, v := range m.Rewards { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOutportBlock(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovOutportBlock(uint64(len(k))) + l + n += mapEntrySize + 1 + sovOutportBlock(uint64(mapEntrySize)) + } + } + if len(m.Receipts) > 0 { + for k, v := range m.Receipts { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOutportBlock(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovOutportBlock(uint64(len(k))) + l + n += mapEntrySize + 1 + sovOutportBlock(uint64(mapEntrySize)) + } + } + if len(m.InvalidTxs) > 0 { + for k, v := range m.InvalidTxs { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOutportBlock(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovOutportBlock(uint64(len(k))) + l + n += mapEntrySize + 1 + sovOutportBlock(uint64(mapEntrySize)) + } + } + if len(m.Logs) > 0 { + for _, e := range m.Logs { + l = e.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + } + if len(m.ScheduledExecutedSCRSHashesPrevBlock) > 0 { + for _, s := range m.ScheduledExecutedSCRSHashesPrevBlock { + l = len(s) + n += 1 + l + sovOutportBlock(uint64(l)) + } + } + if len(m.ScheduledExecutedInvalidTxsHashesPrevBlock) > 0 { + for _, s := range m.ScheduledExecutedInvalidTxsHashesPrevBlock { + l = len(s) + n += 1 + l + sovOutportBlock(uint64(l)) + } + } + return n +} + +func (m *FeeInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GasUsed != 0 { + n += 1 + sovOutportBlock(uint64(m.GasUsed)) + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + l = __caster.Size(m.Fee) + n += 1 + l + sovOutportBlock(uint64(l)) + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + l = __caster.Size(m.InitialPaidFee) + n += 1 + l + sovOutportBlock(uint64(l)) + } + return n +} + +func (m *TxInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Transaction != nil { + l = m.Transaction.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.FeeInfo != nil { + l = m.FeeInfo.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.ExecutionOrder != 0 { + n += 1 + sovOutportBlock(uint64(m.ExecutionOrder)) + } + return n +} + +func (m *SCRInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SmartContractResult != nil { + l = m.SmartContractResult.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.FeeInfo != nil { + l = m.FeeInfo.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.ExecutionOrder != 0 { + n += 1 + sovOutportBlock(uint64(m.ExecutionOrder)) + } + return n +} + +func (m *LogData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.TxHash) + if l > 0 { + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.Log != nil { + l = m.Log.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + return n +} + +func (m *RewardInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Reward != nil { + l = m.Reward.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.ExecutionOrder != 0 { + n += 1 + sovOutportBlock(uint64(m.ExecutionOrder)) + } + return n +} + +func (m *HeaderGasConsumption) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.GasProvided != 0 { + n += 1 + sovOutportBlock(uint64(m.GasProvided)) + } + if m.GasRefunded != 0 { + n += 1 + sovOutportBlock(uint64(m.GasRefunded)) + } + if m.GasPenalized != 0 { + n += 1 + sovOutportBlock(uint64(m.GasPenalized)) + } + if m.MaxGasPerBlock != 0 { + n += 1 + sovOutportBlock(uint64(m.MaxGasPerBlock)) + } + return n +} + +func (m *ValidatorRatingInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PublicKey) + if l > 0 { + n += 1 + l + sovOutportBlock(uint64(l)) + } + if m.Rating != 0 { + n += 5 + } + return n +} + +func (m *ValidatorsRating) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardID)) + } + if m.Epoch != 0 { + n += 1 + sovOutportBlock(uint64(m.Epoch)) + } + if len(m.ValidatorsRatingInfo) > 0 { + for _, e := range m.ValidatorsRatingInfo { + l = e.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + } + return n +} + +func (m *RoundInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Round != 0 { + n += 1 + sovOutportBlock(uint64(m.Round)) + } + if len(m.SignersIndexes) > 0 { + l = 0 + for _, e := range m.SignersIndexes { + l += sovOutportBlock(uint64(e)) + } + n += 1 + sovOutportBlock(uint64(l)) + l + } + if m.BlockWasProposed { + n += 2 + } + if m.ShardId != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardId)) + } + if m.Epoch != 0 { + n += 1 + sovOutportBlock(uint64(m.Epoch)) + } + if m.Timestamp != 0 { + n += 1 + sovOutportBlock(uint64(m.Timestamp)) + } + return n +} + +func (m *RoundsInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardID)) + } + if len(m.RoundsInfo) > 0 { + for _, e := range m.RoundsInfo { + l = e.Size() + n += 1 + l + sovOutportBlock(uint64(l)) + } + } + return n +} + +func (m *PubKeys) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Keys) > 0 { + for _, b := range m.Keys { + l = len(b) + n += 1 + l + sovOutportBlock(uint64(l)) + } + } + return n +} + +func (m *ValidatorsPubKeys) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardID)) + } + if len(m.ShardValidatorsPubKeys) > 0 { + for k, v := range m.ShardValidatorsPubKeys { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOutportBlock(uint64(l)) + } + mapEntrySize := 1 + sovOutportBlock(uint64(k)) + l + n += mapEntrySize + 1 + sovOutportBlock(uint64(mapEntrySize)) + } + } + if m.Epoch != 0 { + n += 1 + sovOutportBlock(uint64(m.Epoch)) + } + return n +} + +func (m *Accounts) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardID)) + } + if m.BlockTimestamp != 0 { + n += 1 + sovOutportBlock(uint64(m.BlockTimestamp)) + } + if len(m.AlteredAccounts) > 0 { + for k, v := range m.AlteredAccounts { + _ = k + _ = v + l = 0 + if v != nil { + l = v.Size() + l += 1 + sovOutportBlock(uint64(l)) + } + mapEntrySize := 1 + len(k) + sovOutportBlock(uint64(len(k))) + l + n += mapEntrySize + 1 + sovOutportBlock(uint64(mapEntrySize)) + } + } + return n +} + +func (m *FinalizedBlock) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardID)) + } + l = len(m.HeaderHash) + if l > 0 { + n += 1 + l + sovOutportBlock(uint64(l)) + } + return n +} + +func (m *Shard) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ShardID != 0 { + n += 1 + sovOutportBlock(uint64(m.ShardID)) + } + return n +} + +func sovOutportBlock(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOutportBlock(x uint64) (n int) { + return sovOutportBlock(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (this *OutportBlock) String() string { + if this == nil { + return "nil" + } + keysForAlteredAccounts := make([]string, 0, len(this.AlteredAccounts)) + for k, _ := range this.AlteredAccounts { + keysForAlteredAccounts = append(keysForAlteredAccounts, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForAlteredAccounts) + mapStringForAlteredAccounts := "map[string]*alteredAccount.AlteredAccount{" + for _, k := range keysForAlteredAccounts { + mapStringForAlteredAccounts += fmt.Sprintf("%v: %v,", k, this.AlteredAccounts[k]) + } + mapStringForAlteredAccounts += "}" + s := strings.Join([]string{`&OutportBlock{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `BlockData:` + strings.Replace(this.BlockData.String(), "BlockData", "BlockData", 1) + `,`, + `TransactionPool:` + strings.Replace(this.TransactionPool.String(), "TransactionPool", "TransactionPool", 1) + `,`, + `HeaderGasConsumption:` + strings.Replace(this.HeaderGasConsumption.String(), "HeaderGasConsumption", "HeaderGasConsumption", 1) + `,`, + `AlteredAccounts:` + mapStringForAlteredAccounts + `,`, + `NotarizedHeadersHashes:` + fmt.Sprintf("%v", this.NotarizedHeadersHashes) + `,`, + `NumberOfShards:` + fmt.Sprintf("%v", this.NumberOfShards) + `,`, + `SignersIndexes:` + fmt.Sprintf("%v", this.SignersIndexes) + `,`, + `HighestFinalBlockNonce:` + fmt.Sprintf("%v", this.HighestFinalBlockNonce) + `,`, + `HighestFinalBlockHash:` + fmt.Sprintf("%v", this.HighestFinalBlockHash) + `,`, + `}`, + }, "") + return s +} +func (this *BlockData) String() string { + if this == nil { + return "nil" + } + repeatedStringForIntraShardMiniBlocks := "[]*MiniBlock{" + for _, f := range this.IntraShardMiniBlocks { + repeatedStringForIntraShardMiniBlocks += strings.Replace(fmt.Sprintf("%v", f), "MiniBlock", "block.MiniBlock", 1) + "," + } + repeatedStringForIntraShardMiniBlocks += "}" + s := strings.Join([]string{`&BlockData{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `HeaderBytes:` + fmt.Sprintf("%v", this.HeaderBytes) + `,`, + `HeaderType:` + fmt.Sprintf("%v", this.HeaderType) + `,`, + `HeaderHash:` + fmt.Sprintf("%v", this.HeaderHash) + `,`, + `Body:` + strings.Replace(fmt.Sprintf("%v", this.Body), "Body", "block.Body", 1) + `,`, + `IntraShardMiniBlocks:` + repeatedStringForIntraShardMiniBlocks + `,`, + `}`, + }, "") + return s +} +func (this *TransactionPool) String() string { + if this == nil { + return "nil" + } + repeatedStringForLogs := "[]*LogData{" + for _, f := range this.Logs { + repeatedStringForLogs += strings.Replace(f.String(), "LogData", "LogData", 1) + "," + } + repeatedStringForLogs += "}" + keysForTransactions := make([]string, 0, len(this.Transactions)) + for k, _ := range this.Transactions { + keysForTransactions = append(keysForTransactions, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForTransactions) + mapStringForTransactions := "map[string]*TxInfo{" + for _, k := range keysForTransactions { + mapStringForTransactions += fmt.Sprintf("%v: %v,", k, this.Transactions[k]) + } + mapStringForTransactions += "}" + keysForSmartContractResults := make([]string, 0, len(this.SmartContractResults)) + for k, _ := range this.SmartContractResults { + keysForSmartContractResults = append(keysForSmartContractResults, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForSmartContractResults) + mapStringForSmartContractResults := "map[string]*SCRInfo{" + for _, k := range keysForSmartContractResults { + mapStringForSmartContractResults += fmt.Sprintf("%v: %v,", k, this.SmartContractResults[k]) + } + mapStringForSmartContractResults += "}" + keysForRewards := make([]string, 0, len(this.Rewards)) + for k, _ := range this.Rewards { + keysForRewards = append(keysForRewards, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForRewards) + mapStringForRewards := "map[string]*RewardInfo{" + for _, k := range keysForRewards { + mapStringForRewards += fmt.Sprintf("%v: %v,", k, this.Rewards[k]) + } + mapStringForRewards += "}" + keysForReceipts := make([]string, 0, len(this.Receipts)) + for k, _ := range this.Receipts { + keysForReceipts = append(keysForReceipts, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForReceipts) + mapStringForReceipts := "map[string]*receipt.Receipt{" + for _, k := range keysForReceipts { + mapStringForReceipts += fmt.Sprintf("%v: %v,", k, this.Receipts[k]) + } + mapStringForReceipts += "}" + keysForInvalidTxs := make([]string, 0, len(this.InvalidTxs)) + for k, _ := range this.InvalidTxs { + keysForInvalidTxs = append(keysForInvalidTxs, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForInvalidTxs) + mapStringForInvalidTxs := "map[string]*TxInfo{" + for _, k := range keysForInvalidTxs { + mapStringForInvalidTxs += fmt.Sprintf("%v: %v,", k, this.InvalidTxs[k]) + } + mapStringForInvalidTxs += "}" + s := strings.Join([]string{`&TransactionPool{`, + `Transactions:` + mapStringForTransactions + `,`, + `SmartContractResults:` + mapStringForSmartContractResults + `,`, + `Rewards:` + mapStringForRewards + `,`, + `Receipts:` + mapStringForReceipts + `,`, + `InvalidTxs:` + mapStringForInvalidTxs + `,`, + `Logs:` + repeatedStringForLogs + `,`, + `ScheduledExecutedSCRSHashesPrevBlock:` + fmt.Sprintf("%v", this.ScheduledExecutedSCRSHashesPrevBlock) + `,`, + `ScheduledExecutedInvalidTxsHashesPrevBlock:` + fmt.Sprintf("%v", this.ScheduledExecutedInvalidTxsHashesPrevBlock) + `,`, + `}`, + }, "") + return s +} +func (this *FeeInfo) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&FeeInfo{`, + `GasUsed:` + fmt.Sprintf("%v", this.GasUsed) + `,`, + `Fee:` + fmt.Sprintf("%v", this.Fee) + `,`, + `InitialPaidFee:` + fmt.Sprintf("%v", this.InitialPaidFee) + `,`, + `}`, + }, "") + return s +} +func (this *TxInfo) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&TxInfo{`, + `Transaction:` + strings.Replace(fmt.Sprintf("%v", this.Transaction), "Transaction", "transaction.Transaction", 1) + `,`, + `FeeInfo:` + strings.Replace(this.FeeInfo.String(), "FeeInfo", "FeeInfo", 1) + `,`, + `ExecutionOrder:` + fmt.Sprintf("%v", this.ExecutionOrder) + `,`, + `}`, + }, "") + return s +} +func (this *SCRInfo) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&SCRInfo{`, + `SmartContractResult:` + strings.Replace(fmt.Sprintf("%v", this.SmartContractResult), "SmartContractResult", "smartContractResult.SmartContractResult", 1) + `,`, + `FeeInfo:` + strings.Replace(this.FeeInfo.String(), "FeeInfo", "FeeInfo", 1) + `,`, + `ExecutionOrder:` + fmt.Sprintf("%v", this.ExecutionOrder) + `,`, + `}`, + }, "") + return s +} +func (this *LogData) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&LogData{`, + `TxHash:` + fmt.Sprintf("%v", this.TxHash) + `,`, + `Log:` + strings.Replace(fmt.Sprintf("%v", this.Log), "Log", "transaction.Log", 1) + `,`, + `}`, + }, "") + return s +} +func (this *RewardInfo) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&RewardInfo{`, + `Reward:` + strings.Replace(fmt.Sprintf("%v", this.Reward), "RewardTx", "rewardTx.RewardTx", 1) + `,`, + `ExecutionOrder:` + fmt.Sprintf("%v", this.ExecutionOrder) + `,`, + `}`, + }, "") + return s +} +func (this *HeaderGasConsumption) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&HeaderGasConsumption{`, + `GasProvided:` + fmt.Sprintf("%v", this.GasProvided) + `,`, + `GasRefunded:` + fmt.Sprintf("%v", this.GasRefunded) + `,`, + `GasPenalized:` + fmt.Sprintf("%v", this.GasPenalized) + `,`, + `MaxGasPerBlock:` + fmt.Sprintf("%v", this.MaxGasPerBlock) + `,`, + `}`, + }, "") + return s +} +func (this *ValidatorRatingInfo) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ValidatorRatingInfo{`, + `PublicKey:` + fmt.Sprintf("%v", this.PublicKey) + `,`, + `Rating:` + fmt.Sprintf("%v", this.Rating) + `,`, + `}`, + }, "") + return s +} +func (this *ValidatorsRating) String() string { + if this == nil { + return "nil" + } + repeatedStringForValidatorsRatingInfo := "[]*ValidatorRatingInfo{" + for _, f := range this.ValidatorsRatingInfo { + repeatedStringForValidatorsRatingInfo += strings.Replace(f.String(), "ValidatorRatingInfo", "ValidatorRatingInfo", 1) + "," + } + repeatedStringForValidatorsRatingInfo += "}" + s := strings.Join([]string{`&ValidatorsRating{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `Epoch:` + fmt.Sprintf("%v", this.Epoch) + `,`, + `ValidatorsRatingInfo:` + repeatedStringForValidatorsRatingInfo + `,`, + `}`, + }, "") + return s +} +func (this *RoundInfo) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&RoundInfo{`, + `Round:` + fmt.Sprintf("%v", this.Round) + `,`, + `SignersIndexes:` + fmt.Sprintf("%v", this.SignersIndexes) + `,`, + `BlockWasProposed:` + fmt.Sprintf("%v", this.BlockWasProposed) + `,`, + `ShardId:` + fmt.Sprintf("%v", this.ShardId) + `,`, + `Epoch:` + fmt.Sprintf("%v", this.Epoch) + `,`, + `Timestamp:` + fmt.Sprintf("%v", this.Timestamp) + `,`, + `}`, + }, "") + return s +} +func (this *RoundsInfo) String() string { + if this == nil { + return "nil" + } + repeatedStringForRoundsInfo := "[]*RoundInfo{" + for _, f := range this.RoundsInfo { + repeatedStringForRoundsInfo += strings.Replace(f.String(), "RoundInfo", "RoundInfo", 1) + "," + } + repeatedStringForRoundsInfo += "}" + s := strings.Join([]string{`&RoundsInfo{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `RoundsInfo:` + repeatedStringForRoundsInfo + `,`, + `}`, + }, "") + return s +} +func (this *PubKeys) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PubKeys{`, + `Keys:` + fmt.Sprintf("%v", this.Keys) + `,`, + `}`, + }, "") + return s +} +func (this *ValidatorsPubKeys) String() string { + if this == nil { + return "nil" + } + keysForShardValidatorsPubKeys := make([]uint32, 0, len(this.ShardValidatorsPubKeys)) + for k, _ := range this.ShardValidatorsPubKeys { + keysForShardValidatorsPubKeys = append(keysForShardValidatorsPubKeys, k) + } + github_com_gogo_protobuf_sortkeys.Uint32s(keysForShardValidatorsPubKeys) + mapStringForShardValidatorsPubKeys := "map[uint32]*PubKeys{" + for _, k := range keysForShardValidatorsPubKeys { + mapStringForShardValidatorsPubKeys += fmt.Sprintf("%v: %v,", k, this.ShardValidatorsPubKeys[k]) + } + mapStringForShardValidatorsPubKeys += "}" + s := strings.Join([]string{`&ValidatorsPubKeys{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `ShardValidatorsPubKeys:` + mapStringForShardValidatorsPubKeys + `,`, + `Epoch:` + fmt.Sprintf("%v", this.Epoch) + `,`, + `}`, + }, "") + return s +} +func (this *Accounts) String() string { + if this == nil { + return "nil" + } + keysForAlteredAccounts := make([]string, 0, len(this.AlteredAccounts)) + for k, _ := range this.AlteredAccounts { + keysForAlteredAccounts = append(keysForAlteredAccounts, k) + } + github_com_gogo_protobuf_sortkeys.Strings(keysForAlteredAccounts) + mapStringForAlteredAccounts := "map[string]*alteredAccount.AlteredAccount{" + for _, k := range keysForAlteredAccounts { + mapStringForAlteredAccounts += fmt.Sprintf("%v: %v,", k, this.AlteredAccounts[k]) + } + mapStringForAlteredAccounts += "}" + s := strings.Join([]string{`&Accounts{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `BlockTimestamp:` + fmt.Sprintf("%v", this.BlockTimestamp) + `,`, + `AlteredAccounts:` + mapStringForAlteredAccounts + `,`, + `}`, + }, "") + return s +} +func (this *FinalizedBlock) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&FinalizedBlock{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `HeaderHash:` + fmt.Sprintf("%v", this.HeaderHash) + `,`, + `}`, + }, "") + return s +} +func (this *Shard) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Shard{`, + `ShardID:` + fmt.Sprintf("%v", this.ShardID) + `,`, + `}`, + }, "") + return s +} +func valueToStringOutportBlock(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} +func (m *OutportBlock) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: OutportBlock: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: OutportBlock: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BlockData == nil { + m.BlockData = &BlockData{} + } + if err := m.BlockData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransactionPool", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TransactionPool == nil { + m.TransactionPool = &TransactionPool{} + } + if err := m.TransactionPool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderGasConsumption", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.HeaderGasConsumption == nil { + m.HeaderGasConsumption = &HeaderGasConsumption{} + } + if err := m.HeaderGasConsumption.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AlteredAccounts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AlteredAccounts == nil { + m.AlteredAccounts = make(map[string]*alteredAccount.AlteredAccount) + } + var mapkey string + var mapvalue *alteredAccount.AlteredAccount + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOutportBlock + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &alteredAccount.AlteredAccount{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.AlteredAccounts[mapkey] = mapvalue + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NotarizedHeadersHashes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NotarizedHeadersHashes = append(m.NotarizedHeadersHashes, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NumberOfShards", wireType) + } + m.NumberOfShards = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NumberOfShards |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SignersIndexes = append(m.SignersIndexes, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.SignersIndexes) == 0 { + m.SignersIndexes = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SignersIndexes = append(m.SignersIndexes, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field SignersIndexes", wireType) + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HighestFinalBlockNonce", wireType) + } + m.HighestFinalBlockNonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HighestFinalBlockNonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HighestFinalBlockHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HighestFinalBlockHash = append(m.HighestFinalBlockHash[:0], dAtA[iNdEx:postIndex]...) + if m.HighestFinalBlockHash == nil { + m.HighestFinalBlockHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BlockData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BlockData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BlockData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderBytes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HeaderBytes = append(m.HeaderBytes[:0], dAtA[iNdEx:postIndex]...) + if m.HeaderBytes == nil { + m.HeaderBytes = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HeaderType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HeaderHash = append(m.HeaderHash[:0], dAtA[iNdEx:postIndex]...) + if m.HeaderHash == nil { + m.HeaderHash = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Body == nil { + m.Body = &block.Body{} + } + if err := m.Body.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IntraShardMiniBlocks", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IntraShardMiniBlocks = append(m.IntraShardMiniBlocks, &block.MiniBlock{}) + if err := m.IntraShardMiniBlocks[len(m.IntraShardMiniBlocks)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TransactionPool) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TransactionPool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TransactionPool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Transactions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Transactions == nil { + m.Transactions = make(map[string]*TxInfo) + } + var mapkey string + var mapvalue *TxInfo + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOutportBlock + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &TxInfo{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Transactions[mapkey] = mapvalue + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SmartContractResults", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SmartContractResults == nil { + m.SmartContractResults = make(map[string]*SCRInfo) + } + var mapkey string + var mapvalue *SCRInfo + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOutportBlock + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &SCRInfo{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.SmartContractResults[mapkey] = mapvalue + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Rewards == nil { + m.Rewards = make(map[string]*RewardInfo) + } + var mapkey string + var mapvalue *RewardInfo + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOutportBlock + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &RewardInfo{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Rewards[mapkey] = mapvalue + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receipts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Receipts == nil { + m.Receipts = make(map[string]*receipt.Receipt) + } + var mapkey string + var mapvalue *receipt.Receipt + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOutportBlock + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &receipt.Receipt{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Receipts[mapkey] = mapvalue + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InvalidTxs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.InvalidTxs == nil { + m.InvalidTxs = make(map[string]*TxInfo) + } + var mapkey string + var mapvalue *TxInfo + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOutportBlock + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &TxInfo{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.InvalidTxs[mapkey] = mapvalue + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Logs = append(m.Logs, &LogData{}) + if err := m.Logs[len(m.Logs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ScheduledExecutedSCRSHashesPrevBlock", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ScheduledExecutedSCRSHashesPrevBlock = append(m.ScheduledExecutedSCRSHashesPrevBlock, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ScheduledExecutedInvalidTxsHashesPrevBlock", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ScheduledExecutedInvalidTxsHashesPrevBlock = append(m.ScheduledExecutedInvalidTxsHashesPrevBlock, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FeeInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FeeInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FeeInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType) + } + m.GasUsed = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasUsed |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } else { + m.Fee = tmp + } + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitialPaidFee", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + { + __caster := &github_com_multiversx_mx_chain_core_go_data.BigIntCaster{} + if tmp, err := __caster.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } else { + m.InitialPaidFee = tmp + } + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TxInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TxInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Transaction", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Transaction == nil { + m.Transaction = &transaction.Transaction{} + } + if err := m.Transaction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FeeInfo == nil { + m.FeeInfo = &FeeInfo{} + } + if err := m.FeeInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutionOrder", wireType) + } + m.ExecutionOrder = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecutionOrder |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SCRInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SCRInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SCRInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SmartContractResult", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.SmartContractResult == nil { + m.SmartContractResult = &smartContractResult.SmartContractResult{} + } + if err := m.SmartContractResult.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.FeeInfo == nil { + m.FeeInfo = &FeeInfo{} + } + if err := m.FeeInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutionOrder", wireType) + } + m.ExecutionOrder = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecutionOrder |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LogData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LogData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LogData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Log", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Log == nil { + m.Log = &transaction.Log{} + } + if err := m.Log.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RewardInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RewardInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RewardInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reward", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Reward == nil { + m.Reward = &rewardTx.RewardTx{} + } + if err := m.Reward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExecutionOrder", wireType) + } + m.ExecutionOrder = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExecutionOrder |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *HeaderGasConsumption) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HeaderGasConsumption: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HeaderGasConsumption: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasProvided", wireType) + } + m.GasProvided = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasProvided |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasRefunded", wireType) + } + m.GasRefunded = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasRefunded |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasPenalized", wireType) + } + m.GasPenalized = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasPenalized |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxGasPerBlock", wireType) + } + m.MaxGasPerBlock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxGasPerBlock |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorRatingInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ValidatorRatingInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorRatingInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PublicKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 5 { + return fmt.Errorf("proto: wrong wireType = %d for field Rating", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return io.ErrUnexpectedEOF + } + v = uint32(encoding_binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + m.Rating = float32(math.Float32frombits(v)) + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorsRating) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ValidatorsRating: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorsRating: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) + } + m.Epoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Epoch |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsRatingInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorsRatingInfo = append(m.ValidatorsRatingInfo, &ValidatorRatingInfo{}) + if err := m.ValidatorsRatingInfo[len(m.ValidatorsRatingInfo)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RoundInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RoundInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RoundInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) + } + m.Round = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Round |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SignersIndexes = append(m.SignersIndexes, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.SignersIndexes) == 0 { + m.SignersIndexes = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SignersIndexes = append(m.SignersIndexes, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field SignersIndexes", wireType) + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockWasProposed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.BlockWasProposed = bool(v != 0) + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardId", wireType) + } + m.ShardId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardId |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) + } + m.Epoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Epoch |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RoundsInfo) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RoundsInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RoundsInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RoundsInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RoundsInfo = append(m.RoundsInfo, &RoundInfo{}) + if err := m.RoundsInfo[len(m.RoundsInfo)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PubKeys) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PubKeys: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubKeys: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Keys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Keys = append(m.Keys, make([]byte, postIndex-iNdEx)) + copy(m.Keys[len(m.Keys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorsPubKeys) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ValidatorsPubKeys: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorsPubKeys: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardValidatorsPubKeys", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ShardValidatorsPubKeys == nil { + m.ShardValidatorsPubKeys = make(map[uint32]*PubKeys) + } + var mapkey uint32 + var mapvalue *PubKeys + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapkey |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOutportBlock + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &PubKeys{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.ShardValidatorsPubKeys[mapkey] = mapvalue + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Epoch", wireType) + } + m.Epoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Epoch |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Accounts) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Accounts: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Accounts: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockTimestamp", wireType) + } + m.BlockTimestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockTimestamp |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AlteredAccounts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AlteredAccounts == nil { + m.AlteredAccounts = make(map[string]*alteredAccount.AlteredAccount) + } + var mapkey string + var mapvalue *alteredAccount.AlteredAccount + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthOutportBlock + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthOutportBlock + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &alteredAccount.AlteredAccount{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.AlteredAccounts[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FinalizedBlock) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FinalizedBlock: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FinalizedBlock: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeaderHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthOutportBlock + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthOutportBlock + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.HeaderHash = append(m.HeaderHash[:0], dAtA[iNdEx:postIndex]...) + if m.HeaderHash == nil { + m.HeaderHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Shard) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Shard: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Shard: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ShardID", wireType) + } + m.ShardID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ShardID |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipOutportBlock(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthOutportBlock + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOutportBlock(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowOutportBlock + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthOutportBlock + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOutportBlock + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOutportBlock + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOutportBlock = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOutportBlock = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOutportBlock = fmt.Errorf("proto: unexpected end of group") +) diff --git a/data/outport/outportBlock.proto b/data/outport/outportBlock.proto new file mode 100644 index 000000000..dfad100a2 --- /dev/null +++ b/data/outport/outportBlock.proto @@ -0,0 +1,133 @@ +syntax = "proto3"; + +package proto; + +option go_package = "github.com/multiversx/mx-chain-core-go/data/outport;outport"; +option (gogoproto.stable_marshaler_all) = true; + +import "github.com/gogo/protobuf/gogoproto/gogo.proto"; +import "github.com/multiversx/mx-chain-core-go/data/block/block.proto"; +import "github.com/multiversx/mx-chain-core-go/data/transaction/log.proto"; +import "github.com/multiversx/mx-chain-core-go/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/receipt/receipt.proto"; +import "github.com/multiversx/mx-chain-core-go/data/rewardTx/rewardTx.proto"; +import "github.com/multiversx/mx-chain-core-go/data/alteredAccount/alteredAccount.proto"; + +message OutportBlock { + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID,omitempty"]; + BlockData BlockData = 2 [(gogoproto.jsontag) = "blockData,omitempty"]; + TransactionPool TransactionPool = 3 [(gogoproto.jsontag) = "transactionPool,omitempty"]; + HeaderGasConsumption HeaderGasConsumption = 4 [(gogoproto.jsontag) = "headerGasConsumption,omitempty"]; + map AlteredAccounts = 5 [(gogoproto.jsontag) = "alteredAccounts,omitempty"]; + repeated string NotarizedHeadersHashes = 6 [(gogoproto.jsontag) = "notarizedHeadersHashes,omitempty"]; + uint32 NumberOfShards = 7 [(gogoproto.jsontag) = "numberOfShards"]; + repeated uint64 SignersIndexes = 8 [(gogoproto.jsontag) = "signersIndexes,omitempty"]; + uint64 HighestFinalBlockNonce = 9 [(gogoproto.jsontag) = "highestFinalBlockNonce"]; + bytes HighestFinalBlockHash = 10 [(gogoproto.jsontag) = "highestFinalBlockHash,omitempty"]; +} + +message BlockData { + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID,omitempty"]; + bytes HeaderBytes = 2 [(gogoproto.jsontag) = "headerBytes,omitempty"]; + string HeaderType = 3 [(gogoproto.jsontag) = "headerType,omitempty"]; + bytes HeaderHash = 4 [(gogoproto.jsontag) = "headerHash,omitempty"]; + Body Body = 5 [(gogoproto.jsontag) = "body,omitempty"]; + repeated MiniBlock IntraShardMiniBlocks = 6 [(gogoproto.jsontag) = "intraShardMiniBlocks,omitempty"]; +} + +message TransactionPool { + map Transactions = 1 [(gogoproto.jsontag) = "transactions,omitempty"]; + map SmartContractResults = 2 [(gogoproto.jsontag) = "smartContractResults,omitempty"]; + map Rewards = 3 [(gogoproto.jsontag) = "rewards,omitempty"]; + map Receipts = 4 [(gogoproto.jsontag) = "receipts,omitempty"]; + map InvalidTxs = 5 [(gogoproto.jsontag) = "invalidTxs,omitempty"]; + repeated LogData Logs = 6 [(gogoproto.jsontag) = "logs,omitempty"]; + repeated string ScheduledExecutedSCRSHashesPrevBlock = 7 [(gogoproto.jsontag) = "scheduledExecutedSCRSHashesPrevBlock,omitempty"]; + repeated string ScheduledExecutedInvalidTxsHashesPrevBlock = 8 [(gogoproto.jsontag) = "scheduledExecutedInvalidTxsHashesPrevBlock,omitempty"]; +} + +message FeeInfo { + uint64 GasUsed = 1 [(gogoproto.jsontag) = "gasUsed"]; + bytes Fee = 2 [(gogoproto.jsontag) = "fee,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; + bytes InitialPaidFee = 3 [(gogoproto.jsontag) = "initialPaidFee,omitempty", (gogoproto.casttypewith) = "math/big.Int;github.com/multiversx/mx-chain-core-go/data.BigIntCaster"]; +} + +message TxInfo { + Transaction Transaction = 1 [(gogoproto.jsontag) = "transaction,omitempty"]; + FeeInfo FeeInfo = 2 [(gogoproto.jsontag) = "feeInfo,omitempty"]; + uint32 ExecutionOrder = 3 [(gogoproto.jsontag) = "executionOrder"]; +} + +message SCRInfo { + SmartContractResult SmartContractResult = 1 [(gogoproto.jsontag) = "smartContractResult,omitempty"]; + FeeInfo FeeInfo = 2 [(gogoproto.jsontag) = "feeInfo,omitempty"]; + uint32 ExecutionOrder = 3 [(gogoproto.jsontag) = "executionOrder"]; +} + +message LogData{ + string TxHash = 1 [(gogoproto.jsontag) = "txHash"]; + Log Log = 2 [(gogoproto.jsontag) = "log"]; +} + +message RewardInfo { + RewardTx Reward = 1 [(gogoproto.jsontag) = "reward,omitempty"]; + uint32 ExecutionOrder = 2 [(gogoproto.jsontag) = "executionOrder"]; +} + +message HeaderGasConsumption { + uint64 GasProvided = 1 [(gogoproto.jsontag) = "gasProvided"]; + uint64 GasRefunded = 2 [(gogoproto.jsontag) = "gasRefunded"]; + uint64 GasPenalized = 3 [(gogoproto.jsontag) = "gasPenalized"]; + uint64 MaxGasPerBlock = 4 [(gogoproto.jsontag) = "maxGasPerBlock"]; +} + +message ValidatorRatingInfo { + string PublicKey = 1 [(gogoproto.jsontag) = "publicKey"]; + float Rating = 2 [(gogoproto.jsontag) = "rating"]; +} + +message ValidatorsRating{ + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + uint32 Epoch = 2 [(gogoproto.jsontag) = "epoch"]; + repeated ValidatorRatingInfo ValidatorsRatingInfo = 3 [(gogoproto.jsontag) = "validatorsRatingInfo,omitempty"]; +} + +message RoundInfo { + uint64 Round = 1 [(gogoproto.jsontag) = "round"]; + repeated uint64 SignersIndexes = 2 [(gogoproto.jsontag) = "signersIndexes"]; + bool BlockWasProposed = 3 [(gogoproto.jsontag) = "blockWasProposed"]; + uint32 ShardId = 4 [(gogoproto.jsontag) = "shardId"]; + uint32 Epoch = 5 [(gogoproto.jsontag) = "epoch"]; + uint64 Timestamp = 6 [(gogoproto.jsontag) = "timestamp"]; +} + +message RoundsInfo { + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + repeated RoundInfo RoundsInfo = 2 [(gogoproto.jsontag) = "roundsInfo,omitempty"]; +} + +message PubKeys { + repeated bytes Keys = 1 [(gogoproto.jsontag) = "keys,omitempty"]; +} + +message ValidatorsPubKeys{ + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + map ShardValidatorsPubKeys = 2 [(gogoproto.jsontag) = "validatorsPubKeys,omitempty"]; + uint32 Epoch = 3 [(gogoproto.jsontag) = "epoch"]; +} + +message Accounts { + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + uint64 BlockTimestamp = 2 [(gogoproto.jsontag) = "blockTimestamp"]; + map AlteredAccounts = 3 [(gogoproto.jsontag) = "alteredAccounts,omitempty"]; +} + +message FinalizedBlock { + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; + bytes HeaderHash = 2 [(gogoproto.jsontag) = "headerHash"]; +} + +message Shard { + uint32 ShardID = 1 [(gogoproto.jsontag) = "shardID"]; +} diff --git a/data/outport/status.go b/data/outport/status.go new file mode 100644 index 000000000..02f417b25 --- /dev/null +++ b/data/outport/status.go @@ -0,0 +1,8 @@ +package outport + +// StatusInfo holds the fields for the transaction status +type StatusInfo struct { + CompletedEvent bool `json:"completedEvent"` + ErrorEvent bool `json:"errorEvent"` + Status string `json:"status"` +} diff --git a/data/outport/txWithFee.go b/data/outport/txWithFee.go deleted file mode 100644 index c515d1a82..000000000 --- a/data/outport/txWithFee.go +++ /dev/null @@ -1,87 +0,0 @@ -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 deleted file mode 100644 index d24724455..000000000 --- a/data/outport/txWithFee_test.go +++ /dev/null @@ -1,22 +0,0 @@ -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 decc94d8f..992e49322 100644 --- a/data/receipt/receipt.go +++ b/data/receipt/receipt.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. receipt.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src receipt.proto package receipt import ( diff --git a/data/receipt/receipt.pb.go b/data/receipt/receipt.pb.go index 9c235d0cf..587d482b3 100644 --- a/data/receipt/receipt.pb.go +++ b/data/receipt/receipt.pb.go @@ -99,27 +99,28 @@ func init() { func init() { proto.RegisterFile("receipt.proto", fileDescriptor_ace1d6eb38fad2c8) } var fileDescriptor_ace1d6eb38fad2c8 = []byte{ - // 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, + // 324 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x51, 0xbd, 0x4e, 0xf3, 0x30, + 0x14, 0x8d, 0xbf, 0xaf, 0x3f, 0x92, 0x05, 0x0c, 0x99, 0x22, 0x86, 0x1b, 0x54, 0x21, 0xc4, 0x40, + 0x92, 0x81, 0xb1, 0x13, 0x05, 0x24, 0xba, 0x06, 0xc4, 0xc0, 0xe6, 0x24, 0x26, 0xb1, 0x54, 0xc7, + 0x95, 0x73, 0x53, 0x95, 0x8d, 0x47, 0xe0, 0x31, 0x10, 0x4f, 0xc2, 0xd8, 0xb1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 0x66, 0x7c, 0xc5, 0xaa, 0xc2, 0x6b, 0xfc, 0x84, 0xa1, 0x55, 0xe2, 0xad, 0xd3, + 0xab, 0x27, 0x73, 0x70, 0xa6, 0x73, 0x70, 0x56, 0x73, 0x20, 0x8f, 0x06, 0xc8, 0xb3, 0x01, 0xf2, + 0x6a, 0x80, 0x4c, 0x0c, 0x90, 0xa9, 0x01, 0xf2, 0x6e, 0x80, 0x7c, 0x1a, 0x70, 0x56, 0x06, 0xc8, + 0xd3, 0x02, 0x9c, 0xc9, 0x02, 0x9c, 0xe9, 0x02, 0x9c, 0xbb, 0xbf, 0x7c, 0x36, 0xda, 0xae, 0xa4, + 0xbb, 0xc5, 0xa4, 0x65, 0xa7, 0x7c, 0xfa, 0x15, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x24, 0x64, 0xda, + 0xac, 0x01, 0x00, 0x00, } func (this *Receipt) Equal(that interface{}) bool { diff --git a/data/receipt/receipt.proto b/data/receipt/receipt.proto index 0fbe44c12..e8761d382 100644 --- a/data/receipt/receipt.proto +++ b/data/receipt/receipt.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package proto; -option go_package = "receipt"; +option go_package = "github.com/multiversx/mx-chain-core-go/data/receipt;receipt"; option (gogoproto.stable_marshaler_all) = true; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; diff --git a/data/rewardTx/rewardTx.go b/data/rewardTx/rewardTx.go index 0e4a3ed43..0ccb44a5e 100644 --- a/data/rewardTx/rewardTx.go +++ b/data/rewardTx/rewardTx.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. rewardTx.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src rewardTx.proto package rewardTx import ( diff --git a/data/rewardTx/rewardTx.pb.go b/data/rewardTx/rewardTx.pb.go index ab1910274..cc40b534b 100644 --- a/data/rewardTx/rewardTx.pb.go +++ b/data/rewardTx/rewardTx.pb.go @@ -14,7 +14,6 @@ import ( math_big "math/big" math_bits "math/bits" reflect "reflect" - strconv "strconv" strings "strings" ) @@ -29,45 +28,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type Type int32 - -const ( - // unknown type - UnknownTx Type = 0 - // LeaderTx identifies a leader reward tx type - LeaderTx Type = 1 - // BurnTx identifies a burn reward tx type - BurnTx Type = 2 - // ProtocolSustainabilityTx identifies a protocol sustainability reward tx type - ProtocolSustainabilityTx Type = 3 - // ProtocolRewardsTx identifies a protocol reward tx type - ProtocolRewardsTx Type = 4 - // ProtocolRewardsForMetaTx identifies a protocol reward for meta tx type - ProtocolRewardsForMetaTx Type = 5 -) - -var Type_name = map[int32]string{ - 0: "UnknownTx", - 1: "LeaderTx", - 2: "BurnTx", - 3: "ProtocolSustainabilityTx", - 4: "ProtocolRewardsTx", - 5: "ProtocolRewardsForMetaTx", -} - -var Type_value = map[string]int32{ - "UnknownTx": 0, - "LeaderTx": 1, - "BurnTx": 2, - "ProtocolSustainabilityTx": 3, - "ProtocolRewardsTx": 4, - "ProtocolRewardsForMetaTx": 5, -} - -func (Type) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_25dbfb608d6baddf, []int{0} -} - // RewardTx holds the data for a reward transaction type RewardTx struct { Round uint64 `protobuf:"varint,1,opt,name=Round,proto3" json:"round"` @@ -133,49 +93,36 @@ func (m *RewardTx) GetEpoch() uint32 { } func init() { - proto.RegisterEnum("protoRewardTx.Type", Type_name, Type_value) - proto.RegisterType((*RewardTx)(nil), "protoRewardTx.RewardTx") + proto.RegisterType((*RewardTx)(nil), "proto.RewardTx") } func init() { proto.RegisterFile("rewardTx.proto", fileDescriptor_25dbfb608d6baddf) } var fileDescriptor_25dbfb608d6baddf = []byte{ - // 409 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0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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, + // 321 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x91, 0xb1, 0x4e, 0xc3, 0x30, + 0x10, 0x86, 0x73, 0xd0, 0x40, 0x89, 0x0a, 0x43, 0xa6, 0x88, 0xe1, 0x52, 0x31, 0xa0, 0x2e, 0x49, + 0x06, 0xc6, 0x8a, 0x81, 0xa0, 0x0e, 0x5d, 0x2d, 0xc4, 0xc0, 0xe6, 0x24, 0x26, 0x89, 0xd4, 0xc4, + 0x95, 0xeb, 0xb4, 0x1d, 0x79, 0x04, 0x1e, 0x03, 0xf1, 0x24, 0x8c, 0x1d, 0x3b, 0x15, 0xea, 0x2e, + 0xa8, 0x53, 0x1f, 0x01, 0xc5, 0x21, 0x12, 0x2b, 0x93, 0xef, 0x3e, 0xdb, 0xff, 0xff, 0xdb, 0x67, + 0x5d, 0x08, 0xb6, 0xa0, 0x22, 0x79, 0x58, 0xfa, 0x53, 0xc1, 0x25, 0xb7, 0x4d, 0xbd, 0x5c, 0x7a, + 0x69, 0x2e, 0xb3, 0x2a, 0xf2, 0x63, 0x5e, 0x04, 0x29, 0x4f, 0x79, 0xa0, 0x71, 0x54, 0x3d, 0xeb, + 0x4e, 0x37, 0xba, 0x6a, 0x6e, 0x5d, 0x6d, 0xc0, 0xea, 0x92, 0x5f, 0x21, 0xdb, 0xb5, 0x4c, 0xc2, + 0xab, 0x32, 0x71, 0xa0, 0x0f, 0x83, 0x4e, 0x78, 0xb6, 0xdf, 0xb8, 0xa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x Type) String() string { - s, ok := Type_name[int32(x)] - if ok { - return s - } - return strconv.Itoa(int(x)) -} func (this *RewardTx) Equal(that interface{}) bool { if that == nil { return this == nil diff --git a/data/rewardTx/rewardTx.proto b/data/rewardTx/rewardTx.proto index f74966c79..042fd2b30 100644 --- a/data/rewardTx/rewardTx.proto +++ b/data/rewardTx/rewardTx.proto @@ -1,33 +1,16 @@ - syntax = "proto3"; -package protoRewardTx; +package proto; -option go_package = "rewardTx"; +option go_package = "github.com/multiversx/mx-chain-core-go/data/rewardTx;rewardTx"; option (gogoproto.stable_marshaler_all) = true; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; -enum Type { - // unknown type - UnknownTx = 0; - // LeaderTx identifies a leader reward tx type - LeaderTx = 1; - // BurnTx identifies a burn reward tx type - BurnTx = 2; - // ProtocolSustainabilityTx identifies a protocol sustainability reward tx type - ProtocolSustainabilityTx = 3; - // ProtocolRewardsTx identifies a protocol reward tx type - ProtocolRewardsTx = 4; - // ProtocolRewardsForMetaTx identifies a protocol reward for meta tx type - ProtocolRewardsForMetaTx = 5; -} - - // 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/multiversx/mx-chain-core-go/data.BigIntCaster"]; - bytes RcvAddr = 4 [(gogoproto.jsontag) = "receiver"]; - uint32 Epoch = 2 [(gogoproto.jsontag) = "epoch"]; + uint64 Round = 1 [(gogoproto.jsontag) = "round"]; + 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/smartContractResult/smartContractResult.go b/data/smartContractResult/smartContractResult.go index c6ab0f8a6..2c2481761 100644 --- a/data/smartContractResult/smartContractResult.go +++ b/data/smartContractResult/smartContractResult.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. smartContractResult.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src smartContractResult.proto package smartContractResult import ( diff --git a/data/smartContractResult/smartContractResult.pb.go b/data/smartContractResult/smartContractResult.pb.go index 45422ffd6..32e485c58 100644 --- a/data/smartContractResult/smartContractResult.pb.go +++ b/data/smartContractResult/smartContractResult.pb.go @@ -195,46 +195,46 @@ func init() { func init() { proto.RegisterFile("smartContractResult.proto", fileDescriptor_edc1605de0d3d805) } var fileDescriptor_edc1605de0d3d805 = []byte{ - // 613 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6f, 0xd3, 0x3e, - 0x18, 0xc6, 0xeb, 0xff, 0xd6, 0xb5, 0xf3, 0xba, 0xfe, 0x91, 0x27, 0x81, 0x19, 0xc8, 0x9e, 0x10, - 0x9a, 0x7a, 0xa0, 0xed, 0x81, 0x03, 0x12, 0x48, 0x48, 0x6b, 0x87, 0xc6, 0x24, 0x06, 0x93, 0x37, - 0x21, 0xc1, 0xcd, 0x75, 0x4c, 0x1a, 0x29, 0x89, 0x2b, 0xc7, 0xa9, 0xb6, 0x03, 0x12, 0x1f, 0x81, - 0x8f, 0x81, 0xf8, 0x24, 0x1c, 0x77, 0x9c, 0x38, 0x04, 0x96, 0x5d, 0x50, 0x4e, 0x3b, 0x73, 0x42, - 0x71, 0xba, 0x2e, 0x19, 0x5c, 0x90, 0x38, 0x25, 0x7e, 0x9e, 0xdf, 0xfb, 0xbc, 0xf1, 0x1b, 0xcb, - 0xf0, 0x76, 0x14, 0x70, 0x6d, 0x86, 0x2a, 0x34, 0x9a, 0x0b, 0xc3, 0x64, 0x14, 0xfb, 0xa6, 0x37, - 0xd1, 0xca, 0x28, 0x54, 0xb7, 0x8f, 0xf5, 0xae, 0xeb, 0x99, 0x71, 0x3c, 0xea, 0x09, 0x15, 0xf4, - 0x5d, 0xe5, 0xaa, 0xbe, 0x95, 0x47, 0xf1, 0x3b, 0xbb, 0xb2, 0x0b, 0xfb, 0x56, 0x54, 0xdd, 0xfb, - 0xda, 0x80, 0x6b, 0x07, 0xbf, 0x67, 0x22, 0x0a, 0xeb, 0x2f, 0x55, 0x28, 0x24, 0x06, 0x1b, 0xa0, - 0xb3, 0x38, 0x58, 0xce, 0x12, 0x5a, 0x0f, 0x73, 0x81, 0x15, 0x3a, 0x1a, 0xc3, 0xfa, 0x6b, 0xee, - 0xc7, 0x12, 0xff, 0xb7, 0x01, 0x3a, 0xad, 0x01, 0xcb, 0x81, 0x69, 0x2e, 0x7c, 0xfe, 0x46, 0x9f, - 0x05, 0xdc, 0x8c, 0xfb, 0x23, 0xcf, 0xed, 0xed, 0x86, 0xe6, 0x49, 0xe9, 0x83, 0x82, 0xd8, 0x37, - 0xde, 0x54, 0xea, 0xe8, 0xa8, 0x1f, 0x1c, 0x75, 0xc5, 0x98, 0x7b, 0x61, 0x57, 0x28, 0x2d, 0xbb, - 0xae, 0xea, 0x3b, 0xdc, 0xf0, 0xde, 0xc0, 0x73, 0x77, 0x43, 0x33, 0xe4, 0x91, 0x91, 0x9a, 0x15, - 0x0d, 0xd0, 0x26, 0x6c, 0x30, 0x31, 0xdd, 0x72, 0x1c, 0x8d, 0x17, 0x6c, 0xaf, 0x56, 0x96, 0xd0, - 0xa6, 0x96, 0x42, 0xe6, 0x51, 0xec, 0xd2, 0x44, 0xf7, 0x61, 0xe3, 0x20, 0x74, 0x2c, 0xb7, 0x68, - 0x39, 0x98, 0x25, 0x74, 0x29, 0x92, 0xa1, 0x93, 0x53, 0x33, 0x0b, 0x75, 0xe1, 0x0a, 0x93, 0x3e, - 0x3f, 0x96, 0xda, 0x92, 0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6, 0xf2, 0xa1, 0xee, 0x49, 0xc3, 0x73, 0x0a, - 0xb7, 0xed, 0x96, 0xd7, 0xb3, 0x84, 0xde, 0x14, 0x25, 0xbd, 0x34, 0xdc, 0x0a, 0x8f, 0xb6, 0xe0, - 0x2a, 0x93, 0x26, 0xd6, 0xe1, 0x9e, 0x8c, 0x22, 0xee, 0x4a, 0xfc, 0xbf, 0x0d, 0xb8, 0x93, 0x25, - 0xf4, 0x96, 0x2e, 0x1b, 0xa5, 0x84, 0x6a, 0x05, 0xda, 0xbe, 0x9a, 0xfb, 0x81, 0x3d, 0xc0, 0xf8, - 0x86, 0xcd, 0xb8, 0x9b, 0x25, 0x14, 0xab, 0x8a, 0x53, 0x0a, 0xb9, 0x56, 0x33, 0xd8, 0x3b, 0x39, - 0x23, 0xb5, 0xd3, 0x33, 0x52, 0xbb, 0x38, 0x23, 0xe0, 0x43, 0x4a, 0xc0, 0xa7, 0x94, 0x80, 0x2f, - 0x29, 0x01, 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, + // 619 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x41, 0x6b, 0x13, 0x41, + 0x18, 0x86, 0x33, 0xb6, 0x69, 0xd2, 0x69, 0x1a, 0x65, 0x04, 0x1d, 0xab, 0xcc, 0x14, 0x91, 0x92, + 0x83, 0x49, 0x0e, 0x1e, 0x04, 0x0b, 0x42, 0x93, 0x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0xa4, 0x74, 0x72, 0x46, 0x4a, 0xef, 0x7b, 0xd7, + 0x19, 0xe3, 0x15, 0x97, 0xd2, 0xe6, 0x15, 0x5a, 0x7f, 0xc9, 0xde, 0x39, 0x4f, 0xfe, 0x06, 0x00, + 0x00, 0xff, 0xff, 0x98, 0xea, 0x6f, 0xf3, 0xc6, 0x04, 0x00, 0x00, } func (this *SmartContractResult) Equal(that interface{}) bool { diff --git a/data/smartContractResult/smartContractResult.proto b/data/smartContractResult/smartContractResult.proto index 4f074fc73..7ef33e2a2 100644 --- a/data/smartContractResult/smartContractResult.proto +++ b/data/smartContractResult/smartContractResult.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package proto; -option go_package = "smartContractResult"; +option go_package = "github.com/multiversx/mx-chain-core-go/data/smartContractResult;smartContractResult"; option (gogoproto.stable_marshaler_all) = true; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; diff --git a/data/transaction/apiTransactionResult.go b/data/transaction/apiTransactionResult.go index 76f3a3985..ca9671b10 100644 --- a/data/transaction/apiTransactionResult.go +++ b/data/transaction/apiTransactionResult.go @@ -117,10 +117,11 @@ type ApiLogs struct { // Events represents the events generated by a transaction with changed fields' types in order to make it friendly for API's json type Events struct { - Address string `json:"address"` - Identifier string `json:"identifier"` - Topics [][]byte `json:"topics"` - Data []byte `json:"data"` + Address string `json:"address"` + Identifier string `json:"identifier"` + Topics [][]byte `json:"topics"` + Data []byte `json:"data"` + AdditionalData [][]byte `json:"additionalData"` } // CostResponse is structure used to return the transaction cost in gas units @@ -128,4 +129,15 @@ type CostResponse struct { GasUnits uint64 `json:"txGasUnits"` ReturnMessage string `json:"returnMessage"` SmartContractResults map[string]*ApiSmartContractResult `json:"smartContractResults"` + Logs *ApiLogs `json:"logs,omitempty"` +} + +// SimulationResults is the data transfer object which will hold results for simulating a transaction's execution +type SimulationResults struct { + Hash string `json:"hash,omitempty"` + FailReason string `json:"failReason,omitempty"` + Status TxStatus `json:"status,omitempty"` + ScResults map[string]*ApiSmartContractResult `json:"scResults,omitempty"` + Receipts map[string]*ApiReceipt `json:"receipts,omitempty"` + Logs *ApiLogs `json:"logs,omitempty"` } diff --git a/data/transaction/log.go b/data/transaction/log.go index 3f917c0f3..fdc022806 100644 --- a/data/transaction/log.go +++ b/data/transaction/log.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. log.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src log.proto package transaction import ( diff --git a/data/transaction/log.pb.go b/data/transaction/log.pb.go index eb9e5e23f..0f0b729e8 100644 --- a/data/transaction/log.pb.go +++ b/data/transaction/log.pb.go @@ -28,10 +28,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Event holds all the data needed for an event structure type Event struct { - Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` - Identifier []byte `protobuf:"bytes,2,opt,name=Identifier,proto3" json:"identifier"` - Topics [][]byte `protobuf:"bytes,3,rep,name=Topics,proto3" json:"topics"` - Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"data"` + Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` + Identifier []byte `protobuf:"bytes,2,opt,name=Identifier,proto3" json:"identifier"` + Topics [][]byte `protobuf:"bytes,3,rep,name=Topics,proto3" json:"topics"` + Data []byte `protobuf:"bytes,4,opt,name=Data,proto3" json:"data"` + AdditionalData [][]byte `protobuf:"bytes,5,rep,name=AdditionalData,proto3" json:"additionalData"` } func (m *Event) Reset() { *m = Event{} } @@ -90,6 +91,13 @@ func (m *Event) GetData() []byte { return nil } +func (m *Event) GetAdditionalData() [][]byte { + if m != nil { + return m.AdditionalData + } + return nil +} + // Log holds all the data needed for a log structure type Log struct { Address []byte `protobuf:"bytes,1,opt,name=Address,proto3" json:"address"` @@ -146,26 +154,28 @@ func init() { func init() { proto.RegisterFile("log.proto", fileDescriptor_a153da538f858886) } var fileDescriptor_a153da538f858886 = []byte{ - // 303 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x8f, 0xbf, 0x4e, 0xf3, 0x30, - 0x14, 0xc5, 0xed, 0xa6, 0x4d, 0xbf, 0xcf, 0xad, 0x18, 0x32, 0x45, 0x08, 0xdd, 0x54, 0x91, 0x90, - 0xb2, 0x90, 0x22, 0x78, 0x02, 0x22, 0x3a, 0x20, 0x31, 0x45, 0x4c, 0x0c, 0x48, 0xce, 0x9f, 0x06, - 0x4b, 0x10, 0x57, 0x89, 0xcb, 0xcc, 0x23, 0xf0, 0x08, 0x8c, 0x3c, 0x0a, 0x63, 0xc6, 0x4c, 0x11, - 0x71, 0x16, 0x94, 0xa9, 0x8f, 0x80, 0x74, 0x53, 0x10, 0x23, 0x93, 0x7d, 0x7f, 0xe7, 0xd8, 0xe7, - 0x1e, 0xf6, 0xff, 0x41, 0x66, 0xfe, 0xa6, 0x90, 0x4a, 0x5a, 0x13, 0x3c, 0x0e, 0x4f, 0x32, 0xa1, - 0xee, 0xb7, 0x91, 0x1f, 0xcb, 0xc7, 0x65, 0x26, 0x33, 0xb9, 0x44, 0x1c, 0x6d, 0xd7, 0x38, 0xe1, - 0x80, 0xb7, 0xe1, 0x95, 0xfb, 0x4a, 0xd9, 0x64, 0xf5, 0x94, 0xe6, 0xca, 0x3a, 0x66, 0xd3, 0x8b, - 0x24, 0x29, 0xd2, 0xb2, 0xb4, 0xe9, 0x82, 0x7a, 0xf3, 0x60, 0xd6, 0x37, 0xce, 0x94, 0x0f, 0x28, - 0xfc, 0xd6, 0x2c, 0x9f, 0xb1, 0xab, 0x24, 0xcd, 0x95, 0x58, 0x8b, 0xb4, 0xb0, 0x47, 0xe8, 0x3c, - 0xe8, 0x1b, 0x87, 0x89, 0x1f, 0x1a, 0xfe, 0x72, 0x58, 0x2e, 0x33, 0x6f, 0xe4, 0x46, 0xc4, 0xa5, - 0x6d, 0x2c, 0x0c, 0x6f, 0x1e, 0xb0, 0xbe, 0x71, 0x4c, 0x85, 0x24, 0xdc, 0x2b, 0xd6, 0x11, 0x1b, - 0x5f, 0x72, 0xc5, 0xed, 0x31, 0xfe, 0xf6, 0xaf, 0x6f, 0x9c, 0x71, 0xc2, 0x15, 0x0f, 0x91, 0xba, - 0x77, 0xcc, 0xb8, 0x96, 0xd9, 0x5f, 0xf7, 0x3b, 0x65, 0x26, 0xf6, 0x29, 0xed, 0xd1, 0xc2, 0xf0, - 0x66, 0x67, 0xf3, 0xa1, 0xa8, 0x8f, 0x70, 0x48, 0x4f, 0x51, 0x0f, 0xf7, 0xbe, 0x60, 0x55, 0xb5, - 0x40, 0xea, 0x16, 0xc8, 0xae, 0x05, 0xfa, 0xac, 0x81, 0xbe, 0x69, 0xa0, 0xef, 0x1a, 0x68, 0xa5, - 0x81, 0xd6, 0x1a, 0xe8, 0x87, 0x06, 0xfa, 0xa9, 0x81, 0xec, 0x34, 0xd0, 0x97, 0x0e, 0x48, 0xd5, - 0x01, 0xa9, 0x3b, 0x20, 0xb7, 0x33, 0x55, 0xf0, 0xbc, 0xe4, 0xb1, 0x12, 0x32, 0x8f, 0x4c, 0xcc, - 0x39, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x4b, 0x55, 0xcf, 0x0b, 0x93, 0x01, 0x00, 0x00, + // 327 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0x31, 0x4f, 0xc2, 0x40, + 0x14, 0xc7, 0x7b, 0x14, 0x8a, 0x3e, 0x08, 0xc3, 0x4d, 0x8d, 0x31, 0xaf, 0x84, 0xc4, 0x84, 0xc5, + 0x62, 0x74, 0x73, 0x83, 0xc8, 0x60, 0xe2, 0xd4, 0x38, 0x39, 0x98, 0x1c, 0xb4, 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x31, 0x7b, 0xb7, 0x60, 0x5f, 0xa9, 0xf8, 0xbf, 0x6f, 0x3b, 0x01, 0x87, 0x76, + 0x91, 0xb9, 0xb5, 0xae, 0xdd, 0x6f, 0x9d, 0xb6, 0xab, 0x25, 0xf9, 0x04, 0xab, 0xc9, 0x23, 0xca, + 0x83, 0x9d, 0x37, 0x1a, 0xaf, 0x36, 0x68, 0xad, 0x37, 0x68, 0x6d, 0x37, 0xc8, 0x1e, 0x0d, 0xb2, + 0x67, 0x83, 0xec, 0xc5, 0x20, 0x5b, 0x19, 0x64, 0x6b, 0x83, 0xec, 0xcd, 0x20, 0x7b, 0x37, 0x68, + 0x6d, 0x0d, 0xb2, 0xa7, 0x02, 0xad, 0x55, 0x81, 0xd6, 0xba, 0x40, 0xeb, 0xa6, 0xa5, 0x53, 0x91, + 0x64, 0x62, 0xfa, 0x39, 0xec, 0xc4, 0xa1, 0x7b, 0xce, 0x3e, 0x02, 0x00, 0x00, 0xff, 0xff, 0xff, + 0xf2, 0x5d, 0xce, 0xcf, 0x01, 0x00, 0x00, } func (this *Event) Equal(that interface{}) bool { @@ -204,6 +214,14 @@ func (this *Event) Equal(that interface{}) bool { if !bytes.Equal(this.Data, that1.Data) { return false } + if len(this.AdditionalData) != len(that1.AdditionalData) { + return false + } + for i := range this.AdditionalData { + if !bytes.Equal(this.AdditionalData[i], that1.AdditionalData[i]) { + return false + } + } return true } func (this *Log) Equal(that interface{}) bool { @@ -242,12 +260,13 @@ func (this *Event) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 8) + s := make([]string, 0, 9) s = append(s, "&transaction.Event{") s = append(s, "Address: "+fmt.Sprintf("%#v", this.Address)+",\n") s = append(s, "Identifier: "+fmt.Sprintf("%#v", this.Identifier)+",\n") s = append(s, "Topics: "+fmt.Sprintf("%#v", this.Topics)+",\n") s = append(s, "Data: "+fmt.Sprintf("%#v", this.Data)+",\n") + s = append(s, "AdditionalData: "+fmt.Sprintf("%#v", this.AdditionalData)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -292,6 +311,15 @@ func (m *Event) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AdditionalData) > 0 { + for iNdEx := len(m.AdditionalData) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AdditionalData[iNdEx]) + copy(dAtA[i:], m.AdditionalData[iNdEx]) + i = encodeVarintLog(dAtA, i, uint64(len(m.AdditionalData[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } if len(m.Data) > 0 { i -= len(m.Data) copy(dAtA[i:], m.Data) @@ -404,6 +432,12 @@ func (m *Event) Size() (n int) { if l > 0 { n += 1 + l + sovLog(uint64(l)) } + if len(m.AdditionalData) > 0 { + for _, b := range m.AdditionalData { + l = len(b) + n += 1 + l + sovLog(uint64(l)) + } + } return n } @@ -441,6 +475,7 @@ func (this *Event) String() string { `Identifier:` + fmt.Sprintf("%v", this.Identifier) + `,`, `Topics:` + fmt.Sprintf("%v", this.Topics) + `,`, `Data:` + fmt.Sprintf("%v", this.Data) + `,`, + `AdditionalData:` + fmt.Sprintf("%v", this.AdditionalData) + `,`, `}`, }, "") return s @@ -632,6 +667,38 @@ func (m *Event) Unmarshal(dAtA []byte) error { m.Data = []byte{} } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AdditionalData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLog + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthLog + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthLog + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AdditionalData = append(m.AdditionalData, make([]byte, postIndex-iNdEx)) + copy(m.AdditionalData[len(m.AdditionalData)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipLog(dAtA[iNdEx:]) diff --git a/data/transaction/log.proto b/data/transaction/log.proto index 1aaa0a3ff..89ec91264 100644 --- a/data/transaction/log.proto +++ b/data/transaction/log.proto @@ -3,17 +3,18 @@ syntax = "proto3"; package proto; -option go_package = "transaction"; +option go_package = "github.com/multiversx/mx-chain-core-go/data/transaction;transaction"; option (gogoproto.stable_marshaler_all) = true; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; // Event holds all the data needed for an event structure message Event { - bytes Address = 1 [(gogoproto.jsontag) = "address"]; - bytes Identifier = 2 [(gogoproto.jsontag) = "identifier"]; - repeated bytes Topics = 3 [(gogoproto.jsontag) = "topics"]; - bytes Data = 4 [(gogoproto.jsontag) = "data"]; + bytes Address = 1 [(gogoproto.jsontag) = "address"]; + bytes Identifier = 2 [(gogoproto.jsontag) = "identifier"]; + repeated bytes Topics = 3 [(gogoproto.jsontag) = "topics"]; + bytes Data = 4 [(gogoproto.jsontag) = "data"]; + repeated bytes AdditionalData = 5 [(gogoproto.jsontag) = "additionalData"]; } // Log holds all the data needed for a log structure diff --git a/data/transaction/transaction.go b/data/transaction/transaction.go index 921226220..b5b42531c 100644 --- a/data/transaction/transaction.go +++ b/data/transaction/transaction.go @@ -1,4 +1,4 @@ -//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=. transaction.proto +//go:generate protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/multiversx/protobuf/protobuf --gogoslick_out=$GOPATH/src transaction.proto package transaction import ( @@ -68,11 +68,21 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M return nil, ErrNilHasher } + receiverAddr, err := encoder.Encode(tx.RcvAddr) + if err != nil { + return nil, err + } + + senderAddr, err := encoder.Encode(tx.SndAddr) + if err != nil { + return nil, err + } + ftx := &FrontendTransaction{ Nonce: tx.Nonce, Value: tx.Value.String(), - Receiver: encoder.Encode(tx.RcvAddr), - Sender: encoder.Encode(tx.SndAddr), + Receiver: receiverAddr, + Sender: senderAddr, GasPrice: tx.GasPrice, GasLimit: tx.GasLimit, SenderUsername: tx.SndUserName, @@ -84,7 +94,12 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M } if len(tx.GuardianAddr) > 0 { - ftx.GuardianAddr = encoder.Encode(tx.GuardianAddr) + guardianAddr, errGuardian := encoder.Encode(tx.GuardianAddr) + if errGuardian != nil { + return nil, errGuardian + } + + ftx.GuardianAddr = guardianAddr } ftxBytes, err := marshaller.Marshal(ftx) diff --git a/data/transaction/transaction.pb.go b/data/transaction/transaction.pb.go index f663d0ada..a8b2dd871 100644 --- a/data/transaction/transaction.pb.go +++ b/data/transaction/transaction.pb.go @@ -187,43 +187,43 @@ func init() { func init() { proto.RegisterFile("transaction.proto", fileDescriptor_2cc4e03d2c28c490) } var fileDescriptor_2cc4e03d2c28c490 = []byte{ - // 564 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x93, 0x41, 0x6f, 0xd3, 0x3e, - 0x18, 0xc6, 0xe3, 0xff, 0x7f, 0x6d, 0x36, 0xb7, 0x1b, 0x9a, 0xd1, 0x20, 0x80, 0x64, 0x4f, 0x08, - 0xa6, 0x1d, 0x58, 0x23, 0x81, 0xb8, 0xb0, 0x13, 0xdd, 0xc6, 0x54, 0x09, 0x0a, 0x4a, 0x61, 0x07, - 0x6e, 0x6e, 0x62, 0x52, 0x8b, 0xc5, 0xae, 0x1c, 0xb7, 0x88, 0x1b, 0x1f, 0x81, 0x8f, 0x81, 0x38, - 0xf2, 0x29, 0x38, 0xf6, 0xd8, 0x53, 0xa0, 0xe9, 0x05, 0xe5, 0xb4, 0x8f, 0x80, 0xe2, 0x34, 0x4b, - 0x36, 0x4e, 0xc9, 0xfb, 0x7b, 0x9f, 0xe7, 0x7d, 0xac, 0x37, 0x31, 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 0x9e, 0xc1, 0xf6, 0xe9, 0x84, 0xaa, 0x80, 0x53, 0x61, 0xbe, - 0xd6, 0x96, 0x89, 0x2a, 0xb6, 0xb2, 0xe2, 0x35, 0xdb, 0x15, 0x2d, 0x7a, 0x05, 0xb7, 0xcb, 0xba, - 0x3a, 0xeb, 0x0d, 0x33, 0x80, 0x64, 0x09, 0xb9, 0x17, 0x5e, 0x6f, 0xd6, 0x26, 0xfd, 0xeb, 0xec, - 0x9e, 0xcc, 0x16, 0xd8, 0x9a, 0x2f, 0xb0, 0x75, 0xb1, 0xc0, 0xe0, 0x4b, 0x8a, 0xc1, 0xb7, 0x14, - 0x83, 0x9f, 0x29, 0x06, 0xb3, 0x14, 0x83, 0x79, 0x8a, 0xc1, 0xef, 0x14, 0x83, 0x3f, 0x29, 0xb6, - 0x2e, 0x52, 0x0c, 0xbe, 0x2e, 0xb1, 0x35, 0x5b, 0x62, 0x6b, 0xbe, 0xc4, 0xd6, 0xfb, 0x56, 0xed, - 0xde, 0x0e, 0x9b, 0xe6, 0x0a, 0x3e, 0xf9, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x29, 0x3a, 0x4b, 0xea, - 0xcd, 0x03, 0x00, 0x00, + // 573 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x6f, 0xd4, 0x3e, + 0x18, 0xc6, 0xe3, 0xff, 0xbf, 0x77, 0x69, 0x7d, 0xd7, 0xa2, 0x1a, 0x15, 0x02, 0x48, 0x76, 0x85, + 0xa0, 0xea, 0xc0, 0x5d, 0x24, 0x10, 0x0b, 0x9d, 0xb8, 0x16, 0x55, 0x95, 0xa0, 0xa0, 0x14, 0x3a, + 0xb0, 0xf9, 0x12, 0x93, 0xb3, 0xd4, 0xd8, 0x95, 0xe3, 0x9c, 0xca, 0x80, 0xc4, 0x47, 0xe0, 0x63, + 0x20, 0x36, 0xbe, 0x05, 0x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 0xab, 0x44, 0x3e, 0x74, 0x5f, 0x1f, 0x57, 0x7f, 0x5c, 0xea, 0x2d, 0x9b, 0xee, 0x6b, 0x65, + 0x4e, 0x56, 0x65, 0x8d, 0x2c, 0x4b, 0xa3, 0x42, 0xcf, 0x60, 0x7f, 0x37, 0xa3, 0x2a, 0xe2, 0x54, + 0x98, 0xd7, 0x5a, 0x31, 0x51, 0xf5, 0xad, 0xcc, 0xb9, 0x65, 0xbb, 0xa2, 0x45, 0xaf, 0xe0, 0x6a, + 0xb3, 0x6f, 0xcf, 0x7a, 0xc3, 0x34, 0x20, 0x65, 0x4e, 0xee, 0xc5, 0xd7, 0x8b, 0x56, 0xa7, 0xbf, + 0x9d, 0xa3, 0x4f, 0xa7, 0xe7, 0xd8, 0x39, 0x3b, 0xc7, 0xce, 0xc5, 0x39, 0x06, 0x9f, 0x0b, 0x0c, + 0xbe, 0x16, 0x18, 0xfc, 0x28, 0x30, 0x38, 0x2d, 0x30, 0x38, 0x2b, 0x30, 0xf8, 0x55, 0x60, 0xf0, + 0xbb, 0xc0, 0xce, 0x45, 0x81, 0xc1, 0x97, 0x19, 0x76, 0x4e, 0x67, 0xd8, 0x39, 0x9b, 0x61, 0xe7, + 0xfd, 0xf6, 0x3f, 0xcc, 0x84, 0x6f, 0x8d, 0xf8, 0x96, 0xb5, 0x1e, 0x77, 0xcd, 0xe4, 0x3e, 0xf9, + 0x13, 0x00, 0x00, 0xff, 0xff, 0x38, 0xda, 0x76, 0x84, 0x04, 0x04, 0x00, 0x00, } func (this *Transaction) Equal(that interface{}) bool { diff --git a/data/transaction/transaction.proto b/data/transaction/transaction.proto index e99597d18..2e8e168d5 100644 --- a/data/transaction/transaction.proto +++ b/data/transaction/transaction.proto @@ -8,7 +8,7 @@ syntax = "proto3"; package proto; -option go_package = "transaction"; +option go_package = "github.com/multiversx/mx-chain-core-go/data/transaction;transaction"; option (gogoproto.stable_marshaler_all) = true; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; diff --git a/data/transaction/transaction_test.go b/data/transaction/transaction_test.go index ed76b2a4d..93151a32e 100644 --- a/data/transaction/transaction_test.go +++ b/data/transaction/transaction_test.go @@ -173,9 +173,9 @@ func TestTransaction_GetDataForSigningMarshalizerErrShouldErr(t *testing.T) { expectedErr := errors.New("expected error") buff, err := tx.GetDataForSigning( &mock.PubkeyConverterStub{ - EncodeCalled: func(pkBytes []byte) string { + EncodeCalled: func(pkBytes []byte) (string, error) { numEncodeCalled++ - return "" + return "", nil }, }, &mock.MarshalizerStub{ @@ -224,9 +224,9 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { hasherWasCalled := false buff, err := tx.GetDataForSigning( &mock.PubkeyConverterStub{ - EncodeCalled: func(pkBytes []byte) string { + EncodeCalled: func(pkBytes []byte) (string, error) { numEncodeCalled++ - return "" + return "", nil }, }, &mock.MarshalizerStub{ @@ -265,9 +265,9 @@ func TestTransaction_GetDataForSigningShouldWork(t *testing.T) { expectedHash := []byte("expectedHash") buff, err := tx.GetDataForSigning( &mock.PubkeyConverterStub{ - EncodeCalled: func(pkBytes []byte) string { + EncodeCalled: func(pkBytes []byte) (string, error) { numEncodeCalled++ - return "" + return "", nil }, }, &mock.MarshalizerStub{ @@ -347,3 +347,12 @@ func TestTransaction_CheckIntegrityShouldErr(t *testing.T) { err = tx.CheckIntegrity() assert.Equal(t, data.ErrInvalidUserNameLength, err) } + +func TestTransaction_ImplementsGuardedTransactionHandler(t *testing.T) { + t.Parallel() + + var tx data.TransactionHandler = &transaction.Transaction{} + + _, ok := tx.(data.GuardedTransactionHandler) + assert.True(t, ok) +} diff --git a/data/vm/vmOutputApi.go b/data/vm/vmOutputApi.go index 68c277b42..f3428b4d9 100644 --- a/data/vm/vmOutputApi.go +++ b/data/vm/vmOutputApi.go @@ -49,10 +49,11 @@ type OutputTransferApi struct { // LogEntryApi is a wrapper over vmcommon's LogEntry type LogEntryApi struct { - Identifier []byte `json:"identifier"` - Address string `json:"address"` - Topics [][]byte `json:"topics"` - Data []byte `json:"data"` + Identifier []byte `json:"identifier"` + Address string `json:"address"` + Topics [][]byte `json:"topics"` + Data []byte `json:"data"` + AdditionalData [][]byte `json:"additionalData"` } // GetFirstReturnData is a helper function that returns the first ReturnData of VMOutput, interpreted as specified. diff --git a/go.mod b/go.mod index 75abb36b0..3dc52a614 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,12 @@ module github.com/multiversx/mx-chain-core-go -go 1.17 +go 1.20 require ( 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 diff --git a/go.sum b/go.sum index c3c008783..c8ab99700 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,6 @@ 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= @@ -47,10 +46,6 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw 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= @@ -83,26 +78,17 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ 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-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= @@ -112,25 +98,13 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w 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/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/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= diff --git a/websocketOutportDriver/data/errors.go b/websocketOutportDriver/data/errors.go deleted file mode 100644 index 41dee246b..000000000 --- a/websocketOutportDriver/data/errors.go +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index b53850a66..000000000 --- a/websocketOutportDriver/data/interface.go +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 893b392b9..000000000 --- a/websocketOutportDriver/data/operations.go +++ /dev/null @@ -1,64 +0,0 @@ -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 deleted file mode 100644 index 414a98cf2..000000000 --- a/websocketOutportDriver/data/shared.go +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index 2bdf8a8dd..000000000 --- a/websocketOutportDriver/factory/factory.go +++ /dev/null @@ -1,126 +0,0 @@ -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 deleted file mode 100644 index 10c31c76f..000000000 --- a/websocketOutportDriver/interface.go +++ /dev/null @@ -1,36 +0,0 @@ -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 deleted file mode 100644 index e9786ec0a..000000000 --- a/websocketOutportDriver/mock/httpServerHandlerStub.go +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 43886ecb8..000000000 --- a/websocketOutportDriver/mock/uint64ByteSliceConverterStub.go +++ /dev/null @@ -1,30 +0,0 @@ -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 deleted file mode 100644 index e475245d6..000000000 --- a/websocketOutportDriver/mock/webSocketSenderStub.go +++ /dev/null @@ -1,42 +0,0 @@ -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 deleted file mode 100644 index 1862e63a3..000000000 --- a/websocketOutportDriver/mock/websocketConnectionStub.go +++ /dev/null @@ -1,35 +0,0 @@ -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 deleted file mode 100644 index 43f682243..000000000 --- a/websocketOutportDriver/payloadParser.go +++ /dev/null @@ -1,154 +0,0 @@ -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 deleted file mode 100644 index 7a97ca7d6..000000000 --- a/websocketOutportDriver/payloadParser_test.go +++ /dev/null @@ -1,148 +0,0 @@ -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 deleted file mode 100644 index f4b5221c0..000000000 --- a/websocketOutportDriver/sender/acknowledgesHolder.go +++ /dev/null @@ -1,52 +0,0 @@ -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 deleted file mode 100644 index 929ecfb67..000000000 --- a/websocketOutportDriver/sender/acknowledgesHolder_test.go +++ /dev/null @@ -1,130 +0,0 @@ -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 deleted file mode 100644 index 9403b0a0b..000000000 --- a/websocketOutportDriver/sender/interface.go +++ /dev/null @@ -1,16 +0,0 @@ -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 deleted file mode 100644 index 9bbfd2730..000000000 --- a/websocketOutportDriver/sender/webSocketSender.go +++ /dev/null @@ -1,249 +0,0 @@ -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 deleted file mode 100644 index b150f733c..000000000 --- a/websocketOutportDriver/sender/webSocketSender_test.go +++ /dev/null @@ -1,213 +0,0 @@ -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 deleted file mode 100644 index d4e7a9e3d..000000000 --- a/websocketOutportDriver/sender/websocketClientAcknowledgesHolder.go +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index f78523ed7..000000000 --- a/websocketOutportDriver/sender/websocketClientAcknowledgesHolder_test.go +++ /dev/null @@ -1,84 +0,0 @@ -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 deleted file mode 100644 index 2e2060087..000000000 --- a/websocketOutportDriver/sender/websocketClientsHolder.go +++ /dev/null @@ -1,60 +0,0 @@ -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 deleted file mode 100644 index 8c06f4e3f..000000000 --- a/websocketOutportDriver/sender/websocketClientsHolder_test.go +++ /dev/null @@ -1,84 +0,0 @@ -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 deleted file mode 100644 index 6af98a7c9..000000000 --- a/websocketOutportDriver/tests/realtest/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# 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 deleted file mode 100644 index b77f2ebb7..000000000 --- a/websocketOutportDriver/tests/realtest/client/bin/main.go +++ /dev/null @@ -1,25 +0,0 @@ -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 deleted file mode 100644 index 730502f63..000000000 --- a/websocketOutportDriver/tests/realtest/client/client.go +++ /dev/null @@ -1,155 +0,0 @@ -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 deleted file mode 100644 index df1393f71..000000000 --- a/websocketOutportDriver/tests/realtest/server/interface.go +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 29641eedb..000000000 --- a/websocketOutportDriver/tests/realtest/server/server.go +++ /dev/null @@ -1,85 +0,0 @@ -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 deleted file mode 100644 index dd374fd63..000000000 --- a/websocketOutportDriver/websocketOutportDriverNodePart.go +++ /dev/null @@ -1,177 +0,0 @@ -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 deleted file mode 100644 index 441f84934..000000000 --- a/websocketOutportDriver/websocketOutportDriverNodePart_test.go +++ /dev/null @@ -1,369 +0,0 @@ -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) -}