-
Notifications
You must be signed in to change notification settings - Fork 132
Add ArbitrumRetryTx type #12
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
Changes from all commits
b575014
be06373
203d5c4
354095e
99f7880
a60ab22
14fb767
27a2039
08bacd5
12c0cdb
a2e19f8
36bcc1d
18b0028
c4b86e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,10 +45,12 @@ const ( | |
LegacyTxType = iota | ||
AccessListTxType | ||
DynamicFeeTxType | ||
ArbitrumDepositTxType = 200 | ||
ArbitrumUnsignedTxType = 201 | ||
ArbitrumContractTxType = 202 | ||
ArbitrumWrappedTxType = 203 | ||
ArbitrumDepositTxType = 100 | ||
ArbitrumUnsignedTxType = 101 | ||
ArbitrumContractTxType = 102 | ||
ArbitrumWrappedTxType = 103 | ||
ArbitrumRetryTxType = 104 | ||
ArbitrumSubmitRetryableTxType = 105 | ||
) | ||
|
||
// Transaction is an Ethereum transaction. | ||
|
@@ -170,7 +172,7 @@ func (tx *Transaction) UnmarshalBinary(b []byte) error { | |
return nil | ||
} | ||
// It's an EIP2718 typed transaction envelope. | ||
inner, err := tx.decodeTyped(b, false) | ||
inner, err := tx.decodeTyped(b, true) | ||
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. I don't think we want arb parsing here, as this function is called for external input, e.g. sendRawTransaction. We only want to accept normal transaction types there. |
||
if err != nil { | ||
return err | ||
} | ||
|
@@ -201,6 +203,14 @@ func (tx *Transaction) decodeTyped(b []byte, arbParsing bool) (TxData, error) { | |
var inner ArbitrumWrappedTx | ||
err := rlp.DecodeBytes(b[1:], &inner) | ||
return &inner, err | ||
case ArbitrumRetryTxType: | ||
var inner ArbitrumRetryTx | ||
err := rlp.DecodeBytes(b[1:], &inner) | ||
return &inner, err | ||
case ArbitrumSubmitRetryableTxType: | ||
var inner ArbitrumSubmitRetryableTx | ||
err := rlp.DecodeBytes(b[1:], &inner) | ||
return &inner, err | ||
} | ||
} | ||
switch b[0] { | ||
|
@@ -412,6 +422,10 @@ func (tx *Transaction) Hash() common.Hash { | |
var h common.Hash | ||
if tx.Type() == LegacyTxType { | ||
h = rlpHash(tx.inner) | ||
} else if tx.Type() == ArbitrumSubmitRetryableTxType { | ||
h = tx.inner.(*ArbitrumSubmitRetryableTx).RequestId | ||
} else if tx.Type() == ArbitrumRetryTxType { | ||
h = tx.inner.(*ArbitrumRetryTx).RequestId | ||
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. These seem a bit dangerous to override if we could avoid it, but I'm guessing using the request id as the hash really simplifies things? |
||
} else { | ||
h = prefixedRlpHash(tx.Type(), tx.inner) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,6 +277,18 @@ func (s eip2930Signer) Sender(tx *Transaction) (common.Address, error) { | |
// AL txs are defined to use 0 and 1 as their recovery | ||
// id, add 27 to become equivalent to unprotected Homestead signatures. | ||
V = new(big.Int).Add(V, big.NewInt(27)) | ||
case ArbitrumDepositTxType: | ||
return tx.inner.(*ArbitrumDepositTx).To, nil | ||
case ArbitrumUnsignedTxType: | ||
return tx.inner.(*ArbitrumUnsignedTx).From, nil | ||
case ArbitrumContractTxType: | ||
return tx.inner.(*ArbitrumContractTx).From, nil | ||
case ArbitrumWrappedTxType: | ||
return s.Sender(NewTx(tx.inner.(*ArbitrumWrappedTx).TxData)) | ||
case ArbitrumRetryTxType: | ||
return tx.inner.(*ArbitrumRetryTx).From, nil | ||
case ArbitrumSubmitRetryableTxType: | ||
return tx.inner.(*ArbitrumSubmitRetryableTx).From, nil | ||
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. I believe these cases should happen in the ArbitrumSigner, which we always instantiate on Arbitrum chains |
||
default: | ||
return common.Address{}, ErrTxTypeNotSupported | ||
} | ||
|
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 believe all the big ints here should be
new(big.Int)
like ChainId. As-is, I don't think it does a deep copy.