-
Notifications
You must be signed in to change notification settings - Fork 0
Credit the deployer's HyperCore account from HyperEVM #147
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
Merged
thedavidmeister
merged 2 commits into
main
from
2026-08-22-credit-hypercore-from-hyperevm
Aug 22, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| // SPDX-License-Identifier: LicenseRef-DCL-1.0 | ||
| // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd | ||
| pragma solidity =0.8.25; | ||
|
|
||
| import {Script} from "forge-std-1.16.2/src/Script.sol"; | ||
|
|
||
| import {LibHyperCore} from "../src/lib/LibHyperCore.sol"; | ||
|
|
||
| /// @title CreditHyperCore | ||
| /// @notice Makes the deployer a HyperCore user, by sending it some of its own | ||
| /// HYPE. | ||
| /// | ||
| /// Deploying anything sizeable to HyperEVM needs big blocks, which are opted | ||
| /// into with an `evmUserModify` action that HyperCore accepts only from an | ||
| /// address that is already a HyperCore user. An address becomes one by holding | ||
| /// a Core asset, and HYPE sent to the system contract from HyperEVM arrives on | ||
| /// Core for the same address — so the deployer, which holds HYPE already | ||
| /// because it pays gas in it, credits itself. `LibHyperCore` carries the | ||
| /// mechanism and every guard; see there for what each one is for. | ||
| /// | ||
| /// This is a sibling of `script/Deploy.sol` rather than a part of it. It moves | ||
| /// the deployer's own funds instead of deploying anything, it touches exactly | ||
| /// one network where the deploy touches all of them, and it is run ONCE per | ||
| /// deployer address for the lifetime of that address — a second run is more | ||
| /// money for no further effect, because a HyperCore user does not stop being | ||
| /// one. | ||
| /// | ||
| /// ## Running it | ||
| /// | ||
| /// Not on `Manual sol artifacts`. That workflow exports `DEPLOYMENT_SUITE`, | ||
| /// `DEPLOYMENT_NETWORK` and `DEPLOYMENT_KEY` and nothing else, so the amount | ||
| /// has no way through it, and an amount squeezed into one of those names would | ||
| /// be a real-money argument travelling under a name that means something else. | ||
| /// It is run by hand instead: | ||
| /// | ||
| /// ```sh | ||
| /// HYPERCORE_CREDIT_WEI=10000000000000000 DEPLOYMENT_KEY=0x... \ | ||
| /// forge script script/CreditHyperCore.sol:CreditHyperCore --legacy | ||
| /// ``` | ||
| /// | ||
| /// Without `--broadcast` that is a dry run against a fork of HyperEVM, which | ||
| /// executes every guard and the transfer itself and sends nothing. Do that | ||
| /// first: it is the same code path, so anything it refuses is something the | ||
| /// real run would have refused after paying for it. `--legacy` because | ||
| /// HyperEVM's RPC rejects the fee-history ranges EIP-1559 estimation asks for, | ||
| /// which is the same reason the deploy workflow carries a `legacy` input. No | ||
| /// `--rpc-url`: the fork comes from the `hyperevm` alias in `foundry.toml`. | ||
| /// | ||
| /// ## The amount | ||
| /// | ||
| /// `HYPERCORE_CREDIT_WEI` is EVM wei — 18 decimals, the units the deployer's | ||
| /// gas balance is in — and it is required rather than defaulted. A default | ||
| /// would be an amount of real money nobody typed, and how much a deployer | ||
| /// should hold on Core is a decision about that deployer rather than a fact | ||
| /// about this mechanism. It has to be a whole number of Core wei; `10 ** 10` | ||
| /// EVM wei is one of them, and `LibHyperCore.CreditNotRound` says why anything | ||
| /// else is refused. | ||
| /// | ||
| /// ## Why the body is three lines and no test drives it | ||
| /// | ||
| /// Everything with behaviour is in `LibHyperCore` and is covered there, without | ||
| /// an env var in sight. What is left here is two reads by name, and driving | ||
| /// them from a test would mean writing `DEPLOYMENT_KEY` — a process-wide | ||
| /// variable that `rainix-sol-test` exports onto the job and that | ||
| /// `RainDeployBroadcastTest` already sequences its own writes of. Forge runs | ||
| /// test contracts concurrently, so a second writer of that name is a race | ||
| /// against a suite that is currently green, which is a worse trade than this | ||
| /// buys. | ||
| /// | ||
| /// So the body is written to make its own mistake impossible rather than | ||
| /// caught. Both env reads are `uint256`, and a key and an amount transposed | ||
| /// between them would send a private key's worth of HYPE — so the key is turned | ||
| /// into an `address` on its own line first, and the call takes that address. | ||
| /// The two arguments no longer have the same type, and the transposition that | ||
| /// no test is watching for does not compile. | ||
| contract CreditHyperCore is Script { | ||
| /// Credits the `DEPLOYMENT_KEY` deployer's HyperCore account with | ||
| /// `HYPERCORE_CREDIT_WEI` of its own HYPE. | ||
| function run() external { | ||
| address deployer = vm.rememberKey(vm.envUint("DEPLOYMENT_KEY")); | ||
| uint256 amount = vm.envUint("HYPERCORE_CREDIT_WEI"); | ||
| LibHyperCore.creditCoreOnHyperEvm(vm, deployer, amount); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.