mirror of
https://github.com/status-im/EIPs.git
synced 2025-02-23 20:28:21 +00:00
Automatically merged updates to draft EIP(s) 2315 (#3380)
Hi, I'm a bot! This change was automatically merged because: - It only modifies existing Draft, Review, or Last Call EIP(s) - The PR was approved or written by at least one author of each modified EIP - The build is passing
This commit is contained in:
parent
b7c7561f9f
commit
324ca88a48
@ -153,20 +153,20 @@ The following is a pseudo-go specification of an algorithm for enforcing program
|
||||
bytecode []byte
|
||||
stack_depth []int
|
||||
SP := 0
|
||||
validate(PC :=0)
|
||||
{
|
||||
validate(PC :=0) {
|
||||
// traverse code sequentially, recurse for subroutines and conditional jumps
|
||||
while true
|
||||
{
|
||||
while true {
|
||||
instruction = bytecode[PC]
|
||||
if is_invalid(instruction)
|
||||
if is_invalid(instruction) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// if stack depth set we have been here before
|
||||
// if stack depth non-zero we have been here before
|
||||
// check for constant depth and return to break cycle
|
||||
if stack_depth[PC] != 0 {
|
||||
if SP != stack_depth[PC]
|
||||
if SP != stack_depth[PC] {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
stack_depth[PC] = SP
|
||||
@ -174,62 +174,70 @@ The following is a pseudo-go specification of an algorithm for enforcing program
|
||||
// effect of instruction on stack
|
||||
SP -= removed_items(instruction)
|
||||
SP += added_items(instruction)
|
||||
if SP < 0 || 1024 < SP
|
||||
if SP < 0 || 1024 < SP {
|
||||
return false
|
||||
}
|
||||
|
||||
// successful validation of path
|
||||
if instruction == STOP, RETURN, or SUICIDE
|
||||
if instruction == STOP, RETURN, or SUICIDE {
|
||||
return true
|
||||
}
|
||||
|
||||
if instruction == JUMP {
|
||||
|
||||
if instruction == JUMP
|
||||
{
|
||||
// check for constant and correct destination
|
||||
if (bytecode[PC - 33] != PUSH32)
|
||||
if (bytecode[PC - 33] != PUSH32) {
|
||||
return false
|
||||
}
|
||||
PC = stack[PC-32]
|
||||
if byte_code[PC] != JUMPDEST
|
||||
if byte_code[PC] != JUMPDEST {
|
||||
return false
|
||||
}
|
||||
|
||||
// reset PC to destination of jump
|
||||
PC = stack[PC-32]
|
||||
continue
|
||||
}
|
||||
if instruction == JUMPI
|
||||
{
|
||||
// check for constant and correct destination
|
||||
if (bytecode[PC - 33] != PUSH32)
|
||||
return false
|
||||
PC = stack[PC-32]
|
||||
if byte_code[PC] != JUMPDEST
|
||||
return false
|
||||
if instruction == JUMPI {
|
||||
|
||||
// recurse to jump to code to validate
|
||||
if !validate(stack[SP]))
|
||||
// check for constant and correct destination
|
||||
if (bytecode[PC - 33] != PUSH32) {
|
||||
return false
|
||||
}
|
||||
PC = stack[PC-32]
|
||||
if byte_code[PC] != JUMPDEST {
|
||||
return false
|
||||
}
|
||||
// recurse to jump to code to validate
|
||||
if !validate(stack[SP])) {
|
||||
return false
|
||||
}
|
||||
continue
|
||||
}
|
||||
if instruction == JUMPSUB
|
||||
{
|
||||
if instruction == JUMPSUB {
|
||||
|
||||
// check for constant and correct destination
|
||||
if (bytecode[PC - 33] != PUSH32)
|
||||
return false
|
||||
prevPC = PC
|
||||
PC = stack[PC-32]
|
||||
if byte_code[PC] != BEGINSUB
|
||||
if byte_code[PC] != BEGINSUB {
|
||||
return false
|
||||
}
|
||||
|
||||
// recurse to jump to code to validate
|
||||
prevSP = SP
|
||||
depth = SP - prevSP
|
||||
SP = depth
|
||||
if !validate(stack[SP]+1))
|
||||
if !validate(stack[SP]+1)) {
|
||||
return false
|
||||
}
|
||||
SP = prevSP - depth + SP
|
||||
PC = prevPC
|
||||
continue
|
||||
}
|
||||
if instruction == RETURNSUB
|
||||
{
|
||||
if instruction == RETURNSUB {
|
||||
|
||||
// successful return from recursion
|
||||
PC = prevPC
|
||||
return true
|
||||
|
Loading…
x
Reference in New Issue
Block a user