Fix implicit account creation

This commit is contained in:
Łukasz Magiera 2020-02-21 18:13:50 +01:00
parent 57c43183e6
commit c744dc06c6
5 changed files with 11 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package genesis
import (
"context"
"encoding/json"
"fmt"
"github.com/ipfs/go-hamt-ipld"
bstore "github.com/ipfs/go-ipfs-blockstore"
@ -36,6 +37,8 @@ func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesi
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
}
fmt.Printf("init set %s t0%d\n", ainfo.Owner, AccountStart+uint64(i))
if err := amap.Set(context.TODO(), string(ainfo.Owner.Bytes()), AccountStart+uint64(i)); err != nil {
return nil, err
}

View File

@ -3,6 +3,7 @@ package state
import (
"context"
"fmt"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"github.com/ipfs/go-cid"
@ -93,7 +94,7 @@ func (st *StateTree) GetActor(addr address.Address) (*types.Actor, error) {
iaddr, err := st.LookupID(addr)
if err != nil {
if xerrors.Is(err, hamt.ErrNotFound) {
if xerrors.Is(err, init_.ErrAddressNotFound) {
return nil, xerrors.Errorf("resolution lookup failed (%s): %w", addr, types.ErrActorNotFound)
}
return nil, xerrors.Errorf("address resolution: %w", err)

View File

@ -1,12 +1,12 @@
package types
import (
"fmt"
"github.com/ipfs/go-cid"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
)
var ErrActorNotFound = fmt.Errorf("actor not found")
var ErrActorNotFound = init_.ErrAddressNotFound
type Actor struct {
Code cid.Cid

2
go.mod
View File

@ -24,7 +24,7 @@ require (
github.com/filecoin-project/go-paramfetch v0.0.1
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200210220012-eb75ec747d6b
github.com/filecoin-project/go-statestore v0.1.0
github.com/filecoin-project/specs-actors v0.0.0-20200221155838-19bb26c4b9d7
github.com/filecoin-project/specs-actors v0.0.0-20200221171119-030c8eaad3ba
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/gorilla/mux v1.7.3

2
go.sum
View File

@ -136,6 +136,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200221134721-ef38bdd3e05f h1:X
github.com/filecoin-project/specs-actors v0.0.0-20200221134721-ef38bdd3e05f/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU=
github.com/filecoin-project/specs-actors v0.0.0-20200221155838-19bb26c4b9d7 h1:iBqYva5s34J0LVBe7Fqrv/ToNVUFyKwpaXLk47wjq3A=
github.com/filecoin-project/specs-actors v0.0.0-20200221155838-19bb26c4b9d7/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU=
github.com/filecoin-project/specs-actors v0.0.0-20200221171119-030c8eaad3ba h1:KXxG0UblgNdQeAxdQZNXdECYV4FCJC/noXrIjvElO/0=
github.com/filecoin-project/specs-actors v0.0.0-20200221171119-030c8eaad3ba/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 h1:EzDjxMg43q1tA2c0MV3tNbaontnHLplHyFF6M5KiVP0=