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/elrond-go-storage #4397

Merged
merged 44 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f1d055a
[wip] use elrond-go-storage
bogdan-rosianu Aug 8, 2022
87a659b
fix test
bogdan-rosianu Aug 8, 2022
71ed404
go fmt
bogdan-rosianu Aug 8, 2022
57694f7
removed constants moved into the new repo
bogdan-rosianu Aug 8, 2022
cff3734
fixes + new reference
bogdan-rosianu Aug 8, 2022
0c2ebd6
fix errkeynotfound
bogdan-rosianu Aug 9, 2022
97de57e
fix mock
bogdan-rosianu Aug 9, 2022
5f2e83b
Merge branch 'development' into refer-elrond-go-storage
bogdan-rosianu Aug 9, 2022
ec948c6
fixes after merge
bogdan-rosianu Aug 9, 2022
0d066b0
fix tests
bogdan-rosianu Aug 9, 2022
20e5ca3
fix test
bogdan-rosianu Aug 9, 2022
020dcf7
update golangci linter action
bogdan-rosianu Aug 9, 2022
2c3f76d
go version range
bogdan-rosianu Aug 9, 2022
69f41e7
roll-back go version to v1.17
bogdan-rosianu Aug 9, 2022
2a0130a
Merge branch 'development' into refer-elrond-go-storage
bogdan-rosianu Aug 10, 2022
79ac4e9
fix tests
bogdan-rosianu Aug 10, 2022
19af831
rollback lint issue
bogdan-rosianu Aug 11, 2022
dc313c8
Merge branch 'development' into refer-elrond-go-storage
bogdan-rosianu Aug 11, 2022
16c0ee9
fixes after merge + go fmt
bogdan-rosianu Aug 11, 2022
58bee12
reference new elrond go storage
bogdan-rosianu Aug 11, 2022
243818c
fixes after review
bogdan-rosianu Aug 11, 2022
018294d
refer new commit
bogdan-rosianu Aug 12, 2022
6d9aa55
use tag for elrond go storage
bogdan-rosianu Aug 12, 2022
cca896e
fix go sum
bogdan-rosianu Aug 12, 2022
3dd2132
Merge pull request #4349 from ElrondNetwork/refer-elrond-go-storage
bogdan-rosianu Aug 25, 2022
b287445
move external repo cache dependencies to storage adapter package
AdoAdoAdo Sep 9, 2022
6d038ca
timecache dependencies update
AdoAdoAdo Sep 9, 2022
927071c
storage errors dependencies update
AdoAdoAdo Sep 12, 2022
9b5a7cb
storage txcache dependencies update
AdoAdoAdo Sep 12, 2022
b180e4c
storage unit dependencies update
AdoAdoAdo Sep 12, 2022
b0c0349
storage memorydb dependencies update
AdoAdoAdo Sep 12, 2022
b12139a
move pathmanager and directory handler back to elrond-go
AdoAdoAdo Sep 13, 2022
a12cffa
refactor immunitycache dependencies
AdoAdoAdo Sep 13, 2022
5a31928
cleanup unused constants, comments, types
AdoAdoAdo Sep 14, 2022
0a022bc
remove unused interfaces
AdoAdoAdo Sep 14, 2022
013b2cf
Merge pull request #4453 from ElrondNetwork/wrapper-storage-package
gabi-vuls Sep 15, 2022
52da3a3
Merge branch 'rc/v1.4.0' into merge-rc1.4-feat-elrond-go-storage
AdoAdoAdo Sep 15, 2022
06f259e
updated elrond-go-storage version with some fixes
AdoAdoAdo Sep 16, 2022
28a9823
reference new elrond-go-storage version
AdoAdoAdo Sep 16, 2022
f33c98a
Merge pull request #4473 from ElrondNetwork/merge-rc1.4-feat-elrond-g…
gabi-vuls Sep 19, 2022
aeddd79
Merge branch 'rc/v1.4.0' into merge-v1.4.0-elrond-storage
AdoAdoAdo Sep 19, 2022
1c5dfa7
fix after merge
AdoAdoAdo Sep 19, 2022
2edb60b
fix storageunit reference
AdoAdoAdo Sep 19, 2022
8de041b
Merge pull request #4480 from ElrondNetwork/merge-v1.4.0-elrond-storage
AdoAdoAdo Sep 19, 2022
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
1 change: 1 addition & 0 deletions api/shared/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

