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

Merge dev into liquid staking 16 06 2022 #4197

Merged
Merged
Changes from 5 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
12 changes: 5 additions & 7 deletions factory/apiResolverFactory.go
Original file line number Diff line number Diff line change
@@ -135,13 +135,11 @@ func CreateApiResolver(args *ApiResolverArgs) (facade.ApiResolver, error) {
}

argsTxTypeHandler := coordinator.ArgNewTxTypeHandler{
PubkeyConverter: args.CoreComponents.AddressPubKeyConverter(),
ShardCoordinator: args.ProcessComponents.ShardCoordinator(),
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: args.CoreComponents.EpochNotifier(),
RelayedTxV2EnableEpoch: args.Configs.EpochConfig.EnableEpochs.RelayedTransactionsV2EnableEpoch,
ESDTTransferParser: esdtTransferParser,
PubkeyConverter: args.CoreComponents.AddressPubKeyConverter(),
ShardCoordinator: args.ProcessComponents.ShardCoordinator(),
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, err := coordinator.NewTxTypeHandler(argsTxTypeHandler)
if err != nil {
24 changes: 10 additions & 14 deletions factory/blockProcessorCreator.go
Original file line number Diff line number Diff line change
@@ -176,13 +176,11 @@ func (pcf *processComponentsFactory) newShardBlockProcessor(
}

argsTxTypeHandler := coordinator.ArgNewTxTypeHandler{
PubkeyConverter: pcf.coreData.AddressPubKeyConverter(),
ShardCoordinator: pcf.bootstrapComponents.ShardCoordinator(),
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: pcf.coreData.EpochNotifier(),
RelayedTxV2EnableEpoch: pcf.epochConfig.EnableEpochs.RelayedTransactionsV2EnableEpoch,
ESDTTransferParser: esdtTransferParser,
PubkeyConverter: pcf.coreData.AddressPubKeyConverter(),
ShardCoordinator: pcf.bootstrapComponents.ShardCoordinator(),
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, err := coordinator.NewTxTypeHandler(argsTxTypeHandler)
if err != nil {
@@ -494,13 +492,11 @@ func (pcf *processComponentsFactory) newMetaBlockProcessor(
}

argsTxTypeHandler := coordinator.ArgNewTxTypeHandler{
PubkeyConverter: pcf.coreData.AddressPubKeyConverter(),
ShardCoordinator: pcf.bootstrapComponents.ShardCoordinator(),
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: pcf.coreData.EpochNotifier(),
RelayedTxV2EnableEpoch: pcf.epochConfig.EnableEpochs.RelayedTransactionsV2EnableEpoch,
ESDTTransferParser: esdtTransferParser,
PubkeyConverter: pcf.coreData.AddressPubKeyConverter(),
ShardCoordinator: pcf.bootstrapComponents.ShardCoordinator(),
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, err := coordinator.NewTxTypeHandler(argsTxTypeHandler)
if err != nil {
12 changes: 5 additions & 7 deletions genesis/process/metaGenesisBlockCreator.go
Original file line number Diff line number Diff line change
@@ -368,13 +368,11 @@ func createProcessorsForMetaGenesisBlock(arg ArgsGenesisBlockCreator, enableEpoc
}

argsTxTypeHandler := coordinator.ArgNewTxTypeHandler{
PubkeyConverter: arg.Core.AddressPubKeyConverter(),
ShardCoordinator: arg.ShardCoordinator,
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: epochNotifier,
RelayedTxV2EnableEpoch: arg.EpochConfig.EnableEpochs.RelayedTransactionsV2EnableEpoch,
ESDTTransferParser: esdtTransferParser,
PubkeyConverter: arg.Core.AddressPubKeyConverter(),
ShardCoordinator: arg.ShardCoordinator,
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, err := coordinator.NewTxTypeHandler(argsTxTypeHandler)
if err != nil {
12 changes: 5 additions & 7 deletions genesis/process/shardGenesisBlockCreator.go
Original file line number Diff line number Diff line change
@@ -470,13 +470,11 @@ func createProcessorsForShardGenesisBlock(arg ArgsGenesisBlockCreator, enableEpo
epochNotifier.CheckEpoch(temporaryBlock)

argsTxTypeHandler := coordinator.ArgNewTxTypeHandler{
PubkeyConverter: arg.Core.AddressPubKeyConverter(),
ShardCoordinator: arg.ShardCoordinator,
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: epochNotifier,
RelayedTxV2EnableEpoch: arg.EpochConfig.EnableEpochs.RelayedTransactionsV2EnableEpoch,
ESDTTransferParser: esdtTransferParser,
PubkeyConverter: arg.Core.AddressPubKeyConverter(),
ShardCoordinator: arg.ShardCoordinator,
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, err := coordinator.NewTxTypeHandler(argsTxTypeHandler)
if err != nil {
2 changes: 0 additions & 2 deletions integrationTests/testProcessorNode.go
Original file line number Diff line number Diff line change
@@ -1561,7 +1561,6 @@ func (tpn *TestProcessorNode) initInnerProcessors(gasMap map[string]map[string]u
ShardCoordinator: tpn.ShardCoordinator,
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: tpn.EpochNotifier,
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argsTxTypeHandler)
@@ -1818,7 +1817,6 @@ func (tpn *TestProcessorNode) initMetaInnerProcessors() {
ShardCoordinator: tpn.ShardCoordinator,
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: tpn.EpochNotifier,
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argsTxTypeHandler)
1 change: 0 additions & 1 deletion integrationTests/testProcessorNodeWithTestWebServer.go
Original file line number Diff line number Diff line change
@@ -152,7 +152,6 @@ func createFacadeComponents(tpn *TestProcessorNode) (nodeFacade.ApiResolver, nod
ShardCoordinator: tpn.ShardCoordinator,
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: tpn.EpochNotifier,
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, err := coordinator.NewTxTypeHandler(argsTxTypeHandler)
1 change: 0 additions & 1 deletion integrationTests/vm/arwen/arwenvm/arwenVM_test.go
Original file line number Diff line number Diff line change
@@ -510,7 +510,6 @@ func TestExecuteTransactionAndTimeToProcessChange(t *testing.T) {
ShardCoordinator: shardCoordinator,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: forking.NewGenericEpochNotifier(),
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argsTxTypeHandler)
1 change: 0 additions & 1 deletion integrationTests/vm/arwen/utils.go
Original file line number Diff line number Diff line change
@@ -310,7 +310,6 @@ func (context *TestContext) initTxProcessorWithOneSCExecutorWithVMs() {
ShardCoordinator: oneShardCoordinator,
BuiltInFunctions: context.BlockchainHook.GetBuiltinFunctionsContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: forking.NewGenericEpochNotifier(),
ESDTTransferParser: esdtTransferParser,
}

2 changes: 0 additions & 2 deletions integrationTests/vm/testInitializer.go
Original file line number Diff line number Diff line change
@@ -446,7 +446,6 @@ func CreateTxProcessorWithOneSCExecutorMockVM(
ShardCoordinator: oneShardCoordinator,
BuiltInFunctions: builtInFuncs,
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: forking.NewGenericEpochNotifier(),
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argsTxTypeHandler)
@@ -791,7 +790,6 @@ func CreateTxProcessorWithOneSCExecutorWithVMs(
ShardCoordinator: shardCoordinator,
BuiltInFunctions: blockChainHook.GetBuiltinFunctionsContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: forking.NewGenericEpochNotifier(),
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argsTxTypeHandler)
51 changes: 15 additions & 36 deletions process/coordinator/transactionType.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import (
"bytes"

"github.com/ElrondNetwork/elrond-go-core/core"
"github.com/ElrondNetwork/elrond-go-core/core/atomic"
"github.com/ElrondNetwork/elrond-go-core/core/check"
"github.com/ElrondNetwork/elrond-go-core/data"
"github.com/ElrondNetwork/elrond-go-core/data/smartContractResult"
@@ -17,24 +16,20 @@ import (
var _ process.TxTypeHandler = (*txTypeHandler)(nil)

type txTypeHandler struct {
pubkeyConv core.PubkeyConverter
shardCoordinator sharding.Coordinator
builtInFunctions vmcommon.BuiltInFunctionContainer
argumentParser process.CallArgumentsParser
flagRelayedTxV2 atomic.Flag
relayedTxV2EnableEpoch uint32
esdtTransferParser vmcommon.ESDTTransferParser
pubkeyConv core.PubkeyConverter
shardCoordinator sharding.Coordinator
builtInFunctions vmcommon.BuiltInFunctionContainer
argumentParser process.CallArgumentsParser
esdtTransferParser vmcommon.ESDTTransferParser
}

// ArgNewTxTypeHandler defines the arguments needed to create a new tx type handler
type ArgNewTxTypeHandler struct {
PubkeyConverter core.PubkeyConverter
ShardCoordinator sharding.Coordinator
BuiltInFunctions vmcommon.BuiltInFunctionContainer
ArgumentParser process.CallArgumentsParser
RelayedTxV2EnableEpoch uint32
EpochNotifier process.EpochNotifier
ESDTTransferParser vmcommon.ESDTTransferParser
PubkeyConverter core.PubkeyConverter
ShardCoordinator sharding.Coordinator
BuiltInFunctions vmcommon.BuiltInFunctionContainer
ArgumentParser process.CallArgumentsParser
ESDTTransferParser vmcommon.ESDTTransferParser
}

// NewTxTypeHandler creates a transaction type handler
@@ -53,25 +48,18 @@ func NewTxTypeHandler(
if check.IfNil(args.BuiltInFunctions) {
return nil, process.ErrNilBuiltInFunction
}
if check.IfNil(args.EpochNotifier) {
return nil, process.ErrNilEpochNotifier
}
if check.IfNil(args.ESDTTransferParser) {
return nil, process.ErrNilESDTTransferParser
}

tc := &txTypeHandler{
pubkeyConv: args.PubkeyConverter,
shardCoordinator: args.ShardCoordinator,
argumentParser: args.ArgumentParser,
builtInFunctions: args.BuiltInFunctions,
relayedTxV2EnableEpoch: args.RelayedTxV2EnableEpoch,
esdtTransferParser: args.ESDTTransferParser,
pubkeyConv: args.PubkeyConverter,
shardCoordinator: args.ShardCoordinator,
argumentParser: args.ArgumentParser,
builtInFunctions: args.BuiltInFunctions,
esdtTransferParser: args.ESDTTransferParser,
}

args.EpochNotifier.RegisterNotifyHandler(tc)
log.Debug("txTypeHandler: enable epoch for relayed transactions v2", "epoch", args.RelayedTxV2EnableEpoch)

return tc, nil
}

@@ -183,9 +171,6 @@ func (tth *txTypeHandler) isRelayedTransactionV1(functionName string) bool {
}

func (tth *txTypeHandler) isRelayedTransactionV2(functionName string) bool {
if !tth.flagRelayedTxV2.IsSet() {
return false
}
return functionName == core.RelayedTransactionV2
}

@@ -213,12 +198,6 @@ func (tth *txTypeHandler) checkTxValidity(tx data.TransactionHandler) error {
return nil
}

// EpochConfirmed is called whenever a new epoch is confirmed
func (tth *txTypeHandler) EpochConfirmed(epoch uint32, _ uint64) {
tth.flagRelayedTxV2.SetValue(epoch >= tth.relayedTxV2EnableEpoch)
log.Debug("txTypeHandler: relayed transactions v2", "enabled", tth.flagRelayedTxV2.IsSet())
}

// IsInterfaceNil returns true if there is no value under the interface
func (tth *txTypeHandler) IsInterfaceNil() bool {
return tth == nil
18 changes: 0 additions & 18 deletions process/coordinator/transactionType_test.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ import (
vmData "github.com/ElrondNetwork/elrond-go-core/data/vm"
"github.com/ElrondNetwork/elrond-go/process"
"github.com/ElrondNetwork/elrond-go/process/mock"
"github.com/ElrondNetwork/elrond-go/testscommon/epochNotifier"
"github.com/ElrondNetwork/elrond-go/vm"
"github.com/ElrondNetwork/elrond-vm-common/builtInFunctions"
"github.com/ElrondNetwork/elrond-vm-common/parsers"
@@ -26,7 +25,6 @@ func createMockArguments() ArgNewTxTypeHandler {
ShardCoordinator: mock.NewMultiShardsCoordinatorMock(3),
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
}
@@ -79,17 +77,6 @@ func TestNewTxTypeHandler_NilBuiltInFuncs(t *testing.T) {
assert.Equal(t, process.ErrNilBuiltInFunction, err)
}

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

arg := createMockArguments()
arg.EpochNotifier = nil
tth, err := NewTxTypeHandler(arg)

assert.Nil(t, tth)
assert.Equal(t, process.ErrNilEpochNotifier, err)
}

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

@@ -450,11 +437,6 @@ func TestTxTypeHandler_ComputeTransactionTypeRelayedV2Func(t *testing.T) {
txTypeIn, txTypeCross := tth.ComputeTransactionType(tx)
assert.Equal(t, process.RelayedTxV2, txTypeIn)
assert.Equal(t, process.RelayedTxV2, txTypeCross)

tth.flagRelayedTxV2.Reset()
txTypeIn, txTypeCross = tth.ComputeTransactionType(tx)
assert.Equal(t, process.MoveBalance, txTypeIn)
assert.Equal(t, process.MoveBalance, txTypeCross)
}

func TestTxTypeHandler_ComputeTransactionTypeForSCRCallBack(t *testing.T) {
1 change: 0 additions & 1 deletion process/transaction/metaProcess_test.go
Original file line number Diff line number Diff line change
@@ -360,7 +360,6 @@ func TestMetaTxProcessor_ProcessTransactionScTxShouldNotBeCalledWhenAdrDstIsNotI
ShardCoordinator: shardCoordinator,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
computeType, _ := coordinator.NewTxTypeHandler(argsTxTypeHandler)
8 changes: 0 additions & 8 deletions process/transaction/shardProcess_test.go
Original file line number Diff line number Diff line change
@@ -1290,7 +1290,6 @@ func TestTxProcessor_ProcessTransactionScTxShouldNotBeCalledWhenAdrDstIsNotInNod
ShardCoordinator: shardCoordinator,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
computeType, _ := coordinator.NewTxTypeHandler(argsTxTypeHandler)
@@ -1675,7 +1674,6 @@ func TestTxProcessor_ProcessRelayedTransactionV2NotActiveShouldErr(t *testing.T)
ShardCoordinator: shardC,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argTxTypeHandler)
@@ -1756,7 +1754,6 @@ func TestTxProcessor_ProcessRelayedTransactionV2WithValueShouldErr(t *testing.T)
ShardCoordinator: shardC,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argTxTypeHandler)
@@ -1836,7 +1833,6 @@ func TestTxProcessor_ProcessRelayedTransactionV2ArgsParserShouldErr(t *testing.T
ShardCoordinator: shardC,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argTxTypeHandler)
@@ -1923,7 +1919,6 @@ func TestTxProcessor_ProcessRelayedTransactionV2InvalidParamCountShouldErr(t *te
ShardCoordinator: shardC,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argTxTypeHandler)
@@ -2003,7 +1998,6 @@ func TestTxProcessor_ProcessRelayedTransactionV2(t *testing.T) {
ShardCoordinator: shardC,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argTxTypeHandler)
@@ -2078,7 +2072,6 @@ func TestTxProcessor_ProcessRelayedTransaction(t *testing.T) {
ShardCoordinator: shardC,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argTxTypeHandler)
@@ -2606,7 +2599,6 @@ func TestTxProcessor_ProcessRelayedTransactionDisabled(t *testing.T) {
ShardCoordinator: shardC,
BuiltInFunctions: builtInFunctions.NewBuiltInFunctionContainer(),
ArgumentParser: parsers.NewCallArgsParser(),
EpochNotifier: &epochNotifier.EpochNotifierStub{},
ESDTTransferParser: esdtTransferParser,
}
txTypeHandler, _ := coordinator.NewTxTypeHandler(argTxTypeHandler)