Skip to content

Commit

Permalink
spec: don't add the trailing pushdata for a final PUSHn (ethereum#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
gballet authored Mar 17, 2022
1 parent 8bb23d8 commit ab87f5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
12 changes: 0 additions & 12 deletions trie/verkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
13 changes: 2 additions & 11 deletions trie/verkle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down

0 comments on commit ab87f5f

Please sign in to comment.