Skip to content
Closed
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
7 changes: 5 additions & 2 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,11 @@ func (m callMsg) IsL1MessageTx() bool { return false }
func (m callMsg) SetCodeAuthorizations() []types.SetCodeAuthorization {
return m.CallMsg.AuthorizationList
}
func (m callMsg) FeeTokenID() uint16 { return m.CallMsg.FeeTokenID }
func (m callMsg) FeeLimit() *big.Int { return m.CallMsg.FeeLimit }
func (m callMsg) FeeTokenID() uint16 { return m.CallMsg.FeeTokenID }
func (m callMsg) FeeLimit() *big.Int { return m.CallMsg.FeeLimit }
func (m callMsg) Version() uint8 { return m.CallMsg.Version }
func (m callMsg) Reference() *common.Reference { return m.CallMsg.Reference }
func (m callMsg) Memo() *[]byte { return m.CallMsg.Memo }

// filterBackend implements filters.Backend to support filtering for logs without
// taking bloom-bits acceleration structures into account.
Expand Down
69 changes: 63 additions & 6 deletions accounts/abi/bind/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ type TransactOpts struct {
GasTipCap *big.Int // Gas priority fee cap to use for the 1559 transaction execution (nil = gas price oracle)
GasLimit uint64 // Gas limit to set for the transaction execution (0 = estimate)

FeeTokenID uint16 // alt fee token id of transaction execution
FeeLimit *big.Int // alt fee token limit of transaction execution
FeeTokenID uint16 // alt fee token id of transaction execution
FeeLimit *big.Int // alt fee token limit of transaction execution
Version *uint8 // version of morph tx (nil = auto-detect)
Reference *common.Reference // reference key for the transaction (optional)
Memo *[]byte // memo for the transaction (optional)

Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)

Expand Down Expand Up @@ -290,12 +293,19 @@ func (c *BoundContract) createDynamicTx(opts *TransactOpts, contract *common.Add
return types.NewTx(baseTx), nil
}

