From 22c2fecbc4230b1a6442535f72353bfb23df524b Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 24 Oct 2024 12:29:09 +0200 Subject: [PATCH] re-enable old features Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com> --- core/state_processor_test.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 2a7676aea197..6e294a29c8d1 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -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) } @@ -1245,6 +1245,7 @@ func TestProcessVerkleSelfDestructInSeparateTx(t *testing.T) { } }) + var zero [32]byte { // Check self-destructed contract in the witness selfDestructContractTreeKey := utils.GetTreeKeyCodeHash(selfDestructContractAddr[:]) @@ -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[:]) @@ -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) + } } }