Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Fix ChainwebChainId deployment during setupChainsForTests - #12

Closed
larskuhtz wants to merge 1 commit into
mainfrom
lars/fix-setupchainsfortest
Closed

Fix ChainwebChainId deployment during setupChainsForTests#12
larskuhtz wants to merge 1 commit into
mainfrom
lars/fix-setupchainsfortest

Conversation

@larskuhtz

Copy link
Copy Markdown
Contributor

No description provided.

@larskuhtz
larskuhtz requested a review from javadkh2 September 3, 2025 18:19
@larskuhtz
larskuhtz force-pushed the lars/fix-setupchainsfortest branch from 024ea4f to 2227b2a Compare September 3, 2025 18:20
Comment thread src/Chainweb.sol
string(abi.encodePacked(_hostUrl, "/chain/", vm.toString(i + _chainwebChainIdOffset), "/evm/rpc"));
console.log("Using custom RPC URL:", url);
_chainForks.push(vm.createFork(url));
_chainForks.push(vm.createSelectFork(url));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will select the last chain as default. thats the thing we want?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there must be an active fork for vm.activFork() to succeed below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the use of selectFork() is generally an issue in any code that is called in constructors of scripts and tests (not just sub-contracts).

selectFork() is also already used elsewhere. A fix for that broader issue is proposed in #13.

@larskuhtz
larskuhtz requested a review from javadkh2 September 5, 2025 19:52
@larskuhtz larskuhtz mentioned this pull request Sep 8, 2025
@larskuhtz
larskuhtz requested a review from hswopeams September 8, 2025 06:09

@hswopeams hswopeams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests all succeed in this branch, but the script doesn't run correctly.
If I start up anvil in one terminal from the top-level and then in another terminal change to /examples/Counter and then run

forge script --multi script/Counter.s.sol:CounterScript \
  --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
  --broadcast

as instructed in the README,

I get this warning:
== Logs ==
Setting main RPC node for 5 chains
Forking http://127.0.0.1:26695
Forking http://127.0.0.1:6865
Forking http://127.0.0.1:20208
Forking http://127.0.0.1:7667
Forking http://127.0.0.1:7048
Switched to chain: 20
Running script on chain: 31337
Switched to chain: 21
Running script on chain: 31338
Switched to chain: 22
Running script on chain: 31339
Switched to chain: 23
Running script on chain: 31340
Switched to chain: 24
Running script on chain: 31341
Switched to chain: 20
Active chain ID: 20
Switched to chain: 21
Active chain ID: 21
Switched to chain: 22
Active chain ID: 22
Switched to chain: 23
Active chain ID: 23
Switched to chain: 24
Active chain ID: 24

Setting up 5 EVMs.

Warning: Script contains a transaction to 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0 which does not contain any code.
Do you wish to continue? [y/n]

If I say "yes", the script runs but doesn't complete. It hangs on pending transactions

@hswopeams

Copy link
Copy Markdown
Contributor

Closing because the examples/Counter/script/Counter.s.sol script doesn't work in this branch. PR 13 supersedes this PR. Tests and scripts work in that PR branch, which has been merged.

@hswopeams hswopeams closed this Sep 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants