Skip to content

Commit c17ae32

Browse files
authored
Merge pull request #6492 from filecoin-project/chore/actor-bundle
Chore/actor bundle
2 parents 124b5a7 + e58dbad commit c17ae32

File tree

34 files changed

+817
-168
lines changed

34 files changed

+817
-168
lines changed

app/submodule/chain/chaininfo_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ func (cia *chainInfoAPI) StateGetNetworkParams(ctx context.Context) (*types.Netw
763763
UpgradeTuktukHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeTuktukHeight,
764764
UpgradeTeepHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeTeepHeight,
765765
UpgradeTockHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeTockHeight,
766-
UpgradeXxHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeXxHeight,
766+
UpgradeGoldenWeekHeight: cfg.NetworkParams.ForkUpgradeParam.UpgradeGoldenWeekHeight,
767767
},
768768
Eip155ChainID: cfg.NetworkParams.Eip155ChainID,
769769
}

app/submodule/chain/miner_api.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,78 @@ func (msa *minerStateAPI) StateMinerInitialPledgeForSector(ctx context.Context,
964964
return types.BigDiv(types.BigMul(initialPledge, initialPledgeNum), initialPledgeDen), nil
965965
}
966966

967+
func (msa *minerStateAPI) StateMinerCreationDeposit(ctx context.Context, tsk types.TipSetKey) (types.BigInt, error) {
968+
// Reference implementation: https://github.com/filecoin-project/builtin-actors/blob/00db828d09c3dfb61fe768ff6a19416a313444bd/actors/miner/src/lib.rs#L5264-L5279
969+
nv, err := msa.ChainSubmodule.API().StateNetworkVersion(ctx, tsk)
970+
if err != nil {
971+
return types.EmptyInt, fmt.Errorf("getting network version: %w", err)
972+
}
973+
974+
if nv < network.Version27 {
975+
return big.Zero(), nil
976+
}
977+
978+
// Get current chain head
979+
ts, err := msa.ChainReader.GetTipSet(ctx, tsk)
980+
if err != nil {
981+
return types.EmptyInt, fmt.Errorf("loading tipset %s: %w", tsk, err)
982+
}
983+
984+
_, state, err := msa.ChainSubmodule.Stmgr.ParentState(ctx, ts)
985+
if err != nil {
986+
return types.EmptyInt, fmt.Errorf("loading state %s: %w", tsk, err)
987+
}
988+
989+
rewardActor, found, err := state.GetActor(ctx, reward.Address)
990+
if err != nil {
991+
return types.EmptyInt, fmt.Errorf("loading reward actor: %w", err)
992+
}
993+
if !found {
994+
return types.EmptyInt, errors.New("not found reward")
995+
}
996+
997+
rewardState, err := reward.Load(msa.ChainReader.Store(ctx), rewardActor)
998+
if err != nil {
999+
return types.EmptyInt, fmt.Errorf("loading reward actor state: %w", err)
1000+
}
1001+
1002+
circSupply, err := msa.StateVMCirculatingSupplyInternal(ctx, ts.Key())
1003+
if err != nil {
1004+
return types.EmptyInt, fmt.Errorf("getting circulating supply: %w", err)
1005+
}
1006+
1007+
pledgeCollateral, powerSmoothed, err := msa.pledgeCalculationInputs(ctx, state)
1008+
if err != nil {
1009+
return types.EmptyInt, err
1010+
}
1011+
1012+
// Get network parameters to obtain ConsensusMinerMinPower
1013+
networkParams, err := msa.ChainSubmodule.API().StateGetNetworkParams(ctx)
1014+
if err != nil {
1015+
return types.EmptyInt, fmt.Errorf("getting network params: %w", err)
1016+
}
1017+
createMinerDepositPower := big.Div(networkParams.ConsensusMinerMinPower, big.NewInt(10))
1018+
1019+
epochsSinceRampStart, rampDurationEpochs, err := msa.getPledgeRampParams(ctx, ts.Height(), state)
1020+
if err != nil {
1021+
return types.EmptyInt, fmt.Errorf("getting pledge ramp params: %w", err)
1022+
}
1023+
1024+
deposit, err := rewardState.InitialPledgeForPower(
1025+
createMinerDepositPower,
1026+
pledgeCollateral,
1027+
powerSmoothed,
1028+
circSupply.FilCirculating,
1029+
epochsSinceRampStart,
1030+
rampDurationEpochs,
1031+
)
1032+
if err != nil {
1033+
return types.EmptyInt, fmt.Errorf("calculating initial pledge for power: %w", err)
1034+
}
1035+
1036+
return deposit, nil
1037+
}
1038+
9671039
// StateVMCirculatingSupplyInternal returns an approximation of the circulating supply of Filecoin at the given tipset.
9681040
// This is the value reported by the runtime interface to actors code.
9691041
func (msa *minerStateAPI) StateVMCirculatingSupplyInternal(ctx context.Context, tsk types.TipSetKey) (types.CirculatingSupply, error) {

cmd/miner.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,15 @@ var newMinerCmd = &cmds.Command{
165165
sender = faddr
166166
}
167167

168+
deposit, err := env.(*node.Env).ChainAPI.StateMinerCreationDeposit(ctx, types.EmptyTSK)
169+
if err != nil {
170+
return err
171+
}
172+
168173
createStorageMinerMsg := &types.Message{
169174
To: power.Address,
170175
From: sender,
171-
Value: big.Zero(),
176+
Value: deposit,
172177

173178
Method: power.Methods.CreateMiner,
174179
Params: params,

fixtures/networks/butterfly.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func ButterflySnapNet() *NetworkConf {
6868
UpgradeTeepHeight: -30,
6969
UpgradeTockFixHeight: -29,
7070
UpgradeTockHeight: -31,
71-
UpgradeXxHeight: 9999999999,
71+
UpgradeGoldenWeekHeight: 9999999999,
7272
},
7373
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: config.DrandQuicknet},
7474
AddressNetwork: address.Testnet,

fixtures/networks/calibration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func Calibration() *NetworkConf {
7575
UpgradeTuktukPowerRampDurationEpochs: builtin.EpochsInDay * 3,
7676
UpgradeTeepHeight: 2523454, // 2025-03-26T23:00:00Z
7777
UpgradeTockFixHeight: 2558014, // 2025-04-07T23:00:00Z
78-
UpgradeXxHeight: 99999999,
78+
UpgradeGoldenWeekHeight: 3007294, // 2025-09-10T23:00:00Z
7979
},
8080
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 1},
8181
AddressNetwork: address.Testnet,

