-
Notifications
You must be signed in to change notification settings - Fork 4
[Do not merge] Nitro Stylus Diff #22
base: nitro-stylus-split
Are you sure you want to change the base?
Conversation
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.
some minor suggestions, yet to review the logic against nitro
bool updateRoot = !(opcode == Instructions.LINK_MODULE || | ||
opcode == Instructions.UNLINK_MODULE); |
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.
can simplify into
bool updateRoot = !(opcode == Instructions.LINK_MODULE || | |
opcode == Instructions.UNLINK_MODULE); | |
bool updateRoot = (opcode != Instructions.LINK_MODULE) && | |
(opcode != Instructions.UNLINK_MODULE); |
@@ -11,6 +11,8 @@ import "./ModuleMemoryCompact.sol"; | |||
library ModuleMemoryLib { | |||
using MerkleProofLib for MerkleProof; | |||
|
|||
uint256 private constant LEAF_SIZE = 32; |
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.
This is defined separately in multiple contracts, we should consider to consolidate them
src/osp/OneStepProverHostIo.sol
Outdated
bytes calldata proof | ||
) internal view { |
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.
bytes calldata proof | |
) internal view { | |
bytes calldata | |
) internal pure { |
src/precompiles/ArbOwner.sol
Outdated
interface ArbOwner { | ||
/// @notice Add account as a chain owner | ||
// @notice Add account as a chain owner |
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.
I believes natspec expect triple slash
2028 change date
2028 change date
Activation Pricing
Added some basic seq inbox foundry tests
Add WAVM KZG preimage proof
Merge nitro v2.3.4 (rc3)
} | ||
|
||
uint256 lastProvedLeafIdx = ~uint256(0); | ||
bytes32 lastProvedLeafContents; |
Check warning
Code scanning / Slither
Uninitialized local variables Medium
@@ -62,16 +64,21 @@ | |||
ValueStack memory values = ValueStack({proved: valuesArray, remainingHash: 0}); | |||
ValueStack memory internalStack; | |||
StackFrameWindow memory frameStack; | |||
MultiStack memory emptyMultiStack; |
Check warning
Code scanning / Slither
Uninitialized local variables Medium
function executeSwitchCoThread( | ||
ExecutionContext calldata, | ||
Machine memory mach, | ||
Module memory, | ||
Instruction calldata inst, | ||
bytes calldata | ||
) internal pure { | ||
if (mach.frameMultiStack.inactiveStackHash == MultiStackLib.NO_STACK_HASH) { | ||
// cannot switch cothread if there isn't one | ||
mach.status = MachineStatus.ERRORED; | ||
return; | ||
} | ||
if (inst.argumentData == 0) { | ||
if (mach.recoveryPc == MachineLib.NO_RECOVERY_PC) { | ||
// switching to main thread, from main thread | ||
mach.status = MachineStatus.ERRORED; | ||
return; | ||
} | ||
mach.recoveryPc = MachineLib.NO_RECOVERY_PC; | ||
} else { | ||
if (mach.recoveryPc != MachineLib.NO_RECOVERY_PC) { | ||
// switching from cothread to cothread | ||
mach.status = MachineStatus.ERRORED; | ||
return; | ||
} | ||
mach.setRecoveryFromPc(uint32(inst.argumentData)); | ||
} | ||
mach.switchCoThreadStacks(); | ||
} |
Check warning
Code scanning / Slither
Unused return Medium
function executeLinkModule( | ||
ExecutionContext calldata, | ||
Machine memory mach, | ||
Module memory mod, | ||
Instruction calldata, | ||
bytes calldata proof | ||
) internal pure { | ||
string memory prefix = "Module merkle tree:"; | ||
bytes32 root = mach.modulesRoot; | ||
|
||
uint256 pointer = mach.valueStack.pop().assumeI32(); | ||
if (!mod.moduleMemory.isValidLeaf(pointer)) { | ||
mach.status = MachineStatus.ERRORED; | ||
return; | ||
} | ||
(bytes32 userMod, uint256 offset, ) = mod.moduleMemory.proveLeaf( | ||
pointer / LEAF_SIZE, | ||
proof, | ||
0 | ||
); | ||
|
||
(uint256 leaf, , MerkleProof memory zeroProof) = proveLastLeaf(mach, offset, proof); | ||
|
||
bool balanced = isPowerOfTwo(leaf + 1); | ||
if (balanced) { | ||
mach.modulesRoot = MerkleProofLib.growToNewRoot(root, leaf + 1, userMod, 0, prefix); | ||
} else { | ||
mach.modulesRoot = zeroProof.computeRootUnsafe(leaf + 1, userMod, prefix); | ||
} | ||
|
||
mach.valueStack.push(ValueLib.newI32(uint32(leaf + 1))); | ||
} |
Check warning
Code scanning / Slither
Unused return Medium
function _deployFactories( | ||
address _inbox, | ||
address _nativeToken, | ||
uint256 _maxFeePerGas | ||
) internal { | ||
if (_nativeToken == address(0)) { | ||
// we need to fund 4 retryable tickets | ||
uint256 cost = l2FactoriesDeployer.getDeploymentTotalCost( | ||
IInboxBase(_inbox), | ||
_maxFeePerGas | ||
); | ||
|
||
// do it | ||
l2FactoriesDeployer.perform{value: cost}(_inbox, _nativeToken, _maxFeePerGas); | ||
|
||
// refund the caller | ||
// solhint-disable-next-line avoid-low-level-calls | ||
(bool sent, ) = msg.sender.call{value: address(this).balance}(""); | ||
require(sent, "Refund failed"); | ||
} else { | ||
// Transfer fee token amount needed to pay for retryable fees to the inbox. | ||
uint256 totalFee = l2FactoriesDeployer.getDeploymentTotalCost( | ||
IInboxBase(_inbox), | ||
_maxFeePerGas | ||
); | ||
IERC20(_nativeToken).safeTransferFrom(msg.sender, _inbox, totalFee); | ||
|
||
// do it | ||
l2FactoriesDeployer.perform(_inbox, _nativeToken, _maxFeePerGas); | ||
} | ||
} |
Check failure
Code scanning / Slither
Functions that send Ether to arbitrary destinations High
Dangerous calls:
- l2FactoriesDeployer.perform{value: cost}(_inbox,_nativeToken,_maxFeePerGas)
- (sent,None) = msg.sender.call{value: address(this).balance}()
Math Host I/Os
Stylus Cache Manager
Optimize Function Merklization
Cache Manager Tweaks
This temporary PR provides a diff between
nitro-contracts
andstylus-contracts
to aid in review.