Skip to content

Commit

Permalink
re-enable old features
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
  • Loading branch information
gballet committed Oct 24, 2024
1 parent 8acc14f commit 22c2fec
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,14 @@ func deserializeAndVerifyVerkleProof(vp *verkle.VerkleProof, preStateRoot []byte
// But all this can be avoided with a even faster way. The EVM block execution can
// keep track of the written keys, and compare that list with this post-values list.
// This can avoid regenerating the post-tree which is somewhat expensive.
_, err = verkle.PostStateTreeFromStateDiff(pretree, statediff)
posttree, err := verkle.PostStateTreeFromStateDiff(pretree, statediff)
if err != nil {
return fmt.Errorf("error rebuilding the post-tree from proof: %w", err)
}
// regeneratedPostTreeRoot := posttree.Commitment().Bytes()
// if !bytes.Equal(regeneratedPostTreeRoot[:], postStateRoot) {
// return fmt.Errorf("post tree root mismatch: %x != %x", regeneratedPostTreeRoot, postStateRoot)
// }
regeneratedPostTreeRoot := posttree.Commitment().Bytes()
if !bytes.Equal(regeneratedPostTreeRoot[:], postStateRoot) {
return fmt.Errorf("post tree root mismatch: %x != %x", regeneratedPostTreeRoot, postStateRoot)
}

return verkle.VerifyVerkleProofWithPreState(proof, pretree)
}
Expand Down Expand Up @@ -1245,6 +1245,7 @@ func TestProcessVerkleSelfDestructInSeparateTx(t *testing.T) {
}
})

var zero [32]byte
{ // Check self-destructed contract in the witness
selfDestructContractTreeKey := utils.GetTreeKeyCodeHash(selfDestructContractAddr[:])

Expand Down Expand Up @@ -1272,9 +1273,9 @@ func TestProcessVerkleSelfDestructInSeparateTx(t *testing.T) {
}

// The new balance must be 0.
// if !bytes.Equal((*balanceStateDiff.NewValue)[utils.BasicDataBalanceOffset:], zero[utils.BasicDataBalanceOffset:]) {
// t.Fatalf("the post-state balance after self-destruct must be 0")
// }
if !bytes.Equal((*balanceStateDiff.NewValue)[utils.BasicDataBalanceOffset:], zero[utils.BasicDataBalanceOffset:]) {
t.Fatalf("the post-state balance after self-destruct must be 0")
}
}
{ // Check self-destructed target in the witness.
selfDestructTargetTreeKey := utils.GetTreeKeyCodeHash(account2[:])
Expand Down Expand Up @@ -1421,14 +1422,14 @@ func TestProcessVerkleSelfDestructInSameTx(t *testing.T) {
if balanceStateDiff.CurrentValue == nil {
t.Fatalf("codeHash.CurrentValue must not be empty")
}
// if balanceStateDiff.NewValue == nil {
// t.Fatalf("codeHash.NewValue must not be empty")
// }
// preStateBalance := binary.BigEndian.Uint64(balanceStateDiff.CurrentValue[utils.BasicDataBalanceOffset+8:])
// postStateBalance := binary.BigEndian.Uint64(balanceStateDiff.NewValue[utils.BasicDataBalanceOffset+8:])
// if postStateBalance-preStateBalance != 42 {
// t.Fatalf("the post-state balance after self-destruct must be 42. got %d", postStateBalance)
// }
if balanceStateDiff.NewValue == nil {
t.Fatalf("codeHash.NewValue must not be empty")
}
preStateBalance := binary.BigEndian.Uint64(balanceStateDiff.CurrentValue[utils.BasicDataBalanceOffset+8:])
postStateBalance := binary.BigEndian.Uint64(balanceStateDiff.NewValue[utils.BasicDataBalanceOffset+8:])
if postStateBalance-preStateBalance != 42 {
t.Fatalf("the post-state balance after self-destruct must be 42. got %d", postStateBalance)
}
}
}

Expand Down

0 comments on commit 22c2fec

Please sign in to comment.