lotus/chain/gen/genesis/util.go
Steven Allen 5733c71c50 Lint everything
We were ignoring quite a few error cases, and had one case where we weren't
actually updating state where we wanted to. Unfortunately, if the linter doesn't
pass, nobody has any reason to actually check lint failures in CI.

There are three remaining XXXs marked in the code for lint.
2020-08-20 20:46:36 -07:00

49 lines
1.2 KiB
Go

package genesis
import (
"context"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
)
func mustEnc(i cbg.CBORMarshaler) []byte {
enc, err := actors.SerializeParams(i)
if err != nil {
panic(err) // ok
}
return enc
}
func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value types.BigInt, method abi.MethodNum, params []byte) ([]byte, error) {
act, err := vm.StateTree().GetActor(from)
if err != nil {
return nil, xerrors.Errorf("doExec failed to get from actor (%s): %w", from, err)
}
ret, err := vm.ApplyImplicitMessage(ctx, &types.Message{
To: to,
From: from,
Method: method,
Params: params,
GasLimit: 1_000_000_000_000_000,
Value: value,
Nonce: act.Nonce,
})
if err != nil {
return nil, xerrors.Errorf("doExec apply message failed: %w", err)
}
if ret.ExitCode != 0 {
return nil, xerrors.Errorf("failed to call method: %w", ret.ActorErr)
}
return ret.Return, nil
}