Skip to content

Commit

Permalink
fixes after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
axenteoctavian committed Jan 31, 2025
1 parent 61368ea commit 8fbcfd6
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 34 deletions.
106 changes: 103 additions & 3 deletions cmd/sovereignnode/config/enableEpochs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@
# ValidatorToDelegationEnableEpoch represents the epoch when the validator-to-delegation feature will be enabled
ValidatorToDelegationEnableEpoch = 0

# WaitingListFixEnableEpoch represents the epoch when the 6 epoch waiting list fix is enabled
WaitingListFixEnableEpoch = 0

# IncrementSCRNonceInMultiTransferEnableEpoch represents the epoch when the fix for preventing the generation of the same SCRs
# is enabled. The fix is done by adding an extra increment.
IncrementSCRNonceInMultiTransferEnableEpoch = 0
Expand Down Expand Up @@ -239,6 +236,109 @@
# RuntimeCodeSizeFixEnableEpoch represents the epoch when the code size fix in the VM is enabled
RuntimeCodeSizeFixEnableEpoch = 0

# RelayedNonceFixEnableEpoch represents the epoch when the nonce fix for relayed txs is enabled
RelayedNonceFixEnableEpoch = 0

# SetGuardianEnableEpoch represents the epoch when the guard account feature is enabled in the protocol
SetGuardianEnableEpoch = 0

# DeterministicSortOnValidatorsInfoEnableEpoch represents the epoch when the deterministic sorting on validators info is enabled
DeterministicSortOnValidatorsInfoEnableEpoch = 0

# SCProcessorV2EnableEpoch represents the epoch when SC processor V2 will be used
SCProcessorV2EnableEpoch = 0

# AutoBalanceDataTriesEnableEpoch represents the epoch when the data tries are automatically balanced by inserting at the hashed key instead of the normal key
AutoBalanceDataTriesEnableEpoch = 0

# MigrateDataTrieEnableEpoch represents the epoch when the data tries migration is enabled
MigrateDataTrieEnableEpoch = 0

# KeepExecOrderOnCreatedSCRsEnableEpoch represents the epoch when the execution order of created SCRs is ensured
KeepExecOrderOnCreatedSCRsEnableEpoch = 0

# MultiClaimOnDelegationEnableEpoch represents the epoch when the multi claim on delegation is enabled
MultiClaimOnDelegationEnableEpoch = 0

# ChangeUsernameEnableEpoch represents the epoch when changing username is enabled
ChangeUsernameEnableEpoch = 0

# ConsistentTokensValuesLengthCheckEnableEpoch represents the epoch when the consistent tokens values length check is enabled
ConsistentTokensValuesLengthCheckEnableEpoch = 0

# FixDelegationChangeOwnerOnAccountEnableEpoch represents the epoch when the fix for the delegation system smart contract is enabled
FixDelegationChangeOwnerOnAccountEnableEpoch = 0

# DynamicGasCostForDataTrieStorageLoadEnableEpoch represents the epoch when dynamic gas cost for data trie storage load will be enabled
DynamicGasCostForDataTrieStorageLoadEnableEpoch = 0

# ScToScLogEventEnableEpoch represents the epoch when the sc to sc log event feature is enabled
ScToScLogEventEnableEpoch = 0

# NFTStopCreateEnableEpoch represents the epoch when NFT stop create feature is enabled
NFTStopCreateEnableEpoch = 0

# ChangeOwnerAddressCrossShardThroughSCEnableEpoch represents the epoch when the change owner address built in function will work also through a smart contract call cross shard
ChangeOwnerAddressCrossShardThroughSCEnableEpoch = 0

# FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch represents the epoch when the fix for the remaining gas in the SaveKeyValue builtin function is enabled
FixGasRemainingForSaveKeyValueBuiltinFunctionEnableEpoch = 0

# CurrentRandomnessOnSortingEnableEpoch represents the epoch when the current randomness on sorting is enabled
CurrentRandomnessOnSortingEnableEpoch = 0