func (c *BoundContract) createAltFeeTx(opts *TransactOpts, contract *common.Address, input []byte, head *types.Header) (*types.Transaction, error) {
func (c *BoundContract) createMorphTx(opts *TransactOpts, contract *common.Address, input []byte, head *types.Header) (*types.Transaction, error) {
// Normalize value
value := opts.Value
if value == nil {
value = new(big.Int)
}

// Determine version and validate fields
version, err := c.morphTxVersion(opts)
if err != nil {
return nil, err
}

// Estimate TipCap
gasTipCap := opts.GasTipCap
if gasTipCap == nil {
Expand Down Expand Up @@ -334,20 +344,64 @@ func (c *BoundContract) createAltFeeTx(opts *TransactOpts, contract *common.Addr
if err != nil {
return nil, err
}
baseTx := &types.AltFeeTx{
baseTx := &types.MorphTx{
To: contract,
Nonce: nonce,
GasFeeCap: gasFeeCap,
GasTipCap: gasTipCap,
FeeTokenID: opts.FeeTokenID,
FeeLimit: opts.FeeLimit,
Gas: gasLimit,
Version: version,
Reference: opts.Reference,
Memo: opts.Memo,
Value: value,
Data: input,
}
return types.NewTx(baseTx), nil
}

// morphTxVersion determines the MorphTx version and validates field requirements.
// If version is explicitly specified, validate that parameters match:
// - Version 0: FeeTokenID must be > 0, Reference and Memo must not be set
// - Version 1: FeeTokenID, Reference, Memo are all optional;
// if FeeTokenID is 0, FeeLimit must not be set
//
// If version is not explicitly specified, default to the highest version.
func (c *BoundContract) morphTxVersion(opts *TransactOpts) (uint8, error) {
// Validate memo length
if opts.Memo != nil && len(*opts.Memo) > common.MaxMemoLength {
return 0, types.ErrMemoTooLong
}

// If version is not explicitly specified, use the highest version
if opts.Version == nil {
if opts.FeeTokenID == 0 && opts.FeeLimit != nil && opts.FeeLimit.Sign() != 0 {
return 0, types.ErrMorphTxV1IllegalExtraParams
}
return types.MorphTxVersion1, nil
}

// Version explicitly specified - validate parameters match
version := *opts.Version
switch version {
case types.MorphTxVersion0:
if opts.FeeTokenID == 0 ||
opts.Reference != nil && *opts.Reference != (common.Reference{}) ||
opts.Memo != nil && len(*opts.Memo) > 0 {
return 0, types.ErrMorphTxV0IllegalExtraParams
}
case types.MorphTxVersion1:
if opts.FeeTokenID == 0 && opts.FeeLimit != nil && opts.FeeLimit.Sign() != 0 {
return 0, types.ErrMorphTxV1IllegalExtraParams
}
default:
return 0, types.ErrMorphTxUnsupportedVersion
}

return version, nil
}

func (c *BoundContract) createLegacyTx(opts *TransactOpts, contract *common.Address, input []byte) (*types.Transaction, error) {
if opts.GasFeeCap != nil || opts.GasTipCap != nil {
return nil, errors.New("maxFeePerGas or maxPriorityFeePerGas specified but curie is not active yet")
Expand Down Expand Up @@ -438,8 +492,11 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
if head, errHead := c.transactor.HeaderByNumber(ensureContext(opts.Context), nil); errHead != nil {
return nil, errHead
} else if head.BaseFee != nil {
if opts.FeeTokenID != 0 {
rawTx, err = c.createAltFeeTx(opts, contract, input, head)
if opts.FeeTokenID != 0 ||
opts.Version != nil ||
(opts.Reference != nil && *opts.Reference != (common.Reference{})) ||
(opts.Memo != nil && len(*opts.Memo) > 0) {
rawTx, err = c.createMorphTx(opts, contract, input, head)
} else {
rawTx, err = c.createDynamicTx(opts, contract, input, head)
}
Expand Down
9 changes: 8 additions & 1 deletion accounts/external/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,19 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
case types.DynamicFeeTxType, types.SetCodeTxType:
args.MaxFeePerGas = (*hexutil.Big)(tx.GasFeeCap())
args.MaxPriorityFeePerGas = (*hexutil.Big)(tx.GasTipCap())
case types.AltFeeTxType:
case types.MorphTxType:
args.MaxFeePerGas = (*hexutil.Big)(tx.GasFeeCap())
args.MaxPriorityFeePerGas = (*hexutil.Big)(tx.GasTipCap())
feeTokenID := hexutil.Uint16(tx.FeeTokenID())
args.FeeTokenID = &feeTokenID
args.FeeLimit = (*hexutil.Big)(tx.FeeLimit())
version := hexutil.Uint64(tx.Version())
args.Version = &version
args.Reference = tx.Reference()
if tx.Memo() != nil {
memo := hexutil.Bytes(*tx.Memo())
args.Memo = &memo
}
default:
return nil, fmt.Errorf("unsupported tx type %d", tx.Type())
}
Expand Down
24 changes: 18 additions & 6 deletions cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,24 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
receipt.TxHash = tx.Hash()
receipt.GasUsed = msgResult.UsedGas
receipt.L1Fee = msgResult.L1DataFee
if msg.FeeTokenID() != 0 {
tokenID := msg.FeeTokenID()
receipt.FeeTokenID = &tokenID
receipt.FeeLimit = msg.FeeLimit()
receipt.FeeRate = msgResult.FeeRate
receipt.TokenScale = msgResult.TokenScale

if msg.FeeTokenID() != 0 ||
msg.Version() != 0 ||
(msg.Reference() != nil && *msg.Reference() != (common.Reference{})) ||
(msg.Memo() != nil && len(*msg.Memo()) > 0) {
if msg.FeeTokenID() != 0 {
tokenID := msg.FeeTokenID()
receipt.FeeTokenID = &tokenID
receipt.FeeLimit = msg.FeeLimit()
receipt.FeeRate = msgResult.FeeRate
receipt.TokenScale = msgResult.TokenScale
}
// Only include V1 fields (version, reference, memo) for V1+ transactions
if msg.Version() >= types.MorphTxVersion1 {
receipt.Version = msg.Version()
receipt.Reference = msg.Reference()
receipt.Memo = msg.Memo()
}
}

// If the transaction created a contract, store the creation address in the receipt.
Expand Down
8 changes: 4 additions & 4 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var (
utils.OverrideMorph203TimeFlag,
utils.OverrideViridianTimeFlag,
utils.OverrideEmeraldTimeFlag,
utils.OverrideMPTForkTimeFlag,
utils.OverrideJadeForkTimeFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand Down Expand Up @@ -226,9 +226,9 @@ func initGenesis(ctx *cli.Context) error {
v := ctx.Uint64(utils.OverrideEmeraldTimeFlag.Name)
overrides.EmeraldTime = &v
}
if ctx.IsSet(utils.OverrideMPTForkTimeFlag.Name) {
v := ctx.Uint64(utils.OverrideMPTForkTimeFlag.Name)
overrides.MPTForkTime = &v
if ctx.IsSet(utils.OverrideJadeForkTimeFlag.Name) {
v := ctx.Uint64(utils.OverrideJadeForkTimeFlag.Name)
overrides.JadeForkTime = &v
}

for _, name := range []string{"chaindata", "lightchaindata"} {
Expand Down
6 changes: 3 additions & 3 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
v := ctx.Uint64(utils.OverrideEmeraldTimeFlag.Name)
cfg.Eth.OverrideEmeraldTime = &v
}
if ctx.GlobalIsSet(utils.OverrideMPTForkTimeFlag.Name) {
v := ctx.Uint64(utils.OverrideMPTForkTimeFlag.Name)
cfg.Eth.OverrideMPTForkTime = &v
if ctx.GlobalIsSet(utils.OverrideJadeForkTimeFlag.Name) {
v := ctx.Uint64(utils.OverrideJadeForkTimeFlag.Name)
cfg.Eth.OverrideJadeForkTime = &v
}

backend, _ := utils.RegisterEthService(stack, &cfg.Eth)
Expand Down
2 changes: 1 addition & 1 deletion cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ var (
utils.OverrideMorph203TimeFlag,
utils.OverrideViridianTimeFlag,
utils.OverrideEmeraldTimeFlag,
utils.OverrideMPTForkTimeFlag,
utils.OverrideJadeForkTimeFlag,
utils.EthashCacheDirFlag,
utils.EthashCachesInMemoryFlag,
utils.EthashCachesOnDiskFlag,
Expand Down
6 changes: 3 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ var (
Name: "override.emeraldtime",
Usage: "Manually specify the Emerald fork timestamp, overriding the bundled setting",
}
OverrideMPTForkTimeFlag = &cli.Uint64Flag{
Name: "override.mptforktime",
Usage: "Manually specify the MPT fork timestamp, overriding the bundled setting",
OverrideJadeForkTimeFlag = &cli.Uint64Flag{
Name: "override.jadeforktime",
Usage: "Manually specify the Jade fork timestamp, overriding the bundled setting",
}
// Light server and client settings
LightServeFlag = cli.IntFlag{
Expand Down
Loading