Skip to content

fix(build)!: adjust FilReserved for FIP-0100 for non-mainnet#12938

Merged
rvagg merged 2 commits intorvagg/fip-0100from
rvagg/calibnet-cs-adjust
Mar 14, 2025
Merged

fix(build)!: adjust FilReserved for FIP-0100 for non-mainnet#12938
rvagg merged 2 commits intorvagg/fip-0100from
rvagg/calibnet-cs-adjust

Conversation

@rvagg
Copy link
Copy Markdown
Member

@rvagg rvagg commented Mar 6, 2025

This is the calibnet fix mentioned in FIP-0100, but it's also for 2k and butterfly. It's a PR into the rvagg/fip-0100 branch, for independent reviewing because this one needs explaining.

Bear with me while I explain the logic here, I want to get this on the historical record without having to put it all in the code.

The aim is to bring circulating supply to a positive value (well, nonzero), and to push it into the millions so we can have comparative values to mainnet. Mainnet is currently at 698M FIL. The FIP states that we're going to bring Calibnet up to 300M but I'm going to change that and push everything closer to 600M just so we have very comparable numbers for fee calculation to mainnet (I'll update the FIP text for calibnet).

The basic equation for circulating supply is:

$$CS = \max(0, FilVested + FilMined + FilReserveDisbursed - FilBurnt - FilLocked)$$

FilReserveDisbursed is the thing we're going to tinker with, it's further broken down as:

$$CS = \max(0, FilVested + FilMined + (InitialFilReserved - FilReserved) - FilBurnt - FilLocked)$$

InitialFilReserved is fixed in Lotus as 300M FIL. But we have different FilReserved (f090 balance) values across our network configs. On mainnet it's 282M, but seems to be set to 900M (or thereabouts) in genesis on butterfly and calibnet (currently 869M on calibnet), and 700M when you start a 2k network, or even an itest without the 2k tag. I don't have an explanation for these numbers, I'm just rolling with it. Butterfly and 2k are easy to adjust in the future, calibnet less so.

For mainnet, calculate CS by filling in:

$$CS = \max(0, 489942212706911624810780299 + 368308309891806770091483994 + (300000000000000000000000000 - 282933381038226594769936954) - 40385212415096332500414561 - 136827985628170331804063944)$$ $$CS = 698M$$

For calibnet:

$$CS = \max(0, 330780229228386605786661888 + 70513551539223285753426670 + (1300000000000000000000000000 - 869144570890006671285774984) - 32241695511329683287634028 - 4227151872445836887470146)$$ $$CS = \max(0, -200M)$$

Butterfly is a bit weirder because it starts off with a FilVested of ~10M FIL, at height 1 we work it out as:

$$CS = \max(0, 10633800385165826624205808 + 0 + (300000000000000000000000000 - 900000000000000000000000000) - 0 - 1440)$$ $$CS = \max(0, -586M)$$

2k starts off with a ~0 vested and a mining reserve of 700M FIL; something like this:

$$CS = \max(0, 0 + 0 + (300000000000000000000000000 - 700000000000000000000000000) - 0 - 0)$$ $$CS = \max(0, -400M)$$

So, with this PR, we introduce a switch at Teep (nv25) upgrade height, so that the Circulating Supply value that gets passed into the FVM will flip. For mainnet we leave it alone, but we make the following changes:

Calibnet 300M -> 1.2B

$$CS = \max(0, 330780229228386605786661888 + 70513551539223285753426670 + (1200000000000000000000000000 - 869144570890006671285774984) - 32241695511329683287634028 - 4227151872445836887470146)$$ $$CS = 695M$$

Butterfly 300M -> 1.6B

$$CS = \max(0, 10633800385165826624205808 + 0 + (1600000000000000000000000000 - 900000000000000000000000000) - 0 - 1440)$$ $$CS = 710M$$

2k 300M -> 1.4B

$$CS = \max(0, 0 + 0 + (1400000000000000000000000000 - 700000000000000000000000000) - 0 - 0)$$ $$CS = 700M$$

The diff isn't super clean because I also moved some variables around in the params files to put the auxiliary settings with their upgrades because they were getting a bit too separated.

I also need to manually fix the itest ensemble because it's not normally run with -tags 2k, so I copy in the 2k settings that I care about to each ensemble build.

I'm removing buildconstants.FilReserved and buildconstants.FilAllocStorageMining entirely, we don't use them internally and you can extract them from the other variables that are exposed in there.

(Also, sorry, my brain hurts too if it's any consolation when reviewing this)

(Edit: updated original numbers to get closer to 700M on each)

@rvagg rvagg requested review from ZenGround0 and rjan90 March 6, 2025 11:54
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FilOz Mar 6, 2025
github-actions[bot]

This comment was marked as resolved.

@github-project-automation github-project-automation Bot moved this from 📌 Triage to ⌨️ In Progress in FilOz Mar 6, 2025
@rvagg rvagg changed the title fix!(build): adjust FilReserved for FIP-0100 for non-mainnet fix(build)!: adjust FilReserved for FIP-0100 for non-mainnet Mar 6, 2025
@github-actions github-actions Bot dismissed their stale review March 6, 2025 11:55

PR title now matches the required format.

@rjan90
Copy link
Copy Markdown
Contributor

rjan90 commented Mar 6, 2025

InitialFilReserved is fixed in Lotus as 300M FIL. But we have different FilReserved (f090 balance) values across our network configs. On mainnet it's 282M, but seems to be set to 900M (or thereabouts) in genesis on butterfly and calibnet (currently 869M on calibnet), and 700M when you start a 2k network, or even an itest without the 2k tag. I don't have an

Just adding to the history here, that I believe the FILReserved (f090 balance) was set higher on the test networks as hack/workaround to get to the 2B FILBase, instead of adding all types of msig/vesting wallets for different initial investors/FF/PL to these networks.

@rvagg
Copy link
Copy Markdown
Member Author

rvagg commented Mar 6, 2025

Having written all of that, I will admit to having second thoughts on changing the FIP or calibnet. 900M makes circulating supply correct on calibnet. 1.1B makes it closer to current mainnet, but not technically correct. We'll still get fees calculated, they'll just be nearly half of what they will be on mainnet. Maybe that's not terrible.

I'd still like to make butterfly and 2k closer to mainnet, and as I said, we can easily change those values for these ephemeral networks in the future.

Comment thread build/buildconstants/params_calibnet.go Outdated
// Canceled - See update in: https://github.com/filecoin-project/community/discussions/74#discussioncomment-11549619
const UpgradeTeepHeight = 9999999999

var UpgradeTeepInitialFilReserved = wholeToNano(1_100_000_000) // FIP-0100: 300M -> 1.1B FIL
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Suggested change
var UpgradeTeepInitialFilReserved = wholeToNano(1_100_000_000) // FIP-0100: 300M -> 1.1B FIL
var UpgradeTeepInitialFilReserved = wholeToNano(900_000_000) // FIP-0100: 300M -> 900M FIL

This would match the current FIP. Need to consider whether it's better to be correct, or make it closer to mainnet just to test fee calculation. 🤔

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.

I think one of the goals for Calibnet is to try to mirror Mainnet. While it has achieved that with regards to SP hardware usage, block times, and proofs, the economics has been really skewed.

I'm in favor of aligning Calibnet more closely with Mainnet's economic conditions. Although we may never fully replicate Mainnet econ due to differences in scale and miner numbers, adjusting the circulating supply to be more accurate to what Mainnet is a positive step forward in my opinion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

filecoin-project/FIPs#1133 & filecoin-project/FIPs#1105

Proposing another 100M FIL to get us to an almost exact match with mainnet. I'm still not sure about it, but these really are just test networks so we can tweak them as we need and it would be nice to have equations resolving to very similar values as mainnet.

Comment thread build/buildconstants/shared_funcs.go Outdated
@rvagg
Copy link
Copy Markdown
Member Author

rvagg commented Mar 7, 2025

Latest commit fixes some things and adjusts the numbers a little bit more to get us closer to 700M which is really what the target should be if we're matching mainnet. I'm still a little torn on accuracy vs matching mainnet, but it would be nice to have a better testing environment. We'll see if filecoin-project/FIPs#1133 gets merged.

@rjan90 re testing - I've not done anything to actively test butterflynet but I did get on to the currently running one to inspect the state and calculations, which is where my numbers are coming from in here. 2k testing I can do locally through itests, and you can see in my latest commit I had to fix the nv24 migration test because it was breaking with my changes, the UpgradeAssemblyHeight change specifically. But it all makes sense and I added more notes about why the changes are made and how they work together to make everything execute properly. What I ended up doing in the itests is setting the InitialFilReserved to 700M, so its actually accurate from genesis for the mining reserve, and then do the additional bump at Teep so what we'll see it doing is go from actually accurate, to inflated to get us to a CS close to 700M.

@rvagg rvagg force-pushed the rvagg/calibnet-cs-adjust branch 2 times, most recently from 8cc349b to 8941d88 Compare March 7, 2025 03:19
@rvagg rvagg linked an issue Mar 7, 2025 that may be closed by this pull request
@rjan90
Copy link
Copy Markdown
Contributor

rjan90 commented Mar 7, 2025

Took the branch for a spin on my calibration network node, and set the upgrade epoch to 2467050:

Circulating supply before the upgrade:

lotus state  circulating-supply --vm-supply
Circulating supply:  0 FIL
Mined:  70577664.517308813132145682 FIL
Vested:  331025785.573779965756217202 FIL
Burnt:  32243030.484932989752921826 FIL
Locked:  4233426.164476084875132204 FIL

Migrations:

2025-03-07T07:58:00.089Z	WARN	statemgr	stmgr/forks.go:250	STARTING pre-migration
2025-03-07T07:58:00.161Z	INFO	fil-consensus	filcns/upgrades.go:3012	Creating migration jobs
2025-03-07T07:58:02.161Z	INFO	fil-consensus	filcns/upgrades.go:3012	Performing migration: 123764 of 123772 jobs processed (61877/s) [2s elapsed]
2025-03-07T07:58:02.696Z	INFO	fil-consensus	filcns/upgrades.go:3012	Done creating 157108 migration jobs after 2.5s
2025-03-07T07:58:03.703Z	WARN	statemgr	stmgr/forks.go:263	COMPLETED pre-migration	{"duration": 3.614123026}
------
2025-03-07T08:58:32.148Z	WARN	statemgr	stmgr/forks.go:202	STARTING migration	{"height": "2467050", "from": "bafy2bzacec2vyxmohmfsrt4amt57bcelpolxag2ckotbizh2ijqijttvsjc6e"}
2025-03-07T08:58:32.324Z	INFO	fil-consensus	filcns/upgrades.go:3012	Creating migration jobs
2025-03-07T08:58:34.281Z	INFO	fil-consensus	filcns/upgrades.go:3012	Done creating 157125 migration jobs after 2s
2025-03-07T08:58:34.470Z	WARN	statemgr	stmgr/forks.go:211	COMPLETED migration	{"height": "2467050", "from": "bafy2bzacec2vyxmohmfsrt4amt57bcelpolxag2ckotbizh2ijqijttvsjc6e", "to": "bafy2bzacec5xvlxmkr3kguz657ycjdjxiwm4qnhnfizog5pvkklqfjlam24vu", "duration": 2.322295557}

Circulating supply after the migration:

lotus state  circulating-supply --vm-supply
Circulating supply:  695998687.800397868318023737 FIL
Mined:  70580720.219537282613540871 FIL
Vested:  331037788.896461187217404256 FIL
Burnt:  32243030.484934148124519106 FIL
Locked:  4235719.943362292089943101 FIL

Which is right on target/according to the calculations above

Copy link
Copy Markdown
Contributor

@rjan90 rjan90 left a comment

Choose a reason for hiding this comment

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

Changes look good to me. Guess the outstanding question is some signal on the accuracy vs matching mainnet CS.

@github-project-automation github-project-automation Bot moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FilOz Mar 7, 2025
@rvagg rvagg force-pushed the rvagg/calibnet-cs-adjust branch 2 times, most recently from 08af2c4 to 0041cb6 Compare March 10, 2025 02:22
@rvagg rvagg force-pushed the rvagg/fip-0100 branch 2 times, most recently from 6ab5711 to 3f15f22 Compare March 10, 2025 08:52
@rvagg rvagg force-pushed the rvagg/calibnet-cs-adjust branch 2 times, most recently from 69ad783 to 28e6193 Compare March 10, 2025 09:13
@BigLep BigLep moved this from 🔎 Awaiting Review to ✔️ Approved by reviewer in nv25 Track Board Mar 10, 2025
@rvagg rvagg force-pushed the rvagg/calibnet-cs-adjust branch from 28e6193 to 33c6ba5 Compare March 11, 2025 01:15
@rvagg rvagg force-pushed the rvagg/calibnet-cs-adjust branch from 33c6ba5 to 17ef76e Compare March 11, 2025 01:52
@rvagg rvagg force-pushed the rvagg/calibnet-cs-adjust branch from 17ef76e to 9d65e33 Compare March 11, 2025 03:53
@rvagg
Copy link
Copy Markdown
Member Author

rvagg commented Mar 14, 2025

filecoin-project/FIPs#1133 merged

@rvagg rvagg merged commit f397a87 into rvagg/fip-0100 Mar 14, 2025
@rvagg rvagg deleted the rvagg/calibnet-cs-adjust branch March 14, 2025 04:07
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in nv25 Track Board Mar 14, 2025
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FilOz Mar 14, 2025
@rjan90 rjan90 moved this from 🎉 Done to ☑️ Done (Archive) in FilOz Mar 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ☑️ Done (Archive)
Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

Calibration (calibnet): fix 0 circulating supply

3 participants