# StakeLimitsEnableEpoch represents the epoch when stake limits on validators are enabled
# Should have the same value as StakingV4Step1EnableEpoch that triggers the automatic unstake operations for the queue nodes
StakeLimitsEnableEpoch = 0

# StakingV4Step1EnableEpoch represents the epoch when staking v4 is initialized. This is the epoch in which
# all nodes from staking queue are moved in the auction list
StakingV4Step1EnableEpoch = 0

# StakingV4Step2EnableEpoch represents the epoch when staking v4 is enabled. Should have a greater value than StakingV4Step1EnableEpoch.
# From this epoch, all shuffled out nodes are moved to auction nodes. No auction nodes selection is done yet.
StakingV4Step2EnableEpoch = 0

# StakingV4Step3EnableEpoch represents the epoch in which selected nodes from auction will be distributed to waiting list
StakingV4Step3EnableEpoch = 0

# CleanupAuctionOnLowWaitingListEnableEpoch represents the epoch when duplicated data cleanup from auction list is enabled in the condition of a low waiting list
# Should have the same value as StakingV4Step1EnableEpoch if the low waiting list has not happened, otherwise should have a greater value
CleanupAuctionOnLowWaitingListEnableEpoch = 0

# AlwaysMergeContextsInEEIEnableEpoch represents the epoch in which the EEI will always merge the contexts
AlwaysMergeContextsInEEIEnableEpoch = 0

# UseGasBoundedShouldFailExecutionEnableEpoch represents the epoch when use bounded gas function should fail execution in case of error
UseGasBoundedShouldFailExecutionEnableEpoch = 0

# DynamicESDTEnableEpoch represents the epoch when dynamic NFT feature is enabled
DynamicESDTEnableEpoch = 0

# EGLDInMultiTransferEnableEpoch represents the epoch when EGLD in multitransfer is enabled
EGLDInMultiTransferEnableEpoch = 0

# CryptoOpcodesV2EnableEpoch represents the epoch when BLSMultiSig, Secp256r1 and other opcodes are enabled
CryptoOpcodesV2EnableEpoch = 0

# UnjailCleanupEnableEpoch represents the epoch when the cleanup of the unjailed nodes is enabled
UnJailCleanupEnableEpoch = 0

# FixRelayedBaseCostEnableEpoch represents the epoch when the fix for relayed base cost will be enabled
FixRelayedBaseCostEnableEpoch = 0

# MultiESDTNFTTransferAndExecuteByUserEnableEpoch represents the epoch when enshrined sovereign cross chain opcodes are enabled
MultiESDTNFTTransferAndExecuteByUserEnableEpoch = 9999999

# FixRelayedMoveBalanceToNonPayableSCEnableEpoch represents the epoch when the fix for relayed move balance to non payable sc will be enabled
FixRelayedMoveBalanceToNonPayableSCEnableEpoch = 0

# RelayedTransactionsV3EnableEpoch represents the epoch when the relayed transactions v3 will be enabled
RelayedTransactionsV3EnableEpoch = 0

# ConsensusModelV2EnableEpoch represents the epoch when the consensus model V2 is enabled
ConsensusModelV2EnableEpoch = 0

# BLSMultiSignerEnableEpoch represents the activation epoch for different types of BLS multi-signers
BLSMultiSignerEnableEpoch = [
{ EnableEpoch = 0, Type = "KOSK"}
Expand Down
3 changes: 1 addition & 2 deletions dataRetriever/requestHandlers/requestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ 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/core/partitioning"
"github.com/multiversx/mx-chain-logger-go"
logger "github.com/multiversx/mx-chain-logger-go"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/dataRetriever"
"github.com/multiversx/mx-chain-go/epochStart"
"github.com/multiversx/mx-chain-go/process/factory"
logger "github.com/multiversx/mx-chain-logger-go"
)

