-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Refactor: Unify EthTx to FilecoinMessage methods v2 #10095
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
edad5f2
Refactor: Unify EthTx to FilecoinMessage methods
arajasek a496300
Filecoin messages can again be converted to Eth Txs
dd5f8b0
All BLS messages should calculated tx hash with unsigned message
5b3e4ee
Refactor newEthTxReceipt
93bab0e
fill in from and to for non-eth transactions
7814d72
Hoist nil check out of newEthTxFromMessageLookup
f15310a
Merge branch 'release/v1.20.0' into gstuart/unify-tx-hash
raulk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,7 +56,44 @@ type EthTxArgs struct { | |||||
S big.Int `json:"s"` | ||||||
} | ||||||
|
||||||
func EthTxArgsFromMessage(msg *types.Message) (EthTxArgs, error) { | ||||||
// EthTxFromSignedEthMessage does NOT populate: | ||||||
// - BlockHash | ||||||
// - BlockNumber | ||||||
// - TransactionIndex | ||||||
// - From | ||||||
// - Hash | ||||||
func EthTxFromSignedEthMessage(smsg *types.SignedMessage) (EthTx, error) { | ||||||
if smsg.Signature.Type != typescrypto.SigTypeDelegated { | ||||||
return EthTx{}, xerrors.Errorf("signature is not delegated type, is type: %d", smsg.Signature.Type) | ||||||
} | ||||||
|
||||||
txArgs, err := EthTxArgsFromUnsignedEthMessage(&smsg.Message) | ||||||
if err != nil { | ||||||
return EthTx{}, xerrors.Errorf("failed to convert the unsigned message: %w", err) | ||||||
} | ||||||
|
||||||
r, s, v, err := RecoverSignature(smsg.Signature) | ||||||
if err != nil { | ||||||
return EthTx{}, xerrors.Errorf("failed to recover signature: %w", err) | ||||||
} | ||||||
|
||||||
return EthTx{ | ||||||
Nonce: EthUint64(txArgs.Nonce), | ||||||
ChainID: EthUint64(txArgs.ChainID), | ||||||
To: txArgs.To, | ||||||
Value: EthBigInt(txArgs.Value), | ||||||
Type: Eip1559TxType, | ||||||
Gas: EthUint64(txArgs.GasLimit), | ||||||
MaxFeePerGas: EthBigInt(txArgs.MaxFeePerGas), | ||||||
MaxPriorityFeePerGas: EthBigInt(txArgs.MaxPriorityFeePerGas), | ||||||
V: v, | ||||||
R: r, | ||||||
S: s, | ||||||
Input: txArgs.Input, | ||||||
}, nil | ||||||
} | ||||||
|
||||||
func EthTxArgsFromUnsignedEthMessage(msg *types.Message) (EthTxArgs, error) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
var ( | ||||||
to *EthAddress | ||||||
params []byte | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eth{...}Message
is a confusing name as it leads to thinking that this is an Eth message/tx, but it's actually a Filecoin one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We kind of need some way of differentiating between
types.Message
/types.SignedMessage
that can be converted into a legitimateEthTx
or not. It makes sense to me to useTransaction
/Tx
for the Ethereum shape, andMessage
for the Filecoin shape, but I know other people might have differing thoughts about those words.I just want to avoid the confusion of someone thinking they can use this function for any signed message.