fixtures/networks/forcenet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func ForceNet() *NetworkConf {
7070
UpgradeTeepHeight: -30,
7171
UpgradeTockHeight: -31,
7272
UpgradeTockFixHeight: -29,
73-
UpgradeXxHeight: 200,
73+
UpgradeGoldenWeekHeight: 200,
7474
},
7575
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: config.DrandQuicknet},
7676
AddressNetwork: address.Testnet,

fixtures/networks/integrationtestnet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func IntegrationNet() *NetworkConf {
6161
UpgradeTuktukHeight: 4461240,
6262
UpgradeTeepHeight: 4867320,
6363
UpgradeTockFixHeight: -29,
64-
UpgradeXxHeight: 999999999,
64+
UpgradeGoldenWeekHeight: 999999999,
6565
},
6666
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1},
6767
AddressNetwork: address.Testnet,

fixtures/networks/interopnet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func InteropNet() *NetworkConf {
6969
UpgradeTeepHeight: -30,
7070
UpgradeTockHeight: -31,
7171
UpgradeTockFixHeight: -29,
72-
UpgradeXxHeight: 50,
72+
UpgradeGoldenWeekHeight: 50,
7373
},
7474
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: config.DrandQuicknet},
7575
AddressNetwork: address.Testnet,

fixtures/networks/mainnet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func Mainnet() *NetworkConf {
7878
UpgradeTuktukPowerRampDurationEpochs: builtin2.EpochsInYear,
7979
UpgradeTeepHeight: 4878840, // 2025-04-14T23:00:00Z
8080
UpgradeTockFixHeight: -1,
81-
UpgradeXxHeight: 9999999999,
81+
UpgradeGoldenWeekHeight: 9999999999,
8282
},
8383
DrandSchedule: map[abi.ChainEpoch]config.DrandEnum{0: 5, 51000: 1},
8484
AddressNetwork: address.Mainnet,

0 commit comments

Comments
 (0)