From bfd48dfa2e7c584484d12fd7d0410dfa30473ff8 Mon Sep 17 00:00:00 2001 From: jules01 Date: Thu, 1 Dec 2022 10:21:51 +0200 Subject: [PATCH 1/3] - added new load keys functionality needed by the multikey feature --- core/constants.go | 3 + core/file.go | 59 +++++++- core/file_test.go | 312 +++++++++++++++++++++++++++-------------- core/keyLoader.go | 25 +++- core/keyLoader_test.go | 77 ++++++++++ core/machineID.go | 6 +- core/machineID_test.go | 4 +- 7 files changed, 363 insertions(+), 123 deletions(-) create mode 100644 core/keyLoader_test.go diff --git a/core/constants.go b/core/constants.go index d57bc6e2f..324123695 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" diff --git a/core/file.go b/core/file.go index 2edf58a23..b6a581cb5 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 @@ -162,16 +165,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 29b09a79b..8464c7a83 100644 --- a/core/file_test.go +++ b/core/file_test.go @@ -5,6 +5,7 @@ import ( "errors" "io/ioutil" "os" + "path/filepath" "strings" "testing" @@ -103,154 +104,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() + assert.Equal(t, core.ErrNilFile, err) + }) + t.Run("should work", func(t *testing.T) { + t.Parallel() - fileName := "testFile12" - file, err := os.Create(fileName) - assert.Nil(t, err) + fileName := filepath.Join(t.TempDir(), "testFile") + file, err := os.Create(fileName) + assert.Nil(t, err) - skBytes := make([]byte, 0) - skBytes = append(skBytes, 10, 20, 30, 40, 50, 60) + skBytes := make([]byte, 0) + skBytes = append(skBytes, 10, 20, 30, 40, 50, 60) - err = core.SaveSkToPemFile(file, "data", skBytes) - if _, errF := os.Stat(fileName); errF == nil { - _ = os.Remove(fileName) - } - - assert.Nil(t, err) + err = core.SaveSkToPemFile(file, "data", skBytes) + assert.Nil(t, err) + }) } func TestCreateFile(t *testing.T) { 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..872b44a08 --- /dev/null +++ b/core/keyLoader_test.go @@ -0,0 +1,77 @@ +package core + +import ( + "os" + "path/filepath" + "testing" + + "github.com/ElrondNetwork/elrond-go-core/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/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)) } From 30b71ec114a213a7c6583a28ddb10dfc8a295c9e Mon Sep 17 00:00:00 2001 From: jules01 Date: Wed, 25 Jan 2023 16:07:43 +0200 Subject: [PATCH 2/3] - fixes after merge --- core/keyLoader_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/keyLoader_test.go b/core/keyLoader_test.go index 872b44a08..7699180e9 100644 --- a/core/keyLoader_test.go +++ b/core/keyLoader_test.go @@ -5,7 +5,7 @@ import ( "path/filepath" "testing" - "github.com/ElrondNetwork/elrond-go-core/core/check" + "github.com/multiversx/mx-chain-core-go/core/check" "github.com/stretchr/testify/assert" ) From e0eb90ae29a54ecbeb48f8bfcf77487aece25017 Mon Sep 17 00:00:00 2001 From: Sorin Stanculeanu Date: Thu, 2 Mar 2023 10:43:22 +0200 Subject: [PATCH 3/3] added topic requests suffix from chain-go --- core/constants.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/constants.go b/core/constants.go index 3ed15b3e9..f6c871266 100644 --- a/core/constants.go +++ b/core/constants.go @@ -254,3 +254,6 @@ const CompletedTxEventIdentifier = "completedTxEvent" // GasRefundForRelayerMessage is the return message for to the smart contract result with refund for the relayer const GasRefundForRelayerMessage = "gas refund for relayer" + +// TopicRequestSuffix represents the topic name suffix for requests +const TopicRequestSuffix = "_REQUEST"