Skip to content

Commit 1714b93

Browse files
committed
remove prune trie for metablock v2 flow
1 parent e77ce87 commit 1714b93

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

process/block/metablock.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,10 +1633,10 @@ func (mp *metaProcessor) updateState(metaBlock data.MetaHeaderHandler, metaBlock
16331633
prevMetaBlock.GetValidatorStatsRootHash(),
16341634
mp.accountsDB[state.PeerAccountsState],
16351635
)
1636-
} else {
1637-
mp.pruneTrieHeaderV3(metaBlock)
16381636
}
16391637

1638+
// for header v3, trie prunning is triggered in async mode from headers executor
1639+
16401640
outportFinalizedHeaderHash := metaBlockHash
16411641
if !common.IsFlagEnabledAfterEpochsStartBlock(metaBlock, mp.enableEpochsHandler, common.AndromedaFlag) {
16421642
outportFinalizedHeaderHash = metaBlock.GetPrevHash()

process/block/metablock_test.go

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4061,6 +4061,41 @@ func TestMetaProcessor_CrossChecksBlockHeightsMetrics(t *testing.T) {
40614061
requireInstance.Equal(uint64(39), savedMetrics["erd_cross_check_block_height_2"])
40624062
}
40634063

4064+
func TestMetaProcessor_PruneTrieAsyncHeader(t *testing.T) {
4065+
t.Parallel()
4066+
4067+
t.Run("prune trie for headerV3, prev header is headerV2", func(t *testing.T) {
4068+
t.Parallel()
4069+
4070+
rootHash1 := []byte("state root hash 1")
4071+
validatorStatsRootHash1 := []byte("validator stats root hash 1")
4072+
4073+
prevHeader := &block.MetaBlock{
4074+
RootHash: rootHash1,
4075+
ValidatorStatsRootHash: validatorStatsRootHash1,
4076+
}
4077+
pruneTrieForHeaderV3Test(t, prevHeader, rootHash1, validatorStatsRootHash1)
4078+
})
4079+
4080+
t.Run("prune trie for headerV3, prev header is headerV3", func(t *testing.T) {
4081+
t.Parallel()
4082+
4083+
rootHash1 := []byte("state root hash 1")
4084+
validatorStatsRootHash1 := []byte("validator stats root hash 1")
4085+
prevHeader := &block.MetaBlockV3{
4086+
LastExecutionResult: &block.MetaExecutionResultInfo{
4087+
ExecutionResult: &block.BaseMetaExecutionResult{
4088+
BaseExecutionResult: &block.BaseExecutionResult{
4089+
RootHash: rootHash1,
4090+
},
4091+
ValidatorStatsRootHash: validatorStatsRootHash1,
4092+
},
4093+
},
4094+
}
4095+
pruneTrieForHeaderV3Test(t, prevHeader, rootHash1, validatorStatsRootHash1)
4096+
})
4097+
}
4098+
40644099
func TestMetaProcessor_UpdateState(t *testing.T) {
40654100
t.Parallel()
40664101

@@ -4127,36 +4162,6 @@ func TestMetaProcessor_UpdateState(t *testing.T) {
41274162
assert.True(t, cancelPruneCalledForUserAccounts)
41284163
assert.True(t, cancelPruneCalledForPeerAccounts)
41294164
})
4130-
t.Run("prune trie for headerV3, prev header is headerV2", func(t *testing.T) {
4131-
t.Parallel()
4132-
4133-
rootHash1 := []byte("state root hash 1")
4134-
validatorStatsRootHash1 := []byte("validator stats root hash 1")
4135-
4136-
prevHeader := &block.MetaBlock{
4137-
RootHash: rootHash1,
4138-
ValidatorStatsRootHash: validatorStatsRootHash1,
4139-
}
4140-
pruneTrieForHeaderV3Test(t, prevHeader, rootHash1, validatorStatsRootHash1)
4141-
4142-
})
4143-
t.Run("prune trie for headerV3, prev header is headerV3", func(t *testing.T) {
4144-
t.Parallel()
4145-
4146-
rootHash1 := []byte("state root hash 1")
4147-
validatorStatsRootHash1 := []byte("validator stats root hash 1")
4148-
prevHeader := &block.MetaBlockV3{
4149-
LastExecutionResult: &block.MetaExecutionResultInfo{
4150-
ExecutionResult: &block.BaseMetaExecutionResult{
4151-
BaseExecutionResult: &block.BaseExecutionResult{
4152-
RootHash: rootHash1,
4153-
},
4154-
ValidatorStatsRootHash: validatorStatsRootHash1,
4155-
},
4156-
},
4157-
}
4158-
pruneTrieForHeaderV3Test(t, prevHeader, rootHash1, validatorStatsRootHash1)
4159-
})
41604165
}
41614166

41624167
func pruneTrieForHeaderV3Test(t *testing.T, prevHeader data.HeaderHandler, rootHash1 []byte, validatorStatsRootHash1 []byte) {
@@ -4238,7 +4243,6 @@ func pruneTrieForHeaderV3Test(t *testing.T, prevHeader data.HeaderHandler, rootH
42384243

42394244
mp, _ := processBlock.NewMetaProcessor(arguments)
42404245

4241-
metaBlockHash := []byte("meta block hash")
42424246
metaBlock := &block.MetaBlockV3{
42434247
PrevHash: []byte("hash"),
42444248
ExecutionResults: []*block.MetaExecutionResult{
@@ -4269,7 +4273,7 @@ func pruneTrieForHeaderV3Test(t *testing.T, prevHeader data.HeaderHandler, rootH
42694273
},
42704274
}
42714275

4272-
mp.UpdateState(metaBlock, metaBlockHash)
4276+
mp.PruneTrieAsyncHeader(metaBlock)
42734277

42744278
assert.Equal(t, 2, pruneCalledForUserAccounts)
42754279
assert.Equal(t, 2, pruneCalledForPeerAccounts)

0 commit comments

Comments
 (0)