axieinfinity / ronin

A DPoS blockchain.
GNU Lesser General Public License v3.0
67 stars 30 forks source link

v2/consortium_test: fix for pbss: do not insert inserted blocks #613

Open Francesco4203 opened 1 day ago

Francesco4203 commented 1 day ago

This PR is originated from https://github.com/axieinfinity/ronin/pull/612

Before this PR, in TestIsPeriodBlock and TestIsTrippEffective, the chain of blocks is inserted while it still includes some previously inserted blocks, causing the below error when running on path scheme.

Potential reason:

[To be updated]...

This PR is to fix it by only inserting newly created blocks.

Run test before this PR

--- FAIL: TestIsTrippEffective (0.19s)
panic: triedb parent [0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421] layer missing [recovered]
        panic: triedb parent [0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421] layer missing

goroutine 4016 [running]:
testing.tRunner.func1.2({0x105c97d20, 0x140002d1770})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/testing/testing.go:1631 +0x1c4
testing.tRunner.func1()
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/testing/testing.go:1634 +0x33c
panic({0x105c97d20?, 0x140002d1770?})
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/runtime/panic.go:770 +0x124
github.com/ethereum/go-ethereum/consensus/consortium/v2.testIsTrippEffective(0x140000c3a00, {0x10592235d, 0x4})
        /Users/long.nguyen/Documents/GitHub/ronin/consensus/consortium/v2/consortium_test.go:2437 +0xe5c
github.com/ethereum/go-ethereum/consensus/consortium/v2.TestIsTrippEffective(0x140000c3a00)
        /Users/long.nguyen/Documents/GitHub/ronin/consensus/consortium/v2/consortium_test.go:2341 +0x40
testing.tRunner(0x140000c3a00, 0x105df9818)
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/testing/testing.go:1689 +0xec
created by testing.(*T).Run in goroutine 1
        /opt/homebrew/Cellar/go/1.22.3/libexec/src/testing/testing.go:1742 +0x318
exit status 2
FAIL    github.com/ethereum/go-ethereum/consensus/consortium/v2 1.631s

Run test after this PR

PASS
ok      github.com/ethereum/go-ethereum/consensus/consortium/v2 1.530s