core/vm: EIP-2315, JUMPSUB for the EVM (#20619)

* core/vm: implement EIP 2315, subroutines for the EVM

* core/vm: eip 2315 - lintfix + check jump dest validity + check ret stack size constraints

  logger: markdown-friendly traces, validate jumpdest, more testcase, correct opcodes

* core/vm: update subroutines acc to eip: disallow walk-into

* core/vm/eips: gas cost changes for subroutines

* core/vm: update opcodes for EIP-2315

* core/vm: define RETURNSUB as a 'jumping' operation + review concerns

Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
Greg Colvin
2020-06-02 04:30:16 -06:00
committed by GitHub
parent a35382de94
commit cd57d5cd38
15 changed files with 529 additions and 52 deletions

View File

@ -23,6 +23,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
Memory hexutil.Bytes `json:"memory"`
MemorySize int `json:"memSize"`
Stack []*math.HexOrDecimal256 `json:"stack"`
ReturnStack []math.HexOrDecimal64 `json:"returnStack"`
Storage map[common.Hash]common.Hash `json:"-"`
Depth int `json:"depth"`
RefundCounter uint64 `json:"refund"`
@ -43,6 +44,12 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
enc.Stack[k] = (*math.HexOrDecimal256)(v)
}
}
if s.ReturnStack != nil {
enc.ReturnStack = make([]math.HexOrDecimal64, len(s.ReturnStack))
for k, v := range s.ReturnStack {
enc.ReturnStack[k] = math.HexOrDecimal64(v)
}
}
enc.Storage = s.Storage
enc.Depth = s.Depth
enc.RefundCounter = s.RefundCounter
@ -62,6 +69,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
Memory *hexutil.Bytes `json:"memory"`
MemorySize *int `json:"memSize"`
Stack []*math.HexOrDecimal256 `json:"stack"`
ReturnStack []math.HexOrDecimal64 `json:"returnStack"`
Storage map[common.Hash]common.Hash `json:"-"`
Depth *int `json:"depth"`
RefundCounter *uint64 `json:"refund"`
@ -95,6 +103,12 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
s.Stack[k] = (*big.Int)(v)
}
}
if dec.ReturnStack != nil {
s.ReturnStack = make([]uint64, len(dec.ReturnStack))
for k, v := range dec.ReturnStack {
s.ReturnStack[k] = uint64(v)
}
}
if dec.Storage != nil {
s.Storage = dec.Storage
}