Skip to content

Conversation

@redpanda-f
Copy link

This PR adds comprehensive support for local Filecoin networks to enable easier development and testing.

Changes

  • Add localnet support to Synapse SDK for local Filecoin network development
  • Introduce localnet configuration utilities with environment variable support for chain ID, RPC URLs, and contract addresses
  • Update FilecoinNetworkType to include 'localnet' alongside mainnet and calibration
  • Enhance network detection to automatically recognize localnet by chain ID
  • Add localnet contract address resolution with required/optional address validation
  • Update example scripts (storage-e2e, post-deploy-setup) to support --network localnet option
  • Export localnet configuration from synapse-core and synapse-sdk packages
  • Maintain backward compatibility with existing mainnet/calibration functionality

Environment 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

@github-project-automation github-project-automation bot moved this to 📌 Triage in FS Jan 2, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 2, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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 redpanda-f changed the title feat: Add Localnet Support to Synapse SDK feat: (foc-localnet-v1-rc) Add Localnet Support to Synapse SDK Jan 2, 2026
@BigLep
Copy link
Contributor

BigLep commented Jan 5, 2026

@redpanda-f : will you take care of the lint failures?

@BigLep BigLep moved this from 📌 Triage to 🔎 Awaiting review in FS Jan 5, 2026
@rvagg rvagg force-pushed the feat/redpanda/localnet-support branch from 4431d7c to ebfd645 Compare January 6, 2026 05:21
* ```
*/

export {
Copy link
Collaborator

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?

Copy link
Collaborator

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(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

http: 'https://api.calibration.node.glif.io/rpc/v1',
websocket: 'wss://wss.calibration.node.glif.io/apigw/lotus/rpc/v1',
},
localnet: {
Copy link
Collaborator

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() {
Copy link
Collaborator

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.

Copy link
Collaborator

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() {
Copy link
Collaborator

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
Copy link
Collaborator

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) {
Copy link
Collaborator

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

@rjan90 rjan90 added this to the M4: Filecoin Service Liftoff milestone Jan 8, 2026
@BigLep BigLep moved this from 🔎 Awaiting review to ⌨️ In Progress in FS Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ⌨️ In Progress

Development

Successfully merging this pull request may close these issues.

5 participants