Merge branch 'master' into feat/sturdypost
This commit is contained in:
@@ -197,7 +197,7 @@ func (a *API) dealStarter(ctx context.Context, params *api.StartDealParams, isSt
|
||||
return nil, xerrors.Errorf("failed to get network version: %w", err)
|
||||
}
|
||||
|
||||
st, err := miner.PreferredSealProofTypeFromWindowPoStType(networkVersion, mi.WindowPoStProofType)
|
||||
st, err := miner.PreferredSealProofTypeFromWindowPoStType(networkVersion, mi.WindowPoStProofType, false)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to get seal proof type: %w", err)
|
||||
}
|
||||
|
||||
+12
-9
@@ -397,26 +397,31 @@ func (a *EthModule) EthGetTransactionReceiptLimited(ctx context.Context, txHash
|
||||
}
|
||||
|
||||
msgLookup, err := a.StateAPI.StateSearchMsg(ctx, types.EmptyTSK, c, limit, true)
|
||||
if err != nil || msgLookup == nil {
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("failed to lookup Eth Txn %s as %s: %w", txHash, c, err)
|
||||
}
|
||||
if msgLookup == nil {
|
||||
// This is the best we can do. In theory, we could have just not indexed this
|
||||
// transaction, but there's no way to check that here.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
tx, err := newEthTxFromMessageLookup(ctx, msgLookup, -1, a.Chain, a.StateAPI)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
return nil, xerrors.Errorf("failed to convert %s into an Eth Txn: %w", txHash, err)
|
||||
}
|
||||
|
||||
var events []types.Event
|
||||
if rct := msgLookup.Receipt; rct.EventsRoot != nil {
|
||||
events, err = a.ChainAPI.ChainGetEvents(ctx, *rct.EventsRoot)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
return nil, xerrors.Errorf("failed get events for %s", txHash)
|
||||
}
|
||||
}
|
||||
|
||||
receipt, err := newEthTxReceipt(ctx, tx, msgLookup, events, a.Chain, a.StateAPI)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
return nil, xerrors.Errorf("failed to convert %s into an Eth Receipt: %w", txHash, err)
|
||||
}
|
||||
|
||||
return &receipt, nil
|
||||
@@ -728,10 +733,11 @@ func (a *EthModule) EthFeeHistory(ctx context.Context, p jsonrpc.RawParams) (eth
|
||||
}
|
||||
|
||||
rewards, totalGasUsed := calculateRewardsAndGasUsed(rewardPercentiles, txGasRewards)
|
||||
maxGas := build.BlockGasLimit * int64(len(ts.Blocks()))
|
||||
|
||||
// arrays should be reversed at the end
|
||||
baseFeeArray = append(baseFeeArray, ethtypes.EthBigInt(basefee))
|
||||
gasUsedRatioArray = append(gasUsedRatioArray, float64(totalGasUsed)/float64(build.BlockGasLimit))
|
||||
gasUsedRatioArray = append(gasUsedRatioArray, float64(totalGasUsed)/float64(maxGas))
|
||||
rewardsArray = append(rewardsArray, rewards)
|
||||
oldestBlkHeight = uint64(ts.Height())
|
||||
blocksIncluded++
|
||||
@@ -942,10 +948,7 @@ func (a *EthModule) EthTraceReplayBlockTransactions(ctx context.Context, blkNum
|
||||
return nil, xerrors.Errorf("failed to decode payload: %w", err)
|
||||
}
|
||||
} else {
|
||||
output, err = handleFilecoinMethodOutput(ir.ExecutionTrace.MsgRct.ExitCode, ir.ExecutionTrace.MsgRct.ReturnCodec, ir.ExecutionTrace.MsgRct.Return)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("could not convert output: %w", err)
|
||||
}
|
||||
output = encodeFilecoinReturnAsABI(ir.ExecutionTrace.MsgRct.ExitCode, ir.ExecutionTrace.MsgRct.ReturnCodec, ir.ExecutionTrace.MsgRct.Return)
|
||||
}
|
||||
|
||||
t := ethtypes.EthTraceReplayBlockTransaction{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package full
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
@@ -162,3 +163,17 @@ func TestRewardPercentiles(t *testing.T) {
|
||||
require.Equal(t, ans, rewards)
|
||||
}
|
||||
}
|
||||
|
||||
func TestABIEncoding(t *testing.T) {
|
||||
// Generated from https://abi.hashex.org/
|
||||
const expected = "000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000510000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000001b1111111111111111111020200301000000044444444444444444010000000000"
|
||||
const data = "111111111111111111102020030100000004444444444444444401"
|
||||
|
||||
expectedBytes, err := hex.DecodeString(expected)
|
||||
require.NoError(t, err)
|
||||
|
||||
dataBytes, err := hex.DecodeString(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, expectedBytes, encodeAsABIHelper(22, 81, dataBytes))
|
||||
}
|
||||
|
||||
+2
-106
@@ -3,18 +3,13 @@ package full
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/multiformats/go-multicodec"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/builtin/v10/evm"
|
||||
"github.com/filecoin-project/go-state-types/exitcode"
|
||||
|
||||
builtinactors "github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@@ -124,14 +119,8 @@ func buildTraces(ctx context.Context, traces *[]*ethtypes.EthTrace, parent *etht
|
||||
} else {
|
||||
// we are going to assume a native method, but we may change it in one of the edge cases below
|
||||
// TODO: only do this if we know it's a native method (optimization)
|
||||
trace.Action.Input, err = handleFilecoinMethodInput(et.Msg.Method, et.Msg.ParamsCodec, et.Msg.Params)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("buildTraces: %w", err)
|
||||
}
|
||||
trace.Result.Output, err = handleFilecoinMethodOutput(et.MsgRct.ExitCode, et.MsgRct.ReturnCodec, et.MsgRct.Return)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("buildTraces: %w", err)
|
||||
}
|
||||
trace.Action.Input = encodeFilecoinParamsAsABI(et.Msg.Method, et.Msg.ParamsCodec, et.Msg.Params)
|
||||
trace.Result.Output = encodeFilecoinReturnAsABI(et.MsgRct.ExitCode, et.MsgRct.ReturnCodec, et.MsgRct.Return)
|
||||
}
|
||||
|
||||
// TODO: is it OK to check this here or is this only specific to certain edge case (evm to evm)?
|
||||
@@ -258,96 +247,3 @@ func buildTraces(ctx context.Context, traces *[]*ethtypes.EthTrace, parent *etht
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func writePadded(w io.Writer, data any, size int) error {
|
||||
tmp := &bytes.Buffer{}
|
||||
|
||||
// first write data to tmp buffer to get the size
|
||||
err := binary.Write(tmp, binary.BigEndian, data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("writePadded: failed writing tmp data to buffer: %w", err)
|
||||
}
|
||||
|
||||
if tmp.Len() > size {
|
||||
return fmt.Errorf("writePadded: data is larger than size")
|
||||
}
|
||||
|
||||
// write tailing zeros to pad up to size
|
||||
cnt := size - tmp.Len()
|
||||
for i := 0; i < cnt; i++ {
|
||||
err = binary.Write(w, binary.BigEndian, uint8(0))
|
||||
if err != nil {
|
||||
return fmt.Errorf("writePadded: failed writing tailing zeros to buffer: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// finally write the actual value
|
||||
err = binary.Write(w, binary.BigEndian, tmp.Bytes())
|
||||
if err != nil {
|
||||
return fmt.Errorf("writePadded: failed writing data to buffer: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleFilecoinMethodInput(method abi.MethodNum, codec uint64, params []byte) ([]byte, error) {
|
||||
NATIVE_METHOD_SELECTOR := []byte{0x86, 0x8e, 0x10, 0xc4}
|
||||
EVM_WORD_SIZE := 32
|
||||
|
||||
staticArgs := []uint64{
|
||||
uint64(method),
|
||||
codec,
|
||||
uint64(EVM_WORD_SIZE) * 3,
|
||||
uint64(len(params)),
|
||||
}
|
||||
totalWords := len(staticArgs) + (len(params) / EVM_WORD_SIZE)
|
||||
if len(params)%EVM_WORD_SIZE != 0 {
|
||||
totalWords++
|
||||
}
|
||||
len := 4 + totalWords*EVM_WORD_SIZE
|
||||
|
||||
w := &bytes.Buffer{}
|
||||
err := binary.Write(w, binary.BigEndian, NATIVE_METHOD_SELECTOR)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("handleFilecoinMethodInput: failed writing method selector: %w", err)
|
||||
}
|
||||
|
||||
for _, arg := range staticArgs {
|
||||
err := writePadded(w, arg, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("handleFilecoinMethodInput: %w", err)
|
||||
}
|
||||
}
|
||||
err = binary.Write(w, binary.BigEndian, params)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("handleFilecoinMethodInput: failed writing params: %w", err)
|
||||
}
|
||||
remain := len - w.Len()
|
||||
for i := 0; i < remain; i++ {
|
||||
err = binary.Write(w, binary.BigEndian, uint8(0))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("handleFilecoinMethodInput: failed writing tailing zeros: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return w.Bytes(), nil
|
||||
}
|
||||
|
||||
func handleFilecoinMethodOutput(exitCode exitcode.ExitCode, codec uint64, data []byte) ([]byte, error) {
|
||||
w := &bytes.Buffer{}
|
||||
|
||||
values := []interface{}{uint32(exitCode), codec, uint32(w.Len()), uint32(len(data))}
|
||||
for _, v := range values {
|
||||
err := writePadded(w, v, 32)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("handleFilecoinMethodOutput: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
err := binary.Write(w, binary.BigEndian, data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("handleFilecoinMethodOutput: failed writing data: %w", err)
|
||||
}
|
||||
|
||||
return w.Bytes(), nil
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package full
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
@@ -15,6 +16,7 @@ import (
|
||||
builtintypes "github.com/filecoin-project/go-state-types/builtin"
|
||||
"github.com/filecoin-project/go-state-types/builtin/v10/eam"
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
"github.com/filecoin-project/go-state-types/exitcode"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
@@ -627,7 +629,13 @@ func newEthTxReceipt(ctx context.Context, tx ethtypes.EthTx, lookup *api.MsgLook
|
||||
return api.EthTxReceipt{}, xerrors.Errorf("failed to lookup tipset %s when constructing the eth txn receipt: %w", lookup.TipSet, err)
|
||||
}
|
||||
|
||||
baseFee := ts.Blocks()[0].ParentBaseFee
|
||||
// The tx is located in the parent tipset
|
||||
parentTs, err := cs.LoadTipSet(ctx, ts.Parents())
|
||||
if err != nil {
|
||||
return api.EthTxReceipt{}, xerrors.Errorf("failed to lookup tipset %s when constructing the eth txn receipt: %w", ts.Parents(), err)
|
||||
}
|
||||
|
||||
baseFee := parentTs.Blocks()[0].ParentBaseFee
|
||||
gasOutputs := vm.ComputeGasOutputs(lookup.Receipt.GasUsed, int64(tx.Gas), baseFee, big.Int(tx.MaxFeePerGas), big.Int(tx.MaxPriorityFeePerGas), true)
|
||||
totalSpent := big.Sum(gasOutputs.BaseFeeBurn, gasOutputs.MinerTip, gasOutputs.OverEstimationBurn)
|
||||
|
||||
@@ -665,6 +673,7 @@ func newEthTxReceipt(ctx context.Context, tx ethtypes.EthTx, lookup *api.MsgLook
|
||||
continue
|
||||
}
|
||||
for _, topic := range topics {
|
||||
log.Debug("LogsBloom set for ", topic)
|
||||
ethtypes.EthBloomSet(receipt.LogsBloom, topic[:])
|
||||
}
|
||||
l.Data = data
|
||||
@@ -687,3 +696,45 @@ func newEthTxReceipt(ctx context.Context, tx ethtypes.EthTx, lookup *api.MsgLook
|
||||
|
||||
return receipt, nil
|
||||
}
|
||||
|
||||
func encodeFilecoinParamsAsABI(method abi.MethodNum, codec uint64, params []byte) []byte {
|
||||
buf := []byte{0x86, 0x8e, 0x10, 0xc4} // Native method selector.
|
||||
return append(buf, encodeAsABIHelper(uint64(method), codec, params)...)
|
||||
}
|
||||
|
||||
func encodeFilecoinReturnAsABI(exitCode exitcode.ExitCode, codec uint64, data []byte) []byte {
|
||||
return encodeAsABIHelper(uint64(exitCode), codec, data)
|
||||
}
|
||||
|
||||
// Format 2 numbers followed by an arbitrary byte array as solidity ABI. Both our native
|
||||
// inputs/outputs follow the same pattern, so we can reuse this code.
|
||||
func encodeAsABIHelper(param1 uint64, param2 uint64, data []byte) []byte {
|
||||
const EVM_WORD_SIZE = 32
|
||||
|
||||
// The first two params are "static" numbers. Then, we record the offset of the "data" arg,
|
||||
// then, at that offset, we record the length of the data.
|
||||
//
|
||||
// In practice, this means we have 4 256-bit words back to back where the third arg (the
|
||||
// offset) is _always_ '32*3'.
|
||||
staticArgs := []uint64{param1, param2, EVM_WORD_SIZE * 3, uint64(len(data))}
|
||||
// We always pad out to the next EVM "word" (32 bytes).
|
||||
totalWords := len(staticArgs) + (len(data) / EVM_WORD_SIZE)
|
||||
if len(data)%EVM_WORD_SIZE != 0 {
|
||||
totalWords++
|
||||
}
|
||||
len := totalWords * EVM_WORD_SIZE
|
||||
buf := make([]byte, len)
|
||||
offset := 0
|
||||
// Below, we use copy instead of "appending" to preserve all the zero padding.
|
||||
for _, arg := range staticArgs {
|
||||
// Write each "arg" into the last 8 bytes of each 32 byte word.
|
||||
offset += EVM_WORD_SIZE
|
||||
start := offset - 8
|
||||
binary.BigEndian.PutUint64(buf[start:offset], arg)
|
||||
}
|
||||
|
||||
// Finally, we copy in the data.
|
||||
copy(buf[offset:], data)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
+105
-31
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
@@ -19,8 +20,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
verifregtypes "github.com/filecoin-project/go-state-types/builtin/v9/verifreg"
|
||||
market12 "github.com/filecoin-project/go-state-types/builtin/v12/market"
|
||||
"github.com/filecoin-project/go-state-types/cbor"
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
@@ -794,7 +794,7 @@ func (a *StateAPI) StateGetAllocationForPendingDeal(ctx context.Context, dealId
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if allocationId == verifregtypes.NoAllocationID {
|
||||
if allocationId == verifreg.NoAllocationID {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@@ -914,32 +914,31 @@ func (a *StateAPI) StateComputeDataCID(ctx context.Context, maddr address.Addres
|
||||
return cid.Cid{}, err
|
||||
}
|
||||
|
||||
var ccparams []byte
|
||||
if nv < network.Version13 {
|
||||
ccparams, err = actors.SerializeParams(&market2.ComputeDataCommitmentParams{
|
||||
DealIDs: deals,
|
||||
SectorType: sectorType,
|
||||
})
|
||||
return a.stateComputeDataCIDv1(ctx, maddr, sectorType, deals, tsk)
|
||||
} else if nv < network.Version21 {
|
||||
return a.stateComputeDataCIDv2(ctx, maddr, sectorType, deals, tsk)
|
||||
} else {
|
||||
ccparams, err = actors.SerializeParams(&market5.ComputeDataCommitmentParams{
|
||||
Inputs: []*market5.SectorDataSpec{
|
||||
{
|
||||
DealIDs: deals,
|
||||
SectorType: sectorType,
|
||||
},
|
||||
},
|
||||
})
|
||||
return a.stateComputeDataCIDv3(ctx, maddr, sectorType, deals, tsk)
|
||||
}
|
||||
}
|
||||
|
||||
func (a *StateAPI) stateComputeDataCIDv1(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) {
|
||||
var err error
|
||||
ccparams, err := actors.SerializeParams(&market2.ComputeDataCommitmentParams{
|
||||
DealIDs: deals,
|
||||
SectorType: sectorType,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("computing params for ComputeDataCommitment: %w", err)
|
||||
}
|
||||
|
||||
ccmt := &types.Message{
|
||||
To: market.Address,
|
||||
From: maddr,
|
||||
Value: types.NewInt(0),
|
||||
Method: market.Methods.ComputeDataCommitment,
|
||||
To: market.Address,
|
||||
From: maddr,
|
||||
Value: types.NewInt(0),
|
||||
// Hard coded, because the method has since been deprecated
|
||||
Method: 8,
|
||||
Params: ccparams,
|
||||
}
|
||||
r, err := a.StateCall(ctx, ccmt, tsk)
|
||||
@@ -950,13 +949,42 @@ func (a *StateAPI) StateComputeDataCID(ctx context.Context, maddr address.Addres
|
||||
return cid.Undef, xerrors.Errorf("receipt for ComputeDataCommitment had exit code %d", r.MsgRct.ExitCode)
|
||||
}
|
||||
|
||||
if nv < network.Version13 {
|
||||
var c cbg.CborCid
|
||||
if err := c.UnmarshalCBOR(bytes.NewReader(r.MsgRct.Return)); err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to unmarshal CBOR to CborCid: %w", err)
|
||||
}
|
||||
var c cbg.CborCid
|
||||
if err := c.UnmarshalCBOR(bytes.NewReader(r.MsgRct.Return)); err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to unmarshal CBOR to CborCid: %w", err)
|
||||
}
|
||||
|
||||
return cid.Cid(c), nil
|
||||
return cid.Cid(c), nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) stateComputeDataCIDv2(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) {
|
||||
var err error
|
||||
ccparams, err := actors.SerializeParams(&market5.ComputeDataCommitmentParams{
|
||||
Inputs: []*market5.SectorDataSpec{
|
||||
{
|
||||
DealIDs: deals,
|
||||
SectorType: sectorType,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("computing params for ComputeDataCommitment: %w", err)
|
||||
}
|
||||
ccmt := &types.Message{
|
||||
To: market.Address,
|
||||
From: maddr,
|
||||
Value: types.NewInt(0),
|
||||
// Hard coded, because the method has since been deprecated
|
||||
Method: 8,
|
||||
Params: ccparams,
|
||||
}
|
||||
r, err := a.StateCall(ctx, ccmt, tsk)
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("calling ComputeDataCommitment: %w", err)
|
||||
}
|
||||
if r.MsgRct.ExitCode != 0 {
|
||||
return cid.Undef, xerrors.Errorf("receipt for ComputeDataCommitment had exit code %d", r.MsgRct.ExitCode)
|
||||
}
|
||||
|
||||
var cr market5.ComputeDataCommitmentReturn
|
||||
@@ -971,6 +999,52 @@ func (a *StateAPI) StateComputeDataCID(ctx context.Context, maddr address.Addres
|
||||
return cid.Cid(cr.CommDs[0]), nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) stateComputeDataCIDv3(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) {
|
||||
if len(deals) == 0 {
|
||||
return cid.Undef, nil
|
||||
}
|
||||
|
||||
var err error
|
||||
ccparams, err := actors.SerializeParams(&market12.VerifyDealsForActivationParams{
|
||||
Sectors: []market12.SectorDeals{{
|
||||
SectorType: sectorType,
|
||||
SectorExpiry: math.MaxInt64,
|
||||
DealIDs: deals,
|
||||
}},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("computing params for VerifyDealsForActivation: %w", err)
|
||||
}
|
||||
ccmt := &types.Message{
|
||||
To: market.Address,
|
||||
From: maddr,
|
||||
Value: types.NewInt(0),
|
||||
Method: market.Methods.VerifyDealsForActivation,
|
||||
Params: ccparams,
|
||||
}
|
||||
r, err := a.StateCall(ctx, ccmt, tsk)
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("calling VerifyDealsForActivation: %w", err)
|
||||
}
|
||||
if r.MsgRct.ExitCode != 0 {
|
||||
return cid.Undef, xerrors.Errorf("receipt for VerifyDealsForActivation had exit code %d", r.MsgRct.ExitCode)
|
||||
}
|
||||
|
||||
var cr market12.VerifyDealsForActivationReturn
|
||||
if err := cr.UnmarshalCBOR(bytes.NewReader(r.MsgRct.Return)); err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to unmarshal CBOR to VerifyDealsForActivationReturn: %w", err)
|
||||
}
|
||||
if len(cr.UnsealedCIDs) != 1 {
|
||||
return cid.Undef, xerrors.Errorf("Sectors output must have 1 entry")
|
||||
}
|
||||
ucid := cr.UnsealedCIDs[0]
|
||||
if ucid == nil {
|
||||
return cid.Undef, xerrors.Errorf("computed data CID is nil")
|
||||
}
|
||||
return *ucid, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateChangedActors(ctx context.Context, old cid.Cid, new cid.Cid) (map[string]types.Actor, error) {
|
||||
store := a.Chain.ActorStore(ctx)
|
||||
|
||||
@@ -1040,7 +1114,7 @@ func (a *StateAPI) StateMinerAllocated(ctx context.Context, addr address.Address
|
||||
return mas.GetAllocatedSectors()
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*minertypes.SectorPreCommitOnChainInfo, error) {
|
||||
func (a *StateAPI) StateSectorPreCommitInfo(ctx context.Context, maddr address.Address, n abi.SectorNumber, tsk types.TipSetKey) (*miner.SectorPreCommitOnChainInfo, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
@@ -1315,7 +1389,7 @@ func (m *StateModule) MsigGetPending(ctx context.Context, addr address.Address,
|
||||
var initialPledgeNum = types.NewInt(110)
|
||||
var initialPledgeDen = types.NewInt(100)
|
||||
|
||||
func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci minertypes.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) {
|
||||
func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return types.EmptyInt, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
@@ -1347,7 +1421,7 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr
|
||||
sectorWeight = builtin.QAPowerForWeight(ssize, duration, w, vw)
|
||||
}
|
||||
} else {
|
||||
sectorWeight = minertypes.QAPowerMax(ssize)
|
||||
sectorWeight = miner.QAPowerMax(ssize)
|
||||
}
|
||||
|
||||
var powerSmoothed builtin.FilterEstimate
|
||||
@@ -1379,7 +1453,7 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr
|
||||
return types.BigDiv(types.BigMul(deposit, initialPledgeNum), initialPledgeDen), nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci minertypes.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) {
|
||||
func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr address.Address, pci miner.SectorPreCommitInfo, tsk types.TipSetKey) (types.BigInt, error) {
|
||||
// TODO: this repeats a lot of the previous function. Fix that.
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
|
||||
@@ -36,7 +36,7 @@ func (a *NetAPI) NetStat(ctx context.Context, scope string) (result api.NetStat,
|
||||
if len(stat.Peers) > 0 {
|
||||
result.Peers = make(map[string]network.ScopeStat, len(stat.Peers))
|
||||
for p, stat := range stat.Peers {
|
||||
result.Peers[p.Pretty()] = stat
|
||||
result.Peers[p.String()] = stat
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
builtintypes "github.com/filecoin-project/go-state-types/builtin"
|
||||
minertypes "github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||
"github.com/filecoin-project/go-state-types/network"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
@@ -43,6 +42,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||
"github.com/filecoin-project/lotus/chain/gen"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
||||
@@ -500,7 +500,7 @@ func (sm *StorageMinerAPI) SectorReceive(ctx context.Context, meta api.RemoteSec
|
||||
return err
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]minertypes.SubmitWindowedPoStParams, error) {
|
||||
func (sm *StorageMinerAPI) ComputeWindowPoSt(ctx context.Context, dlIdx uint64, tsk types.TipSetKey) ([]lminer.SubmitWindowedPoStParams, error) {
|
||||
var ts *types.TipSet
|
||||
var err error
|
||||
if tsk == types.EmptyTSK {
|
||||
@@ -1407,7 +1407,7 @@ func (sm *StorageMinerAPI) withdrawBalance(ctx context.Context, amount abi.Token
|
||||
amount = available
|
||||
}
|
||||
|
||||
params, err := actors.SerializeParams(&minertypes.WithdrawBalanceParams{
|
||||
params, err := actors.SerializeParams(&lminer.WithdrawBalanceParams{
|
||||
AmountRequested: amount,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user