From e939d2e4b6af057534a53d100853d03c63e14265 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Thu, 17 Mar 2022 07:38:50 +0100 Subject: [PATCH] spec: don't add the trailing pushdata for a final PUSHn --- trie/verkle.go | 12 ------------ trie/verkle_test.go | 13 ++----------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/trie/verkle.go b/trie/verkle.go index a31c99f1d12a..ad73ebd08769 100644 --- a/trie/verkle.go +++ b/trie/verkle.go @@ -322,7 +322,6 @@ func ChunkifyCode(code []byte) ([][32]byte, error) { } chunks := make([][32]byte, chunkCount) for i := range chunks { - // number of bytes to copy, 31 unless // the end of the code has been reached. end := 31 * (i + 1) @@ -359,16 +358,5 @@ func ChunkifyCode(code []byte) ([][32]byte, error) { } } - // if PUSHDATA went past the code end, add 0-filled chunks with - // the correct offset. - if chunkOffset > 0 { - - if chunkOffset > 31 { - chunks = append(chunks, [32]byte{31}, [32]byte{1}) - } else { - chunks = append(chunks, [32]byte{byte(chunkOffset)}) - } - } - return chunks, nil } diff --git a/trie/verkle_test.go b/trie/verkle_test.go index 3c6e05a810e0..de77bcc1db73 100644 --- a/trie/verkle_test.go +++ b/trie/verkle_test.go @@ -193,15 +193,12 @@ func TestChunkifyCodeFuzz(t *testing.T) { if err != nil { t.Fatal(err) } - if len(chunks) != 2 { + if len(chunks) != 1 { t.Fatalf("invalid length %d", len(chunks)) } if chunks[0][0] != 0 { t.Fatalf("invalid offset in first chunk %d != 0", chunks[0][0]) } - if chunks[1][0] != 3 { - t.Fatalf("invalid offset in second chunk %d != 3, chunk=%x", chunks[1][0], chunks[1]) - } t.Logf("code=%x, chunks=%x\n", code, chunks) code = []byte{ @@ -212,18 +209,12 @@ func TestChunkifyCodeFuzz(t *testing.T) { if err != nil { t.Fatal(err) } - if len(chunks) != 3 { + if len(chunks) != 1 { t.Fatalf("invalid length %d", len(chunks)) } if chunks[0][0] != 0 { t.Fatalf("invalid offset in first chunk %d != 0", chunks[0][0]) } - if chunks[1][0] != 31 { - t.Fatalf("invalid offset in second chunk %d != 31, chunk=%x", chunks[1][0], chunks[1]) - } - if chunks[2][0] != 1 { - t.Fatalf("invalid offset in third chunk %d != 1, chunk=%x", chunks[2][0], chunks[1]) - } t.Logf("code=%x, chunks=%x\n", code, chunks) code = []byte{