-
Notifications
You must be signed in to change notification settings - Fork 106
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
Add tipping tx subtype #260
Closed
Closed
Changes from 29 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
4fb310d
add ArbitrumExtendedTx transaction type
magicxyyz e1cc692
remove flags field, rename the new tx to ArbitrumTippingTx
magicxyyz de1b3e6
remove unused const
magicxyyz dbd9780
Merge branch 'master' into tipping-tx-type
magicxyyz da0917b
Merge remote-tracking branch 'origin/ws_jwt_client' into tipping-tx-type
magicxyyz 3fdc17c
add support for tipping tx to londonSinger
magicxyyz 8c86873
add flat rlp tag
magicxyyz d21ef14
make tipping tx a subtype of subtyped tx
magicxyyz 66e7bdb
Merge branch 'master' into tipping-tx-type
magicxyyz cf55b99
fix json decoded type check
magicxyyz 964d825
revert unneeded whitespace change in a comment
magicxyyz 1126004
fix RPCTransaction subtype json field name
magicxyyz b9c1c4e
latest tipping tx fixes
rauljordan 9380b87
latest
rauljordan a9739e1
sync
rauljordan bcec1f8
latest tests from master
rauljordan 35b2da6
marshaling
rauljordan 47eac23
fix subtype json field name in receipt
magicxyyz d650824
remove ineffectual assignment to inner
magicxyyz 3a54079
remove space in tag
magicxyyz 43a7d13
fix json tag of subtype in RPCTransaction
magicxyyz d4d6370
remove unnecessary trailing newline
magicxyyz e4d6af3
Merge branch 'master' into latest-tipping-tx
magicxyyz ce5b737
Merge branch 'master' into latest-tipping-tx
magicxyyz 873384d
Merge branch 'master' into latest-tipping-tx
magicxyyz 88498e8
Merge branch 'master' into latest-tipping-tx
magicxyyz 8952bb9
drop rlp flat tag
magicxyyz d59a026
drop subtype from receipt
magicxyyz fe9d3e3
move subtyped tx signing to arbitrum signer
magicxyyz 980abc5
include subtype in transaction signing
magicxyyz bd4b275
Merge branch 'master' into latest-tipping-tx
magicxyyz 1324ffd
refactor ArbitrumSubtypedTx encoding and decoding
magicxyyz b430ae6
cleanup removed flat rlp flag
magicxyyz bcb7de4
drop DecodeTxJSON and EncodeTxJSON methods
magicxyyz c7b244d
remove arbitrumSubtypeOffset constant
magicxyyz 0f09b6d
add empty line before upstream tx type consts
magicxyyz 43ab2a1
remove repeated access list setting when unmarshalling json
magicxyyz 8d925b3
re-add removed empty line
magicxyyz 2cf65c2
set yparity in tipping tx rpc result
magicxyyz 7594ef3
make fake tx in arbitrumSigner.SignatureValues, add comment in .Sender
magicxyyz 8ac00e8
move AccessList coping in json marshalling
magicxyyz 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
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 |
---|---|---|
|
@@ -48,6 +48,7 @@ type txJSON struct { | |
YParity *hexutil.Uint64 `json:"yParity,omitempty"` | ||
|
||
// Arbitrum fields: | ||
Subtype *hexutil.Uint64 `json:"subtype,omitempty"` // ArbitrumSubtypedTx | ||
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. why uint64 and not byte? 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.
|
||
From *common.Address `json:"from,omitempty"` // Contract SubmitRetryable Unsigned Retry | ||
RequestId *common.Hash `json:"requestId,omitempty"` // Contract SubmitRetryable Deposit | ||
TicketId *common.Hash `json:"ticketId,omitempty"` // Retry | ||
|
@@ -223,7 +224,29 @@ func (tx *Transaction) MarshalJSON() ([]byte, error) { | |
data := itx.data() | ||
enc.Input = (*hexutil.Bytes)(&data) | ||
enc.To = tx.To() | ||
|
||
magicxyyz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
case *ArbitrumSubtypedTx: | ||
subtype := uint64(itx.TxSubtype()) | ||
enc.Subtype = (*hexutil.Uint64)(&subtype) | ||
switch subtype { | ||
case ArbitrumTippingTxSubtype: | ||
enc.ChainID = (*hexutil.Big)(itx.chainID()) | ||
accessList := itx.accessList() | ||
enc.AccessList = &accessList | ||
nonce := itx.nonce() | ||
enc.Nonce = (*hexutil.Uint64)(&nonce) | ||
gas := itx.gas() | ||
enc.Gas = (*hexutil.Uint64)(&gas) | ||
enc.MaxFeePerGas = (*hexutil.Big)(itx.gasFeeCap()) | ||
enc.MaxPriorityFeePerGas = (*hexutil.Big)(itx.gasTipCap()) | ||
enc.Value = (*hexutil.Big)(itx.value()) | ||
data := itx.data() | ||
enc.Input = (*hexutil.Bytes)(&data) | ||
enc.To = tx.To() | ||
v, r, s := itx.rawSignatureValues() | ||
enc.V = (*hexutil.Big)(v) | ||
enc.R = (*hexutil.Big)(r) | ||
enc.S = (*hexutil.Big)(s) | ||
} | ||
case *BlobTx: | ||
enc.ChainID = (*hexutil.Big)(itx.ChainID.ToBig()) | ||
enc.Nonce = (*hexutil.Uint64)(&itx.Nonce) | ||
|
@@ -255,7 +278,15 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { | |
|
||
// Decode / verify fields according to transaction type. | ||
var inner TxData | ||
switch dec.Type { | ||
decType := uint64(dec.Type) | ||
if decType == ArbitrumSubtypedTxType { | ||
if dec.Subtype != nil { | ||
decType = uint64(*dec.Subtype) + arbitrumSubtypeOffset | ||
} else { | ||
return errors.New("missing required field 'subtype' in transaction") | ||
} | ||
} | ||
switch decType { | ||
case LegacyTxType: | ||
var itx LegacyTx | ||
inner = &itx | ||
|
@@ -359,9 +390,12 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { | |
} | ||
} | ||
|
||
case DynamicFeeTxType: | ||
case DynamicFeeTxType, ArbitrumTippingTxSubtype + arbitrumSubtypeOffset: | ||
var itx DynamicFeeTx | ||
inner = &itx | ||
// Access list is optional for now. | ||
if dec.AccessList != nil { | ||
itx.AccessList = *dec.AccessList | ||
} | ||
magicxyyz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if dec.ChainID == nil { | ||
return errors.New("missing required field 'chainId' in transaction") | ||
} | ||
|
@@ -420,6 +454,15 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { | |
return err | ||
} | ||
} | ||
if decType == ArbitrumTippingTxSubtype+arbitrumSubtypeOffset { | ||
inner = &ArbitrumSubtypedTx{ | ||
TxData: &ArbitrumTippingTx{ | ||
DynamicFeeTx: itx, | ||
}, | ||
} | ||
} else { | ||
inner = &itx | ||
} | ||
|
||
case ArbitrumLegacyTxType: | ||
var itx LegacyTx | ||
|
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
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.
I think I get it but I still find it kind of confusing and a room for error..
could we add a separate subtype field in SubtypedTx and use that?
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.
It'd be great to keep the subtype a constant, but adding a field invalidates the property
Maybe I should add a
func (tx *ArbitrumSubtypedTx) SubTx() TxData
method, and then we'd use it this way:tx.SubTx().Type()
, would it be better?