-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add arbos 30 methods #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ff94e82
feat: add arbos 30 methods
gzeoneth 7d48c91
Merge branch 'arbos-20' into arbos-30
gzeoneth a1b73a8
chore: 30.0.0
gzeoneth d96af9b
chore: setup repo and retag historical versions (#2)
gzeoneth 98c918a
feat: add arbos 5 methods (#3)
gzeoneth 78673c3
feat: add arbos 10 methods (#4)
gzeoneth 1cba988
feat: add arbos 11 methods (#5)
gzeoneth 18a940a
Merge remote-tracking branch 'origin/main' into arbos-30
gzeoneth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
andcached
are marked as uint64 in the implementation file (here).