Merge pull request #224 from filecoin-project/fix/addrinit
statetree: add actor to actcache in SetActor
This commit is contained in:
commit
ab293f2ff4
@ -62,6 +62,8 @@ func (st *StateTree) SetActor(addr address.Address, act *types.Actor) error {
|
||||
}
|
||||
}
|
||||
|
||||
st.actorcache[addr] = act
|
||||
|
||||
return st.root.Set(context.TODO(), string(addr.Bytes()), act)
|
||||
}
|
||||
|
||||
|
@ -107,3 +107,39 @@ func BenchmarkStateTree10kGetActor(b *testing.B) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetCache(t *testing.T) {
|
||||
cst := hamt.NewCborStore()
|
||||
st, err := NewStateTree(cst)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
a, err := address.NewIDAddress(uint64(222))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
Balance: types.NewInt(0),
|
||||
Code: actors.StorageMinerCodeCid,
|
||||
Head: actors.AccountActorCodeCid,
|
||||
Nonce: 0,
|
||||
}
|
||||
|
||||
err = st.SetActor(a, act)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
act.Nonce = 1
|
||||
|
||||
outact, err := st.GetActor(a)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if outact.Nonce != act.Nonce {
|
||||
t.Error("nonce didn't match")
|
||||
}
|
||||
}
|
||||
|
@ -468,6 +468,9 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet,
|
||||
if aerrors.IsFatal(actorErr) {
|
||||
return nil, xerrors.Errorf("fatal error: %w", actorErr)
|
||||
}
|
||||
if actorErr != nil {
|
||||
log.Warn("Send actor error: %s", actorErr)
|
||||
}
|
||||
|
||||
var errcode uint8
|
||||
var gasUsed types.BigInt
|
||||
|
Loading…
Reference in New Issue
Block a user