This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note: - the deposit-tx type fee payment is not final - the deposit-tx gas handling is not final Also Includes: - Include invalid deposits, rewind state, but always persist mint (#10) - Provide gas to Call/Create in deposit transactions (#12) Co-authored-by: Diederik Loerakker <proto@protolambda.com>
- Loading branch information
1 parent
111a1b7
commit d0070e0
Showing
15 changed files
with
388 additions
and
30 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright 2021 The go-ethereum Authors | ||
// This file is part of the go-ethereum library. | ||
// | ||
// The go-ethereum library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The go-ethereum library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package types | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
const DepositTxType = 0x7E | ||
|
||
type DepositTx struct { | ||
// SourceHash uniquely identifies the source of the deposit | ||
SourceHash common.Hash | ||
// From is exposed through the types.Signer, not through TxData | ||
From common.Address | ||
// nil means contract creation | ||
To *common.Address `rlp:"nil"` | ||
// Mint is minted on L2, locked on L1, nil if no minting. | ||
Mint *big.Int `rlp:"nil"` | ||
// Value is transferred from L2 balance, executed after Mint (if any) | ||
Value *big.Int | ||
// gas limit | ||
Gas uint64 | ||
Data []byte | ||
} | ||
|
||
// copy creates a deep copy of the transaction data and initializes all fields. | ||
func (tx *DepositTx) copy() TxData { | ||
cpy := &DepositTx{ | ||
SourceHash: tx.SourceHash, | ||
From: tx.From, | ||
To: copyAddressPtr(tx.To), | ||
Mint: nil, | ||
Value: new(big.Int), | ||
Gas: tx.Gas, | ||
Data: common.CopyBytes(tx.Data), | ||
} | ||
if tx.Mint != nil { | ||
cpy.Mint = new(big.Int).Set(tx.Mint) | ||
} | ||
if tx.Value != nil { | ||
cpy.Value.Set(tx.Value) | ||
} | ||
return cpy | ||
} | ||
|
||
// DepositsNonce identifies a deposit, since go-ethereum abstracts all transaction types to a core.Message. | ||
// Deposits do not set a nonce, deposits are included by the system and cannot be repeated or included elsewhere. | ||
const DepositsNonce uint64 = 0xffff_ffff_ffff_fffd | ||
|
||
// accessors for innerTx. | ||
func (tx *DepositTx) txType() byte { return DepositTxType } | ||
func (tx *DepositTx) chainID() *big.Int { panic("deposits are not signed and do not have a chain-ID") } | ||
func (tx *DepositTx) protected() bool { return true } | ||
func (tx *DepositTx) accessList() AccessList { return nil } | ||
func (tx *DepositTx) data() []byte { return tx.Data } | ||
func (tx *DepositTx) gas() uint64 { return tx.Gas } | ||
func (tx *DepositTx) gasFeeCap() *big.Int { return new(big.Int) } | ||
func (tx *DepositTx) gasTipCap() *big.Int { return new(big.Int) } | ||
func (tx *DepositTx) gasPrice() *big.Int { return new(big.Int) } | ||
func (tx *DepositTx) value() *big.Int { return tx.Value } | ||
func (tx *DepositTx) nonce() uint64 { return DepositsNonce } | ||
func (tx *DepositTx) to() *common.Address { return tx.To } | ||
|
||
func (tx *DepositTx) rawSignatureValues() (v, r, s *big.Int) { | ||
panic("deposit tx does not have a signature") | ||
} | ||
|
||
func (tx *DepositTx) setSignatureValues(chainID, v, r, s *big.Int) { | ||
panic("deposit tx does not have a signature") | ||
} |
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
Oops, something went wrong.