var log = logger.GetOrCreate("api/shared/logging")

const thresholdMinAPICallDurationToLog = 200 * time.Millisecond

// LogAPIActionDurationIfNeeded will log the duration of an action triggered by an API call if it's above a threshold
Expand Down
26 changes: 1 addition & 25 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,6 @@ const ConnectionTopic = "connection"
// ValidatorInfoTopic is the topic used for validatorInfo signaling
const ValidatorInfoTopic = "validatorInfo"

// PathShardPlaceholder represents the placeholder for the shard ID in paths
const PathShardPlaceholder = "[S]"

// PathEpochPlaceholder represents the placeholder for the epoch number in paths
const PathEpochPlaceholder = "[E]"

// PathIdentifierPlaceholder represents the placeholder for the identifier in paths
const PathIdentifierPlaceholder = "[I]"

// MetricCurrentRound is the metric for monitoring the current round of a node
const MetricCurrentRound = "erd_current_round"

Expand Down Expand Up @@ -301,7 +292,7 @@ const MetricCreatedProposedBlock = "erd_consensus_created_proposed_block"
// MetricRedundancyLevel is the metric that specifies the redundancy level of the current node
const MetricRedundancyLevel = "erd_redundancy_level"

// MetricRedundancyIsMainActive is the metrics that specifies data about the redundancy main machine
// MetricRedundancyIsMainActive is the metric that specifies data about the redundancy main machine
const MetricRedundancyIsMainActive = "erd_redundancy_is_main_active"

// MetricValueNA represents the value to be used when a metric is not available/applicable
Expand Down Expand Up @@ -683,27 +674,12 @@ const WrongConfiguration = "wrongConfiguration"
// ImportComplete signals that a node restart will be done because the import did complete
const ImportComplete = "importComplete"

// MaxRetriesToCreateDB represents the maximum number of times to try to create DB if it failed
const MaxRetriesToCreateDB = 10

// SleepTimeBetweenCreateDBRetries represents the number of seconds to sleep between DB creates
const SleepTimeBetweenCreateDBRetries = 5 * time.Second

// DefaultStatsPath is the default path where the node stats are logged
const DefaultStatsPath = "stats"

// DefaultDBPath is the default path for nodes databases
const DefaultDBPath = "db"

// DefaultEpochString is the default folder root name for node per epoch databases
const DefaultEpochString = "Epoch"

// DefaultStaticDbString is the default name for the static databases (not changing with epoch)
const DefaultStaticDbString = "Static"

// DefaultShardString is the default folder root name for per shard databases
const DefaultShardString = "Shard"

// MetachainShardName is the string identifier of the metachain shard
const MetachainShardName = "metachain"

Expand Down
4 changes: 2 additions & 2 deletions consensus/broadcast/delayedBroadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/ElrondNetwork/elrond-go/process/factory"
"github.com/ElrondNetwork/elrond-go/sharding"
"github.com/ElrondNetwork/elrond-go/storage"
"github.com/ElrondNetwork/elrond-go/storage/lrucache"
"github.com/ElrondNetwork/elrond-go/storage/cache"
)

const prefixHeaderAlarm = "header_"
Expand Down Expand Up @@ -98,7 +98,7 @@ func NewDelayedBlockBroadcaster(args *ArgsDelayedBlockBroadcaster) (*delayedBloc
return nil, spos.ErrNilAlarmScheduler
}

cacheHeaders, err := lrucache.NewCache(sizeHeadersCache)
cacheHeaders, err := cache.NewLRUCache(sizeHeadersCache)
if err != nil {
return nil, err
}
Expand Down
3 changes: 0 additions & 3 deletions dataRetriever/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package dataRetriever
// TxPoolNumSendersToPreemptivelyEvict instructs tx pool eviction algorithm to remove this many senders when eviction takes place
const TxPoolNumSendersToPreemptivelyEvict = uint32(100)

// TxPoolNumTxsToPreemptivelyEvict instructs tx pool eviction algorithm to remove this many transactions when eviction takes place
const TxPoolNumTxsToPreemptivelyEvict = uint32(1000)

// UnsignedTxPoolName defines the name of the unsigned transactions pool
const UnsignedTxPoolName = "uTxPool"

