Merge pull request #232 from filecoin-project/feat/devdevnet
Setup first devnet params
This commit is contained in:
commit
e1b987c093
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@
|
|||||||
**/*.a
|
**/*.a
|
||||||
**/*.pc
|
**/*.pc
|
||||||
build/.*
|
build/.*
|
||||||
|
build/paramfetch.sh
|
||||||
/vendor
|
/vendor
|
||||||
|
|
||||||
*-fuzz.zip
|
*-fuzz.zip
|
||||||
|
7
Makefile
7
Makefile
@ -56,8 +56,11 @@ bin/ipget:
|
|||||||
PARAM_SECTOR_SIZES:=1024 16777216 268435456 1073741824
|
PARAM_SECTOR_SIZES:=1024 16777216 268435456 1073741824
|
||||||
PARAM_SECTOR_SIZES:=$(addprefix build/.params-,$(PARAM_SECTOR_SIZES))
|
PARAM_SECTOR_SIZES:=$(addprefix build/.params-,$(PARAM_SECTOR_SIZES))
|
||||||
|
|
||||||
$(PARAM_SECTOR_SIZES): build/proof-params/parameters.json bin/ipget
|
./build/paramfetch.sh: build/proof-params/parameters.json
|
||||||
./build/proof-params/paramfetch.sh
|
build/proof-params/mkparamfetch.sh
|
||||||
|
|
||||||
|
$(PARAM_SECTOR_SIZES): ./build/paramfetch.sh build/proof-params/parameters.json bin/ipget
|
||||||
|
./build/paramfetch.sh
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
BUILD_DEPS+=build/.params-1024
|
BUILD_DEPS+=build/.params-1024
|
||||||
|
@ -116,6 +116,7 @@ type FullNode interface {
|
|||||||
StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error)
|
StateMinerWorker(context.Context, address.Address, *types.TipSet) (address.Address, error)
|
||||||
StateMinerPeerID(ctx context.Context, m address.Address, ts *types.TipSet) (peer.ID, 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)
|
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)
|
PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*ChannelInfo, error)
|
||||||
PaychList(context.Context) ([]address.Address, error)
|
PaychList(context.Context) ([]address.Address, error)
|
||||||
|
@ -84,6 +84,7 @@ type FullNodeStruct struct {
|
|||||||
StateReplay func(context.Context, *types.TipSet, cid.Cid) (*ReplayResults, error) `perm:"read"`
|
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"`
|
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"`
|
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"`
|
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"`
|
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)
|
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) {
|
func (c *FullNodeStruct) PaychGet(ctx context.Context, from, to address.Address, ensureFunds types.BigInt) (*ChannelInfo, error) {
|
||||||
return c.Internal.PaychGet(ctx, from, to, ensureFunds)
|
return c.Internal.PaychGet(ctx, from, to, ensureFunds)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ const MaxVouchersPerDeal = 768 // roughly one voucher per 10h over a year
|
|||||||
// Consensus / Network
|
// Consensus / Network
|
||||||
|
|
||||||
// Seconds
|
// Seconds
|
||||||
const BlockDelay = 3
|
const BlockDelay = 6
|
||||||
|
|
||||||
// Seconds
|
// Seconds
|
||||||
const AllowableClockDrift = BlockDelay * 2
|
const AllowableClockDrift = BlockDelay * 2
|
||||||
@ -43,10 +43,10 @@ const ForkLengthThreshold = 20
|
|||||||
const RandomnessLookback = 20
|
const RandomnessLookback = 20
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
const ProvingPeriodDuration = 10
|
const ProvingPeriodDuration = 40
|
||||||
|
|
||||||
// Blocks
|
// Blocks
|
||||||
const PoSTChallangeTime = 5
|
const PoSTChallangeTime = 20
|
||||||
|
|
||||||
const PowerCollateralProportion = 20
|
const PowerCollateralProportion = 20
|
||||||
const PerCapitaCollateralProportion = 5
|
const PerCapitaCollateralProportion = 5
|
||||||
|
6
build/proof-params/mkparamfetch.sh
Executable file
6
build/proof-params/mkparamfetch.sh
Executable file
@ -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
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
PARAMS='{{PARAMSJSON}}'
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
echo "$@" >&2
|
echo "$@" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -73,10 +75,9 @@ fetch_gateway() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OUT_DIR="/var/tmp/filecoin-proof-parameters"
|
OUT_DIR="/var/tmp/filecoin-proof-parameters"
|
||||||
PARAMS="build/proof-params/parameters.json"
|
|
||||||
|
|
||||||
mkdir -p $OUT_DIR
|
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
|
while read -r dest cid digest; do
|
||||||
if [[ -f "$dest" ]]; then
|
if [[ -f "$dest" ]]; then
|
||||||
b2=$(b2sum "$dest" | head -c 32)
|
b2=$(b2sum "$dest" | head -c 32)
|
@ -129,8 +129,8 @@ func NewGenerator() (*ChainGen, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
genb, err := MakeGenesisBlock(bs, map[address.Address]types.BigInt{
|
genb, err := MakeGenesisBlock(bs, map[address.Address]types.BigInt{
|
||||||
worker: types.NewInt(5000000000),
|
worker: types.FromFil(40000),
|
||||||
banker: types.NewInt(9000000000),
|
banker: types.FromFil(50000),
|
||||||
}, minercfg, 100000)
|
}, minercfg, 100000)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("make genesis block failed: %w", err)
|
return nil, xerrors.Errorf("make genesis block failed: %w", err)
|
||||||
|
@ -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
|
// TODO: hardcoding 7000000 here is a little fragile, it changes any
|
||||||
// time anyone changes the initial account allocations
|
// 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 {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
|
|
||||||
var log = logging.Logger("main")
|
var log = logging.Logger("main")
|
||||||
|
|
||||||
var sendPerRequest = types.NewInt(5_000_000)
|
var sendPerRequest = types.NewInt(500_000_000)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logging.SetLogLevel("*", "INFO")
|
logging.SetLogLevel("*", "INFO")
|
||||||
|
@ -233,7 +233,10 @@ func createStorageMiner(ctx context.Context, api api.FullNode, peerid peer.ID, c
|
|||||||
return address.Undef, err
|
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{
|
params, err := actors.SerializeParams(&actors.CreateStorageMinerParams{
|
||||||
Owner: owner,
|
Owner: owner,
|
||||||
|
@ -83,6 +83,30 @@ func (a *StateAPI) StateMinerProvingPeriodEnd(ctx context.Context, actor address
|
|||||||
return stmgr.GetMinerProvingPeriodEnd(ctx, a.StateManager, ts, actor)
|
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) {
|
func (a *StateAPI) StateCall(ctx context.Context, msg *types.Message, ts *types.TipSet) (*types.MessageReceipt, error) {
|
||||||
return a.StateManager.Call(ctx, msg, ts)
|
return a.StateManager.Call(ctx, msg, ts)
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ func MakeGenesisMem(out io.Writer) func(bs dtypes.ChainBlockstore, w *wallet.Wal
|
|||||||
PeerIDs: []peer.ID{"peerID 1"},
|
PeerIDs: []peer.ID{"peerID 1"},
|
||||||
}
|
}
|
||||||
alloc := map[address.Address]types.BigInt{
|
alloc := map[address.Address]types.BigInt{
|
||||||
w: types.NewInt(1000000000),
|
w: types.FromFil(10000),
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := gen.MakeGenesisBlock(bs, alloc, gmc, 100000)
|
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{
|
addrs := map[address.Address]types.BigInt{
|
||||||
minerAddr: types.NewInt(5000000000),
|
minerAddr: types.NewInt(5000000000000000000),
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := gen.MakeGenesisBlock(bs, addrs, gmc, 100000)
|
b, err := gen.MakeGenesisBlock(bs, addrs, gmc, 100000)
|
||||||
|
Loading…
Reference in New Issue
Block a user