Repository navigation
Expand file tree
/
Copy pathArbWasm.sol
More file actions
165 lines (136 loc) · 6.9 KB
/
Copy pathArbWasm.sol
File metadata and controls
165 lines (136 loc) · 6.9 KB
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
164
165
// Copyright 2022-2024, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.4.21 <0.9.0;
/**
* @title Methods for managing user programs
* @notice Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000071.
* @notice Available in ArbOS version 30 and above
*/
interface ArbWasm {
/// @notice Activate a wasm program
/// @param program the program to activate
/// @return version the stylus version the program was activated against
/// @return dataFee the data fee paid to store the activated program
function activateProgram(
address program
) external payable returns (uint16 version, uint256 dataFee);
/// @notice Gets the latest stylus version
/// @return version the stylus version
function stylusVersion() external view returns (uint16 version);
/// @notice Gets the stylus version the program with codehash was most recently activated against
/// @return version the program version (reverts for EVM contracts)
function codehashVersion(
bytes32 codehash
) external view returns (uint16 version);
/// @notice Extends a program's expiration date.
/// Reverts if too soon or if the program is not up to date.
function codehashKeepalive(
bytes32 codehash
) external payable;
/// @notice Gets a program's asm size.
/// Reverts if program is not active.
/// @return size the size in bytes
function codehashAsmSize(
bytes32 codehash
) external view returns (uint32 size);
/// @notice Gets the stylus version the program was most recently activated against
/// @return version the program version (reverts for EVM contracts)
function programVersion(
address program
) external view returns (uint16 version);
/// @notice Gets the cost to invoke the program
/// @return gas the amount of gas
/// @return gasWhenCached the amount of gas if the program was recently used
function programInitGas(
address program
) external view returns (uint64 gas, uint64 gasWhenCached);
/// @notice Gets the memory footprint of the program at the given address in pages
/// @return footprint the memory footprint of program in pages (reverts for EVM contracts)
function programMemoryFootprint(
address program
) external view returns (uint16 footprint);
/// @notice Gets the amount of time remaining until the program expires
/// @return _secs the time left in seconds (reverts for EVM contracts)
function programTimeLeft(
address program
) external view returns (uint64 _secs);
/// @notice Gets the conversion rate between gas and ink
/// @return price the amount of ink 1 gas buys
function inkPrice() external view returns (uint32 price);
/// @notice Gets the wasm stack size limit
/// @return depth the maximum depth (in wasm words) a wasm stack may grow
function maxStackDepth() external view returns (uint32 depth);
/// @notice Gets the number of free wasm pages a program gets
/// @return pages the number of wasm pages (2^16 bytes)
function freePages() external view returns (uint16 pages);
/// @notice Gets the base cost of each additional wasm page (2^16 bytes)
/// @return gas base amount of gas needed to grow another wasm page
function pageGas() external view returns (uint16 gas);
/// @notice Gets the ramp that drives exponential memory costs
/// @return ramp bits representing the floating point value
function pageRamp() external view returns (uint64 ramp);
/// @notice Gets the maximum number of pages a wasm may allocate
/// @return limit the number of pages
function pageLimit() external view returns (uint16 limit);
/// @notice Gets the minimum costs to invoke a program
/// @return gas amount of gas in increments of 256 when not cached
/// @return cached amount of gas in increments of 64 when cached
function minInitGas() external view returns (uint64 gas, uint64 cached);
/// @notice Gets the linear adjustment made to program init costs.
/// @return percent the adjustment (100% = no adjustment).
function initCostScalar() external view returns (uint64 percent);
/// @notice Gets the number of days after which programs deactivate
/// @return _days the number of days
function expiryDays() external view returns (uint16 _days);
/// @notice Gets the age a program must be to perform a keepalive
/// @return _days the number of days
function keepaliveDays() external view returns (uint16 _days);
/// @notice Gets the number of extra programs ArbOS caches during a given block.
/// @return count the number of same-block programs.
function blockCacheSize() external view returns (uint16 count);
/// @notice Gets the constant gas charge applied before each stylus contract activation.
/// @notice Available in ArbOS version 60 and above
/// @return gas the activation gas charge
function activationGas() external view returns (uint64 gas);
/// @notice Deactivates all programs with the given codehash.
/// Caller must be a chain owner or a wasm deactivator.
/// @notice Available in ArbOS version 70 and above
function deactivateCodehash(
bytes32 codehash
) external;
/// @notice Checks whether account may activate new stylus programs
/// @notice Available in ArbOS version 70 and above
function isActivator(
address account
) external view returns (bool);
/// @notice Gets all accounts that may activate new stylus programs
/// @notice Available in ArbOS version 70 and above
function allActivators() external view returns (address[] memory);
/// @notice Checks whether account may deactivate stylus programs
/// @notice Available in ArbOS version 70 and above
function isDeactivator(
address account
) external view returns (bool);
/// @notice Gets all accounts that may deactivate stylus programs
/// @notice Available in ArbOS version 70 and above
function allDeactivators() external view returns (address[] memory);
event ProgramActivated(
bytes32 indexed codehash,
bytes32 moduleHash,
address program,
uint256 dataFee,
uint16 version
);
event ProgramLifetimeExtended(bytes32 indexed codehash, uint256 dataFee);
event ProgramDeactivated(address indexed deactivator, bytes32 indexed codehash);
error ProgramNotWasm();
error ProgramNotActivated();
error ProgramNeedsUpgrade(uint16 version, uint16 stylusVersion);
error ProgramExpired(uint64 ageInSeconds);
error ProgramUpToDate();
error ProgramKeepaliveTooSoon(uint64 ageInSeconds);
error ProgramInsufficientValue(uint256 have, uint256 want);
error ProgramActivationNotPermitted(address caller);
error ProgramDeactivationNotPermitted(address caller);
}