forked from MariusVanDerWijden/tx-fuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
london.go
70 lines (62 loc) · 1.64 KB
/
london.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package txfuzz
import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/holiman/goevmlab/ops"
"github.com/holiman/goevmlab/program"
)
func Selfdestructor() []byte {
selfdestructTo := []byte{
byte(vm.PUSH1),
0,
byte(vm.CALLDATALOAD),
byte(vm.PUSH20),
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
byte(vm.AND),
byte(vm.SELFDESTRUCT),
}
initcode := program.NewProgram()
initcode.Mstore(selfdestructTo, 0)
initcode.Return(0, uint32(len(selfdestructTo)))
program := program.NewProgram()
Create(program, selfdestructTo, false, true)
program.Op(ops.POP)
Create(program, selfdestructTo, true, false)
program.Op(ops.POP)
Create(program, initcode.Bytecode(), true, false)
//program.CreateAndCall(initcode.Bytecode(), true, ops.STATICCALL)
//program.CreateAndCall(initcode.Bytecode(), true, ops.DELEGATECALL)
return program.Bytecode()
}
func EfByte() []byte {
inner := []byte{
0xEF,
}
initcode := program.NewProgram()
initcode.Mstore(inner, 0)
initcode.Return(0, uint32(len(inner)))
program := program.NewProgram()
Create(program, initcode.Bytecode(), false, false)
program.Op(ops.POP)
Create(program, initcode.Bytecode(), true, true)
program.Op(ops.POP)
return program.Bytecode()
}
func Create(p *program.Program, code []byte, inMemory bool, isCreate2 bool) {
var (
value = 0
offset = 0
size = len(code)
salt = 0
createOp = ops.CREATE
)
// Load the code into mem
if !inMemory {
p.Mstore(code, 0)
}
// Create it
if isCreate2 {
p.Push(salt)
createOp = ops.CREATE2
}
p.Push(size).Push(offset).Push(value).Op(createOp)
}