-
Notifications
You must be signed in to change notification settings - Fork 23
feat: (foc-localnet-v1-rc) Add Localnet Support to Synapse SDK #527
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?
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
synapse-dev | ebfd645 | Commit Preview URL Branch Preview URL |
Jan 06 2026, 05:24 AM |
|
@redpanda-f : will you take care of the lint failures? |
4431d7c to
ebfd645
Compare
| * ``` | ||
| */ | ||
|
|
||
| export { |
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 think this was a mistake? we recently removed a bunch of stuff from here, are they needed for this PR?
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 don't think this is the right approach to take here. Env var reading doesn't really belong in synapse-sdk or synapse-core, that's an external concern, I'd very much prefer the approach of injecting the things that need to be variable rather than implicitly discovering them by magic. We already have that with things like the ability to override warmStorageAddress. So a lot of the heavy-lifting of figuring out what to inject can come from outside, specifically in example-storage-e2e.js which you're using primarily to test and can demonstrate how to do it for other apps. I'll comment more inline with my thoughts on how we could do it alternatively.
| export const CHAIN_IDS: Record<FilecoinNetworkType, number> = { | ||
| mainnet: 314, | ||
| calibration: 314159, | ||
| localnet: getLocalnetChainId(), |
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 should be safe to just hardwire this to 31415926: https://github.com/filecoin-project/lotus/blob/fcb6f93aaf65823cc274f1ac8220fadf6eef6d83/build/buildconstants/params_2k.go#L213
| http: 'https://api.calibration.node.glif.io/rpc/v1', | ||
| websocket: 'wss://wss.calibration.node.glif.io/apigw/lotus/rpc/v1', | ||
| }, | ||
| localnet: { |
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 don't need this, it's not consumed externally and only exists as a convenience for users
| WARM_STORAGE: { | ||
| mainnet: '0x8408502033C418E1bbC97cE9ac48E5528F371A9f', | ||
| calibration: '0x02925630df557F957f70E112bA06e50965417CA0', | ||
| get localnet() { |
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 not needed because the only place it matters is here where it can be overridden:
| const warmStorageAddress = options.warmStorageAddress ?? CONTRACT_ADDRESSES.WARM_STORAGE[network] |
What we can do is throw if we get to that point and find we don't have an override address - the workflow I'd prefer is to force users to provide an address where we're not on calib or mainnet.
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.
in fact the current code should already cover this because it throws on the next line.
| MULTICALL3: { | ||
| mainnet: '0xcA11bde05977b3631167028862bE2a173976CA11', | ||
| calibration: '0xcA11bde05977b3631167028862bE2a173976CA11', | ||
| get localnet() { |
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 one and usdfc are trickier because we don't currently have overrides, but my preferred approach is to extend the options object and add overrides just like we do for warmStorageAddress.
We can take the same approach as I suggested above where we force the user to supply if we find that we don't have an address for network. We do have the option with Multicall3 of putting in 0xcA11bde05977b3631167028862bE2a173976CA11 as the default address here that can be overridden, but I think given the experience of not being able to replicate stable deploy on a devnet we may as well leave it blank.
| PDP_PERMISSION_NAMES, | ||
| } from '../packages/synapse-sdk/src/session/index.ts' | ||
|
|
||
| // Parse command line arguments |
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.
let's not do this, it already uses env vars and we can stick to that, I don't really want to overcomplicate it for now and keep it ~clean, let's just extend the env var use to add in the devnet variables
| let WARM_STORAGE_ADDRESS = process.env.WARM_STORAGE_ADDRESS | ||
|
|
||
| // Set defaults based on network if not provided | ||
| if (!RPC_URL) { |
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.
as above, I don't think this is required, make the caller specify RPC_URL
This PR adds comprehensive support for local Filecoin networks to enable easier development and testing.
Changes
--network localnetoptionEnvironment Variables
The following environment variables can be used to configure localnet:
LOCALNET_CHAIN_ID(default: 1414)LOCALNET_RPC_URL(default: http://127.0.0.1:5700/rpc/v1)LOCALNET_RPC_WS_URL(default: ws://127.0.0.1:5700/rpc/v1)LOCALNET_BLOCK_EXPLORER_URL(default: http://localhost:8080)LOCALNET_MULTICALL3_ADDRESS,LOCALNET_USDFC_ADDRESS, etc. for contract addresses