Expand Down
26 changes: 12 additions & 14 deletions dataRetriever/factory/dataPoolFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ import (
"github.com/ElrondNetwork/elrond-go/process"
"github.com/ElrondNetwork/elrond-go/sharding"
"github.com/ElrondNetwork/elrond-go/storage"
"github.com/ElrondNetwork/elrond-go/storage/cache"
"github.com/ElrondNetwork/elrond-go/storage/disabled"
"github.com/ElrondNetwork/elrond-go/storage/factory"
"github.com/ElrondNetwork/elrond-go/storage/lrucache/capacity"
"github.com/ElrondNetwork/elrond-go/storage/storageCacherAdapter"
"github.com/ElrondNetwork/elrond-go/storage/storageUnit"
"github.com/ElrondNetwork/elrond-go/storage/timecache"
"github.com/ElrondNetwork/elrond-go/storage/storageunit"
trieFactory "github.com/ElrondNetwork/elrond-go/trie/factory"
)

Expand Down Expand Up @@ -88,18 +86,18 @@ func NewDataPoolFromConfig(args ArgsDataPool) (dataRetriever.PoolsHolder, error)
}

cacherCfg := factory.GetCacherFromConfig(mainConfig.TxBlockBodyDataPool)
txBlockBody, err := storageUnit.NewCache(cacherCfg)
txBlockBody, err := storageunit.NewCache(cacherCfg)
if err != nil {
return nil, fmt.Errorf("%w while creating the cache for the miniblocks", err)
}

cacherCfg = factory.GetCacherFromConfig(mainConfig.PeerBlockBodyDataPool)
peerChangeBlockBody, err := storageUnit.NewCache(cacherCfg)
peerChangeBlockBody, err := storageunit.NewCache(cacherCfg)
if err != nil {
return nil, fmt.Errorf("%w while creating the cache for the peer mini block body", err)
}

cacher, err := capacity.NewCapacityLRU(
cacher, err := cache.NewCapacityLRU(
int(mainConfig.TrieSyncStorage.Capacity),
int64(mainConfig.TrieSyncStorage.SizeInBytes),
)
Expand All @@ -113,24 +111,24 @@ func NewDataPoolFromConfig(args ArgsDataPool) (dataRetriever.PoolsHolder, error)
}

tnf := trieFactory.NewTrieNodeFactory()
adaptedTrieNodesStorage, err := storageCacherAdapter.NewStorageCacherAdapter(cacher, trieSyncDB, tnf, args.Marshalizer)
adaptedTrieNodesStorage, err := storageunit.NewStorageCacherAdapter(cacher, trieSyncDB, tnf, args.Marshalizer)
if err != nil {
return nil, fmt.Errorf("%w while creating the adapter for the trie nodes", err)
}

cacherCfg = factory.GetCacherFromConfig(mainConfig.TrieNodesChunksDataPool)
trieNodesChunks, err := storageUnit.NewCache(cacherCfg)
trieNodesChunks, err := storageunit.NewCache(cacherCfg)
if err != nil {
return nil, fmt.Errorf("%w while creating the cache for the trie chunks", err)
}

cacherCfg = factory.GetCacherFromConfig(mainConfig.SmartContractDataPool)
smartContracts, err := storageUnit.NewCache(cacherCfg)
smartContracts, err := storageunit.NewCache(cacherCfg)
if err != nil {
return nil, fmt.Errorf("%w while creating the cache for the smartcontract results", err)
}

peerAuthPool, err := timecache.NewTimeCacher(timecache.ArgTimeCacher{
peerAuthPool, err := cache.NewTimeCacher(cache.ArgTimeCacher{
DefaultSpan: time.Duration(mainConfig.HeartbeatV2.PeerAuthenticationTimeBetweenSendsInSec) * time.Second * peerAuthExpiryMultiplier,
CacheExpiry: peerAuthenticationCacheRefresh,
})
Expand All @@ -139,7 +137,7 @@ func NewDataPoolFromConfig(args ArgsDataPool) (dataRetriever.PoolsHolder, error)
}

cacherCfg = factory.GetCacherFromConfig(mainConfig.HeartbeatV2.HeartbeatPool)
heartbeatPool, err := storageUnit.NewCache(cacherCfg)
heartbeatPool, err := storageunit.NewCache(cacherCfg)
if err != nil {
return nil, fmt.Errorf("%w while creating the cache for the heartbeat messages", err)
}
Expand Down Expand Up @@ -180,7 +178,7 @@ func createTrieSyncDB(args ArgsDataPool) (storage.Persister, error) {

dbCfg := factory.GetDBFromConfig(mainConfig.TrieSyncStorage.DB)
shardId := core.GetShardIDString(args.ShardCoordinator.SelfId())
argDB := storageUnit.ArgDB{
argDB := storageunit.ArgDB{
DBType: dbCfg.Type,
Path: args.PathManager.PathForStatic(shardId, mainConfig.TrieSyncStorage.DB.FilePath),
BatchDelaySeconds: dbCfg.BatchDelaySeconds,
Expand All @@ -197,7 +195,7 @@ func createTrieSyncDB(args ArgsDataPool) (storage.Persister, error) {
argDB.Path = filePath
}

db, err := storageUnit.NewDB(argDB)
db, err := storageunit.NewDB(argDB)
if err != nil {
return nil, fmt.Errorf("%w while creating the db for the trie nodes", err)
}
Expand Down
6 changes: 3 additions & 3 deletions dataRetriever/requestHandlers/requestHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/ElrondNetwork/elrond-go/common"
"github.com/ElrondNetwork/elrond-go/dataRetriever"
"github.com/ElrondNetwork/elrond-go/dataRetriever/mock"
"github.com/ElrondNetwork/elrond-go/storage/timecache"
cache "github.com/ElrondNetwork/elrond-go/storage/cache"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -203,14 +203,14 @@ func TestResolverRequestHandler_RequestTransactionShouldRequest4TimesIfDifferent
}

timeSpan := time.Second
cache := timecache.NewTimeCache(timeSpan)
timeCache := cache.NewTimeCache(timeSpan)
rrh, _ := NewResolverRequestHandler(
&mock.ResolversFinderStub{
CrossShardResolverCalled: func(baseTopic string, crossShard uint32) (resolver dataRetriever.Resolver, e error) {
return txResolver, nil
},
},
cache,
timeCache,
&mock.WhiteListHandlerStub{},
1,
0,
Expand Down
24 changes: 12 additions & 12 deletions dataRetriever/shardedData/shardedData.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
logger "github.com/ElrondNetwork/elrond-go-logger"
"github.com/ElrondNetwork/elrond-go/dataRetriever"
"github.com/ElrondNetwork/elrond-go/storage"
"github.com/ElrondNetwork/elrond-go/storage/immunitycache"
"github.com/ElrondNetwork/elrond-go/storage/storageUnit"
"github.com/ElrondNetwork/elrond-go/storage/cache"
"github.com/ElrondNetwork/elrond-go/storage/storageunit"
)

var log = logger.GetOrCreate("dataretriever/shardeddata")
Expand All @@ -32,7 +32,7 @@ type shardedData struct {
// Each key represents a destination shard id and the value will contain all
// data hashes that have that shard as destination
shardedDataStore map[string]*shardStore
configPrototype immunitycache.CacheConfig
configPrototype cache.CacheConfig

mutAddedDataHandlers sync.RWMutex
addedDataHandlers []func(key []byte, value interface{})
Expand All @@ -44,15 +44,15 @@ type shardStore struct {
}

// NewShardedData is responsible for creating an empty pool of data
func NewShardedData(name string, config storageUnit.CacheConfig) (*shardedData, error) {
func NewShardedData(name string, config storageunit.CacheConfig) (*shardedData, error) {
log.Debug("NewShardedData", "name", name, "config", config.String())

configPrototype := immunitycache.CacheConfig{
configPrototype := cache.CacheConfig{
Name: untitledCacheName,
NumChunks: config.Shards,
MaxNumItems: config.Capacity,
MaxNumBytes: uint32(config.SizeInBytes),
NumItemsToPreemptivelyEvict: dataRetriever.TxPoolNumTxsToPreemptivelyEvict,
NumItemsToPreemptivelyEvict: storage.TxPoolNumTxsToPreemptivelyEvict,
}

err := configPrototype.Verify()
Expand Down Expand Up @@ -128,14 +128,14 @@ func (sd *shardedData) addShardStoreNoLock(cacheID string) *shardStore {
func (sd *shardedData) newShardStore(cacheID string) (*shardStore, error) {
config := sd.configPrototype
config.Name = fmt.Sprintf("%s:%s", sd.name, cacheID)
cache, err := immunitycache.NewImmunityCache(config)
newImmunityCache, err := cache.NewImmunityCache(config)
if err != nil {
return nil, err
}

return &shardStore{
cacheID: cacheID,
cache: cache,
cache: newImmunityCache,
}, nil
}

Expand Down Expand Up @@ -263,8 +263,8 @@ func (sd *shardedData) Keys() [][]byte {

keys := make([][]byte, 0)
for _, shard := range sd.shardedDataStore {
cache := shard.cache
keys = append(keys, cache.Keys()...)
c := shard.cache
keys = append(keys, c.Keys()...)
}

return keys
Expand All @@ -278,8 +278,8 @@ func (sd *shardedData) GetCounts() counting.CountsWithSize {
counts := counting.NewConcurrentShardedCountsWithSize()

for cacheID, shard := range sd.shardedDataStore {
cache := shard.cache
counts.PutCounts(cacheID, int64(cache.Len()), int64(cache.NumBytes()))
c := shard.cache
counts.PutCounts(cacheID, int64(c.Len()), int64(c.NumBytes()))
}

return counts
Expand Down
6 changes: 3 additions & 3 deletions dataRetriever/shardedData/shardedData_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (

"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-core/data/transaction"
"github.com/ElrondNetwork/elrond-go/storage/storageUnit"
"github.com/ElrondNetwork/elrond-go/storage/storageunit"
"github.com/stretchr/testify/assert"
)

var timeoutWaitForWaitGroups = time.Second * 2

var defaultTestConfig = storageUnit.CacheConfig{
var defaultTestConfig = storageunit.CacheConfig{
Capacity: 75000,
SizeInBytes: 104857600,
Shards: 1,
Expand All @@ -25,7 +25,7 @@ var defaultTestConfig = storageUnit.CacheConfig{
func TestNewShardedData_BadConfigShouldErr(t *testing.T) {
t.Parallel()

cacheConfigBad := storageUnit.CacheConfig{
cacheConfigBad := storageunit.CacheConfig{
Capacity: 0,
}

Expand Down
4 changes: 2 additions & 2 deletions dataRetriever/txpool/argShardedTxPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (

"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go/dataRetriever"
"github.com/ElrondNetwork/elrond-go/storage/storageUnit"
"github.com/ElrondNetwork/elrond-go/storage/storageunit"
"github.com/ElrondNetwork/elrond-go/storage/txcache"
)

// ArgShardedTxPool is the argument for ShardedTxPool's constructor
type ArgShardedTxPool struct {
Config storageUnit.CacheConfig
Config storageunit.CacheConfig
TxGasHandler txcache.TxGasHandler
NumberOfShards uint32
SelfShardID uint32
Expand Down
8 changes: 5 additions & 3 deletions dataRetriever/txpool/memorytests/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/ElrondNetwork/elrond-go-core/data/transaction"
"github.com/ElrondNetwork/elrond-go/dataRetriever"
"github.com/ElrondNetwork/elrond-go/dataRetriever/txpool"
"github.com/ElrondNetwork/elrond-go/storage/storageUnit"
"github.com/ElrondNetwork/elrond-go/storage/storageunit"
"github.com/ElrondNetwork/elrond-go/testscommon/txcachemocks"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -101,7 +101,7 @@ type memoryAssertion struct {
}

func newPool() dataRetriever.ShardedDataCacherNotifier {
config := storageUnit.CacheConfig{
config := storageunit.CacheConfig{
Capacity: 600000,
SizePerSender: 60000,
SizeInBytes: 400 * core.MegabyteSize,
Expand Down Expand Up @@ -229,7 +229,9 @@ func pprofHeap(scenario *scenario, step string) {

defer func() {
errClose := file.Close()
panic(fmt.Sprintf("cannot close file: %s", errClose.Error()))
if errClose != nil {
panic(fmt.Sprintf("cannot close file: %s", errClose.Error()))
}
}()

err = pprof.WriteHeapProfile(file)
Expand Down
2 changes: 1 addition & 1 deletion dataRetriever/txpool/shardedTxPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewShardedTxPool(args ArgShardedTxPool) (*shardedTxPool, error) {
NumChunks: args.Config.Shards,
MaxNumBytes: uint32(halfOfSizeInBytes) / numCrossTxCaches,
MaxNumItems: halfOfCapacity / numCrossTxCaches,
NumItemsToPreemptivelyEvict: dataRetriever.TxPoolNumTxsToPreemptivelyEvict,
NumItemsToPreemptivelyEvict: storage.TxPoolNumTxsToPreemptivelyEvict,
}

shardedTxPoolObject := &shardedTxPool{
Expand Down
Loading