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

Arbitrum Stylus #170

Merged
merged 164 commits into from
May 6, 2024
Merged

Arbitrum Stylus #170

merged 164 commits into from
May 6, 2024

Conversation

rachel-bousfield
Copy link
Contributor

@rachel-bousfield rachel-bousfield commented Apr 19, 2024

This PR adds support for Arbitrum Stylus, which is slated to go live as part of ArbOS 30 pending DAO approval.

rachel-bousfield and others added 30 commits May 17, 2023 14:22
User Programs (copied from stylus repo)
Remove blockhash and difficulty from unit tests
* Change cost to per eighth of a kb
* Add getter for call scalar
}

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

Comment on lines +433 to +464
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)));
}
Comment on lines +572 to +600
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();
}
@gzeoneth gzeoneth self-requested a review April 23, 2024 17:25
@gzeoneth
Copy link
Member

gzeoneth commented May 6, 2024

foundry-rs/foundry#7869

eljobe added a commit to OffchainLabs/nitro that referenced this pull request May 6, 2024
This is a temporary measure until
OffchainLabs/nitro-contracts#170 is merged.
@gzeoneth gzeoneth merged commit 77ee9de into develop May 6, 2024
8 of 10 checks passed
@gzeoneth gzeoneth deleted the stylus branch May 6, 2024 16:51
@gzeoneth gzeoneth mentioned this pull request Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants