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

WIP mega eof #29518

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c23f8af
core/vm: add eof container
lightclient Dec 6, 2022
e8953bd
happy lint, happy life
MariusVanDerWijden Apr 12, 2024
9aa46f3
core/vm: add optional containerSections
MariusVanDerWijden Apr 12, 2024
9ca1532
core/vm: add optional containerSections
MariusVanDerWijden Apr 12, 2024
e5724b2
core/types: implement InitCodeTransaction for EOF
MariusVanDerWijden Apr 12, 2024
4723974
core/vm: implement JUMPF, added disallowed opcodes
MariusVanDerWijden Apr 15, 2024
1e381a3
core/vm: started work on eofcreate, safety push
MariusVanDerWijden Apr 15, 2024
319d022
core/vm: started work on eofcreate
MariusVanDerWijden Apr 16, 2024
ed5b362
core/vm: implement dataload opcodes
MariusVanDerWijden Apr 16, 2024
61aa4c1
core/vm: implement dupN, swapN
MariusVanDerWijden Apr 16, 2024
1762ea3
core/vm: refactor using min
MariusVanDerWijden Apr 16, 2024
e1e0a7a
core/vm: implement opReturnDataLoad
MariusVanDerWijden Apr 16, 2024
6e16cf5
core/vm: implement opExt{Call,StaticCall,DelegateCall}
MariusVanDerWijden Apr 16, 2024
5eac46f
core/vm: added opcode names
MariusVanDerWijden Apr 17, 2024
9640e5f
core/vm: add opcodes to the jumptable
MariusVanDerWijden Apr 17, 2024
7e7517d
cmd/evm: implement evm eofdump
MariusVanDerWijden Apr 17, 2024
22f49b5
cmd/evm: implement evm eofdump
MariusVanDerWijden Apr 17, 2024
b537b7d
cmd/evm: fix tests
MariusVanDerWijden Apr 17, 2024
fc4f265
cmd/eofdump: move eofdump to own subcommand
MariusVanDerWijden Apr 17, 2024
e677308
core/vm: fixed bug in marshaling
MariusVanDerWijden Apr 17, 2024
9443916
core/vm: better validation
MariusVanDerWijden Apr 18, 2024
f5ecd89
core/vm: fixed pc skip
MariusVanDerWijden Apr 18, 2024
ee16514
cmd/eofdump: add recursive mode for tests
MariusVanDerWijden Apr 19, 2024
a033d6b
core/vm: fix a few bugs, prettier print
MariusVanDerWijden Apr 22, 2024
8835928
core/vm: fix bugs in DATALOADN, Validation, PUSH9 etc
MariusVanDerWijden Apr 22, 2024
f669cfc
core/vm: fix bugs in RETURNCONTRACT validation
MariusVanDerWijden Apr 22, 2024
06872b2
core/vm: fix bugs in EOFCREATE validation and others
MariusVanDerWijden Apr 23, 2024
96fd50a
core/vm: make sure every section is reachable
MariusVanDerWijden Apr 23, 2024
046f287
core/vm: fix subcontainer validation
MariusVanDerWijden Apr 24, 2024
efb9807
core/vm: fix max-stack-height validation
MariusVanDerWijden Apr 24, 2024
44d876c
core/vm: fix RJUMPV to use max_size + 1, fix tests
MariusVanDerWijden Apr 24, 2024
56a0ca8
core/vm: fix CALLF stack height validation
MariusVanDerWijden Apr 24, 2024
104df43
core/vm: fix DUPN, SWAPN, EXCHANGE stack height validation
MariusVanDerWijden Apr 24, 2024
ab6003b
core/vm: fix DUPN, SWAPN, EXCHANGE stack height validation
MariusVanDerWijden Apr 24, 2024
4add7c2
core/vm: fix JUMPF stack height validation
MariusVanDerWijden Apr 24, 2024
f762178
core/vm: fix backward jump validation
MariusVanDerWijden May 6, 2024
3929447
core/vm: fix ext stack heights, fix jumpdest validation bitmap
MariusVanDerWijden May 6, 2024
2f91f0b
core/vm: started work on linear validation
MariusVanDerWijden May 21, 2024
8c7de99
core/vm: more fixes for validate_linear
MariusVanDerWijden May 22, 2024
65a20c4
core/vm: more fixes for validate_linear
MariusVanDerWijden May 23, 2024
ab1c88c
core/vm: fix stack limit
MariusVanDerWijden May 24, 2024
076a587
core/vm: fix rjumpv offsets
MariusVanDerWijden May 24, 2024
a643fe9
core/vm: fix test
MariusVanDerWijden May 24, 2024
4d29707
core/vm: fix underflow checks
MariusVanDerWijden May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions cmd/evm/eofparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,24 @@ func parseAndValidate(s string) (*vm.Container, error) {
}
return &c, nil
}

