/
ArbDebug.go
61 lines (48 loc) · 1.99 KB
/
ArbDebug.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
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE
package precompiles
import (
"errors"
"github.com/ethereum/go-ethereum/common"
)
// All calls to this precompile are authorized by the DebugPrecompile wrapper,
// which ensures these methods are not accessible in production.
type ArbDebug struct {
Address addr // 0xff
Basic func(ctx, mech, bool, bytes32) error // index'd: 2nd
Mixed func(ctx, mech, bool, bool, bytes32, addr, addr) error // index'd: 1st 3rd 5th
Store func(ctx, mech, bool, addr, huge, bytes32, []byte) error // index'd: 1st 2nd
BasicGasCost func(bool, bytes32) (uint64, error)
MixedGasCost func(bool, bool, bytes32, addr, addr) (uint64, error)
StoreGasCost func(bool, addr, huge, bytes32, []byte) (uint64, error)
CustomError func(uint64, string, bool) error
UnusedError func() error
}
func (con ArbDebug) Events(c ctx, evm mech, paid huge, flag bool, value bytes32) (addr, huge, error) {
// Emits 2 events that cover each case
// Basic tests an index'd value & a normal value
// Mixed interleaves index'd and normal values that may need to be padded
err := con.Basic(c, evm, !flag, value)
if err != nil {
return addr{}, nil, err
}
err = con.Mixed(c, evm, flag, !flag, value, con.Address, c.caller)
if err != nil {
return addr{}, nil, err
}
return c.caller, paid, nil
}
func (con ArbDebug) EventsView(c ctx, evm mech) error {
_, _, err := con.Events(c, evm, common.Big0, true, bytes32{})
return err
}
func (con ArbDebug) CustomRevert(c ctx, number uint64) error {
return con.CustomError(number, "This spider family wards off bugs: /\\oo/\\ //\\(oo)/\\ /\\oo/\\", true)
}
// Caller becomes a chain owner
func (con ArbDebug) BecomeChainOwner(c ctx, evm mech) error {
return c.State.ChainOwners().Add(c.caller)
}
func (con ArbDebug) LegacyError(c ctx) error {
return errors.New("example legacy error")
}