fix(rollup-fee): support set code tx in asUnsignedTx (#1123)

* fix asUnsignedTx

* fix goimport

* prevent panic
This commit is contained in:
colin 2025-02-25 23:26:58 +08:00 committed by GitHub
parent 3d3032c0e1
commit bcfdb48dd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 2 deletions

View file

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

View file

@ -24,7 +24,7 @@ import (
const (
VersionMajor = 5 // Major version component of the current release
VersionMinor = 8 // Minor version component of the current release
VersionPatch = 12 // Patch version component of the current release
VersionPatch = 13 // Patch version component of the current release
VersionMeta = "mainnet" // Version metadata to append to the version string
)

View file

@ -5,6 +5,8 @@ import (
"math"
"math/big"
"github.com/holiman/uint256"
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/crypto"
@ -35,6 +37,7 @@ type Message interface {
Data() []byte
AccessList() types.AccessList
IsL1MessageTx() bool
SetCodeAuthorizations() []types.SetCodeAuthorization
}
// StateDB represents the StateDB interface
@ -92,7 +95,11 @@ func asUnsignedTx(msg Message, baseFee, chainID *big.Int) *types.Transaction {
return asUnsignedAccessListTx(msg, chainID)
}
return asUnsignedDynamicTx(msg, chainID)
if msg.SetCodeAuthorizations() == nil {
return asUnsignedDynamicTx(msg, chainID)
}
return asUnsignedSetCodeTx(msg, chainID)
}
func asUnsignedLegacyTx(msg Message) *types.Transaction {
@ -133,6 +140,24 @@ func asUnsignedDynamicTx(msg Message, chainID *big.Int) *types.Transaction {
})
}
func asUnsignedSetCodeTx(msg Message, chainID *big.Int) *types.Transaction {
tx := types.SetCodeTx{
Nonce: msg.Nonce(),
Value: uint256.MustFromBig(msg.Value()),
Gas: msg.Gas(),
GasFeeCap: uint256.MustFromBig(msg.GasFeeCap()),
GasTipCap: uint256.MustFromBig(msg.GasTipCap()),
Data: msg.Data(),
AccessList: msg.AccessList(),
AuthList: msg.SetCodeAuthorizations(),
ChainID: uint256.MustFromBig(chainID),
}
if msg.To() != nil {
tx.To = *msg.To()
}
return types.NewTx(&tx)
}
func readGPOStorageSlots(addr common.Address, state StateDB) gpoState {
var gpoState gpoState
gpoState.l1BaseFee = state.GetState(addr, rcfg.L1BaseFeeSlot).Big()