func eofDump(ctx *cli.Context) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have cmd/rlpdump and cmd/abidump. How about a cmd/eofdump ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, will move

// If `--hex` is set, parse and validate the hex string argument.
if ctx.IsSet(HexFlag.Name) {
s := ctx.String(HexFlag.Name)
if len(s) >= 2 && strings.HasPrefix(s, "0x") {
s = s[2:]
}
b, err := hex.DecodeString(s)
if err != nil {
return fmt.Errorf("unable to decode data: %w", err)
}
var c vm.Container
if err := c.UnmarshalBinary(b); err != nil {
return err
}
fmt.Print(c.String())
return nil
}
return nil
}
9 changes: 9 additions & 0 deletions cmd/evm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ var eofParserCommand = &cli.Command{
},
}

var eofDumpCommand = &cli.Command{
Name: "eofdump",
Usage: "parses hex eof container",
Action: eofDump,
Flags: []cli.Flag{
HexFlag,
},
}

var app = flags.NewApp("the evm command line interface")

func init() {
Expand Down
40 changes: 40 additions & 0 deletions core/vm/eof.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package vm
import (
"bytes"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -361,3 +362,42 @@ func sum(list []int) (s int) {
}
return
}

func (c *Container) String() string {
var result string
result += "Header\n"
result += "-----------\n"
result += fmt.Sprintf("EOFMagic: %v\n", eofMagic)
result += fmt.Sprintf("EOFVersion: %v\n", eof1Version)
result += fmt.Sprintf("KindType: %v\n", kindTypes)
result += fmt.Sprintf("TypesSize: %v\n", len(c.Types)*4)
result += fmt.Sprintf("KindCode: %v\n", kindCode)
result += fmt.Sprintf("CodeSize: %v\n", len(c.Code))
for i, code := range c.Code {
result += fmt.Sprintf("Code %v length: %v\n", i, len(code))
}
if len(c.ContainerSections) != 0 {
result += fmt.Sprintf("KindContainer: %v\n", kindContainer)
result += fmt.Sprintf("ContainerSize: %v\n", len(c.ContainerSections))
for i, section := range c.ContainerSections {
result += fmt.Sprintf("Container %v length: %v\n", i, len(section))
}
}
result += fmt.Sprintf("KindData: %v\n", kindData)
result += fmt.Sprintf("DataSize: %v\n", len(c.Data))
result += fmt.Sprintf("Terminator: %v\n", 0x0)
result += "-----------\n"
result += "Body\n"
result += "-----------\n"
for i, typ := range c.Types {
result += fmt.Sprintf("Type %v: %v", i, hex.EncodeToString([]byte{typ.Input, typ.Output, byte(typ.MaxStackHeight >> 8), byte(typ.MaxStackHeight & 0x00ff)}))
}
for i, code := range c.Code {
result += fmt.Sprintf("Code %v: %v", i, hex.EncodeToString(code))
}
for i, section := range c.ContainerSections {
result += fmt.Sprintf("Section %v: %v", i, hex.EncodeToString(section))
}
result += fmt.Sprintf("Data: %v", hex.EncodeToString(c.Data))
return result
}