var _ epochStart.RequestHandler = (*resolverRequestHandler)(nil)
Expand Down
10 changes: 9 additions & 1 deletion process/block/preprocess/sovereignChainTransactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-core-go/data/block"
"github.com/multiversx/mx-chain-core-go/data/transaction"

"github.com/multiversx/mx-chain-go/process"
"github.com/multiversx/mx-chain-go/storage/txcache"
)
Expand Down Expand Up @@ -110,7 +111,14 @@ func (sct *sovereignChainTransactions) computeSortedTxs(
}

sortedTransactionsProvider := createSortedTransactionsProvider(txShardPool)
sortedTxs := sortedTransactionsProvider.GetSortedTransactions()
session, err := NewSelectionSession(ArgsSelectionSession{
AccountsAdapter: sct.accounts,
TransactionsProcessor: sct.txProcessor,
})
if err != nil {
return nil, err
}
sortedTxs := sortedTransactionsProvider.GetSortedTransactions(session)
sct.sortTransactionsBySenderAndNonce(sortedTxs, randomness)

return sortedTxs, nil
Expand Down
22 changes: 12 additions & 10 deletions process/block/preprocess/sovereignChainTransactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"errors"
"math/big"
"testing"
"time"

"github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-core-go/data/block"
"github.com/multiversx/mx-chain-core-go/data/transaction"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/process"
state2 "github.com/multiversx/mx-chain-go/state"
Expand All @@ -17,8 +21,6 @@ import (
"github.com/multiversx/mx-chain-go/testscommon/economicsmocks"
"github.com/multiversx/mx-chain-go/testscommon/enableEpochsHandlerMock"
"github.com/multiversx/mx-chain-go/testscommon/state"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestTxsPreprocessor_NewSovereignChainTransactionPreprocessorShouldErrNilPreProcessor(t *testing.T) {
Expand Down Expand Up @@ -144,10 +146,10 @@ func TestTxsPreprocessor_CreateAndProcessMiniBlocksShouldWork(t *testing.T) {
args.TxDataPool = &testscommon.ShardedDataStub{
ShardDataStoreCalled: func(id string) (c storage.Cacher) {
return &testscommon.TxCacherStub{
SelectTransactionsWithBandwidthCalled: func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
SelectTransactionsCalled: func(_ txcache.SelectionSession, _ uint64, _ int, _ time.Duration) ([]*txcache.WrappedTransaction, uint64) {
return []*txcache.WrappedTransaction{
{Tx: &transaction.Transaction{Nonce: 1}},
}
}, 0
},
}
},
Expand All @@ -169,10 +171,10 @@ func TestTxsPreprocessor_CreateAndProcessMiniBlocksShouldWork(t *testing.T) {
args.TxDataPool = &testscommon.ShardedDataStub{
ShardDataStoreCalled: func(id string) (c storage.Cacher) {
return &testscommon.TxCacherStub{
SelectTransactionsWithBandwidthCalled: func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
SelectTransactionsCalled: func(_ txcache.SelectionSession, _ uint64, _ int, _ time.Duration) ([]*txcache.WrappedTransaction, uint64) {
return []*txcache.WrappedTransaction{
{Tx: &transaction.Transaction{Nonce: 1}},
}
}, 0
},
}
},
Expand Down Expand Up @@ -224,12 +226,12 @@ func TestTxsPreprocessor_CreateAndProcessMiniBlocksShouldWork(t *testing.T) {
args.TxDataPool = &testscommon.ShardedDataStub{
ShardDataStoreCalled: func(id string) (c storage.Cacher) {
return &testscommon.TxCacherStub{
SelectTransactionsWithBandwidthCalled: func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
SelectTransactionsCalled: func(_ txcache.SelectionSession, _ uint64, _ int, _ time.Duration) ([]*txcache.WrappedTransaction, uint64) {
return []*txcache.WrappedTransaction{
{Tx: tx1, TxHash: txHash1},
{Tx: tx2, TxHash: txHash2},
{Tx: tx3, TxHash: txHash3},
}
}, 0
},
}
},
Expand Down Expand Up @@ -275,10 +277,10 @@ func TestTxsPreprocessor_ComputeSortedTxsShouldWork(t *testing.T) {
args.TxDataPool = &testscommon.ShardedDataStub{
ShardDataStoreCalled: func(id string) (c storage.Cacher) {
return &testscommon.TxCacherStub{
SelectTransactionsWithBandwidthCalled: func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
SelectTransactionsCalled: func(_ txcache.SelectionSession, _ uint64, _ int, _ time.Duration) ([]*txcache.WrappedTransaction, uint64) {
return []*txcache.WrappedTransaction{
{Tx: tx, TxHash: txHash},
}
}, 0
},
}
},
Expand Down
2 changes: 1 addition & 1 deletion process/smartContract/processorV2/processV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ func (sc *scProcessor) getFeePayer(tx data.TransactionHandler, acntSnd state.Use
return acntSnd, nil // do not load the same account twice
}

account, err := sc.getAccountFromAddress(relayedTx.GetRelayerAddr())
account, err := sc.scProcessorHelper.GetAccountFromAddress(relayedTx.GetRelayerAddr())
if err != nil {
return nil, err
}
Expand Down
5 changes: 3 additions & 2 deletions process/smartContract/processorV2/sovereignSCProcess.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ 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/smartContractResult"
"github.com/multiversx/mx-chain-go/process"
vmcommon "github.com/multiversx/mx-chain-vm-common-go"

"github.com/multiversx/mx-chain-go/process"
)

// SovereignSCProcessArgs - arguments for creating a new sovereign smart contract processor
Expand Down Expand Up @@ -77,7 +78,7 @@ func (sc *sovereignSCProcessor) ProcessSmartContractResult(scr *smartContractRes
return returnCode, err
}

txType, _ := sc.txTypeHandler.ComputeTransactionType(scr)
txType, _, _ := sc.txTypeHandler.ComputeTransactionType(scr)
switch txType {
case process.BuiltInFunctionCall:
err = sc.checkBuiltInFuncCall(string(scr.Data))
Expand Down
26 changes: 11 additions & 15 deletions testscommon/txCacherStub.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package testscommon

import "github.com/multiversx/mx-chain-go/storage/txcache"
import (
"time"

"github.com/multiversx/mx-chain-go/storage/txcache"
)

type TxCacherStub struct {
CacherStub
SelectTransactionsWithBandwidthCalled func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction
NotifyAccountNonceCalled func(accountKey []byte, nonce uint64)
SelectTransactionsCalled func(session txcache.SelectionSession, gasRequested uint64, maxNum int, selectionLoopMaximumDuration time.Duration) ([]*txcache.WrappedTransaction, uint64)
}

// SelectTransactionsWithBandwidth -
func (tcs *TxCacherStub) SelectTransactionsWithBandwidth(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
if tcs.SelectTransactionsWithBandwidthCalled != nil {
return tcs.SelectTransactionsWithBandwidthCalled(numRequested, batchSizePerSender, bandwidthPerSender)
// SelectTransactions -
func (tcs *TxCacherStub) SelectTransactions(session txcache.SelectionSession, gasRequested uint64, maxNum int, selectionLoopMaximumDuration time.Duration) ([]*txcache.WrappedTransaction, uint64) {
if tcs.SelectTransactionsCalled != nil {
return tcs.SelectTransactionsCalled(session, gasRequested, maxNum, selectionLoopMaximumDuration)
}

return make([]*txcache.WrappedTransaction, 0)
}

// NotifyAccountNonce -
func (tcs *TxCacherStub) NotifyAccountNonce(accountKey []byte, nonce uint64) {
if tcs.NotifyAccountNonceCalled != nil {
tcs.NotifyAccountNonceCalled(accountKey, nonce)
}
return make([]*txcache.WrappedTransaction, 0), 0
}

0 comments on commit 8fbcfd6

Please sign in to comment.