|
5 | 5 | "math"
|
6 | 6 | "math/big"
|
7 | 7 |
|
| 8 | + "github.com/holiman/uint256" |
| 9 | + |
8 | 10 | "github.com/scroll-tech/go-ethereum/common"
|
9 | 11 | "github.com/scroll-tech/go-ethereum/core/types"
|
10 | 12 | "github.com/scroll-tech/go-ethereum/crypto"
|
@@ -35,6 +37,7 @@ type Message interface {
|
35 | 37 | Data() []byte
|
36 | 38 | AccessList() types.AccessList
|
37 | 39 | IsL1MessageTx() bool
|
| 40 | + SetCodeAuthorizations() []types.SetCodeAuthorization |
38 | 41 | }
|
39 | 42 |
|
40 | 43 | // StateDB represents the StateDB interface
|
@@ -92,7 +95,11 @@ func asUnsignedTx(msg Message, baseFee, chainID *big.Int) *types.Transaction {
|
92 | 95 | return asUnsignedAccessListTx(msg, chainID)
|
93 | 96 | }
|
94 | 97 |
|
95 |
| - return asUnsignedDynamicTx(msg, chainID) |
| 98 | + if msg.SetCodeAuthorizations() == nil { |
| 99 | + return asUnsignedDynamicTx(msg, chainID) |
| 100 | + } |
| 101 | + |
| 102 | + return asUnsignedSetCodeTx(msg, chainID) |
96 | 103 | }
|
97 | 104 |
|
98 | 105 | func asUnsignedLegacyTx(msg Message) *types.Transaction {
|
@@ -133,6 +140,24 @@ func asUnsignedDynamicTx(msg Message, chainID *big.Int) *types.Transaction {
|
133 | 140 | })
|
134 | 141 | }
|
135 | 142 |
|
| 143 | +func asUnsignedSetCodeTx(msg Message, chainID *big.Int) *types.Transaction { |
| 144 | + tx := types.SetCodeTx{ |
| 145 | + Nonce: msg.Nonce(), |
| 146 | + Value: uint256.MustFromBig(msg.Value()), |
| 147 | + Gas: msg.Gas(), |
| 148 | + GasFeeCap: uint256.MustFromBig(msg.GasFeeCap()), |
| 149 | + GasTipCap: uint256.MustFromBig(msg.GasTipCap()), |
| 150 | + Data: msg.Data(), |
| 151 | + AccessList: msg.AccessList(), |
| 152 | + AuthList: msg.SetCodeAuthorizations(), |
| 153 | + ChainID: uint256.MustFromBig(chainID), |
| 154 | + } |
| 155 | + if msg.To() != nil { |
| 156 | + tx.To = *msg.To() |
| 157 | + } |
| 158 | + return types.NewTx(&tx) |
| 159 | +} |
| 160 | + |
136 | 161 | func readGPOStorageSlots(addr common.Address, state StateDB) gpoState {
|
137 | 162 | var gpoState gpoState
|
138 | 163 | gpoState.l1BaseFee = state.GetState(addr, rcfg.L1BaseFeeSlot).Big()
|
|
0 commit comments