Skip to content

Commit aa68aaa

Browse files
committed
test(sae): Clarify last synchronous behavior
1 parent cccf5d3 commit aa68aaa

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

vms/saevm/sae/recovery.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ func (rec *recovery) lastCommittedBlock() (_ *blocks.Block, retErr error) {
9797
func (rec *recovery) canonicalAfter(parent *blocks.Block) iter.Seq2[*blocks.Block, error] {
9898
return func(yield func(*blocks.Block, error) bool) {
9999
lastAcceptedHash := rawdb.ReadHeadFastBlockHash(rec.db)
100+
if lastAcceptedHash == (common.Hash{}) {
101+
// SAE writes this hash on [VM.AcceptBlock], so the set of accepted,
102+
// asynchronous blocks MUST be empty.
103+
return
104+
}
105+
100106
for curr := parent; curr.Hash() != lastAcceptedHash; {
101107
b, err := rec.newCanonicalBlock(curr.Height()+1, curr)
102108
if !yield(b, err) || err != nil {

vms/saevm/sae/recovery_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ func TestRecoverSimple(t *testing.T) {
137137
numBlocks int
138138
archival bool
139139
}{
140+
{
141+
name: "genesis",
142+
numBlocks: 0,
143+
},
140144
{
141145
name: "archival",
142146
numBlocks: 10,

0 commit comments

Comments
 (0)