Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: don't add the trailing pushdata for a final PUSHn #90

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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