diff --git a/.github/workflows/contract-tests.yml b/.github/workflows/contract-tests.yml new file mode 100644 index 0000000..7d141e3 --- /dev/null +++ b/.github/workflows/contract-tests.yml @@ -0,0 +1,39 @@ +name: CI + +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + +jobs: + test-format: + name: Test format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: stable + cache: false + + - name: Setup node/yarn + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + cache-dependency-path: '**/yarn.lock' + + - name: Install packages + run: yarn + + - name: Check Contracts Format + run: yarn format --check + + - name: Make sure contracts can be built + run: yarn build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dc03a0d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +cache +out +lib +node_modules \ No newline at end of file diff --git a/ArbDebug.sol b/ArbDebug.sol index 66a9297..405241b 100644 --- a/ArbDebug.sol +++ b/ArbDebug.sol @@ -31,8 +31,6 @@ interface ArbDebug { uint64 number ) external pure; - function panic() external; - function legacyError() external pure; error Custom(uint64, string, bool); diff --git a/ArbGasInfo.sol b/ArbGasInfo.sol index a369403..f8961fd 100644 --- a/ArbGasInfo.sol +++ b/ArbGasInfo.sol @@ -61,14 +61,6 @@ interface ArbGasInfo { /// @notice Get how slowly ArbOS updates its estimate of the L1 basefee function getL1BaseFeeEstimateInertia() external view returns (uint64); - /// @notice Get the L1 pricer reward rate, in wei per unit - /// Available in ArbOS version 11 - function getL1RewardRate() external view returns (uint64); - - /// @notice Get the L1 pricer reward recipient - /// Available in ArbOS version 11 - function getL1RewardRecipient() external view returns (address); - /// @notice Deprecated -- Same as getL1BaseFeeEstimate() function getL1GasPriceEstimate() external view returns (uint256); @@ -92,27 +84,4 @@ interface ArbGasInfo { /// @notice Returns the cost amortization cap in basis points function getAmortizedCostCapBips() external view returns (uint64); - - /// @notice Returns the available funds from L1 fees - function getL1FeesAvailable() external view returns (uint256); - - /// @notice Returns the equilibration units parameter for L1 price adjustment algorithm - /// Available in ArbOS version 20 - function getL1PricingEquilibrationUnits() external view returns (uint256); - - /// @notice Returns the last time the L1 calldata pricer was updated. - /// Available in ArbOS version 20 - function getLastL1PricingUpdateTime() external view returns (uint64); - - /// @notice Returns the amount of L1 calldata payments due for rewards (per the L1 reward rate) - /// Available in ArbOS version 20 - function getL1PricingFundsDueForRewards() external view returns (uint256); - - /// @notice Returns the amount of L1 calldata posted since the last update. - /// Available in ArbOS version 20 - function getL1PricingUnitsSinceUpdate() external view returns (uint64); - - /// @notice Returns the L1 pricing surplus as of the last update (may be negative). - /// Available in ArbOS version 20 - function getLastL1PricingSurplus() external view returns (int256); } diff --git a/ArbNativeTokenManager.sol b/ArbNativeTokenManager.sol deleted file mode 100644 index 2efb86f..0000000 --- a/ArbNativeTokenManager.sol +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2021-2025, Offchain Labs, Inc. -// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE.md -// SPDX-License-Identifier: BUSL-1.1 - -pragma solidity >=0.4.21 <0.9.0; - -/** - * @title Enables minting and burning native tokens. - * @notice Authorized callers are added/removed through ArbOwner precompile. - * Precompiled contract that exists in every Arbitrum chain at 0x0000000000000000000000000000000000000073. - * Available in ArbOS version 41 - */ -interface ArbNativeTokenManager { - /** - * @notice Emitted when some amount of the native gas token is minted to a NativeTokenOwner. - */ - event NativeTokenMinted(address indexed to, uint256 amount); - - /** - * @notice Emitted when some amount of the native gas token is burned from a NativeTokenOwner. - */ - event NativeTokenBurned(address indexed from, uint256 amount); - - /** - * @notice In case the caller is authorized, - * mints some amount of the native gas token for this chain to the caller. - */ - function mintNativeToken( - uint256 amount - ) external; - - /** - * @notice In case the caller is authorized, - * burns some amount of the native gas token for this chain from the caller. - */ - function burnNativeToken( - uint256 amount - ) external; -} diff --git a/ArbOwner.sol b/ArbOwner.sol index 8c04e4a..8138b61 100644 --- a/ArbOwner.sol +++ b/ArbOwner.sol @@ -33,34 +33,6 @@ interface ArbOwner { /// @notice Retrieves the list of chain owners function getAllChainOwners() external view returns (address[] memory); - /// @notice Sets the NativeTokenManagementFrom time - /// Available in ArbOS version 41 - function setNativeTokenManagementFrom( - uint64 timestamp - ) external; - - /// @notice Add account as a native token owner - /// Available in ArbOS version 41 - function addNativeTokenOwner( - address newOwner - ) external; - - /// @notice Remove account from the list of native token owners - /// Available in ArbOS version 41 - function removeNativeTokenOwner( - address ownerToRemove - ) external; - - /// @notice See if the user is a native token owner - /// Available in ArbOS version 41 - function isNativeTokenOwner( - address addr - ) external view returns (bool); - - /// @notice Retrieves the list of native token owners - /// Available in ArbOS version 41 - function getAllNativeTokenOwners() external view returns (address[] memory); - /// @notice Set how slowly ArbOS updates its estimate of the L1 basefee function setL1BaseFeeEstimateInertia( uint64 inertia @@ -99,19 +71,11 @@ interface ArbOwner { /// @notice Get the network fee collector function getNetworkFeeAccount() external view returns (address); - /// @notice Get the infrastructure fee collector - function getInfraFeeAccount() external view returns (address); - /// @notice Set the network fee collector function setNetworkFeeAccount( address newNetworkFeeAccount ) external; - /// @notice Set the infrastructure fee collector - function setInfraFeeAccount( - address newInfraFeeAccount - ) external; - /// @notice Upgrades ArbOS to the requested version at the requested timestamp function scheduleArbOSUpgrade(uint64 newVersion, uint64 timestamp) external; @@ -145,104 +109,11 @@ interface ArbOwner { int64 cost ) external; - /** - * @notice Sets the Brotli compression level used for fast compression - * Available in ArbOS version 12 with default level as 1 - */ - function setBrotliCompressionLevel( - uint64 level - ) external; - /// @notice Sets the cost amortization cap in basis points function setAmortizedCostCapBips( uint64 cap ) external; - /// @notice Releases surplus funds from L1PricerFundsPoolAddress for use - function releaseL1PricerSurplusFunds( - uint256 maxWeiToRelease - ) external returns (uint256); - - /// @notice Sets the amount of ink 1 gas buys - /// @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 - function setWasmMaxStackDepth( - uint32 depth - ) external; - - /// @notice Sets the number of free wasm pages a tx gets - function setWasmFreePages( - uint16 pages - ) external; - - /// @notice Sets the base cost of each additional wasm page - function setWasmPageGas( - uint16 gas - ) external; - - /// @notice Sets the maximum number of pages a wasm may allocate - function setWasmPageLimit( - uint16 limit - ) external; - - /// @notice Sets the maximum size of the uncompressed wasm code in bytes - function setWasmMaxSize( - uint32 size - ) external; - - /// @notice Sets the minimum costs to invoke a program - /// @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; - - /// @notice Sets the linear adjustment made to program init costs. - /// @param percent the adjustment (100% = no adjustment). - function setWasmInitCostScalar( - uint64 percent - ) external; - - /// @notice Sets the number of days after which programs deactivate - function setWasmExpiryDays( - uint16 _days - ) external; - - /// @notice Sets the age a program must be to perform a keepalive - function setWasmKeepaliveDays( - uint16 _days - ) external; - - /// @notice Sets the number of extra programs ArbOS caches during a given block - function setWasmBlockCacheSize( - uint16 count - ) external; - - /// @notice Adds account as a wasm cache manager - function addWasmCacheManager( - address manager - ) external; - - /// @notice Removes account from the list of wasm cache managers - function removeWasmCacheManager( - address manager - ) external; - - /// @notice Sets serialized chain config in ArbOS state - function setChainConfig( - string calldata chainConfig - ) external; - - /** - * @notice Sets the increased calldata price feature on or off (EIP-7623) - * Available in ArbOS version 40 with default as false - */ - function setCalldataPriceIncrease( - bool enable - ) external; - /// Emitted when a successful call is made to this precompile event OwnerActs(bytes4 indexed method, address indexed owner, bytes data); } diff --git a/ArbOwnerPublic.sol b/ArbOwnerPublic.sol index ff52259..08597a4 100644 --- a/ArbOwnerPublic.sol +++ b/ArbOwnerPublic.sol @@ -12,50 +12,12 @@ interface ArbOwnerPublic { address addr ) external view returns (bool); - /** - * @notice Rectify the list of chain owners - * If successful, emits ChainOwnerRectified event - * Available in ArbOS version 11 - */ - function rectifyChainOwner( - address ownerToRectify - ) external; - /// @notice Retrieves the list of chain owners function getAllChainOwners() external view returns (address[] memory); - /// @notice See if the user is a native token owner - /// Available in ArbOS version 41 - function isNativeTokenOwner( - address addr - ) external view returns (bool); - - /// @notice Retrieves the list of native token owners - /// Available in ArbOS version 41 - function getAllNativeTokenOwners() external view returns (address[] memory); - /// @notice Gets the network fee collector function getNetworkFeeAccount() external view returns (address); /// @notice Get the infrastructure fee collector function getInfraFeeAccount() external view returns (address); - - /// @notice Get the Brotli compression level used for fast compression - function getBrotliCompressionLevel() external view returns (uint64); - - /// @notice Get the next scheduled ArbOS version upgrade and its activation timestamp. - /// Returns (0, 0) if no ArbOS upgrade is scheduled. - /// Available in ArbOS version 20. - function getScheduledUpgrade() - external - view - returns (uint64 arbosVersion, uint64 scheduledForTimestamp); - - /** - * @notice Checks if the increased calldata price feature (EIP-7623) is enabled - * Available in ArbOS version 40 with default as false - */ - function isCalldataPriceIncreaseEnabled() external view returns (bool); - - event ChainOwnerRectified(address rectifiedOwner); } diff --git a/ArbWasm.sol b/ArbWasm.sol deleted file mode 100644 index 5e94420..0000000 --- a/ArbWasm.sol +++ /dev/null @@ -1,129 +0,0 @@ -// 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. - */ -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); -} diff --git a/ArbWasmCache.sol b/ArbWasmCache.sol deleted file mode 100644 index fc22ac2..0000000 --- a/ArbWasmCache.sol +++ /dev/null @@ -1,46 +0,0 @@ -// 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. - */ -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); - - /// @dev Deprecated, replaced with cacheProgram - function cacheCodehash( - bytes32 codehash - ) external; - - /// @notice Caches all programs with a codehash equal to the given address. - /// @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. - function cacheProgram( - address addr - ) 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); -} diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..42c819a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,116 @@ +Business Source License 1.1 + +License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. +"Business Source License" is a trademark of MariaDB Corporation Ab. + +----------------------------------------------------------------------------- + +Parameters + +Licensor: Offchain Labs + +Licensed Work: Arbitrum Nitro Contracts + The Licensed Work is (c) 2021-2024 Offchain Labs + +Additional Use Grant: You may use the Licensed Work in a production environment solely + to provide a point of interface to permit end users or applications + utilizing the Covered Arbitrum Chains to interact and query the + state of a Covered Arbitrum Chain, including without limitation + validating the correctness of the posted chain state, or to deploy + and operate (x) a blockchain that settles to a Covered Arbitrum Chain + or (y) a blockchain in accordance with, and subject to, the [Arbitrum + Expansion Program Term of Use](https://docs.arbitrum.foundation/aep/ArbitrumExpansionProgramTerms.pdf). For purposes of this + Additional Use Grant, the "Covered Arbitrum Chains" are + (a) Arbitrum One (chainid:42161), Arbitrum Nova (chainid:42170), + Arbitrum Rinkeby testnet/Rinkarby (chainid:421611),Arbitrum Nitro + Goerli testnet (chainid:421613), and Arbitrum Sepolia Testnet + (chainid:421614); (b) any future blockchains authorized to be + designated as Covered Arbitrum Chains by the decentralized autonomous + organization governing the Arbitrum network; and (c) any “Layer 3” + Arbitrum-based blockchain that is built on and settles to another + Covered Arbitrum Chain. + + + +Change Date: Dec 31, 2028 + +Change License: Apache License Version 2.0 + +----------------------------------------------------------------------------- + +Terms + +The Licensor hereby grants you the right to copy, modify, create derivative +works, redistribute, and make non-production use of the Licensed Work. The +Licensor may make an Additional Use Grant, above, permitting limited +production use. + +Effective on the Change Date, or the fourth anniversary of the first publicly +available distribution of a specific version of the Licensed Work under this +License, whichever comes first, the Licensor hereby grants you rights under +the terms of the Change License, and the rights granted in the paragraph +above terminate. + +If your use of the Licensed Work does not comply with the requirements +currently in effect as described in this License, you must purchase a +commercial license from the Licensor, its affiliated entities, or authorized +resellers, or you must refrain from using the Licensed Work. + +All copies of the original and modified Licensed Work, and derivative works +of the Licensed Work, are subject to this License. This License applies +separately for each version of the Licensed Work and the Change Date may vary +for each version of the Licensed Work released by Licensor. + +You must conspicuously display this License on each original or modified copy +of the Licensed Work. If you receive the Licensed Work in original or +modified form from a third party, the terms and conditions set forth in this +License apply to your use of that work. + +Any use of the Licensed Work in violation of this License will automatically +terminate your rights under this License for the current and all other +versions of the Licensed Work. + +This License does not grant you any right in any trademark or logo of +Licensor or its affiliates (provided that you may use a trademark or logo of +Licensor as expressly required by this License). + +TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON +AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, +EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND +TITLE. + +MariaDB hereby grants you permission to use this License’s text to license +your works, and to refer to it using the trademark "Business Source License", +as long as you comply with the Covenants of Licensor below. + +----------------------------------------------------------------------------- + +Covenants of Licensor + +In consideration of the right to use this License’s text and the "Business +Source License" name and trademark, Licensor covenants to MariaDB, and to all +other recipients of the licensed work to be provided by Licensor: + +1. To specify as the Change License the GPL Version 2.0 or any later version, + or a license that is compatible with GPL Version 2.0 or a later version, + where "compatible" means that software provided under the Change License can + be included in a program with software provided under GPL Version 2.0 or a + later version. Licensor may specify additional Change Licenses without + limitation. + +2. To either: (a) specify an additional grant of rights to use that does not + impose any additional restriction on the right granted in this License, as + the Additional Use Grant; or (b) insert the text "None". + +3. To specify a Change Date. + +4. Not to modify this License in any other way. + +----------------------------------------------------------------------------- + +Notice + +The Business Source License (this document, or the "License") is not an Open +Source license. However, the Licensed Work will eventually be made available +under an Open Source License, as stated in this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1842cd1 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Nitro Precompile Interfaces + +Solidity interfaces for Arbitrum Nitro precompiled contracts. + +## Overview + +This repository contains the Solidity interface definitions for Arbitrum Nitro's precompiled contracts. + +## License + +Licensed under BUSL-1.1. See individual files for specific license information. diff --git a/foundry.toml b/foundry.toml new file mode 100644 index 0000000..4e75ba8 --- /dev/null +++ b/foundry.toml @@ -0,0 +1,20 @@ +[profile.default] +src = '' + +[fmt] +line_length = 100 +tab_width = 4 +bracket_spacing = false +int_types = "long" +multiline_func_header = "params_first" +quote_style = "double" +number_underscore = "preserve" +hex_underscore = "remove" +single_line_statement_blocks = "preserve" +override_spacing = false +wrap_comments = false +ignore = [] +contract_new_lines = false +sort_imports = false + +# See more config options https://github.com/foundry-rs/foundry/tree/master/config \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..14177cc --- /dev/null +++ b/package.json @@ -0,0 +1,24 @@ +{ + "name": "@arbitrum/nitro-precompile-interfaces", + "version": "1.0.0", + "description": "Solidity interfaces for Arbitrum Nitro precompiled contracts", + "author": "Offchain Labs, Inc.", + "license": "BUSL-1.1", + "repository": { + "type": "git", + "url": "git+https://github.com/offchainlabs/nitro-precompile-interfaces.git" + }, + "files": [ + "*.sol", + "README.md", + "LICENSE.md" + ], + "bugs": { + "url": "https://github.com/offchainlabs/nitro-precompile-interfaces/issues" + }, + "scripts": { + "build": "forge build", + "format": "forge fmt" + }, + "private": false +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +