From 6db1c2dc163e8860145c3f1855a0940bc9050909 Mon Sep 17 00:00:00 2001 From: Francesco4203 Date: Fri, 25 Oct 2024 15:36:24 +0700 Subject: [PATCH 1/2] v2/consortium_test: only insert newly created blocks --- consensus/consortium/v2/consortium_test.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/consensus/consortium/v2/consortium_test.go b/consensus/consortium/v2/consortium_test.go index 175bf54ef..c8cc2c246 100644 --- a/consensus/consortium/v2/consortium_test.go +++ b/consensus/consortium/v2/consortium_test.go @@ -2219,7 +2219,7 @@ func testSystemTransactionOrder(t *testing.T, scheme string) { } func TestIsPeriodBlock(t *testing.T) { - //testIsPeriodBlock(t, rawdb.PathScheme) + testIsPeriodBlock(t, rawdb.PathScheme) testIsPeriodBlock(t, rawdb.HashScheme) } @@ -2302,7 +2302,7 @@ func testIsPeriodBlock(t *testing.T, scheme string) { block, _ := core.GenerateChain(&chainConfig, bs[len(bs)-1], ethash.NewFaker(), db, 1, callback, true) bs = append(bs, block...) } - if _, err := chain.InsertChain(bs[:], nil); err != nil { + if _, err := chain.InsertChain(bs[399:], nil); err != nil { panic(err) } @@ -2322,15 +2322,9 @@ func testIsPeriodBlock(t *testing.T, scheme string) { } } -/* -Got issues related to parent layer missing in the test -panic: triedb parent [0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421] layer missing [recovered] -panic: triedb parent [0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421] layer missing -Will disable this test firstly for further investigation. -*/ func TestIsTrippEffective(t *testing.T) { testIsTrippEffective(t, rawdb.HashScheme) - // testIsTrippEffective(t, rawdb.PathScheme) + testIsTrippEffective(t, rawdb.PathScheme) } @@ -2417,7 +2411,7 @@ func testIsTrippEffective(t *testing.T, scheme string) { block, _ := core.GenerateChain(&chainConfig, bs[len(bs)-1], ethash.NewFaker(), db, 1, callback, true) bs = append(bs, block...) } - if _, err := chain.InsertChain(bs[:], nil); err != nil { + if _, err := chain.InsertChain(bs[399:], nil); err != nil { panic(err) } From 2684d3b2f588aefc352ce9bdfa0e5230cb8e991a Mon Sep 17 00:00:00 2001 From: Francesco4203 Date: Thu, 14 Nov 2024 17:58:10 +0700 Subject: [PATCH 2/2] consortium_test.go: add comments --- consensus/consortium/v2/consortium_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/consensus/consortium/v2/consortium_test.go b/consensus/consortium/v2/consortium_test.go index c8cc2c246..c4d2d81af 100644 --- a/consensus/consortium/v2/consortium_test.go +++ b/consensus/consortium/v2/consortium_test.go @@ -2302,6 +2302,10 @@ func testIsPeriodBlock(t *testing.T, scheme string) { block, _ := core.GenerateChain(&chainConfig, bs[len(bs)-1], ethash.NewFaker(), db, 1, callback, true) bs = append(bs, block...) } + // Only the new blocks are inserted here + // For path scheme, the number of db diff layers corresponding to blocks are limited to 128 + // So just the newest 128 blocks can be retrieved from the db + // Therefore, the handling of the inserted blocks can result in error since the older blocks can not be retrieved for checking if _, err := chain.InsertChain(bs[399:], nil); err != nil { panic(err) } @@ -2411,6 +2415,10 @@ func testIsTrippEffective(t *testing.T, scheme string) { block, _ := core.GenerateChain(&chainConfig, bs[len(bs)-1], ethash.NewFaker(), db, 1, callback, true) bs = append(bs, block...) } + // Only the new blocks are inserted here + // For path scheme, the number of db diff layers corresponding to blocks are limited to 128 + // So just the newest 128 blocks can be retrieved from the db + // Therefore, the handling of the inserted blocks can result in error since the older blocks can not be retrieved for checking if _, err := chain.InsertChain(bs[399:], nil); err != nil { panic(err) }