get chain to runnable state

This commit is contained in:
Łukasz Magiera 2020-02-22 14:10:46 +01:00
parent 99c0e14fd8
commit b8428423a1
7 changed files with 27 additions and 14 deletions

View File

@ -84,7 +84,11 @@ func (st *StateTree) LookupID(addr address.Address) (address.Address, error) {
return address.Undef, xerrors.Errorf("loading init actor state: %w", err) return address.Undef, xerrors.Errorf("loading init actor state: %w", err)
} }
return ias.ResolveAddress(&AdtStore{st.Store}, addr) a, err := ias.ResolveAddress(&AdtStore{st.Store}, addr)
if err != nil {
return address.Undef, xerrors.Errorf("resolve address %s: %w", addr, err)
}
return a, nil
} }
func (st *StateTree) GetActor(addr address.Address) (*types.Actor, error) { func (st *StateTree) GetActor(addr address.Address) (*types.Actor, error) {
@ -95,7 +99,7 @@ func (st *StateTree) GetActor(addr address.Address) (*types.Actor, error) {
iaddr, err := st.LookupID(addr) iaddr, err := st.LookupID(addr)
if err != nil { if err != nil {
if xerrors.Is(err, init_.ErrAddressNotFound) { if xerrors.Is(err, init_.ErrAddressNotFound) {
return nil, xerrors.Errorf("resolution lookup failed (%s): %w", addr, types.ErrActorNotFound) return nil, xerrors.Errorf("resolution lookup failed (%s): %w", addr, err)
} }
return nil, xerrors.Errorf("address resolution: %w", err) return nil, xerrors.Errorf("address resolution: %w", err)
} }

View File

@ -191,7 +191,8 @@ func GetMinerSectorSize(ctx context.Context, sm *StateManager, ts *types.TipSet,
} }
func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (uint64, error) { func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (uint64, error) {
panic("TODO") log.Warn("stub GetMinerSlashed")
return 0, nil
} }
func GetMinerFaults(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) ([]abi.SectorNumber, error) { func GetMinerFaults(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) ([]abi.SectorNumber, error) {

View File

@ -512,7 +512,9 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
if h.Timestamp < baseTs.MinTimestamp()+(build.BlockDelay*uint64(h.Height-baseTs.Height())) { if h.Timestamp < baseTs.MinTimestamp()+(build.BlockDelay*uint64(h.Height-baseTs.Height())) {
log.Warn("timestamp funtimes: ", h.Timestamp, baseTs.MinTimestamp(), h.Height, baseTs.Height()) log.Warn("timestamp funtimes: ", h.Timestamp, baseTs.MinTimestamp(), h.Height, baseTs.Height())
return xerrors.Errorf("block was generated too soon (h.ts:%d < base.mints:%d + BLOCK_DELAY:%d * deltaH:%d)", h.Timestamp, baseTs.MinTimestamp(), build.BlockDelay, h.Height-baseTs.Height()) diff := (baseTs.MinTimestamp()+(build.BlockDelay*uint64(h.Height-baseTs.Height()))) - h.Timestamp
return xerrors.Errorf("block was generated too soon (h.ts:%d < base.mints:%d + BLOCK_DELAY:%d * deltaH:%d; diff %d)", h.Timestamp, baseTs.MinTimestamp(), build.BlockDelay, h.Height-baseTs.Height(), diff)
} }
winnerCheck := async.Err(func() error { winnerCheck := async.Err(func() error {

View File

@ -7,11 +7,6 @@ import (
"math/big" "math/big"
"reflect" "reflect"
commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime"
block "github.com/ipfs/go-block-format" block "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
hamt "github.com/ipfs/go-hamt-ipld" hamt "github.com/ipfs/go-hamt-ipld"
@ -24,6 +19,12 @@ import (
"golang.org/x/xerrors" "golang.org/x/xerrors"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors"
@ -370,7 +371,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *VMContext,
toActor, err := st.GetActor(msg.To) toActor, err := st.GetActor(msg.To)
if err != nil { if err != nil {
if xerrors.Is(err, types.ErrActorNotFound) { if xerrors.Is(err, init_.ErrAddressNotFound) {
a, err := TryCreateAccountActor(st, msg.To) a, err := TryCreateAccountActor(st, msg.To)
if err != nil { if err != nil {
return nil, aerrors.Absorb(err, 1, "could not create account"), nil return nil, aerrors.Absorb(err, 1, "could not create account"), nil

View File

@ -43,7 +43,7 @@ func init() {
msgs = msgs[:build.BlockMessageLimit] msgs = msgs[:build.BlockMessageLimit]
} }
addr, _ := address.NewIDAddress(101) addr, _ := address.NewIDAddress(1000)
var ticket *types.Ticket var ticket *types.Ticket
{ {
vrfBase := head.MinTicket().VRFProof vrfBase := head.MinTicket().VRFProof

View File

@ -23,13 +23,18 @@ Create the genesis block and start up the first node:
./lotus-seed genesis new localnet.json ./lotus-seed genesis new localnet.json
./lotus-seed genesis add-miner localnet.json ~/.genesis-sectors/pre-seal-t01000.json ./lotus-seed genesis add-miner localnet.json ~/.genesis-sectors/pre-seal-t01000.json
./lotus daemon --lotus-make-genesis=dev.gen --genesis-template=localnet.json --bootstrap=false ./lotus daemon --lotus-make-genesis=dev.gen --genesis-template=localnet.json --bootstrap=false
# TODO Key import ```
Then, in another console, import the genesis miner key:
```sh
./lotus wallet import ~/.genesis-sectors/pre-seal-t01000.key
``` ```
Set up the genesis miner: Set up the genesis miner:
```sh ```sh
./lotus-storage-miner init --genesis-miner --actor=t0101 --sector-size=1024 --pre-sealed-sectors=~/.genesis-sectors --nosync ./lotus-storage-miner init --genesis-miner --actor=t01000 --sector-size=1024 --pre-sealed-sectors=~/.genesis-sectors --nosync
``` ```
Now, finally, start up the miner: Now, finally, start up the miner:

View File

@ -135,7 +135,7 @@ func (m *Sealing) PledgeSector() error {
return return
} }
pieces, err := m.pledgeSector(ctx, sid, []abi.UnpaddedPieceSize{}, abi.UnpaddedPieceSize(size)) pieces, err := m.pledgeSector(ctx, sid, []abi.UnpaddedPieceSize{}, size)
if err != nil { if err != nil {
log.Errorf("%+v", err) log.Errorf("%+v", err)
return return