Skip to content
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

Unique Module Hashes #179

Merged
merged 4 commits into from
May 6, 2024
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
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 extraHash;
uint32 internalsOffset;
(globalsMerkleRoot, offset) = b32(proof, offset);
(mem, offset) = moduleMemory(proof, offset);
(tablesMerkleRoot, offset) = b32(proof, offset);
(functionsMerkleRoot, offset) = b32(proof, offset);
(extraHash, offset) = b32(proof, offset);
(internalsOffset, offset) = u32(proof, offset);
mod = Module({
globalsMerkleRoot: globalsMerkleRoot,
moduleMemory: mem,
tablesMerkleRoot: tablesMerkleRoot,
functionsMerkleRoot: functionsMerkleRoot,
extraHash: extraHash,
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 extraHash;
uint32 internalsOffset;
}

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