Skip to content
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 ArbitrumInternalTx #45

Merged
merged 6 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions core/types/arb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,46 @@ func (d *ArbitrumDepositTx) setSignatureValues(chainID, v, r, s *big.Int) {

}

type ArbitrumInternalTx struct {
ChainId *big.Int
Data []byte
BlockNumber uint64
TxIndex uint64
}

func (t *ArbitrumInternalTx) txType() byte {
return ArbitrumInternalTxType
}

func (t *ArbitrumInternalTx) copy() TxData {
return &ArbitrumInternalTx{
new(big.Int).Set(t.ChainId),
common.CopyBytes(t.Data),
t.BlockNumber,
t.TxIndex,
}
}

func (t *ArbitrumInternalTx) chainID() *big.Int { return t.ChainId }
func (t *ArbitrumInternalTx) accessList() AccessList { return nil }
func (t *ArbitrumInternalTx) data() []byte { return t.Data }
func (t *ArbitrumInternalTx) gas() uint64 { return 0 }
func (t *ArbitrumInternalTx) gasPrice() *big.Int { return bigZero }
func (t *ArbitrumInternalTx) gasTipCap() *big.Int { return bigZero }
func (t *ArbitrumInternalTx) gasFeeCap() *big.Int { return bigZero }
func (t *ArbitrumInternalTx) value() *big.Int { return common.Big0 }
func (t *ArbitrumInternalTx) nonce() uint64 { return 0 }
func (t *ArbitrumInternalTx) to() *common.Address { return &arbAddress }
func (t *ArbitrumInternalTx) isFake() bool { return true }

func (d *ArbitrumInternalTx) rawSignatureValues() (v, r, s *big.Int) {
return bigZero, bigZero, bigZero
}

func (d *ArbitrumInternalTx) setSignatureValues(chainID, v, r, s *big.Int) {

}

type ArbitrumWrappedTx struct {
l1Calldata uint64
TxData
Expand Down
6 changes: 5 additions & 1 deletion core/types/arbitrum_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/ethereum/go-ethereum/common"
)

var arbAddress = common.HexToAddress("0xabc")
var arbAddress = common.HexToAddress("0xa4b05")

type arbitrumSigner struct{ Signer }

Expand All @@ -22,6 +22,8 @@ func (s arbitrumSigner) Sender(tx *Transaction) (common.Address, error) {
return inner.From, nil
case *ArbitrumDepositTx:
return arbAddress, nil
case *ArbitrumInternalTx:
return arbAddress, nil
case *ArbitrumRetryTx:
return inner.From, nil
case *ArbitrumSubmitRetryableTx:
Expand All @@ -44,6 +46,8 @@ func (s arbitrumSigner) SignatureValues(tx *Transaction, sig []byte) (R, S, V *b
return bigZero, bigZero, bigZero, nil
case *ArbitrumDepositTx:
return bigZero, bigZero, bigZero, nil
case *ArbitrumInternalTx:
return bigZero, bigZero, bigZero, nil
case *ArbitrumRetryTx:
return bigZero, bigZero, bigZero, nil
case *ArbitrumSubmitRetryableTx:
Expand Down
5 changes: 5 additions & 0 deletions core/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
ArbitrumWrappedTxType = 103
ArbitrumRetryTxType = 104
ArbitrumSubmitRetryableTxType = 105
ArbitrumInternalTxType = 106
)

// Transaction is an Ethereum transaction.
Expand Down Expand Up @@ -191,6 +192,10 @@ func (tx *Transaction) decodeTyped(b []byte, arbParsing bool) (TxData, error) {
var inner ArbitrumDepositTx
err := rlp.DecodeBytes(b[1:], &inner)
return &inner, err
case ArbitrumInternalTxType:
var inner ArbitrumInternalTx
err := rlp.DecodeBytes(b[1:], &inner)
return &inner, err
case ArbitrumUnsignedTxType:
var inner ArbitrumUnsignedTx
err := rlp.DecodeBytes(b[1:], &inner)
Expand Down
8 changes: 0 additions & 8 deletions core/types/transaction_signing.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,6 @@ 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))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to this PR, but when looking for where all I needed to add this tx type, I discovered this. I'm pretty sure it's left over from before we had an ArbitrumSigner (or before it was used in all places). We shouldn't need this anymore, and tests pass without it, so this PR removes it.

default:
return common.Address{}, ErrTxTypeNotSupported
}
Expand Down