Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feat/sovereign #259

Draft
wants to merge 48 commits into
base: rc/v1.7.next1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
6915b47
add sovereign header type
bogdan-rosianu Sep 28, 2023
96fb367
update core commit hash
bogdan-rosianu Sep 29, 2023
98a3964
update vm common commit hash
bogdan-rosianu Sep 29, 2023
d7fa746
Merge pull request #250 from multiversx/add-sovereign-header-type
mariusmihaic Oct 4, 2023
4cb6f3e
ignore scrs with no original tx hash
miiu96 Oct 5, 2023
225bc17
Merge pull request #251 from multiversx/ignore-scrs-no-original-tx-hash
mariusmihaic Oct 5, 2023
65fd3d9
remove metachain check
miiu96 Oct 6, 2023
57a0698
remove unit test
miiu96 Oct 11, 2023
2353c69
Merge pull request #252 from multiversx/remove-meta-check
mariusmihaic Jan 18, 2024
4a2cd80
Merge branch 'master' into merge-master-into-sovereign-30-jan-2024
mariusmihaic Jan 30, 2024
51a477e
FEAT: Update dependencies
mariusmihaic Jan 30, 2024
5eb1849
Merge pull request #262 from multiversx/merge-master-into-sovereign-3…
mariusmihaic Jan 30, 2024
fc27514
Merge branch 'rc/v1.7.next1' into merge-rc-v1-7-next-into-sovereign-1…
mariusmihaic May 14, 2024
92975ee
FIX: go mod
mariusmihaic May 14, 2024
62fd4fa
Merge pull request #279 from multiversx/merge-rc-v1-7-next-into-sover…
mariusmihaic May 15, 2024
2e10fe5
fix mappings
miiu96 Sep 5, 2024
17f4760
Merge pull request #295 from multiversx/fix-token-type-mappings
axenteoctavian Sep 6, 2024
7dc6e64
Merge branch 'master' into merge-master-into-feat-sovereign-9-oct-2024
mariusmihaic Oct 9, 2024
f37745c
FIX: go mod
mariusmihaic Oct 9, 2024
cbc1607
Merge branch 'rc/v1.7.next1' into merge-master-into-feat-sovereign-9-…
mariusmihaic Oct 9, 2024
7b5c180
FIX: go mod 2
mariusmihaic Oct 9, 2024
e1ddfdb
Merge pull request #299 from multiversx/merge-master-into-feat-sovere…
mariusmihaic Oct 11, 2024
8f3ff23
Merge branch 'rc/v1.7.next1' into merge-rc-1-7-next-into-sovereign-11…
axenteoctavian Nov 11, 2024
cbffebf
Merge pull request #303 from multiversx/merge-rc-1-7-next-into-sovere…
axenteoctavian Nov 11, 2024
641a7d1
run type components implementation
axenteoctavian Dec 3, 2024
92a42d0
sovereign flag
axenteoctavian Dec 4, 2024
b74e23e
tx hashes extractor implementation
axenteoctavian Dec 4, 2024
d4734ca
unit test fixes
axenteoctavian Dec 5, 2024
da7a422
reward tx data in run type components
axenteoctavian Dec 5, 2024
c1c08ba
reward tx data in run type components fixes
axenteoctavian Dec 5, 2024
81a630f
comments fixes
axenteoctavian Dec 5, 2024
d74e00e
Merge branch 'MX-16238-tx-hash-extractor' into MX-16244-transaction-s…
axenteoctavian Dec 5, 2024
6f08221
fixes after self review
axenteoctavian Dec 5, 2024
948c8fc
fixes after self review
axenteoctavian Dec 5, 2024
bba9bb6
Merge branch 'MX-16238-tx-hash-extractor' into MX-16244-transaction-s…
axenteoctavian Dec 5, 2024
d1394c4
integration tests fixes
axenteoctavian Dec 5, 2024
7ee3615
fix after review
axenteoctavian Dec 6, 2024
5c50ac4
fixes after review, refactor
axenteoctavian Dec 6, 2024
0623a0c
Merge branch 'MX-16233-sovereign-flag' into MX-16238-tx-hash-extractor
axenteoctavian Dec 6, 2024
a6f176c
fixes after review
axenteoctavian Dec 6, 2024
1c39a58
Merge branch 'MX-16238-tx-hash-extractor' into MX-16244-transaction-s…
axenteoctavian Dec 6, 2024
26330fc
fixes after review
axenteoctavian Dec 6, 2024
e3add43
fixes after review
axenteoctavian Dec 9, 2024
9ca95d3
renaming to Sovereign
axenteoctavian Dec 11, 2024
b30e362
Merge pull request #312 from multiversx/MX-16233-runtype-components
axenteoctavian Dec 11, 2024
417430d
Merge pull request #314 from multiversx/MX-16233-sovereign-flag
axenteoctavian Dec 11, 2024
4c6d164
Merge pull request #315 from multiversx/MX-16238-tx-hash-extractor
axenteoctavian Dec 11, 2024
23de514
Merge pull request #317 from multiversx/MX-16244-transaction-sender
axenteoctavian Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/elasticindexer/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ var (
Name: "disable-ansi-color",
Usage: "Boolean option for disabling ANSI colors in the logging system.",
}
// sovereign defines a flag that specifies if the es instance should run for a sovereign chain
sovereign = cli.BoolFlag{
Name: "sovereign",
Usage: "If set to true, will use sovereign run type components",
}
)
9 changes: 6 additions & 3 deletions cmd/elasticindexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import (
"github.com/multiversx/mx-chain-core-go/core/check"
"github.com/multiversx/mx-chain-core-go/core/closing"
"github.com/multiversx/mx-chain-core-go/data/outport"
logger "github.com/multiversx/mx-chain-logger-go"
"github.com/multiversx/mx-chain-logger-go/file"
"github.com/urfave/cli"

"github.com/multiversx/mx-chain-es-indexer-go/config"
"github.com/multiversx/mx-chain-es-indexer-go/factory"
"github.com/multiversx/mx-chain-es-indexer-go/metrics"
"github.com/multiversx/mx-chain-es-indexer-go/process/wsindexer"
logger "github.com/multiversx/mx-chain-logger-go"
"github.com/multiversx/mx-chain-logger-go/file"
"github.com/urfave/cli"
)

