-
Notifications
You must be signed in to change notification settings - Fork 79
feat: Migrate SP1Helios #1231
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
base: master
Are you sure you want to change the base?
feat: Migrate SP1Helios #1231
Conversation
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
…e were reverting due to revert strings being stripped Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
This reverts commit 679640c.
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
contracts/sp1-helios/SP1Helios.sol
Outdated
| @@ -0,0 +1,319 @@ | |||
| // SPDX-License-Identifier: MIT | |||
| pragma solidity ^0.8.28; | |||
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.
Changed from pragma solidity 0.8.28;
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.
we might still need to get it audited since we would be deploying it under 0.8.30 and it can have unexpected behaviour
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.
Is there a way we can use some path-conditional compiler settings in foundry to still just compile with 0.8.28?
I.e., if path-to-sp1-helios, compile with 0.8.28, else compile with default repo version
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.
@tbwebb22 take a look at https://getfoundry.sh/config/reference/solidity-compiler/ : compilation_restrictions
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.
Haven't been able to get the compilation restrictions to work with two different solc versions - so went back to SP1Helios at pragma solidity ^0.8.28;. So we should get it audited for this change
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.
@grasphoper @fusmanii I updated this contract to pragma solidity 0.8.30 to lock it in at that version since that's what we're getting it audited at.
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.
Updated to pragma solidity ^0.8.30 based on conversation with Faisal
contracts/sp1-helios/SP1Helios.sol
Outdated
|
|
||
| uint256 fromHead = po.prevHead; | ||
| // Ensure that po.newHead is strictly greater than po.prevHead | ||
| if (po.newHead <= fromHead) revert NonIncreasingHead(po.newHead); |
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.
Changed from require(po.newHead > fromHead, NonIncreasingHead(po.newHead));, along with other reverts throughout the contract.
In this codebase we are stripping revert strings - this was causing tests checking for reverts with custom error + data to fail
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.
We shouldn't be changing audited contracts, even with something minor as this. We should rather change the tests to accomodate. In hardhat, we were using different strip settings for debug vs prod builds. Alternatively, we could use something similar here.
Although that wasn't perfect because it was causing constant rebuilds of the whole repo.
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.
Yeah totally makes sense. I've reverted all the require statement changes. So now the only change from the SP1Helios repo is the pragma solidity ^0.8.28;. Will look into solutions for the tests
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.
@grasphoper @fusmanii lmk if you guys are good with this solution for being able to still test revert strings. This creates a separate cache and contract artifact folder for contracts that are compiled with the local test profile, and doesn't strip revert strings for these.
So these tests are run with FOUNDRY_PROFILE=local forge test
The downside is if you run forge tests, any tests that are checking revert strings or custom errors returning data will fail.
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 solution looks good to me. We're supposed to be running local foundry tests with a yarn test-evm-foundry command, or a FOUNDRY_PROFILE=local flag for that matter too.
For reference, were there a lot of tests that are failing because of the strings being stripped? I see there are code changes to change a single test in the commit above, but I think you just didn't start fixing the rest right?
Eventually (or now) we might want to rename this profile to something else, e.g. local-test?
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.
So initially, no tests were failing - all the foundry tests expected strings to be stripped. Then when I migrated the SP1Helios tests over - 4 Sp1Helios tests started failing as they expected revert strings to be there. When turning off revert string stripping, the 4 SP1Helios tests passed, but that one MulticallUpgradeable test modified in this PR began to fail. So I modified that test to expect revert strings and all are passing now. Hopefully that makes sense.
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
… revert strings Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
27490a9 to
36ebd2e
Compare
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
| runCmd[4] = string.concat("SP1_VERIFIER_ADDRESS=", sp1VerifierAddress); | ||
| runCmd[5] = string.concat("UPDATERS=", stateUpdaters); | ||
| runCmd[6] = string.concat("VKEY_UPDATER=", vkeyUpdater); | ||
| runCmd[7] = string.concat("CONSENSUS_RPCS_LIST=", consensusRpcsList); |
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.
The variables we're assigning here are read via vm.envString above. Why do we need to reassign here? Is the environment not inherited by this process that we're launching?
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.
They're reassigned here because the binary expects different env var names than what I wanted to use in this repo. I wanted the additional env vars in this repo to all be prefixed with "SP1_". Also the binary expects a private key, while the contracts repo env has mnemomic, so pk needs to be derived from that and passed to the binary.
| chmodCmd[0] = "chmod"; | ||
| chmodCmd[1] = "+x"; | ||
| chmodCmd[2] = binaryPath; | ||
| vm.ffi(chmodCmd); |
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.
We're downloading a binary and executing it immediately. Feels a bit scary. I suggest we do some kind of a checksum check
2 options I see are:
- developer provides a checksum as a script arg (that they get, say, from a release page Web UI) or
- we donwload a checksum file simultaneously (from the same resource, or from where?) and check against that
- or any other ideas to make this a bit more safe
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.
Yeah this makes sense. What about if we maintain in this repo somewhere a .json file of the latest known good checksums per toolchain binary? That way to change a checksum here requires a PR and multiple people looking at those changes
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
d8802d4 to
1cbd2d2
Compare
Signed-off-by: Taylor Webb <tbwebb22@gmail.com>
This PR adds the SP1Helios contract, tests, and a Foundry deployment script. The deployment script downloads the appropriate genesis binary from our sp1-helios GitHub releases (detecting macOS vs Linux automatically), runs it to generate the initial light client configuration, and then deploys the SP1Helios contract with those parameters.
Currently, the genesis binary gets added to the root, and genesis.json gets written to the /contracts folder.
Deploy script still needs to be tested on Linux