diff --git a/app/submodule/eth/eth_utils.go b/app/submodule/eth/eth_utils.go index 00bcfd701e..74969f0d98 100644 --- a/app/submodule/eth/eth_utils.go +++ b/app/submodule/eth/eth_utils.go @@ -14,7 +14,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/big" "github.com/filecoin-project/go-state-types/builtin" - 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" @@ -549,12 +548,12 @@ func ethTxFromNativeMessage(ctx context.Context, msg *types.Message, ca v1.IChai // Then we try to see if it's "special". If we fail, we ignore the error and keep treating // it as a native message. Unfortunately, the user is free to send garbage that may not // properly decode. - if msg.Method == builtintypes.MethodsEVM.InvokeContract { + if msg.Method == builtin.MethodsEVM.InvokeContract { // try to decode it as a contract invocation first. if inp, err := decodePayload(msg.Params, codec); err == nil { ethTx.Input = []byte(inp) } - } else if msg.To == builtin.EthereumAddressManagerActorAddr && msg.Method == builtintypes.MethodsEAM.CreateExternal { + } else if msg.To == builtin.EthereumAddressManagerActorAddr && msg.Method == builtin.MethodsEAM.CreateExternal { // Then, try to decode it as a contract deployment from an EOA. if inp, err := decodePayload(msg.Params, codec); err == nil { ethTx.Input = []byte(inp) diff --git a/venus-shared/actors/types/eth_1559_transactions.go b/venus-shared/actors/types/eth_1559_transactions.go index 4a41e92d48..7a7dbaafcb 100644 --- a/venus-shared/actors/types/eth_1559_transactions.go +++ b/venus-shared/actors/types/eth_1559_transactions.go @@ -171,7 +171,7 @@ func (tx *Eth1559TxArgs) InitialiseSignature(sig typescrypto.Signature) error { } func (tx *Eth1559TxArgs) packTxFields() ([]interface{}, error) { - chainId, err := formatInt(tx.ChainID) + chainID, err := formatInt(tx.ChainID) if err != nil { return nil, err } @@ -202,7 +202,7 @@ func (tx *Eth1559TxArgs) packTxFields() ([]interface{}, error) { } res := []interface{}{ - chainId, + chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, @@ -233,7 +233,7 @@ func parseEip1559Tx(data []byte) (*Eth1559TxArgs, error) { return nil, xerrors.Errorf("not an EIP-1559 transaction: should have 12 elements in the rlp list") } - chainId, err := parseInt(decoded[0]) + chainID, err := parseInt(decoded[0]) if err != nil { return nil, err } @@ -301,7 +301,7 @@ func parseEip1559Tx(data []byte) (*Eth1559TxArgs, error) { } args := Eth1559TxArgs{ - ChainID: chainId, + ChainID: chainID, Nonce: nonce, To: to, MaxPriorityFeePerGas: maxPriorityFeePerGas, diff --git a/venus-shared/actors/types/eth_legacy_155_transactions.go b/venus-shared/actors/types/eth_legacy_155_transactions.go index db0daacfc3..83ccf52880 100644 --- a/venus-shared/actors/types/eth_legacy_155_transactions.go +++ b/venus-shared/actors/types/eth_legacy_155_transactions.go @@ -84,7 +84,7 @@ func (tx *EthLegacy155TxArgs) ToRawTxBytesSigned() ([]byte, error) { return nil, err } - packed1 = packed1[:len(packed1)-3] // remove chainId, r and s as they are only used for signature verification + packed1 = packed1[:len(packed1)-3] // remove chainID, r and s as they are only used for signature verification packed2, err := packSigFields(tx.legacyTx.V, tx.legacyTx.R, tx.legacyTx.S) if err != nil { @@ -239,7 +239,7 @@ func (tx *EthLegacy155TxArgs) packTxFields() ([]interface{}, error) { } chainIdBigInt := big.NewIntUnsigned(uint64(Eip155ChainID)) - chainId, err := formatBigInt(chainIdBigInt) + chainID, err := formatBigInt(chainIdBigInt) if err != nil { return nil, err } @@ -261,7 +261,7 @@ func (tx *EthLegacy155TxArgs) packTxFields() ([]interface{}, error) { formatEthAddr(tx.legacyTx.To), value, tx.legacyTx.Input, - chainId, + chainID, r, s, } return res, nil @@ -290,8 +290,8 @@ func deriveEIP155ChainId(v big.Int) big.Int { } func calcEIP155TxSignatureLen(chain uint64, v int) int { - chainId := big.NewIntUnsigned(chain) - vVal := big.Add(big.Mul(chainId, big.NewInt(2)), big.NewInt(int64(v))) + chainID := big.NewIntUnsigned(chain) + vVal := big.Add(big.Mul(chainID, big.NewInt(2)), big.NewInt(int64(v))) vLen := len(vVal.Int.Bytes()) // EthLegacyHomesteadTxSignatureLen includes the 1 byte legacy tx marker prefix and also 1 byte for the V value. diff --git a/venus-shared/actors/types/eth_legacy_155_transactions_test.go b/venus-shared/actors/types/eth_legacy_155_transactions_test.go index 3ebdd938b7..443009b05a 100644 --- a/venus-shared/actors/types/eth_legacy_155_transactions_test.go +++ b/venus-shared/actors/types/eth_legacy_155_transactions_test.go @@ -107,39 +107,39 @@ func TestDeriveEIP155ChainId(t *testing.T) { tests := []struct { name string v big.Int - expectedChainId big.Int + expectedChainID big.Int }{ { name: "V equals 27", v: big.NewInt(27), - expectedChainId: big.NewInt(0), + expectedChainID: big.NewInt(0), }, { name: "V equals 28", v: big.NewInt(28), - expectedChainId: big.NewInt(0), + expectedChainID: big.NewInt(0), }, { name: "V small chain ID", v: big.NewInt(37), // (37 - 35) / 2 = 1 - expectedChainId: big.NewInt(1), + expectedChainID: big.NewInt(1), }, { name: "V large chain ID", v: big.NewInt(1001), // (1001 - 35) / 2 = 483 - expectedChainId: big.NewInt(483), + expectedChainID: big.NewInt(483), }, { name: "V very large chain ID", v: big.NewInt(1 << 20), // (1048576 - 35) / 2 = 524770 - expectedChainId: big.NewInt(524270), + expectedChainID: big.NewInt(524270), }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result := deriveEIP155ChainId(tt.v) - require.True(t, result.Equals(tt.expectedChainId), "Expected %s, got %s for V=%s", tt.expectedChainId.String(), result.String(), tt.v.String()) + require.True(t, result.Equals(tt.expectedChainID), "Expected %s, got %s for V=%s", tt.expectedChainID.String(), result.String(), tt.v.String()) }) } }