Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
add wasm to module & new precompile methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rachel-bousfield committed Apr 30, 2024
1 parent e3725f7 commit 8b6aded
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/precompiles/ArbOwner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ interface ArbOwner {
/// @notice Sets the base cost of each additional wasm page
function setWasmPageGas(uint16 gas) external;

/// @notice Sets the ramp that drives exponential wasm memory costs
function setWasmPageRamp(uint64 ramp) external;

/// @notice Sets the maximum number of pages a wasm may allocate
function setWasmPageLimit(uint16 limit) external;

Expand All @@ -116,6 +113,10 @@ interface ArbOwner {
/// @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;

Expand Down
8 changes: 6 additions & 2 deletions src/precompiles/ArbWasm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ interface ArbWasm {
/// @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 (not including minInitGas)
/// @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 (uint16 gas, uint16 gasWhenCached);
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)
Expand Down Expand Up @@ -84,6 +84,10 @@ interface ArbWasm {
/// @return cached amount of gas in increments of 64 when cached
function minInitGas() external view returns (uint8 gas, uint8 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);
Expand Down
3 changes: 3 additions & 0 deletions src/state/Deserialize.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,20 @@ library Deserialize {
ModuleMemory memory mem;
bytes32 tablesMerkleRoot;
bytes32 functionsMerkleRoot;
bytes32 wasmHash;
uint32 internalsOffset;
(globalsMerkleRoot, offset) = b32(proof, offset);
(mem, offset) = moduleMemory(proof, offset);
(tablesMerkleRoot, offset) = b32(proof, offset);
(functionsMerkleRoot, offset) = b32(proof, offset);
(wasmHash, offset) = b32(proof, offset);
(internalsOffset, offset) = u32(proof, offset);
mod = Module({
globalsMerkleRoot: globalsMerkleRoot,
moduleMemory: mem,
tablesMerkleRoot: tablesMerkleRoot,
functionsMerkleRoot: functionsMerkleRoot,
wasmHash: wasmHash,
internalsOffset: internalsOffset
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/state/Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ struct Module {
ModuleMemory moduleMemory;
bytes32 tablesMerkleRoot;
bytes32 functionsMerkleRoot;
bytes32 wasmHash;
uint32 internalsOffset;
}

Expand All @@ -26,6 +27,7 @@ library ModuleLib {
mod.moduleMemory.hash(),
mod.tablesMerkleRoot,
mod.functionsMerkleRoot,
mod.wasmHash,
mod.internalsOffset
)
);
Expand Down

0 comments on commit 8b6aded

Please sign in to comment.