Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ArbDebug.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ interface ArbDebug {
uint64 number
) external pure;

/// @notice Available in ArbOS version 30 and above
function panic() external;

function legacyError() external pure;

error Custom(uint64, string, bool);
Expand Down
80 changes: 80 additions & 0 deletions ArbOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,86 @@ interface ArbOwner {
uint256 maxWeiToRelease
) external returns (uint256);

/// @notice Sets the amount of ink 1 gas buys
/// @notice Available in ArbOS version 30 and above
/// @param price the conversion rate (must fit in a uint24)
function setInkPrice(
uint32 price
) external;

/// @notice Sets the maximum depth (in wasm words) a wasm stack may grow
/// @notice Available in ArbOS version 30 and above
function setWasmMaxStackDepth(
uint32 depth
) external;

/// @notice Sets the number of free wasm pages a tx gets
/// @notice Available in ArbOS version 30 and above
function setWasmFreePages(
uint16 pages
) external;

/// @notice Sets the base cost of each additional wasm page
/// @notice Available in ArbOS version 30 and above
function setWasmPageGas(
uint16 gas
) external;

/// @notice Sets the maximum number of pages a wasm may allocate
/// @notice Available in ArbOS version 30 and above
function setWasmPageLimit(
uint16 limit
) external;

/// @notice Sets the maximum size of the uncompressed wasm code in bytes
/// @notice Available in ArbOS version 30 and above
function setWasmMaxSize(
uint32 size
) external;

/// @notice Sets the minimum costs to invoke a program
/// @notice Available in ArbOS version 30 and above
/// @param gas amount of gas paid in increments of 256 when not the program is not cached
/// @param cached amount of gas paid in increments of 64 when the program is cached
function setWasmMinInitGas(uint8 gas, uint16 cached) external;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential type mismatch. Both gas and cached are marked as uint64 in the implementation file (here).


/// @notice Sets the linear adjustment made to program init costs.
/// @notice Available in ArbOS version 30 and above
/// @param percent the adjustment (100% = no adjustment).
function setWasmInitCostScalar(
uint64 percent
) external;

/// @notice Sets the number of days after which programs deactivate
/// @notice Available in ArbOS version 30 and above
function setWasmExpiryDays(
uint16 _days
) external;

/// @notice Sets the age a program must be to perform a keepalive
/// @notice Available in ArbOS version 30 and above
function setWasmKeepaliveDays(
uint16 _days
) external;

/// @notice Sets the number of extra programs ArbOS caches during a given block
/// @notice Available in ArbOS version 30 and above
function setWasmBlockCacheSize(
uint16 count
) external;

/// @notice Adds account as a wasm cache manager
/// @notice Available in ArbOS version 30 and above
function addWasmCacheManager(
address manager
) external;

/// @notice Removes account from the list of wasm cache managers
/// @notice Available in ArbOS version 30 and above
function removeWasmCacheManager(
address manager
) external;

/// @notice Sets serialized chain config in ArbOS state
/// @notice Available in ArbOS version 11 and above
function setChainConfig(
Expand Down
130 changes: 130 additions & 0 deletions ArbWasm.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
// 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);

event ProgramActivated(
bytes32 indexed codehash,
bytes32 moduleHash,
address program,
uint256 dataFee,
uint16 version
);
event ProgramLifetimeExtended(bytes32 indexed codehash, uint256 dataFee);

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);
}
43 changes: 43 additions & 0 deletions ArbWasmCache.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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 Stylus caches
* @notice Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000072.
* @notice Available in ArbOS version 30 and above
*/
interface ArbWasmCache {
/// @notice See if the user is a cache manager.
function isCacheManager(
address manager
) external view returns (bool);

/// @notice Retrieve all address managers.
/// @return managers the list of managers.
function allCacheManagers() external view returns (address[] memory managers);

/// @notice Caches all programs with the given codehash.
/// @notice Reverts if the programs have expired.
/// @notice Caller must be a cache manager or chain owner.
/// @notice If you're looking for how to bid for position, interact with the chain's cache manager contract.
/// @notice Available in ArbOS version 30.
function cacheCodehash(
bytes32 codehash
) external;

/// @notice Evicts all programs with the given codehash.
/// @notice Caller must be a cache manager or chain owner.
function evictCodehash(
bytes32 codehash
) external;

/// @notice Gets whether a program is cached. Note that the program may be expired.
function codehashIsCached(
bytes32 codehash
) external view returns (bool);

event UpdateProgramCache(address indexed manager, bytes32 indexed codehash, bool cached);
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arbitrum/nitro-precompile-interfaces",
"version": "20.0.0",
"version": "30.0.0",
"description": "Solidity interfaces for Arbitrum Nitro precompiled contracts",
"author": "Offchain Labs, Inc.",
"license": "BUSL-1.1",
Expand Down