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

Index incoming tokens #6736

Open
wants to merge 6 commits into
base: feat/chain-go-sdk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions cmd/node/config/external.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
# ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations", "esdts"]
EnabledIndexes = ["rating", "transactions", "blocks", "validators", "miniblocks", "rounds", "accounts", "accountshistory", "receipts", "scresults", "accountsesdt", "accountsesdthistory", "epochinfo", "scdeploys", "tokens", "tags", "logs", "delegators", "operations", "esdts"]

# MainChainElasticSearchConnector defines settings related to ElasticSearch such as login information or URL
[MainChainElasticSearchConnector]
## We do not recommend to activate this indexer on a validator node since
#the node might lose rating (even facing penalties) due to the fact that
#the indexer is called synchronously and might block due to external causes.
#Strongly suggested to activate this on a regular observer node.
Enabled = false
URL = "http://localhost:9201"
Username = ""
Password = ""

# EventNotifierConnector defines settings needed to configure and launch the event notifier component
# HTTP event notifier connector integration will be DEPRECATED in the following iterations
[EventNotifierConnector]
Expand Down
2 changes: 1 addition & 1 deletion cmd/sovereignnode/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ require (
github.com/multiversx/concurrent-map v0.1.4 // indirect
github.com/multiversx/mx-chain-communication-go v1.1.1 // indirect
github.com/multiversx/mx-chain-crypto-go v1.2.12 // indirect
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20241211094055-23de51462ca4 // indirect
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20250128112625-86bc0754b1e9 // indirect
github.com/multiversx/mx-chain-scenario-go v1.4.4 // indirect
github.com/multiversx/mx-chain-storage-go v1.0.16 // indirect
github.com/multiversx/mx-chain-vm-common-go v1.5.17-0.20241119132002-2fa80c5ec516 // indirect
Expand Down
4 changes: 2 additions & 2 deletions cmd/sovereignnode/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ github.com/multiversx/mx-chain-core-go v1.2.24-0.20241209142414-762196f8dd06 h1:
github.com/multiversx/mx-chain-core-go v1.2.24-0.20241209142414-762196f8dd06/go.mod h1:P/YBoFnt25XUaCQ7Q/SD15vhnc9yV5JDhHxyFO9P8Z0=
github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk=
github.com/multiversx/mx-chain-crypto-go v1.2.12/go.mod h1:HzcPpCm1zanNct/6h2rIh+MFrlXbjA5C8+uMyXj3LI4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20241211094055-23de51462ca4 h1:IfjK6IQy65eMWr/FEv3CMUz13ZqH9sWLnKv85/AoayM=
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20241211094055-23de51462ca4/go.mod h1:i5xoCUsrHteffxx3yfR8bj9tmpP/DtastZGOc/KRAoY=
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20250128112625-86bc0754b1e9 h1:rQL4GS2fLvSHzPqbZ08emtfh+IzMkFJOlwtNenyHtAI=
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20250128112625-86bc0754b1e9/go.mod h1:i5xoCUsrHteffxx3yfR8bj9tmpP/DtastZGOc/KRAoY=
github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc=
github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ=
github.com/multiversx/mx-chain-scenario-go v1.4.4 h1:DVE2V+FPeyD/yWoC+KEfPK3jsFzHeruelESfpTlf460=
Expand Down
1 change: 1 addition & 0 deletions cmd/sovereignnode/sovereignNodeRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,7 @@ func (snr *sovereignNodeRunner) CreateManagedStatusComponents(
StatusCoreComponents: managedStatusCoreComponents,
CryptoComponents: cryptoComponents,
IsSovereign: true,
ESDTPrefix: snr.configs.SystemSCConfig.ESDTSystemSCConfig.ESDTPrefix,
}

statusComponentsFactory, err := statusComp.NewStatusComponentsFactory(statArgs)
Expand Down
15 changes: 12 additions & 3 deletions config/externalConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package config

// ExternalConfig will hold the configurations for external tools, such as Explorer or Elasticsearch
type ExternalConfig struct {
ElasticSearchConnector ElasticSearchConfig
EventNotifierConnector EventNotifierConfig
HostDriversConfig []HostDriversConfig
ElasticSearchConnector ElasticSearchConfig
MainChainElasticSearchConnector MainChainElasticSearchConfig
EventNotifierConnector EventNotifierConfig
HostDriversConfig []HostDriversConfig
}

// ElasticSearchConfig will hold the configuration for the elastic search
Expand All @@ -19,6 +20,14 @@ type ElasticSearchConfig struct {
EnabledIndexes []string
}

// MainChainElasticSearchConfig will hold the configuration for the main chain elastic search
type MainChainElasticSearchConfig struct {
Enabled bool
URL string
Username string
Password string
}

// EventNotifierConfig will hold the configuration for the events notifier driver
type EventNotifierConfig struct {
Enabled bool
Expand Down
13 changes: 13 additions & 0 deletions factory/status/statusComponents.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/multiversx/mx-chain-core-go/core"
"github.com/multiversx/mx-chain-core-go/core/check"
factoryMarshalizer "github.com/multiversx/mx-chain-core-go/marshal/factory"
esFactory "github.com/multiversx/mx-chain-es-indexer-go/process/elasticproc/factory"
indexerFactory "github.com/multiversx/mx-chain-es-indexer-go/process/factory"
logger "github.com/multiversx/mx-chain-logger-go"

Expand Down Expand Up @@ -47,6 +48,7 @@ type StatusComponentsFactoryArgs struct {
CryptoComponents factory.CryptoComponentsHolder
IsInImportMode bool
IsSovereign bool
ESDTPrefix string
}

type statusComponentsFactory struct {
Expand All @@ -64,6 +66,7 @@ type statusComponentsFactory struct {
cryptoComponents factory.CryptoComponentsHolder
isInImportMode bool
isSovereign bool
esdtPrefix string
}

var log = logger.GetOrCreate("factory")
Expand Down Expand Up @@ -109,6 +112,7 @@ func NewStatusComponentsFactory(args StatusComponentsFactoryArgs) (*statusCompon
isInImportMode: args.IsInImportMode,
cryptoComponents: args.CryptoComponents,
isSovereign: args.IsSovereign,
esdtPrefix: args.ESDTPrefix,
}, nil
}

Expand Down Expand Up @@ -218,6 +222,13 @@ func (scf *statusComponentsFactory) createOutportDriver() (outport.OutportHandle

func (scf *statusComponentsFactory) makeElasticIndexerArgs() indexerFactory.ArgsIndexerFactory {
elasticSearchConfig := scf.externalConfig.ElasticSearchConnector
mainChainElastic := esFactory.ElasticConfig{
Enabled: scf.externalConfig.MainChainElasticSearchConnector.Enabled,
Url: scf.externalConfig.MainChainElasticSearchConnector.URL,
UserName: scf.externalConfig.MainChainElasticSearchConnector.Username,
Password: scf.externalConfig.MainChainElasticSearchConnector.Password,
}

return indexerFactory.ArgsIndexerFactory{
Enabled: elasticSearchConfig.Enabled,
BulkRequestMaxSize: elasticSearchConfig.BulkRequestMaxSizeInBytes,
Expand All @@ -234,6 +245,8 @@ func (scf *statusComponentsFactory) makeElasticIndexerArgs() indexerFactory.Args
ImportDB: scf.isInImportMode,
HeaderMarshaller: scf.coreComponents.InternalMarshalizer(),
Sovereign: scf.isSovereign,
ESDTPrefix: scf.esdtPrefix,
MainChainElastic: mainChainElastic,
}
}

Expand Down
1 change: 1 addition & 0 deletions factory/status/statusComponents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func createMockStatusComponentsFactoryArgs() statusComp.StatusComponentsFactoryA
},
IsInImportMode: false,
IsSovereign: false,
ESDTPrefix: "",
}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/multiversx/mx-chain-communication-go v1.1.1
github.com/multiversx/mx-chain-core-go v1.2.24-0.20241209142414-762196f8dd06
github.com/multiversx/mx-chain-crypto-go v1.2.12
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20241211094055-23de51462ca4
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20250128112625-86bc0754b1e9
github.com/multiversx/mx-chain-logger-go v1.0.15
github.com/multiversx/mx-chain-scenario-go v1.4.4
github.com/multiversx/mx-chain-storage-go v1.0.16
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ github.com/multiversx/mx-chain-core-go v1.2.24-0.20241209142414-762196f8dd06 h1:
github.com/multiversx/mx-chain-core-go v1.2.24-0.20241209142414-762196f8dd06/go.mod h1:P/YBoFnt25XUaCQ7Q/SD15vhnc9yV5JDhHxyFO9P8Z0=
github.com/multiversx/mx-chain-crypto-go v1.2.12 h1:zWip7rpUS4CGthJxfKn5MZfMfYPjVjIiCID6uX5BSOk=
github.com/multiversx/mx-chain-crypto-go v1.2.12/go.mod h1:HzcPpCm1zanNct/6h2rIh+MFrlXbjA5C8+uMyXj3LI4=
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20241211094055-23de51462ca4 h1:IfjK6IQy65eMWr/FEv3CMUz13ZqH9sWLnKv85/AoayM=
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20241211094055-23de51462ca4/go.mod h1:i5xoCUsrHteffxx3yfR8bj9tmpP/DtastZGOc/KRAoY=
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20250128112625-86bc0754b1e9 h1:rQL4GS2fLvSHzPqbZ08emtfh+IzMkFJOlwtNenyHtAI=
github.com/multiversx/mx-chain-es-indexer-go v1.7.11-0.20250128112625-86bc0754b1e9/go.mod h1:i5xoCUsrHteffxx3yfR8bj9tmpP/DtastZGOc/KRAoY=
github.com/multiversx/mx-chain-logger-go v1.0.15 h1:HlNdK8etyJyL9NQ+6mIXyKPEBo+wRqOwi3n+m2QIHXc=
github.com/multiversx/mx-chain-logger-go v1.0.15/go.mod h1:t3PRKaWB1M+i6gUfD27KXgzLJJC+mAQiN+FLlL1yoGQ=
github.com/multiversx/mx-chain-scenario-go v1.4.4 h1:DVE2V+FPeyD/yWoC+KEfPK3jsFzHeruelESfpTlf460=
Expand Down
1 change: 1 addition & 0 deletions node/nodeRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ func (nr *nodeRunner) CreateManagedStatusComponents(
StatusCoreComponents: managedStatusCoreComponents,
CryptoComponents: cryptoComponents,
IsSovereign: false,
ESDTPrefix: nr.configs.SystemSCConfig.ESDTSystemSCConfig.ESDTPrefix,
}

statusComponentsFactory, err := statusComp.NewStatusComponentsFactory(statArgs)
Expand Down
1 change: 1 addition & 0 deletions scripts/testnet/include/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ updateNodeConfig() {

if [ $USE_ELASTICSEARCH -eq 1 ]; then
sed -i '/^\[ElasticSearchConnector\]/,/^\[/ s/Enabled *= *false/Enabled = true/' external_observer.toml
sed -i '/^\[MainChainElasticSearchConnector\]/,/^\[/ s/Enabled *= *false/Enabled = true/' external_observer.toml
fi

sed -i '/^\[DbLookupExtensions\]/,/^\[/ s/Enabled *= *false/Enabled = true/' config_observer.toml
Expand Down
1 change: 1 addition & 0 deletions scripts/testnet/sovereignBridge/config/configs.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ WALLET="~/wallet.pem"
WALLET_SOVEREIGN="~/MultiversX/testnet/node/config/walletKey.pem"

#=========== NETWORK CONFIGURATION ===========
MAIN_CHAIN_ELASTIC=https://testnet-index.multiversx.com
PROXY=https://testnet-gateway.multiversx.com
CHAIN_ID=T
PROXY_SOVEREIGN=http://localhost:${PORT_PROXY}
Expand Down
9 changes: 0 additions & 9 deletions scripts/testnet/sovereignBridge/config/deploy.snippets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ sovereignStart() {
$TESTNET_DIR/sovereignStart.sh
}

# This function will restart sovereign:
# - stop sovereign nodes and services
# - deploy sovereign nodes with all services
sovereignRestart() {
stopSovereign

sovereignStart
}

# This function will reset sovereign:
# - stop sovereign nodes and services
# - deploy sovereign nodes with all services
Expand Down
2 changes: 1 addition & 1 deletion scripts/testnet/sovereignBridge/config/py.snippets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ updateSovereignConfig() {
ESDT_PREFIX=$1
fi

python3 $SCRIPT_PATH/pyScripts/update_toml.py $ESDT_SAFE_ADDRESS $ESDT_SAFE_ADDRESS_SOVEREIGN $ESDT_PREFIX
python3 $SCRIPT_PATH/pyScripts/update_toml.py $ESDT_SAFE_ADDRESS $ESDT_SAFE_ADDRESS_SOVEREIGN $ESDT_PREFIX $MAIN_CHAIN_ELASTIC
}

generateRandomEsdtPrefix() {
Expand Down
31 changes: 30 additions & 1 deletion scripts/testnet/sovereignBridge/pyScripts/update_toml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import sys
import re
import sys


def update_subscribed_addresses(lines, section, identifier, main_chain_address) -> []:
Expand Down Expand Up @@ -68,11 +68,37 @@ def update_node_configs(config_path, esdt_prefix, sovereign_chain_address):
update_transfer_and_execute_address(config_path + "/config.toml", sovereign_chain_address)


def update_main_chain_elastic_url(lines, section, key, value):
updated_lines = []
section_found = False

for line in lines:
if line.startswith("[" + section + "]"):
section_found = True
if section_found and key in line:
line = re.sub(rf'({re.escape(key)}\s*=\s*)".*?"', rf'\1"{value}"', line)
section_found = False
updated_lines.append(line)

return updated_lines


def update_external_config(file_path, main_chain_elastic):
with open(file_path, 'r') as file:
lines = file.readlines()

updated_lines = update_main_chain_elastic_url(lines, "MainChainElasticSearchConnector", "URL", main_chain_elastic)

with open(file_path, 'w') as file:
file.writelines(updated_lines)


def main():
# input arguments
main_chain_address = sys.argv[1]
sovereign_chain_address = sys.argv[2]
esdt_prefix = sys.argv[3]
main_chain_elastic = sys.argv[4]

current_path = os.getcwd()
project = 'mx-chain-go'
Expand All @@ -84,6 +110,9 @@ def main():
config_path = project_path + "/cmd/node/config"
update_node_configs(config_path, esdt_prefix, sovereign_chain_address)

external_path = project_path + "/cmd/node/config/external.toml"
update_external_config(external_path, main_chain_elastic)


if __name__ == "__main__":
main()