diff --git a/.gitignore b/.gitignore index 82e6ef566..4e008cccc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ **/*.a **/*.pc build/.* +build/paramfetch.sh /vendor *-fuzz.zip diff --git a/Makefile b/Makefile index ae7b13f64..212f95d8d 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,11 @@ bin/ipget: PARAM_SECTOR_SIZES:=1024 16777216 268435456 1073741824 PARAM_SECTOR_SIZES:=$(addprefix build/.params-,$(PARAM_SECTOR_SIZES)) -$(PARAM_SECTOR_SIZES): build/proof-params/parameters.json bin/ipget - ./build/proof-params/paramfetch.sh +./build/paramfetch.sh: build/proof-params/parameters.json + build/proof-params/mkparamfetch.sh + +$(PARAM_SECTOR_SIZES): ./build/paramfetch.sh build/proof-params/parameters.json bin/ipget + ./build/paramfetch.sh touch $@ BUILD_DEPS+=build/.params-1024 diff --git a/api/api.go b/api/api.go index 1b6d5361a..13d4de47d 100644 --- a/api/api.go +++ b/api/api.go @@ -116,6 +116,7 @@ type FullNode interface { StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error) StateMinerPeerID(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, error) StateMinerProvingPeriodEnd(ctx context.Context, actor address.Address, ts *types.TipSet) (uint64, error) + StatePledgeCollateral(context.Context, *types.TipSet) (types.BigInt, error) PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*ChannelInfo, error) PaychList(context.Context) ([]address.Address, error) diff --git a/api/struct.go b/api/struct.go index 3437bb47d..78a08bb62 100644 --- a/api/struct.go +++ b/api/struct.go @@ -84,6 +84,7 @@ type FullNodeStruct struct { StateReplay func(context.Context, *types.TipSet, cid.Cid) (*ReplayResults, error) `perm:"read"` StateGetActor func(context.Context, address.Address, *types.TipSet) (*types.Actor, error) `perm:"read"` StateReadState func(context.Context, *types.Actor, *types.TipSet) (*ActorState, error) `perm:"read"` + StatePledgeCollateral func(context.Context, *types.TipSet) (types.BigInt, error) `perm:"read"` PaychGet func(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*ChannelInfo, error) `perm:"sign"` PaychList func(context.Context) ([]address.Address, error) `perm:"read"` @@ -322,6 +323,10 @@ func (c *FullNodeStruct) StateReadState(ctx context.Context, act *types.Actor, t return c.Internal.StateReadState(ctx, act, ts) } +func (c *FullNodeStruct) StatePledgeCollateral(ctx context.Context, ts *types.TipSet) (types.BigInt, error) { + return c.Internal.StatePledgeCollateral(ctx, ts) +} + func (c *FullNodeStruct) PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*ChannelInfo, error) { return c.Internal.PaychGet(ctx, from, to, ensureFunds) } diff --git a/build/params.go b/build/params.go index 19611fb43..7c00f1920 100644 --- a/build/params.go +++ b/build/params.go @@ -28,7 +28,7 @@ const MaxVouchersPerDeal = 768 // roughly one voucher per 10h over a year // Consensus / Network // Seconds -const BlockDelay = 3 +const BlockDelay = 6 // Seconds const AllowableClockDrift = BlockDelay * 2 @@ -43,10 +43,10 @@ const ForkLengthThreshold = 20 const RandomnessLookback = 20 // Blocks -const ProvingPeriodDuration = 10 +const ProvingPeriodDuration = 40 // Blocks -const PoSTChallangeTime = 5 +const PoSTChallangeTime = 20 const PowerCollateralProportion = 20 const PerCapitaCollateralProportion = 5 diff --git a/build/proof-params/mkparamfetch.sh b/build/proof-params/mkparamfetch.sh new file mode 100755 index 000000000..b503e22ef --- /dev/null +++ b/build/proof-params/mkparamfetch.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -euo pipefail + +sed "s/{{PARAMSJSON}}/$(base64 build/proof-params/parameters.json -w 0)/g" build/proof-params/paramfetch.sh.template > ./build/paramfetch.sh +chmod +x ./build/paramfetch.sh diff --git a/build/proof-params/paramfetch.sh b/build/proof-params/paramfetch.sh.template similarity index 93% rename from build/proof-params/paramfetch.sh rename to build/proof-params/paramfetch.sh.template index 97894ac39..739b8b0e1 100755 --- a/build/proof-params/paramfetch.sh +++ b/build/proof-params/paramfetch.sh.template @@ -2,6 +2,8 @@ set -euo pipefail +PARAMS='{{PARAMSJSON}}' + die() { echo "$@" >&2 exit 1 @@ -73,10 +75,9 @@ fetch_gateway() { } OUT_DIR="/var/tmp/filecoin-proof-parameters" -PARAMS="build/proof-params/parameters.json" mkdir -p $OUT_DIR -jq '. | to_entries | map("'$OUT_DIR'/\(.key) \(.value.cid) \(.value.digest)") | .[]' --raw-output $PARAMS | \ +printf $PARAMS | base64 -d | jq '. | to_entries | map("'$OUT_DIR'/\(.key) \(.value.cid) \(.value.digest)") | .[]' --raw-output | \ while read -r dest cid digest; do if [[ -f "$dest" ]]; then b2=$(b2sum "$dest" | head -c 32) diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 8e0024422..75e9e3d80 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -129,8 +129,8 @@ func NewGenerator() (*ChainGen, error) { } genb, err := MakeGenesisBlock(bs, map[address.Address]types.BigInt{ - worker: types.NewInt(5000000000), - banker: types.NewInt(9000000000), + worker: types.FromFil(40000), + banker: types.FromFil(50000), }, minercfg, 100000) if err != nil { return nil, xerrors.Errorf("make genesis block failed: %w", err) diff --git a/chain/gen/utils.go b/chain/gen/utils.go index 9362a4083..249a1ab73 100644 --- a/chain/gen/utils.go +++ b/chain/gen/utils.go @@ -202,7 +202,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid // TODO: hardcoding 7000000 here is a little fragile, it changes any // time anyone changes the initial account allocations - rval, err := doExecValue(ctx, vm, actors.StorageMarketAddress, owner, types.NewInt(700000000), actors.SMAMethods.CreateStorageMiner, params) + rval, err := doExecValue(ctx, vm, actors.StorageMarketAddress, owner, types.FromFil(6000), actors.SMAMethods.CreateStorageMiner, params) if err != nil { return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err) } diff --git a/cmd/lotus-fountain/main.go b/cmd/lotus-fountain/main.go index efef52a40..1a9017b31 100644 --- a/cmd/lotus-fountain/main.go +++ b/cmd/lotus-fountain/main.go @@ -19,7 +19,7 @@ import ( var log = logging.Logger("main") -var sendPerRequest = types.NewInt(5_000_000) +var sendPerRequest = types.NewInt(500_000_000) func main() { logging.SetLogLevel("*", "INFO") diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index 4254924cd..3d2e113dd 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -233,7 +233,10 @@ func createStorageMiner(ctx context.Context, api api.FullNode, peerid peer.ID, c return address.Undef, err } - collateral := types.NewInt(1000) // TODO: Get this from params + collateral, err := api.StatePledgeCollateral(ctx, nil) + if err != nil { + return address.Undef, err + } params, err := actors.SerializeParams(&actors.CreateStorageMinerParams{ Owner: owner, diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 2b1414d4d..1e1558cf8 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -83,6 +83,30 @@ func (a *StateAPI) StateMinerProvingPeriodEnd(ctx context.Context, actor address return stmgr.GetMinerProvingPeriodEnd(ctx, a.StateManager, ts, actor) } +func (a *StateAPI) StatePledgeCollateral(ctx context.Context, ts *types.TipSet) (types.BigInt, error) { + param, err := actors.SerializeParams(&actors.PledgeCollateralParams{Size: types.NewInt(0)}) + if err != nil { + return types.NewInt(0), err + } + + ret, aerr := a.StateManager.Call(ctx, &types.Message{ + From: actors.StorageMarketAddress, + To: actors.StorageMarketAddress, + Method: actors.SMAMethods.PledgeCollateralForSize, + + Params: param, + }, ts) + if aerr != nil { + return types.NewInt(0), xerrors.Errorf("failed to get miner worker addr: %w", err) + } + + if ret.ExitCode != 0 { + return types.NewInt(0), xerrors.Errorf("failed to get miner worker addr (exit code %d)", ret.ExitCode) + } + + return types.BigFromBytes(ret.Return), nil +} + func (a *StateAPI) StateCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error) { return a.StateManager.Call(ctx, msg, ts) } diff --git a/node/modules/testing/genesis.go b/node/modules/testing/genesis.go index 5085ac4fc..c6c75d9e7 100644 --- a/node/modules/testing/genesis.go +++ b/node/modules/testing/genesis.go @@ -40,7 +40,7 @@ func MakeGenesisMem(out io.Writer) func(bs dtypes.ChainBlockstore, w *wallet.Wal PeerIDs: []peer.ID{"peerID 1"}, } alloc := map[address.Address]types.BigInt{ - w: types.NewInt(1000000000), + w: types.FromFil(10000), } b, err := gen.MakeGenesisBlock(bs, alloc, gmc, 100000) @@ -76,7 +76,7 @@ func MakeGenesis(outFile string) func(bs dtypes.ChainBlockstore, w *wallet.Walle } addrs := map[address.Address]types.BigInt{ - minerAddr: types.NewInt(5000000000), + minerAddr: types.NewInt(5000000000000000000), } b, err := gen.MakeGenesisBlock(bs, addrs, gmc, 100000)