Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: eth refactor fixup #9900

Merged
merged 1 commit into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin"
lminer "github.com/filecoin-project/lotus/chain/actors/builtin/miner"
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/node/modules/dtypes"
Expand Down Expand Up @@ -773,13 +772,13 @@ type FullNode interface {
// EthGetBlockTransactionCountByHash returns the number of messages in the TipSet
EthGetBlockTransactionCountByHash(ctx context.Context, blkHash ethtypes.EthHash) (ethtypes.EthUint64, error) //perm:read

EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*eth.EthTx, error) //perm:read
EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error) //perm:read
EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*EthTxReceipt, error) //perm:read
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (eth.EthTx, error) //perm:read
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (eth.EthTx, error) //perm:read
EthGetBlockByHash(ctx context.Context, blkHash ethtypes.EthHash, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
EthGetBlockByNumber(ctx context.Context, blkNum string, fullTxInfo bool) (ethtypes.EthBlock, error) //perm:read
EthGetTransactionByHash(ctx context.Context, txHash *ethtypes.EthHash) (*ethtypes.EthTx, error) //perm:read
EthGetTransactionCount(ctx context.Context, sender ethtypes.EthAddress, blkOpt string) (ethtypes.EthUint64, error) //perm:read
EthGetTransactionReceipt(ctx context.Context, txHash ethtypes.EthHash) (*EthTxReceipt, error) //perm:read
EthGetTransactionByBlockHashAndIndex(ctx context.Context, blkHash ethtypes.EthHash, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) //perm:read
EthGetTransactionByBlockNumberAndIndex(ctx context.Context, blkNum ethtypes.EthUint64, txIndex ethtypes.EthUint64) (ethtypes.EthTx, error) //perm:read

EthGetCode(ctx context.Context, address ethtypes.EthAddress, blkOpt string) (ethtypes.EthBytes, error) //perm:read
EthGetStorageAt(ctx context.Context, address ethtypes.EthAddress, position ethtypes.EthBytes, blkParam string) (ethtypes.EthBytes, error) //perm:read
Expand Down
13 changes: 6 additions & 7 deletions api/mocks/mock_full.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 13 additions & 14 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/gateway.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.json.gz
Binary file not shown.
Binary file modified build/openrpc/worker.json.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions chain/consensus/filcns/filecoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ import (
"github.com/filecoin-project/lotus/chain/actors/builtin/power"
"github.com/filecoin-project/lotus/chain/beacon"
"github.com/filecoin-project/lotus/chain/consensus"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/rand"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/lib/async"
"github.com/filecoin-project/lotus/lib/sigs"
Expand Down Expand Up @@ -577,7 +577,7 @@ func (filec *FilecoinEC) checkBlockMessages(ctx context.Context, b *types.FullBl

digest := m.Message.Cid().Bytes()
if m.Signature.Type == crypto.SigTypeDelegated {
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
txArgs, err := ethtypes.NewEthTxArgsFromMessage(&m.Message)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions chain/messagepool/messagepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import (
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/consensus/filcns"
"github.com/filecoin-project/lotus/chain/eth"
"github.com/filecoin-project/lotus/chain/stmgr"
"github.com/filecoin-project/lotus/chain/store"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/journal"
"github.com/filecoin-project/lotus/lib/sigs"
Expand Down Expand Up @@ -778,7 +778,7 @@ func sigCacheKey(m *types.SignedMessage) (string, error) {
case crypto.SigTypeSecp256k1:
return string(m.Cid().Bytes()), nil
case crypto.SigTypeDelegated:
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
txArgs, err := ethtypes.NewEthTxArgsFromMessage(&m.Message)
if err != nil {
return "", err
}
Expand All @@ -805,7 +805,7 @@ func (mp *MessagePool) VerifyMsgSig(m *types.SignedMessage) error {
}

if m.Signature.Type == crypto.SigTypeDelegated {
txArgs, err := eth.NewEthTxArgsFromMessage(&m.Message)
txArgs, err := ethtypes.NewEthTxArgsFromMessage(&m.Message)
if err != nil {
return xerrors.Errorf("failed to convert to eth tx args: %w", err)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eth
package ethtypes

import (
"bytes"
Expand All @@ -20,48 +20,47 @@ import (
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes"
)

const Eip1559TxType = 2

type EthTx struct {
ChainID ethtypes.EthUint64 `json:"chainId"`
Nonce ethtypes.EthUint64 `json:"nonce"`
Hash ethtypes.EthHash `json:"hash"`
BlockHash ethtypes.EthHash `json:"blockHash"`
BlockNumber ethtypes.EthUint64 `json:"blockNumber"`
TransactionIndex ethtypes.EthUint64 `json:"transactionIndex"`
From ethtypes.EthAddress `json:"from"`
To *ethtypes.EthAddress `json:"to"`
Value ethtypes.EthBigInt `json:"value"`
Type ethtypes.EthUint64 `json:"type"`
Input ethtypes.EthBytes `json:"input"`
Gas ethtypes.EthUint64 `json:"gas"`
MaxFeePerGas ethtypes.EthBigInt `json:"maxFeePerGas"`
MaxPriorityFeePerGas ethtypes.EthBigInt `json:"maxPriorityFeePerGas"`
V ethtypes.EthBytes `json:"v"`
R ethtypes.EthBytes `json:"r"`
S ethtypes.EthBytes `json:"s"`
ChainID EthUint64 `json:"chainId"`
Nonce EthUint64 `json:"nonce"`
Hash EthHash `json:"hash"`
BlockHash EthHash `json:"blockHash"`
BlockNumber EthUint64 `json:"blockNumber"`
TransactionIndex EthUint64 `json:"transactionIndex"`
From EthAddress `json:"from"`
To *EthAddress `json:"to"`
Value EthBigInt `json:"value"`
Type EthUint64 `json:"type"`
Input EthBytes `json:"input"`
Gas EthUint64 `json:"gas"`
MaxFeePerGas EthBigInt `json:"maxFeePerGas"`
MaxPriorityFeePerGas EthBigInt `json:"maxPriorityFeePerGas"`
V EthBytes `json:"v"`
R EthBytes `json:"r"`
S EthBytes `json:"s"`
}

type EthTxArgs struct {
ChainID int `json:"chainId"`
Nonce int `json:"nonce"`
To *ethtypes.EthAddress `json:"to"`
Value big.Int `json:"value"`
MaxFeePerGas big.Int `json:"maxFeePerGas"`
MaxPriorityFeePerGas big.Int `json:"maxPriorityFeePerGas"`
GasLimit int `json:"gasLimit"`
Input []byte `json:"input"`
V []byte `json:"v"`
R []byte `json:"r"`
S []byte `json:"s"`
ChainID int `json:"chainId"`
Nonce int `json:"nonce"`
To *EthAddress `json:"to"`
Value big.Int `json:"value"`
MaxFeePerGas big.Int `json:"maxFeePerGas"`
MaxPriorityFeePerGas big.Int `json:"maxPriorityFeePerGas"`
GasLimit int `json:"gasLimit"`
Input []byte `json:"input"`
V []byte `json:"v"`
R []byte `json:"r"`
S []byte `json:"s"`
}

func NewEthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) {
var (
to *ethtypes.EthAddress
to *EthAddress
decodedParams []byte
paramsReader = bytes.NewReader(msg.Params)
)
Expand All @@ -84,7 +83,7 @@ func NewEthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) {
return EthTxArgs{}, fmt.Errorf("unsupported EAM method")
}
} else {
addr, err := ethtypes.EthAddressFromFilecoinAddress(msg.To)
addr, err := EthAddressFromFilecoinAddress(msg.To)
if err != nil {
return EthTxArgs{}, err
}
Expand Down Expand Up @@ -442,7 +441,7 @@ func formatInt(val int) ([]byte, error) {
return removeLeadingZeros(buf.Bytes()), nil
}

func formatEthAddr(addr *ethtypes.EthAddress) []byte {
func formatEthAddr(addr *EthAddress) []byte {
if addr == nil {
return nil
}
Expand Down Expand Up @@ -497,15 +496,15 @@ func parseBytes(v interface{}) ([]byte, error) {
return val, nil
}

func parseEthAddr(v interface{}) (*ethtypes.EthAddress, error) {
func parseEthAddr(v interface{}) (*EthAddress, error) {
b, err := parseBytes(v)
if err != nil {
return nil, err
}
if len(b) == 0 {
return nil, nil
}
addr, err := ethtypes.EthAddressFromBytes(b)
addr, err := EthAddressFromBytes(b)
if err != nil {
return nil, err
}
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chain/eth/rlp.go → chain/types/ethtypes/rlp.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eth
package ethtypes

import (
"bytes"
Expand Down
7 changes: 1 addition & 6 deletions chain/eth/rlp_test.go → chain/types/ethtypes/rlp_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eth
package ethtypes

import (
"encoding/hex"
Expand All @@ -11,11 +11,6 @@ import (
"github.com/filecoin-project/go-address"
)

type TestCase struct {
Input interface{}
Output interface{}
}

func TestEncode(t *testing.T) {
testcases := []TestCase{
{[]byte(""), mustDecodeHex("0x80")},
Expand Down
28 changes: 9 additions & 19 deletions cmd/lotus-miner/sectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -1119,31 +1119,21 @@ var sectorsExtendCmd = &cli.Command{
ArgsUsage: "<sectorNumbers...>",
Flags: []cli.Flag{
&cli.Int64Flag{
Name: "new-expiration",
Usage: "new expiration epoch",
Required: false,
Name: "new-expiration",
Usage: "new expiration epoch",
},
&cli.BoolFlag{
Name: "v1-sectors",
Usage: "renews all v1 sectors up to the maximum possible lifetime",
Required: false,
},
&cli.Int64Flag{
Name: "tolerance",
Value: 20160,
Usage: "when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs",
Required: false,
Name: "v1-sectors",
Usage: "renews all v1 sectors up to the maximum possible lifetime",
},
&cli.Int64Flag{
Name: "expiration-ignore",
Value: 120,
Usage: "when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now",
Required: false,
Name: "expiration-ignore",
Value: 120,
Usage: "when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now",
},
&cli.Int64Flag{
Name: "expiration-cutoff",
Usage: "when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified)",
Required: false,
Name: "expiration-cutoff",
Usage: "when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified)",
},
&cli.StringFlag{},
},
Expand Down
1 change: 0 additions & 1 deletion documentation/en/cli-lotus-miner.md
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,6 @@ OPTIONS:
--expiration-cutoff value when extending v1 sectors, skip sectors whose current expiration is more than <cutoff> epochs from now (infinity if unspecified) (default: 0)
--expiration-ignore value when extending v1 sectors, skip sectors whose current expiration is less than <ignore> epochs from now (default: 120)
--new-expiration value new expiration epoch (default: 0)
--tolerance value when extending v1 sectors, don't try to extend sectors by fewer than this number of epochs (default: 20160)
--v1-sectors renews all v1 sectors up to the maximum possible lifetime (default: false)

```
Expand Down
Loading