From c95399d7d4059deed7082fd85b85918b43b7860f Mon Sep 17 00:00:00 2001 From: Joshua Colvin Date: Mon, 7 Aug 2023 21:18:17 -0700 Subject: [PATCH 1/6] Add `setWasmCallScalar` --- src/precompiles/ArbOwner.sol | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/precompiles/ArbOwner.sol b/src/precompiles/ArbOwner.sol index 42c7a9918..419eb8156 100644 --- a/src/precompiles/ArbOwner.sol +++ b/src/precompiles/ArbOwner.sol @@ -107,6 +107,9 @@ interface ArbOwner { // @notice sets the maximum number of pages a wasm may allocate function setWasmPageLimit(uint16 limit) external view; + // @notice sets the cost of calling 64kb wasm, cost is scaled according to actual wasm size + function setWasmCallScalar(uint16 gas) external view; + /// @notice Sets serialized chain config in ArbOS state function setChainConfig(string calldata chainConfig) external; From 2cc238ff82939a0e6daf9541af4d56e1c990e30f Mon Sep 17 00:00:00 2001 From: Joshua Colvin Date: Tue, 8 Aug 2023 08:42:07 -0700 Subject: [PATCH 2/6] Address code review comments * Change cost to per eighth of a kb * Add getter for call scalar --- src/precompiles/ArbOwner.sol | 2 +- src/precompiles/ArbWasm.sol | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/precompiles/ArbOwner.sol b/src/precompiles/ArbOwner.sol index 419eb8156..9bf1a99db 100644 --- a/src/precompiles/ArbOwner.sol +++ b/src/precompiles/ArbOwner.sol @@ -107,7 +107,7 @@ interface ArbOwner { // @notice sets the maximum number of pages a wasm may allocate function setWasmPageLimit(uint16 limit) external view; - // @notice sets the cost of calling 64kb wasm, cost is scaled according to actual wasm size + // @notice sets the call overhead priced per eighth of a kb of compressed wasm function setWasmCallScalar(uint16 gas) external view; /// @notice Sets serialized chain config in ArbOS state diff --git a/src/precompiles/ArbWasm.sol b/src/precompiles/ArbWasm.sol index 18dabead6..eb5993e51 100644 --- a/src/precompiles/ArbWasm.sol +++ b/src/precompiles/ArbWasm.sol @@ -50,6 +50,10 @@ interface ArbWasm { // @return limit the number of pages function pageLimit() external view returns (uint16 limit); + // @notice gets the call overhead priced per eighth of a kb of compressed wasm + // @return call overhead priced per eighth of a kb of compressed wasm + function callScalar() external view returns (uint16 limit); + error ProgramNotCompiled(); error ProgramOutOfDate(uint32 version); error ProgramUpToDate(); From 14151a3b7df5586412b63c24279fc697452f3fda Mon Sep 17 00:00:00 2001 From: Joshua Colvin Date: Tue, 8 Aug 2023 11:56:22 -0700 Subject: [PATCH 3/6] Update wasmcallscalar to be per half kb --- src/precompiles/ArbOwner.sol | 2 +- src/precompiles/ArbWasm.sol | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/precompiles/ArbOwner.sol b/src/precompiles/ArbOwner.sol index 9bf1a99db..d4ac7bcce 100644 --- a/src/precompiles/ArbOwner.sol +++ b/src/precompiles/ArbOwner.sol @@ -107,7 +107,7 @@ interface ArbOwner { // @notice sets the maximum number of pages a wasm may allocate function setWasmPageLimit(uint16 limit) external view; - // @notice sets the call overhead priced per eighth of a kb of compressed wasm + // @notice sets the call overhead priced per half of a kb of compressed wasm function setWasmCallScalar(uint16 gas) external view; /// @notice Sets serialized chain config in ArbOS state diff --git a/src/precompiles/ArbWasm.sol b/src/precompiles/ArbWasm.sol index eb5993e51..48aa8f050 100644 --- a/src/precompiles/ArbWasm.sol +++ b/src/precompiles/ArbWasm.sol @@ -50,8 +50,8 @@ interface ArbWasm { // @return limit the number of pages function pageLimit() external view returns (uint16 limit); - // @notice gets the call overhead priced per eighth of a kb of compressed wasm - // @return call overhead priced per eighth of a kb of compressed wasm + // @notice gets the call overhead priced per half of a kb of compressed wasm + // @return call overhead priced per half of a kb of compressed wasm function callScalar() external view returns (uint16 limit); error ProgramNotCompiled(); From 8dc93a760094b5189f538871ead61c5a74ff2f70 Mon Sep 17 00:00:00 2001 From: Joshua Colvin Date: Tue, 8 Aug 2023 13:01:07 -0700 Subject: [PATCH 4/6] Make method names consistent --- src/precompiles/ArbWasm.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/precompiles/ArbWasm.sol b/src/precompiles/ArbWasm.sol index 48aa8f050..9d43f84bc 100644 --- a/src/precompiles/ArbWasm.sol +++ b/src/precompiles/ArbWasm.sol @@ -28,11 +28,11 @@ interface ArbWasm { // @notice gets the wasm stack size limit // @return depth the maximum depth (in wasm words) a wasm stack may grow - function wasmMaxDepth() external view returns (uint32 depth); + function maxStackDepth() external view returns (uint32 depth); // @notice gets the fixed-cost overhead needed to initiate a hostio call // @return ink the cost of starting a stylus hostio call - function wasmHostioInk() external view returns (uint64 ink); + function hostioInk() external view returns (uint64 ink); // @notice gets the number of free wasm pages a program gets // @return pages the number of wasm pages (2^16 bytes) From e65b52d8df83299f29fff2ba534cc64575febf5d Mon Sep 17 00:00:00 2001 From: Joshua Colvin Date: Fri, 11 Aug 2023 12:30:20 -0700 Subject: [PATCH 5/6] Fix method name --- src/precompiles/ArbOwner.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/precompiles/ArbOwner.sol b/src/precompiles/ArbOwner.sol index 9af3b0ec5..01ca33033 100644 --- a/src/precompiles/ArbOwner.sol +++ b/src/precompiles/ArbOwner.sol @@ -91,7 +91,7 @@ interface ArbOwner { function setInkPrice(uint32 price) external; // @notice sets the maximum depth (in wasm words) a wasm stack may grow - function setWasmMaxDepth(uint32 depth) external; + function setWasmMaxStackDepth(uint32 depth) external; // @notice sets the number of free wasm pages a tx gets function setWasmFreePages(uint16 pages) external; From 1f6172c8b958d5856e5a6c8e8d9e91b1cb7a56bb Mon Sep 17 00:00:00 2001 From: Rachel Bousfield Date: Sat, 12 Aug 2023 09:52:09 -0600 Subject: [PATCH 6/6] update comments --- src/precompiles/ArbOwner.sol | 2 +- src/precompiles/ArbWasm.sol | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/precompiles/ArbOwner.sol b/src/precompiles/ArbOwner.sol index 01ca33033..45a297037 100644 --- a/src/precompiles/ArbOwner.sol +++ b/src/precompiles/ArbOwner.sol @@ -105,7 +105,7 @@ interface ArbOwner { // @notice sets the maximum number of pages a wasm may allocate function setWasmPageLimit(uint16 limit) external view; - // @notice sets the call overhead priced per half of a kb of compressed wasm + // @notice sets the added wasm call cost based on binary size function setWasmCallScalar(uint16 gas) external view; /// @notice Sets serialized chain config in ArbOS state diff --git a/src/precompiles/ArbWasm.sol b/src/precompiles/ArbWasm.sol index 78ae36e41..14716c19d 100644 --- a/src/precompiles/ArbWasm.sol +++ b/src/precompiles/ArbWasm.sol @@ -46,9 +46,9 @@ interface ArbWasm { // @return limit the number of pages function pageLimit() external view returns (uint16 limit); - // @notice gets the call overhead priced per half of a kb of compressed wasm - // @return call overhead priced per half of a kb of compressed wasm - function callScalar() external view returns (uint16 limit); + // @notice gets the added wasm call cost based on binary size + // @return gas cost paid per half kb uncompressed. + function callScalar() external view returns (uint16 gas); error ProgramNotCompiled(); error ProgramOutOfDate(uint16 version);