zink/ffi/
evm.rs

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//! EVM FFI.

use crate::primitives::{Address, Bytes32};

#[link(wasm_import_module = "evm")]
#[allow(improper_ctypes)]
extern "C" {
    /// Push 1 byte to the stack.
    pub fn push0();

    /// Push 1 byte to the stack.
    pub fn push1(val: i32);

    /// Push 2 bytes to the stack.
    pub fn push2(val: i32);

    /// Push 3 bytes to the stack.
    pub fn push3(val: i32);

    /// Push 4 bytes to the stack.
    pub fn push4(val: i32);

    /// Push 5 bytes to the stack.
    pub fn push5(val: i32);

    /// Push 6 bytes to the stack.
    pub fn push6(val: i32);

    /// Push 7 bytes to the stack.
    pub fn push7(val: i32);

    /// Push 8 bytes to the stack.
    pub fn push8(val: i32);

    /// Push 9 bytes to the stack.
    pub fn push9(val: i32);

    /// Push 10 bytes to the stack.
    pub fn push10(val: i32);

    /// Push 11 bytes to the stack.
    pub fn push11(val: i32);

    /// Push 12 bytes to the stack.
    pub fn push12(val: i32);

    /// Push 13 bytes to the stack.
    pub fn push13(val: i32);

    /// Push 14 bytes to the stack.
    pub fn push14(val: i32);

    /// Push 15 bytes to the stack.
    pub fn push15(val: i32);

    /// Push 16 bytes to the stack.
    pub fn push16(val: i32);

    /// Push 17 bytes to the stack.
    pub fn push17(val: i32);

    /// Push 18 bytes to the stack.
    pub fn push18(val: i32);

    /// Push 19 bytes to the stack.
    pub fn push19(val: i32);

    /// Push 20 bytes to the stack.
    pub fn push20(val: i32);

    /// Push 21 bytes to the stack.
    pub fn push21(val: i32);

    /// Push 22 bytes to the stack.
    pub fn push22(val: i32);

    /// Push 23 bytes to the stack.
    pub fn push23(val: i32);

    /// Push 24 bytes to the stack.
    pub fn push24(val: i32);

    /// Push 25 bytes to the stack.
    pub fn push25(val: i32);

    /// Push 26 bytes to the stack.
    pub fn push26(val: i32);

    /// Push 27 bytes to the stack.
    pub fn push27(val: i32);

    /// Push 28 bytes to the stack.
    pub fn push28(val: i32);

    /// Push 29 bytes to the stack.
    pub fn push29(val: i32);

    /// Push 30 bytes to the stack.
    pub fn push30(val: i32);

    /// Push 31 bytes to the stack.
    pub fn push31(val: i32);

    /// Push 32 bytes to the stack.
    pub fn push32();

    /// Store a value in the storage
    pub fn sstore();

    /// Load a value from the storage
    pub fn sload();

    /// Store a value in the transient storage
    pub fn tstore();

    /// Load a value from the transient storage
    pub fn tload();

    /// Save word to memory
    pub fn mstore();

    /// Save byte to memory
    pub fn mstore8();

    /// Load word from memory
    pub fn mload();

    /// Copy memory to memory
    pub fn mcopy();

    /// Compute Keccak-256 hash
    pub fn keccak256();

    /// Get the current message sender
    pub fn caller() -> Address;

    /// Get the current blob hash at index
    pub fn blobhash();

    /// Get the current blob base fee
    pub fn blobbasefee();

    /// Append log record with no topics
    pub fn log0(name: &'static [u8]);

    /// Append log record with one topic
    pub fn log1(topic1: Bytes32, name: &'static [u8]);

    /// Append log record with two topics
    pub fn log2(topic1: Bytes32, topic2: Bytes32, name: &'static [u8]);

    /// Append log record with three topics
    pub fn log3(topic1: Bytes32, topic2: Bytes32, topic3: Bytes32, name: &'static [u8]);

    /// Append log record with four topics
    pub fn log4(
        topic1: Bytes32,
        topic2: Bytes32,
        topic3: Bytes32,
        topic4: Bytes32,
        name: &'static [u8],
    );
}