var (
Expand Down Expand Up @@ -63,6 +64,7 @@ func main() {
logLevel,
logSaveFile,
disableAnsiColor,
sovereign,
}
app.Authors = []cli.Author{
{
Expand All @@ -86,6 +88,7 @@ func startIndexer(ctx *cli.Context) error {
if err != nil {
return fmt.Errorf("%w while loading the config file", err)
}
cfg.Sovereign = ctx.GlobalBool(sovereign.Name)

clusterCfg, err := loadClusterConfig(ctx.GlobalString(configurationPreferencesFile.Name))
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
LogsPath string `toml:"logs-path"`
} `toml:"logs"`
} `toml:"config"`
Sovereign bool
}

// ClusterConfig will hold the config for the Elasticsearch cluster
Expand Down
7 changes: 7 additions & 0 deletions factory/runType/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package runType

import (
"errors"
)

var errNilRunTypeComponents = errors.New("nil run type components")
36 changes: 36 additions & 0 deletions factory/runType/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package runType

import (
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/transactions"
)

// RunTypeComponentsCreator is the interface for creating run type components
type RunTypeComponentsCreator interface {
Create() *runTypeComponents
IsInterfaceNil() bool
}

// ComponentHandler defines the actions common to all component handlers
type ComponentHandler interface {
Create() error
Close() error
CheckSubcomponents() error
String() string
}

// RunTypeComponentsHandler defines the run type components handler actions
type RunTypeComponentsHandler interface {
ComponentHandler
RunTypeComponentsHolder
}

// RunTypeComponentsHolder holds the run type components
type RunTypeComponentsHolder interface {
TxHashExtractorCreator() transactions.TxHashExtractor
RewardTxDataCreator() transactions.RewardTxDataHandler
Create() error
Close() error
CheckSubcomponents() error
String() string
IsInterfaceNil() bool
}
20 changes: 20 additions & 0 deletions factory/runType/runTypeComponents.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package runType

import (
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/transactions"
)

type runTypeComponents struct {
txHashExtractor transactions.TxHashExtractor
rewardTxData transactions.RewardTxDataHandler
}

// Close does nothing
func (rtc *runTypeComponents) Close() error {
return nil
}

// IsInterfaceNil returns true if there is no value under the interface
func (rtc *runTypeComponents) IsInterfaceNil() bool {
return rtc == nil
}
25 changes: 25 additions & 0 deletions factory/runType/runTypeComponentsFactory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package runType

import (
"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/transactions"
)

type runTypeComponentsFactory struct{}

// NewRunTypeComponentsFactory will return a new instance of run type components factory
func NewRunTypeComponentsFactory() *runTypeComponentsFactory {
return &runTypeComponentsFactory{}
}

// Create will create the run type components
func (rtcf *runTypeComponentsFactory) Create() *runTypeComponents {
return &runTypeComponents{
txHashExtractor: transactions.NewTxHashExtractor(),
rewardTxData: transactions.NewRewardTxData(),
}
}

// IsInterfaceNil returns true if there is no value under the interface
func (rtcf *runTypeComponentsFactory) IsInterfaceNil() bool {
return rtcf == nil
}
113 changes: 113 additions & 0 deletions factory/runType/runTypeComponentsHandler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package runType

import (
"sync"

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

"github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/transactions"
)

const runTypeComponentsName = "managedRunTypeComponents"

var _ ComponentHandler = (*managedRunTypeComponents)(nil)
var _ RunTypeComponentsHandler = (*managedRunTypeComponents)(nil)
var _ RunTypeComponentsHolder = (*managedRunTypeComponents)(nil)

type managedRunTypeComponents struct {
*runTypeComponents
factory RunTypeComponentsCreator
mutRunTypeCoreComponents sync.RWMutex
}

// NewManagedRunTypeComponents returns a news instance of managed runType core components
func NewManagedRunTypeComponents(rtc RunTypeComponentsCreator) (*managedRunTypeComponents, error) {
if rtc == nil {
return nil, errNilRunTypeComponents
}

return &managedRunTypeComponents{
runTypeComponents: nil,
factory: rtc,
}, nil
}

// Create will create the managed components
func (mrtc *managedRunTypeComponents) Create() error {
rtc := mrtc.factory.Create()

mrtc.mutRunTypeCoreComponents.Lock()
mrtc.runTypeComponents = rtc
mrtc.mutRunTypeCoreComponents.Unlock()

return nil
}

// Close will close all underlying subcomponents
func (mrtc *managedRunTypeComponents) Close() error {
mrtc.mutRunTypeCoreComponents.Lock()
defer mrtc.mutRunTypeCoreComponents.Unlock()

if check.IfNil(mrtc.runTypeComponents) {
return nil
}

err := mrtc.runTypeComponents.Close()
if err != nil {
return err
}
mrtc.runTypeComponents = nil

return nil
}

// CheckSubcomponents verifies all subcomponents
func (mrtc *managedRunTypeComponents) CheckSubcomponents() error {
mrtc.mutRunTypeCoreComponents.RLock()
defer mrtc.mutRunTypeCoreComponents.RUnlock()

if check.IfNil(mrtc.runTypeComponents) {
return errNilRunTypeComponents
}
if check.IfNil(mrtc.txHashExtractor) {
return transactions.ErrNilTxHashExtractor
}
if check.IfNil(mrtc.rewardTxData) {
return transactions.ErrNilRewardTxDataHandler
}
return nil
}

// TxHashExtractorCreator returns tx hash extractor
func (mrtc *managedRunTypeComponents) TxHashExtractorCreator() transactions.TxHashExtractor {
mrtc.mutRunTypeCoreComponents.Lock()
defer mrtc.mutRunTypeCoreComponents.Unlock()

if check.IfNil(mrtc.runTypeComponents) {
return nil
}

return mrtc.runTypeComponents.txHashExtractor
}

// RewardTxDataCreator return reward tx handler
func (mrtc *managedRunTypeComponents) RewardTxDataCreator() transactions.RewardTxDataHandler {
mrtc.mutRunTypeCoreComponents.Lock()
defer mrtc.mutRunTypeCoreComponents.Unlock()

if check.IfNil(mrtc.runTypeComponents) {
return nil
}

return mrtc.runTypeComponents.rewardTxData
}

// IsInterfaceNil returns true if the interface is nil
func (mrtc *managedRunTypeComponents) IsInterfaceNil() bool {
return mrtc == nil
}

// String returns the name of the component
func (mrtc *managedRunTypeComponents) String() string {
return runTypeComponentsName
}
80 changes: 80 additions & 0 deletions factory/runType/runTypeComponentsHandler_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package runType

import (
"testing"

"github.com/stretchr/testify/require"
)

func createComponents() (RunTypeComponentsHandler, error) {
rtcf := NewRunTypeComponentsFactory()
return NewManagedRunTypeComponents(rtcf)
}

func TestNewManagedRunTypeComponents(t *testing.T) {
t.Parallel()

t.Run("should error", func(t *testing.T) {
managedRunTypeComponents, err := NewManagedRunTypeComponents(nil)
require.ErrorIs(t, err, errNilRunTypeComponents)
require.Nil(t, managedRunTypeComponents)
})
t.Run("should work", func(t *testing.T) {
rtcf := NewRunTypeComponentsFactory()
managedRunTypeComponents, err := NewManagedRunTypeComponents(rtcf)
require.NoError(t, err)
require.False(t, managedRunTypeComponents.IsInterfaceNil())
})
}

func TestManagedRunTypeComponents_Create(t *testing.T) {
t.Parallel()

t.Run("should work with getters", func(t *testing.T) {
t.Parallel()

managedRunTypeComponents, err := createComponents()
require.NoError(t, err)

require.Nil(t, managedRunTypeComponents.TxHashExtractorCreator())
require.Nil(t, managedRunTypeComponents.RewardTxDataCreator())

err = managedRunTypeComponents.Create()
require.NoError(t, err)

require.NotNil(t, managedRunTypeComponents.TxHashExtractorCreator())
require.NotNil(t, managedRunTypeComponents.RewardTxDataCreator())

require.Equal(t, runTypeComponentsName, managedRunTypeComponents.String())
require.NoError(t, managedRunTypeComponents.Close())
})
}

func TestManagedRunTypeComponents_Close(t *testing.T) {
t.Parallel()

managedRunTypeComponents, _ := createComponents()
require.NoError(t, managedRunTypeComponents.Close())

err := managedRunTypeComponents.Create()
require.NoError(t, err)

require.NoError(t, managedRunTypeComponents.Close())
}

func TestManagedRunTypeComponents_CheckSubcomponents(t *testing.T) {
t.Parallel()

managedRunTypeComponents, _ := createComponents()
err := managedRunTypeComponents.CheckSubcomponents()
require.Equal(t, errNilRunTypeComponents, err)

err = managedRunTypeComponents.Create()
require.NoError(t, err)

//TODO check for nil each subcomponent - MX-15371
err = managedRunTypeComponents.CheckSubcomponents()
require.NoError(t, err)

require.NoError(t, managedRunTypeComponents.Close())
}
38 changes: 38 additions & 0 deletions factory/runType/runTypeComponents_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package runType

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestNewRunTypeComponentsFactory(t *testing.T) {
t.Parallel()

t.Run("should work", func(t *testing.T) {
rtc := NewRunTypeComponentsFactory()
require.NotNil(t, rtc)
})
}

func TestRunTypeComponentsFactory_Create(t *testing.T) {
t.Parallel()

rtcf := NewRunTypeComponentsFactory()
require.NotNil(t, rtcf)

rtc := rtcf.Create()
require.NotNil(t, rtc)
}

func TestRunTypeComponentsFactory_Close(t *testing.T) {
t.Parallel()

rtcf := NewRunTypeComponentsFactory()
require.NotNil(t, rtcf)

rtc := rtcf.Create()
require.NotNil(t, rtc)

require.NoError(t, rtc.Close())
}
Loading
Loading