Skip to content
Closed
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
5 changes: 0 additions & 5 deletions process/block/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,11 +912,6 @@ func (sp *shardProcessor) DataPool() dataRetriever.PoolsHolder {
return sp.dataPool
}

// ShouldDisableOutgoingTxs -
func ShouldDisableOutgoingTxs(enableEpochsHandler common.EnableEpochsHandler, enableRoundsHandler common.EnableRoundsHandler) bool {
return shouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler)
}

// ShouldEpochStartInfoBeAvailable -
func (sp *shardProcessor) ShouldEpochStartInfoBeAvailable(header data.ShardHeaderHandler) bool {
return sp.shouldEpochStartInfoBeAvailable(header)
Expand Down
8 changes: 1 addition & 7 deletions process/block/shardblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,7 @@ func (sp *shardProcessor) createMiniBlocks(haveTime func() bool, randomness []by
return &block.Body{MiniBlocks: miniBlocks}, processedMiniBlocksDestMeInfo, nil
}

if shouldDisableOutgoingTxs(sp.enableEpochsHandler, sp.enableRoundsHandler) {
if process.ShouldDisableOutgoingTxs(sp.enableEpochsHandler, sp.enableRoundsHandler) {
interMBs := sp.txCoordinator.CreatePostProcessMiniBlocks()
miniBlocks = append(miniBlocks, interMBs...)

Expand Down Expand Up @@ -2426,12 +2426,6 @@ func (sp *shardProcessor) createMiniBlocks(haveTime func() bool, randomness []by
return &block.Body{MiniBlocks: miniBlocks}, processedMiniBlocksDestMeInfo, nil
}

func shouldDisableOutgoingTxs(enableEpochsHandler common.EnableEpochsHandler, enableRoundsHandler common.EnableRoundsHandler) bool {
isSupernovaEnabled := enableEpochsHandler.IsFlagEnabled(common.SupernovaFlag)
supernovaRoundEnabled := enableRoundsHandler.IsFlagEnabled(common.SupernovaRoundFlag)
return isSupernovaEnabled && !supernovaRoundEnabled
}

// applyBodyToHeader creates a miniblock header list given a block body
func (sp *shardProcessor) applyBodyToHeader(
shardHeader data.ShardHeaderHandler,
Expand Down
2 changes: 1 addition & 1 deletion process/block/shardblockProposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3910,7 +3910,7 @@ func TestShouldDisableOutgoingTxs(t *testing.T) {
enableEpochsHandler := coreComponents.EnableEpochsHandler()
enableRoundsHandler := coreComponents.EnableRoundsHandler()

result := blproc.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler)
result := process.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler)
// This tests that the function executes without error
require.NotNil(t, result) // result can be true or false depending on configuration
})
Expand Down
8 changes: 4 additions & 4 deletions process/block/shardblock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6891,7 +6891,7 @@ func Test_ShouldDisableOutgoingTxs(t *testing.T) {
t.Run("both flag not set, should return false", func(t *testing.T) {
enableEpochsHandler := &enableEpochsHandlerMock.EnableEpochsHandlerStub{}
enableRoundsHandler := &testscommon.EnableRoundsHandlerStub{}
require.False(t, blproc.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler))
require.False(t, process.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler))
})
t.Run("epoch flag enabled, round flag disabled, should return true", func(t *testing.T) {
enableEpochsHandler := &enableEpochsHandlerMock.EnableEpochsHandlerStub{
Expand All @@ -6904,7 +6904,7 @@ func Test_ShouldDisableOutgoingTxs(t *testing.T) {
return false
},
}
require.True(t, blproc.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler))
require.True(t, process.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler))
})
t.Run("epoch flag disabled, round flag enabled, should return false", func(t *testing.T) {
enableEpochsHandler := &enableEpochsHandlerMock.EnableEpochsHandlerStub{
Expand All @@ -6917,7 +6917,7 @@ func Test_ShouldDisableOutgoingTxs(t *testing.T) {
return true
},
}
require.False(t, blproc.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler))
require.False(t, process.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler))
})
t.Run("both flag enabled, should return false", func(t *testing.T) {
enableEpochsHandler := &enableEpochsHandlerMock.EnableEpochsHandlerStub{
Expand All @@ -6930,7 +6930,7 @@ func Test_ShouldDisableOutgoingTxs(t *testing.T) {
return true
},
}
require.False(t, blproc.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler))
require.False(t, process.ShouldDisableOutgoingTxs(enableEpochsHandler, enableRoundsHandler))
})
}

Expand Down
9 changes: 9 additions & 0 deletions process/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -1636,3 +1636,12 @@ func getExecutionResultToSetOnReplacedHeader(

return executionResultToSet, nil
}

// ShouldDisableOutgoingTxs returns true when the Supernova feature flag is enabled
// but the Supernova round flag is still disabled, meaning outgoing transactions
// should remain blocked until the round-based activation is also in effect.
func ShouldDisableOutgoingTxs(enableEpochsHandler common.EnableEpochsHandler, enableRoundsHandler common.EnableRoundsHandler) bool {
isSupernovaEnabled := enableEpochsHandler.IsFlagEnabled(common.SupernovaFlag)
supernovaRoundEnabled := enableRoundsHandler.IsFlagEnabled(common.SupernovaRoundFlag)
return isSupernovaEnabled && !supernovaRoundEnabled
}
3 changes: 3 additions & 0 deletions process/coordinator/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ func (tc *transactionCoordinator) ProcessBlockTransaction(
}

miniBlocksFromMe := body.MiniBlocks[mbIndex:]
if process.ShouldDisableOutgoingTxs(tc.enableEpochsHandler, tc.enableRoundsHandler) && len(miniBlocksFromMe) > 0 {
return process.ErrOutgoingTxsDisabled
}
startTime = time.Now()
err = tc.processMiniBlocksFromMe(header, &block.Body{MiniBlocks: miniBlocksFromMe}, haveTime)
elapsedTime = time.Since(startTime)
Expand Down
3 changes: 3 additions & 0 deletions process/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -1508,3 +1508,6 @@ var ErrInvalidShardInfo = errors.New("invalid shard info")

// ErrNilClosingNodeStartedFlag signals that the closing node started flag is nil
var ErrNilClosingNodeStartedFlag = errors.New("closing node started flag is nil")

// ErrOutgoingTxsDisabled signals that the outgoing transactions are disabled
var ErrOutgoingTxsDisabled = errors.New("outgoing transactions are disabled")
Loading