Merge pull request #10411 from filecoin-project/asr/simplity-new-eth-tx-rct

refactor: EthAPI: Drop unnecessary param from newEthTxReceipt
This commit is contained in:
Aayush Rajasekaran 2023-03-09 12:44:44 -05:00 committed by GitHub
commit 9fa81673da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -433,7 +433,7 @@ func (a *EthModule) EthGetTransactionReceipt(ctx context.Context, txHash ethtype
} }
} }
receipt, err := newEthTxReceipt(ctx, tx, msgLookup, replay, events, a.StateAPI) receipt, err := newEthTxReceipt(ctx, tx, replay, events, a.StateAPI)
if err != nil { if err != nil {
return nil, nil return nil, nil
} }
@ -2033,7 +2033,7 @@ func newEthTxFromMessageLookup(ctx context.Context, msgLookup *api.MsgLookup, tx
return tx, nil return tx, nil
} }
func newEthTxReceipt(ctx context.Context, tx ethtypes.EthTx, lookup *api.MsgLookup, replay *api.InvocResult, events []types.Event, sa StateAPI) (api.EthTxReceipt, error) { func newEthTxReceipt(ctx context.Context, tx ethtypes.EthTx, replay *api.InvocResult, events []types.Event, sa StateAPI) (api.EthTxReceipt, error) {
var ( var (
transactionIndex ethtypes.EthUint64 transactionIndex ethtypes.EthUint64
blockHash ethtypes.EthHash blockHash ethtypes.EthHash
@ -2062,25 +2062,25 @@ func newEthTxReceipt(ctx context.Context, tx ethtypes.EthTx, lookup *api.MsgLook
LogsBloom: ethtypes.EmptyEthBloom[:], LogsBloom: ethtypes.EmptyEthBloom[:],
} }
if lookup.Receipt.ExitCode.IsSuccess() { if replay.MsgRct.ExitCode.IsSuccess() {
receipt.Status = 1 receipt.Status = 1
} }
if lookup.Receipt.ExitCode.IsError() { if replay.MsgRct.ExitCode.IsError() {
receipt.Status = 0 receipt.Status = 0
} }
receipt.GasUsed = ethtypes.EthUint64(lookup.Receipt.GasUsed) receipt.GasUsed = ethtypes.EthUint64(replay.MsgRct.GasUsed)
// TODO: handle CumulativeGasUsed // TODO: handle CumulativeGasUsed
receipt.CumulativeGasUsed = ethtypes.EmptyEthInt receipt.CumulativeGasUsed = ethtypes.EmptyEthInt
effectiveGasPrice := big.Div(replay.GasCost.TotalCost, big.NewInt(lookup.Receipt.GasUsed)) effectiveGasPrice := big.Div(replay.GasCost.TotalCost, big.NewInt(replay.MsgRct.GasUsed))
receipt.EffectiveGasPrice = ethtypes.EthBigInt(effectiveGasPrice) receipt.EffectiveGasPrice = ethtypes.EthBigInt(effectiveGasPrice)
if receipt.To == nil && lookup.Receipt.ExitCode.IsSuccess() { if receipt.To == nil && replay.MsgRct.ExitCode.IsSuccess() {
// Create and Create2 return the same things. // Create and Create2 return the same things.
var ret eam.CreateExternalReturn var ret eam.CreateExternalReturn
if err := ret.UnmarshalCBOR(bytes.NewReader(lookup.Receipt.Return)); err != nil { if err := ret.UnmarshalCBOR(bytes.NewReader(replay.MsgRct.Return)); err != nil {
return api.EthTxReceipt{}, xerrors.Errorf("failed to parse contract creation result: %w", err) return api.EthTxReceipt{}, xerrors.Errorf("failed to parse contract creation result: %w", err)
} }
addr := ethtypes.EthAddress(ret.EthAddress) addr := ethtypes.EthAddress(ret.EthAddress)