Skip to content

Commit bcfdb48

Browse files
authored
fix(rollup-fee): support set code tx in asUnsignedTx (#1123)
* fix asUnsignedTx * fix goimport * prevent panic
1 parent 3d3032c commit bcfdb48

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

core/vm/logger.go

+2
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ func (l *StructLogger) CaptureStart(env *EVM, from common.Address, to common.Add
208208
// because contract creation is not allowed in set code transactions
209209
for _, auth := range authorizationResults {
210210
if auth.Success {
211+
// Does not record the createdAccount account yet, since it will change the return value of CreatedAccount,
212+
// which is used in assigning the "to" field of transaction in scroll_getBlockTraceByNumberOrHash.
211213
l.statesAffected[auth.Authority] = struct{}{}
212214
}
213215
}

params/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 12 // Patch version component of the current release
27+
VersionPatch = 13 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

rollup/fees/rollup_fee.go

+26-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"math"
66
"math/big"
77

8+
"github.com/holiman/uint256"
9+
810
"github.com/scroll-tech/go-ethereum/common"
911
"github.com/scroll-tech/go-ethereum/core/types"
1012
"github.com/scroll-tech/go-ethereum/crypto"
@@ -35,6 +37,7 @@ type Message interface {
3537
Data() []byte
3638
AccessList() types.AccessList
3739
IsL1MessageTx() bool
40+
SetCodeAuthorizations() []types.SetCodeAuthorization
3841
}
3942

4043
// StateDB represents the StateDB interface
@@ -92,7 +95,11 @@ func asUnsignedTx(msg Message, baseFee, chainID *big.Int) *types.Transaction {
9295
return asUnsignedAccessListTx(msg, chainID)
9396
}
9497

95-
return asUnsignedDynamicTx(msg, chainID)
98+
if msg.SetCodeAuthorizations() == nil {
99+
return asUnsignedDynamicTx(msg, chainID)
100+
}
101+
102+
return asUnsignedSetCodeTx(msg, chainID)
96103
}
97104

98105
func asUnsignedLegacyTx(msg Message) *types.Transaction {
@@ -133,6 +140,24 @@ func asUnsignedDynamicTx(msg Message, chainID *big.Int) *types.Transaction {
133140
})
134141
}
135142

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+
136161
func readGPOStorageSlots(addr common.Address, state StateDB) gpoState {
137162
var gpoState gpoState
138163
gpoState.l1BaseFee = state.GetState(addr, rcfg.L1BaseFeeSlot).Big()

0 commit comments

Comments
 (0)