diff --git a/adapters.go b/adapters.go index 401541de..b715a684 100644 --- a/adapters.go +++ b/adapters.go @@ -3,8 +3,11 @@ package monomer import ( "errors" "fmt" + "time" bfttypes "github.com/cometbft/cometbft/types" + "github.com/ethereum-optimism/optimism/op-node/rollup" + "github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" rolluptypes "github.com/polymerdao/monomer/x/rollup/types" @@ -32,17 +35,12 @@ func AdaptPayloadTxsToCosmosTxs(ethTxs []hexutil.Bytes) (bfttypes.Txs, error) { return nil, fmt.Errorf("marshal tx: %v", err) } - cosmosTxs := make(bfttypes.Txs, 0, 1+numDepositTxs) - cosmosTxs = append(cosmosTxs, depositTxBytes) - cosmosNonDepositTxs, err := convertToCosmosNonDepositTxs(ethTxs[numDepositTxs:]) if err != nil { return nil, fmt.Errorf("convert to cosmos txs: %v", err) } - cosmosTxs = append(cosmosTxs, cosmosNonDepositTxs...) - - return cosmosTxs, nil + return append(bfttypes.Txs{depositTxBytes}, cosmosNonDepositTxs...), nil } func countDepositTransactions(ethTxs []hexutil.Bytes) (int, error) { @@ -65,17 +63,47 @@ func countDepositTransactions(ethTxs []hexutil.Bytes) (int, error) { return numDepositTxs, nil } -func packDepositTxsToCosmosTx(ethDepositTxs []hexutil.Bytes, _ string) (*rolluptypes.DepositsTx, error) { //nolint:unparam - depositTxs := make([]*rolluptypes.EthDepositTx, 0, len(ethDepositTxs)) - for _, ethDepositTx := range ethDepositTxs { - depositTxs = append(depositTxs, &rolluptypes.EthDepositTx{ - Tx: ethDepositTx, - }) +func packDepositTxsToCosmosTx(ethDepositTxs []hexutil.Bytes, _ string) (*rolluptypes.DepositsTx, error) { + var ethL1AttributesTx ethtypes.Transaction + if err := ethL1AttributesTx.UnmarshalBinary(ethDepositTxs[0]); err != nil { + return nil, fmt.Errorf("unmarshal binary: %v", err) } - return &rolluptypes.DepositsTx{ - Deposits: &rolluptypes.MsgApplyL1Txs{ - Txs: depositTxs, + l1BlockInfo, err := derive.L1BlockInfoFromBytes(&rollup.Config{}, uint64(time.Now().Unix()), ethL1AttributesTx.Data()) + if err != nil { + return nil, fmt.Errorf("l1 block info from bytes: %v", err) + } + l1Attributes := &rolluptypes.MsgSetL1Attributes{ + L1BlockInfo: &rolluptypes.L1BlockInfo{ + Number: l1BlockInfo.Number, + Time: l1BlockInfo.Time, + BlockHash: l1BlockInfo.BlockHash[:], + SequenceNumber: l1BlockInfo.SequenceNumber, + BatcherAddr: l1BlockInfo.BatcherAddr[:], + L1FeeOverhead: l1BlockInfo.L1FeeOverhead[:], + L1FeeScalar: l1BlockInfo.L1FeeScalar[:], + BaseFeeScalar: l1BlockInfo.BaseFeeScalar, + BlobBaseFeeScalar: l1BlockInfo.BlobBaseFeeScalar, }, + EthTx: ethDepositTxs[0], + } + if l1Attributes.L1BlockInfo.BaseFee != nil { + l1Attributes.L1BlockInfo.BaseFee = l1BlockInfo.BaseFee.Bytes() + } + if l1Attributes.L1BlockInfo.BlobBaseFee != nil { + l1Attributes.L1BlockInfo.BlobBaseFee = l1BlockInfo.BlobBaseFee.Bytes() + } + + depositTxs := make([]*rolluptypes.MsgApplyUserDeposit, 0) + if len(ethDepositTxs) > 1 { + for _, ethDepositTx := range ethDepositTxs[1:] { + depositTxs = append(depositTxs, &rolluptypes.MsgApplyUserDeposit{ + Tx: ethDepositTx, + }) + } + } + return &rolluptypes.DepositsTx{ + L1Attributes: l1Attributes, + UserDeposits: depositTxs, }, nil } @@ -98,31 +126,35 @@ func AdaptCosmosTxsToEthTxs(cosmosTxs bfttypes.Txs) (ethtypes.Transactions, erro return ethtypes.Transactions{}, nil } txsBytes := cosmosTxs.ToSliceOfBytes() - ethTxs, err := GetDepositTxs(txsBytes) + ethTxs, err := GetDepositTxs(txsBytes[0]) if err != nil { return nil, fmt.Errorf("get deposit txs: %v", err) } - for _, txBytes := range txsBytes[1:] { - ethTxs = append(ethTxs, AdaptNonDepositCosmosTxToEthTx(txBytes)) + if len(txsBytes) > 1 { + for _, txBytes := range txsBytes[1:] { + ethTxs = append(ethTxs, AdaptNonDepositCosmosTxToEthTx(txBytes)) + } } return ethTxs, nil } -func GetDepositTxs(txsBytes [][]byte) (ethtypes.Transactions, error) { +func GetDepositTxs(cosmosDepositTx []byte) (ethtypes.Transactions, error) { msg := new(rolluptypes.DepositsTx) - if err := msg.Unmarshal(txsBytes[0]); err != nil { + if err := msg.Unmarshal(cosmosDepositTx); err != nil { return nil, fmt.Errorf("unmarshal MsgL1Txs msg: %v", err) } - ethTxsBytes := msg.GetDeposits().Txs - if len(ethTxsBytes) == 0 { - return nil, errL1AttributesNotFound + var ethL1AttributesTx ethtypes.Transaction + if err := ethL1AttributesTx.UnmarshalBinary(msg.L1Attributes.EthTx); err != nil { + return nil, fmt.Errorf("unmarshal binary l1 attributes tx: %v", err) } - txs := make(ethtypes.Transactions, 0, len(ethTxsBytes)+len(txsBytes)-1) + txs := ethtypes.Transactions{ðL1AttributesTx} + + ethTxsBytes := msg.GetUserDeposits() for _, userDepositTx := range ethTxsBytes { var tx ethtypes.Transaction if err := tx.UnmarshalBinary(userDepositTx.Tx); err != nil { - return nil, fmt.Errorf("unmarshal binary: %v", err) + return nil, fmt.Errorf("unmarshal binary user deposit tx: %v", err) } if !tx.IsDepositTx() { return nil, errors.New("MsgL1Tx contains non-deposit tx") diff --git a/builder/builder_test.go b/builder/builder_test.go index 5a3a7b1b..65fa41bf 100644 --- a/builder/builder_test.go +++ b/builder/builder_test.go @@ -400,7 +400,7 @@ func TestBuildRollupTxs(t *testing.T) { // Verify deposit and withdrawal msg event expectedEvents := []string{ - "/rollup.v1.MsgApplyL1Txs", + "/rollup.v1.MsgSetL1Attributes", "/rollup.v1.MsgInitiateWithdrawal", } diff --git a/docs/docs/learn/deposits.md b/docs/docs/learn/deposits.md index 0dd879db..955eed1b 100644 --- a/docs/docs/learn/deposits.md +++ b/docs/docs/learn/deposits.md @@ -42,22 +42,13 @@ Because the OP stack and the EngineAPI are Ethereum specific, Monomer's chief re In the `x/rollup` module, Monomer defines a custom Cosmos-SDK message type to carry deposit transaction data. -```go -// MsgApplyL1Txs defines the message for applying all L1 system and user deposit txs. -message MsgApplyL1Txs { - // Array of bytes where each bytes is a eth.Transaction.MarshalBinary tx. - // The first tx must be the L1 system deposit tx, and the rest are user txs if present. - repeated bytes tx_bytes = 1; -} -``` +For each rollup block, all deposit transactions sourced from the L1 are batched into a single `DepositTxs` transaction. The engine now awaits the `op-node`'s request to finalize a block. When that request comes: -For each rollup block, all deposit transactions sourced from the L1 are batched into a single `MsgApplyL1Txs` message, which in turn is bundled into a single `cometbft` style transaction and cached in the engine. The engine now awaits the `op-node`'s request to finalize a block. When that request comes: - -5. the cached transaction is passed to Monomer's `builder.Build()`, which encapsulates the Cosmos-SDK appchain. In accordance with the OP stack spec, the transaction that packs the `MsgApplyL1Txs` message is the first transaction in each L2 block. +5. the cached transaction is passed to Monomer's `builder.Build()`, which encapsulates the Cosmos-SDK appchain. In accordance with the OP stack spec, the `DepositTxs` transaction is the first transaction in each L2 block. ## The Cosmos-SDK Appchain -The Cosmos Appchain now builds a block as usual. Monomer's contribution here is the `x/rollup` module, and its keeper method `processL1UserDepositTxs`, which: +The Cosmos Appchain now builds a block as usual. Monomer's contribution here is the `x/rollup` module, which: -6. unpacks the `MsgApplyL1Txs` `tx_bytes` field into a slice of `eth.Transaction` objects, minting ETH according to embedded values +6. unpacks the deposit transaction, minting ETH according to embedded values 7. emits events for each deposit diff --git a/mempool/mempool.go b/mempool/mempool.go index b50c2320..e7cbb28d 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -42,7 +42,7 @@ func (p *Pool) Enqueue(userTxn comettypes.Tx) (err error) { // Attempt to adapt the Cosmos transaction to an Ethereum deposit transaction. // If the adaptation succeeds, it indicates that the // user transaction is a deposit transaction, which is not allowed in the pool. - if _, err := monomer.GetDepositTxs([][]byte{userTxn}); err == nil { + if _, err := monomer.GetDepositTxs(userTxn); err == nil { return errors.New("deposit txs are not allowed in the pool") } diff --git a/mempool/mempool_test.go b/mempool/mempool_test.go index 3833a999..deadac62 100644 --- a/mempool/mempool_test.go +++ b/mempool/mempool_test.go @@ -25,11 +25,13 @@ func TestMempool(t *testing.T) { }) t.Run("deposit transaction", func(t *testing.T) { - _, depositTx, _ := testutils.GenerateEthTxs(t) + l1AttributesTx, depositTx, _ := testutils.GenerateEthTxs(t) + l1AttributesTxBytes, err := l1AttributesTx.MarshalBinary() + require.NoError(t, err) depositTxBytes, err := depositTx.MarshalBinary() require.NoError(t, err) - cosmosTxs, err := monomer.AdaptPayloadTxsToCosmosTxs([]hexutil.Bytes{depositTxBytes}) + cosmosTxs, err := monomer.AdaptPayloadTxsToCosmosTxs([]hexutil.Bytes{l1AttributesTxBytes, depositTxBytes}) require.NoError(t, err) require.ErrorContains(t, pool.Enqueue(cosmosTxs[0]), "deposit txs are not allowed in the pool") }) diff --git a/proto/rollup/v1/tx.proto b/proto/rollup/v1/tx.proto index e1414355..8036b9e9 100644 --- a/proto/rollup/v1/tx.proto +++ b/proto/rollup/v1/tx.proto @@ -13,8 +13,12 @@ option go_package = "github.com/polymerdao/monomer/x/rollup/types"; // Msg defines all tx endpoints for the x/rollup module. service Msg { option (cosmos.msg.v1.service) = true; - // ApplyL1Txs defines a method for applying applying all L1 system and user deposit txs. - rpc ApplyL1Txs(MsgApplyL1Txs) returns (MsgApplyL1TxsResponse); + + // SetL1Attributes sets the l1 attributes in the L2 state. + rpc SetL1Attributes(MsgSetL1Attributes) returns (MsgSetL1AttributesResponse); + + // ApplyUserDeposit defines a method for applying a user deposit tx. + rpc ApplyUserDeposit(MsgApplyUserDeposit) returns (MsgApplyUserDepositResponse); // InitiateWithdrawal defines a method for initiating a withdrawal from L2 to L1. rpc InitiateWithdrawal(MsgInitiateWithdrawal) returns (MsgInitiateWithdrawalResponse); @@ -28,23 +32,27 @@ service Msg { // DepositsTx is the Cosmos SDK transaction type that wraps OP Stack deposit transactions. message DepositsTx { - MsgApplyL1Txs deposits = 1; + MsgSetL1Attributes l1_attributes = 1; + repeated MsgApplyUserDeposit user_deposits = 2; } -// DepositTx is a eth deposit tx. -message EthDepositTx { - // tx is the marshaled Ethereum Deposit tx. - bytes tx = 1; +// MsgSetL1Attributes is the l1 attributes message. +message MsgSetL1Attributes { + L1BlockInfo l1_block_info = 1; + bytes eth_tx = 2; } -// MsgApplyL1Txs defines the message for applying all L1 system and user deposit txs. -message MsgApplyL1Txs { - // txs are all of the system and user deposit txs. - repeated EthDepositTx txs = 1; +// MsgSetL1AttributesResponse defines the SetL1Attributes response type. +message MsgSetL1AttributesResponse {} + +// MsgApplyUserDeposit is a eth deposit tx. +message MsgApplyUserDeposit { + // tx is the marshaled Ethereum Deposit tx. + bytes tx = 1; } -// MsgApplyL1TxsResponse defines the Msg/ApplyL1Txs response type. -message MsgApplyL1TxsResponse {} +// MsgApplyUserDepositResponse defines the ApplyUserDeposit response type. +message MsgApplyUserDepositResponse {} // MsgInitiateWithdrawal defines the message for initiating an L2 withdrawal. message MsgInitiateWithdrawal { diff --git a/x/rollup/keeper/deposits.go b/x/rollup/keeper/deposits.go index 24d30e8b..6c1a7308 100644 --- a/x/rollup/keeper/deposits.go +++ b/x/rollup/keeper/deposits.go @@ -2,6 +2,7 @@ package keeper import ( "bytes" + "errors" "fmt" "math/big" "reflect" @@ -11,7 +12,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" opbindings "github.com/ethereum-optimism/optimism/op-bindings/bindings" "github.com/ethereum-optimism/optimism/op-chain-ops/crossdomain" - "github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -19,119 +19,74 @@ import ( "github.com/polymerdao/monomer" "github.com/polymerdao/monomer/bindings" "github.com/polymerdao/monomer/x/rollup/types" - "github.com/samber/lo" ) -// processL1AttributesTx processes the L1 Attributes tx and returns the L1 block info. -func (k *Keeper) processL1AttributesTx(ctx sdk.Context, txBytes []byte) (*types.L1BlockInfo, error) { //nolint:gocritic // hugeParam +// processL1UserDepositTxs processes the L1 user deposit txs, mints ETH to the user's cosmos address, +// and returns associated events. +func (k *Keeper) processL1UserDepositTxs( + ctx sdk.Context, //nolint:gocritic // hugeParam + deposit *types.MsgApplyUserDeposit, + l1blockInfo *types.L1BlockInfo, +) (sdk.Events, error) { + mintEvents := sdk.Events{} + + txBytes := deposit.Tx var tx ethtypes.Transaction if err := tx.UnmarshalBinary(txBytes); err != nil { - return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to unmarshal L1 attributes transaction: %v", err) + return nil, fmt.Errorf("unmarshal binary deposit tx: %v", err) } - if !tx.IsDepositTx() { - return nil, types.WrapError(types.ErrInvalidL1Txs, "first L1 tx must be a L1 attributes tx, but got type %d", tx.Type()) + if tx.IsSystemTx() { + return nil, errors.New("deposit tx must not be a system tx") } - - l1blockInfo, err := derive.L1BlockInfoFromBytes(k.rollupCfg, uint64(ctx.BlockTime().Unix()), tx.Data()) - if err != nil { - return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to derive L1 block info from L1 Info Deposit tx: %v", err) + // if the receipient is nil, it means the tx is creating a contract which we don't support, so return an error. + // see https://github.com/ethereum-optimism/op-geth/blob/v1.101301.0-rc.2/core/state_processor.go#L154 + if tx.To() == nil { + return nil, errors.New("contract creation is not supported") } - // Convert derive.L1BlockInfo to types.L1BlockInfo - protoL1BlockInfo := &types.L1BlockInfo{ - Number: l1blockInfo.Number, - Time: l1blockInfo.Time, - BlockHash: l1blockInfo.BlockHash[:], - SequenceNumber: l1blockInfo.SequenceNumber, - BatcherAddr: l1blockInfo.BatcherAddr[:], - L1FeeOverhead: l1blockInfo.L1FeeOverhead[:], - L1FeeScalar: l1blockInfo.L1FeeScalar[:], - BaseFeeScalar: l1blockInfo.BaseFeeScalar, - BlobBaseFeeScalar: l1blockInfo.BlobBaseFeeScalar, + // Get the sender's address from the transaction + from, err := ethtypes.MakeSigner( + monomer.NewChainConfig(tx.ChainId()), + new(big.Int).SetUint64(l1blockInfo.Number), + l1blockInfo.Time, + ).Sender(&tx) + if err != nil { + return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to get sender address: %v", err) } - - if l1blockInfo.BaseFee != nil { - protoL1BlockInfo.BaseFee = l1blockInfo.BaseFee.Bytes() + addrPrefix := sdk.GetConfig().GetBech32AccountAddrPrefix() + mintAddr, err := monomer.CosmosETHAddress(from).Encode(addrPrefix) + if err != nil { + return nil, fmt.Errorf("evm to cosmos address: %v", err) } - if l1blockInfo.BlobBaseFee != nil { - protoL1BlockInfo.BlobBaseFee = l1blockInfo.BlobBaseFee.Bytes() + mintAmount := sdkmath.NewIntFromBigInt(tx.Mint()) + recipientAddr, err := monomer.CosmosETHAddress(*tx.To()).Encode(addrPrefix) + if err != nil { + return nil, fmt.Errorf("evm to cosmos address: %v", err) } - return protoL1BlockInfo, nil -} + transferAmount := sdkmath.NewIntFromBigInt(tx.Value()) -// processL1UserDepositTxs processes the L1 user deposit txs, mints ETH to the user's cosmos address, -// and returns associated events. -func (k *Keeper) processL1UserDepositTxs( - ctx sdk.Context, //nolint:gocritic // hugeParam - txs []*types.EthDepositTx, - l1blockInfo *types.L1BlockInfo, -) (sdk.Events, error) { - mintEvents := sdk.Events{} - - // skip the first tx - it is the L1 attributes tx - for i := 1; i < len(txs); i++ { - txBytes := txs[i].Tx - var tx ethtypes.Transaction - if err := tx.UnmarshalBinary(txBytes); err != nil { - return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to unmarshal user deposit transaction", "index", i, "err", err) - } - if !tx.IsDepositTx() { - return nil, types.WrapError(types.ErrInvalidL1Txs, "L1 tx must be a user deposit tx, index:%d, type:%d", i, tx.Type()) - } - if tx.IsSystemTx() { - return nil, types.WrapError(types.ErrInvalidL1Txs, "L1 tx must be a user deposit tx, type %d", tx.Type()) - } - ctx.Logger().Debug("User deposit tx", "index", i, "tx", string(lo.Must(tx.MarshalJSON()))) - // if the receipient is nil, it means the tx is creating a contract which we don't support, so return an error. - // see https://github.com/ethereum-optimism/op-geth/blob/v1.101301.0-rc.2/core/state_processor.go#L154 - if tx.To() == nil { - return nil, types.WrapError(types.ErrInvalidL1Txs, "Contract creation txs are not supported, index:%d", i) - } + mintEvent, err := k.mintETH(ctx, mintAddr, recipientAddr, mintAmount, transferAmount) + if err != nil { + return nil, types.WrapError(types.ErrMintETH, "failed to mint ETH for cosmosAddress: %v; err: %v", mintAddr, err) + } + mintEvents = append(mintEvents, *mintEvent) - // Get the sender's address from the transaction - from, err := ethtypes.MakeSigner( - monomer.NewChainConfig(tx.ChainId()), - new(big.Int).SetUint64(l1blockInfo.Number), - l1blockInfo.Time, - ).Sender(&tx) - if err != nil { - return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to get sender address: %v", err) - } - addrPrefix := sdk.GetConfig().GetBech32AccountAddrPrefix() - mintAddr, err := monomer.CosmosETHAddress(from).Encode(addrPrefix) - if err != nil { - return nil, fmt.Errorf("evm to cosmos address: %v", err) - } - mintAmount := sdkmath.NewIntFromBigInt(tx.Mint()) - recipientAddr, err := monomer.CosmosETHAddress(*tx.To()).Encode(addrPrefix) - if err != nil { - return nil, fmt.Errorf("evm to cosmos address: %v", err) - } - transferAmount := sdkmath.NewIntFromBigInt(tx.Value()) + params, err := k.GetParams(ctx) + if err != nil { + return nil, types.WrapError(types.ErrParams, "failed to get params: %v", err) + } - mintEvent, err := k.mintETH(ctx, mintAddr, recipientAddr, mintAmount, transferAmount) - if err != nil { - return nil, types.WrapError(types.ErrMintETH, "failed to mint ETH for cosmosAddress: %v; err: %v", mintAddr, err) - } - mintEvents = append(mintEvents, *mintEvent) + // Convert the L1CrossDomainMessenger address to its L2 aliased address + aliasedL1CrossDomainMessengerAddress := crossdomain.ApplyL1ToL2Alias(common.HexToAddress(params.L1CrossDomainMessenger)) - params, err := k.GetParams(ctx) + // Check if the tx is a cross domain message from the aliased L1CrossDomainMessenger address + if from == aliasedL1CrossDomainMessengerAddress && tx.Data() != nil { + crossDomainMessageEvent, err := k.processCrossDomainMessage(ctx, tx.Data()) + // TODO: Investigate when to return an error if a cross domain message can't be parsed or executed - look at OP Spec if err != nil { - return nil, types.WrapError(types.ErrParams, "failed to get params: %v", err) - } - - // Convert the L1CrossDomainMessenger address to its L2 aliased address - aliasedL1CrossDomainMessengerAddress := crossdomain.ApplyL1ToL2Alias(common.HexToAddress(params.L1CrossDomainMessenger)) - - // Check if the tx is a cross domain message from the aliased L1CrossDomainMessenger address - if from == aliasedL1CrossDomainMessengerAddress && tx.Data() != nil { - crossDomainMessageEvent, err := k.processCrossDomainMessage(ctx, tx.Data()) - // TODO: Investigate when to return an error if a cross domain message can't be parsed or executed - look at OP Spec - if err != nil { - return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to parse or execute cross domain message: %v", err) - } else if crossDomainMessageEvent != nil { - mintEvents = append(mintEvents, *crossDomainMessageEvent) - } + return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to parse or execute cross domain message: %v", err) + } else if crossDomainMessageEvent != nil { + mintEvents = append(mintEvents, *crossDomainMessageEvent) } } diff --git a/x/rollup/keeper/msg_server.go b/x/rollup/keeper/msg_server.go index 00c2e1ba..f09dc056 100644 --- a/x/rollup/keeper/msg_server.go +++ b/x/rollup/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" "math/big" "cosmossdk.io/math" @@ -9,39 +10,36 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/polymerdao/monomer/x/rollup/types" - "github.com/samber/lo" ) var _ types.MsgServer = &Keeper{} -// ApplyL1Txs implements types.MsgServer. -func (k *Keeper) ApplyL1Txs(goCtx context.Context, msg *types.MsgApplyL1Txs) (*types.MsgApplyL1TxsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) +func (k *Keeper) SetL1Attributes(ctx context.Context, msg *types.MsgSetL1Attributes) (*types.MsgSetL1AttributesResponse, error) { + sdkCtx := sdk.UnwrapSDKContext(ctx) + if err := k.SetL1BlockInfo(sdkCtx, *msg.L1BlockInfo); err != nil { + return nil, fmt.Errorf("set l1 block info: %v", err) + } + return &types.MsgSetL1AttributesResponse{}, nil +} - ctx.Logger().Debug("Processing L1 txs", "txCount", len(msg.Txs)) +func (k *Keeper) ApplyUserDeposit(goCtx context.Context, msg *types.MsgApplyUserDeposit) (*types.MsgApplyUserDepositResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) - // process L1 attributes tx and get L1 block info - l1blockInfo, err := k.processL1AttributesTx(ctx, msg.Txs[0].Tx) + // L1BlockInfo is set in SetL1Attributes at the top of the block. + l1blockInfo, err := k.GetL1BlockInfo(ctx) if err != nil { - return nil, types.WrapError(types.ErrProcessL1SystemDepositTx, "err: %v", err) + return nil, fmt.Errorf("get l1 block info: %v", err) } - // save L1 block info to AppState - if err = k.SetL1BlockInfo(ctx, *l1blockInfo); err != nil { - return nil, types.WrapError(types.ErrL1BlockInfo, "save error: %v", err) - } - - ctx.Logger().Debug("Save L1 block info", "l1blockInfo", string(lo.Must(l1blockInfo.Marshal()))) - // process L1 user deposit txs - mintEvents, err := k.processL1UserDepositTxs(ctx, msg.Txs, l1blockInfo) + mintEvents, err := k.processL1UserDepositTxs(ctx, msg, l1blockInfo) if err != nil { return nil, types.WrapError(types.ErrProcessL1UserDepositTxs, "err: %v", err) } k.EmitEvents(goCtx, mintEvents) - return &types.MsgApplyL1TxsResponse{}, nil + return &types.MsgApplyUserDepositResponse{}, nil } func (k *Keeper) InitiateWithdrawal( diff --git a/x/rollup/keeper/msg_server_test.go b/x/rollup/keeper/msg_server_test.go index f1b8e172..c20b9fa2 100644 --- a/x/rollup/keeper/msg_server_test.go +++ b/x/rollup/keeper/msg_server_test.go @@ -1,19 +1,40 @@ package keeper_test import ( + "time" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/ethereum-optimism/optimism/op-service/eth" gethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/golang/mock/gomock" "github.com/polymerdao/monomer/testutils" "github.com/polymerdao/monomer/x/rollup/types" ) -func (s *KeeperTestSuite) TestApplyL1Txs() { +func (s *KeeperTestSuite) TestSetL1Attributes() { + l1AttributesTx, _, _ := testutils.GenerateEthTxs(s.T()) + l1AttributesTxBz := testutils.TxToBytes(s.T(), l1AttributesTx) + _, err := s.rollupKeeper.SetL1Attributes(s.ctx, &types.MsgSetL1Attributes{ + L1BlockInfo: &types.L1BlockInfo{ + Number: 1, + }, + EthTx: l1AttributesTxBz, + }) + s.NoError(err) + + l1BlockInfoBz := s.rollupStore.Get([]byte(types.L1BlockInfoKey)) + s.Require().NotNil(l1BlockInfoBz) + + l1BlockInfo := &types.L1BlockInfo{} + err = l1BlockInfo.Unmarshal(l1BlockInfoBz) + s.Require().NoError(err) + s.Require().Equal(uint64(1), l1BlockInfo.Number) +} + +func (s *KeeperTestSuite) TestApplyUserDeposit() { l1AttributesTx, depositTx, cosmosEthTx := testutils.GenerateEthTxs(s.T()) // The only constraint for a contract creation tx is that it must be a non-system DepositTx with no To field contractCreationTx := gethtypes.NewTx(&gethtypes.DepositTx{}) @@ -24,77 +45,53 @@ func (s *KeeperTestSuite) TestApplyL1Txs() { contractCreationTxBz := testutils.TxToBytes(s.T(), contractCreationTx) invalidTxBz := []byte("invalid tx bytes") + _, err := s.rollupKeeper.SetL1Attributes(s.ctx, &types.MsgSetL1Attributes{ + L1BlockInfo: &types.L1BlockInfo{ + Time: uint64(time.Now().Unix()), + }, + EthTx: l1AttributesTxBz, + }) + s.NoError(err) + tests := map[string]struct { - txBytes [][]byte + txBytes []byte setupMocks func() shouldError bool expectedEventTypes []string }{ - "successful message with no user deposit txs": { - txBytes: [][]byte{l1AttributesTxBz}, - shouldError: false, - expectedEventTypes: []string{ - sdk.EventTypeMessage, - }, - }, "successful message with single user deposit tx": { - txBytes: [][]byte{l1AttributesTxBz, depositTxBz}, + txBytes: depositTxBz, shouldError: false, expectedEventTypes: []string{ sdk.EventTypeMessage, types.EventTypeMintETH, }, }, - "successful message with multiple user deposit txs": { - txBytes: [][]byte{l1AttributesTxBz, depositTxBz, depositTxBz}, - shouldError: false, - expectedEventTypes: []string{ - sdk.EventTypeMessage, - types.EventTypeMintETH, - types.EventTypeMintETH, - }, - }, - "invalid l1 attributes tx bytes": { - txBytes: [][]byte{invalidTxBz, depositTxBz}, - shouldError: true, - }, - "non-deposit tx passed in as l1 attributes tx": { - txBytes: [][]byte{cosmosEthTxBz, depositTxBz}, - shouldError: true, - }, - "user deposit tx passed in as l1 attributes tx": { - txBytes: [][]byte{depositTxBz, depositTxBz}, - shouldError: true, - }, - "invalid user deposit tx bytes": { - txBytes: [][]byte{l1AttributesTxBz, invalidTxBz}, + "invalid deposit tx bytes": { + txBytes: invalidTxBz, shouldError: true, }, "non-deposit tx passed in as user deposit tx": { - txBytes: [][]byte{l1AttributesTxBz, cosmosEthTxBz}, + txBytes: cosmosEthTxBz, shouldError: true, }, "l1 attributes tx passed in as user deposit tx": { - txBytes: [][]byte{l1AttributesTxBz, l1AttributesTxBz}, + txBytes: l1AttributesTxBz, shouldError: true, }, "contract creation tx passed in as user deposit tx": { - txBytes: [][]byte{l1AttributesTxBz, contractCreationTxBz}, - shouldError: true, - }, - "one valid l1 user deposit tx and an invalid tx passed in as user deposit txs": { - txBytes: [][]byte{l1AttributesTxBz, depositTxBz, invalidTxBz}, + txBytes: contractCreationTxBz, shouldError: true, }, "bank keeper mint coins failure": { - txBytes: [][]byte{l1AttributesTxBz, depositTxBz}, + txBytes: depositTxBz, setupMocks: func() { s.bankKeeper.EXPECT().MintCoins(s.ctx, types.ModuleName, gomock.Any()).Return(sdkerrors.ErrUnauthorized) }, shouldError: true, }, "bank keeper send coins failure": { - txBytes: [][]byte{l1AttributesTxBz, depositTxBz}, + txBytes: depositTxBz, setupMocks: func() { s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(s.ctx, types.ModuleName, gomock.Any(), gomock.Any()).Return(sdkerrors.ErrUnknownRequest) }, @@ -109,15 +106,8 @@ func (s *KeeperTestSuite) TestApplyL1Txs() { } s.mockMintETH() - depositTxs := make([]*types.EthDepositTx, 0) - for _, txBytes := range test.txBytes { - depositTxs = append(depositTxs, &types.EthDepositTx{ - Tx: txBytes, - }) - } - - resp, err := s.rollupKeeper.ApplyL1Txs(s.ctx, &types.MsgApplyL1Txs{ - Txs: depositTxs, + resp, err := s.rollupKeeper.ApplyUserDeposit(s.ctx, &types.MsgApplyUserDeposit{ + Tx: test.txBytes, }) if test.shouldError { @@ -131,20 +121,6 @@ func (s *KeeperTestSuite) TestApplyL1Txs() { for i, event := range s.eventManger.Events() { s.Require().Equal(test.expectedEventTypes[i], event.Type) } - - // Verify that the l1 block info and l1 block history are saved to the store - expectedBlockInfo := eth.BlockToInfo(testutils.GenerateL1Block()) - - l1BlockInfoBz := s.rollupStore.Get([]byte(types.L1BlockInfoKey)) - s.Require().NotNil(l1BlockInfoBz) - - l1BlockInfo := &types.L1BlockInfo{} - err = l1BlockInfo.Unmarshal(l1BlockInfoBz) - s.Require().NoError(err) - s.Require().Equal(expectedBlockInfo.NumberU64(), l1BlockInfo.Number) - s.Require().Equal(expectedBlockInfo.BaseFee().Bytes(), l1BlockInfo.BaseFee) - s.Require().Equal(expectedBlockInfo.Time(), l1BlockInfo.Time) - s.Require().Equal(expectedBlockInfo.Hash().Bytes(), l1BlockInfo.BlockHash) } }) } diff --git a/x/rollup/module.go b/x/rollup/module.go index 8d2c0dcb..954f96c3 100644 --- a/x/rollup/module.go +++ b/x/rollup/module.go @@ -46,13 +46,27 @@ type ModuleOutputs struct { } func init() { //nolint:gochecknoinits - appmodule.Register(&modulev1.Module{}, appmodule.Provide(ProvideModule), appmodule.Provide(ProvideCustomGetSigner)) + appmodule.Register( + &modulev1.Module{}, + appmodule.Provide(ProvideModule), + appmodule.Provide(ProvideApplyUserDepositGetSigner), + appmodule.Provide(ProvideSetL1AttributesGetSigner), + ) } -func ProvideCustomGetSigner() signing.CustomGetSigner { +func ProvideApplyUserDepositGetSigner() signing.CustomGetSigner { return signing.CustomGetSigner{ // gocosmos is built on gogoproto, which generates protov1 protobufs, unfortunately. - MsgType: protoreflect.FullName(protov1.MessageName(&types.MsgApplyL1Txs{})), //nolint:staticcheck + MsgType: protoreflect.FullName(protov1.MessageName(&types.MsgApplyUserDeposit{})), //nolint:staticcheck + Fn: func(msg proto.Message) ([][]byte, error) { + return [][]byte{}, nil + }, + } +} + +func ProvideSetL1AttributesGetSigner() signing.CustomGetSigner { + return signing.CustomGetSigner{ + MsgType: protoreflect.FullName(protov1.MessageName(&types.MsgSetL1Attributes{})), //nolint:staticcheck Fn: func(msg proto.Message) ([][]byte, error) { return [][]byte{}, nil }, diff --git a/x/rollup/tests/integration/rollup_test.go b/x/rollup/tests/integration/rollup_test.go index 79c35803..3f75a0d8 100644 --- a/x/rollup/tests/integration/rollup_test.go +++ b/x/rollup/tests/integration/rollup_test.go @@ -75,37 +75,25 @@ func TestRollup(t *testing.T) { require.NoError(t, err) require.Equal(t, math.ZeroInt(), queryERC20Balance(t, bankQueryClient, erc20userCosmosAddr, erc20tokenAddr, integrationApp)) + _, err = integrationApp.RunMsg(&rolluptypes.MsgSetL1Attributes{ + L1BlockInfo: &rolluptypes.L1BlockInfo{}, // Technically incorrect, but it works for this test. + EthTx: l1AttributesTxBz, + }) + require.NoError(t, err) + // send an invalid MsgApplyL1Txs and assert error - _, err = integrationApp.RunMsg(&rolluptypes.MsgApplyL1Txs{ - Txs: []*rolluptypes.EthDepositTx{ - { - Tx: l1AttributesTxBz, - }, - { - Tx: l1AttributesTxBz, - }, - }, + _, err = integrationApp.RunMsg(&rolluptypes.MsgApplyUserDeposit{ + Tx: l1AttributesTxBz, }) require.Error(t, err) // send a successful MsgApplyL1Txs and mint ETH to user - _, err = integrationApp.RunMsg(&rolluptypes.MsgApplyL1Txs{ - Txs: []*rolluptypes.EthDepositTx{ - { - Tx: l1AttributesTxBz, - }, - { - Tx: ethDepositTxBz, - }, - { - Tx: ethBridgeDepositTxBz, - }, - { - Tx: erc20DepositTxBz, - }, - }, - }) - require.NoError(t, err) + for _, txBytes := range [][]byte{ethDepositTxBz, ethBridgeDepositTxBz, erc20DepositTxBz} { + _, err = integrationApp.RunMsg(&rolluptypes.MsgApplyUserDeposit{ + Tx: txBytes, + }) + require.NoError(t, err) + } // query the mint address ETH balance and assert it's equal to the mint amount minus the transfer amount require.Equal(t, new(big.Int).Sub(ethMintAmount, ethTransferAmount), queryETHBalance(t, bankQueryClient, mintAddr, integrationApp).BigInt()) diff --git a/x/rollup/types/deposit_tx.go b/x/rollup/types/deposit_tx.go index ec8cae4e..37672232 100644 --- a/x/rollup/types/deposit_tx.go +++ b/x/rollup/types/deposit_tx.go @@ -10,7 +10,11 @@ import ( var _ sdktypes.Tx = (*DepositsTx)(nil) func (d *DepositsTx) GetMsgs() []proto.Message { - return []proto.Message{d.Deposits} + protoMsgUserDeposits := make([]proto.Message, 0, len(d.UserDeposits)) + for _, userDeposit := range d.UserDeposits { + protoMsgUserDeposits = append(protoMsgUserDeposits, userDeposit) + } + return append([]proto.Message{d.L1Attributes}, protoMsgUserDeposits...) } func (d *DepositsTx) GetMsgsV2() ([]protoreflect.ProtoMessage, error) { diff --git a/x/rollup/types/msgs.go b/x/rollup/types/msgs.go index 938da4aa..4f4a5f1c 100644 --- a/x/rollup/types/msgs.go +++ b/x/rollup/types/msgs.go @@ -1,11 +1,13 @@ package types import ( + "errors" "fmt" "math/big" sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" ) @@ -14,21 +16,45 @@ const ( MaxTxGasLimit = params.MaxGasLimit ) -var _ sdktypes.Msg = (*MsgApplyL1Txs)(nil) +var _ sdktypes.Msg = (*MsgApplyUserDeposit)(nil) -func (m *MsgApplyL1Txs) ValidateBasic() error { - if m.Txs == nil || len(m.Txs) < 1 { - return WrapError(ErrInvalidL1Txs, "must have at least one L1 Info Deposit tx") +func (m *MsgApplyUserDeposit) ValidateBasic() error { + if m.Tx == nil { + return errors.New("tx is nil") } + var tx ethtypes.Transaction + if err := tx.UnmarshalBinary(m.Tx); err != nil { + return fmt.Errorf("unmarshal binary deposit tx: %v", err) + } + if !tx.IsDepositTx() { + return errors.New("tx is not a deposit tx") + } + if tx.IsSystemTx() { + return errors.New("tx must not be a system tx") + } + return nil +} + +func (*MsgApplyUserDeposit) Type() string { + return "apply_user_deposit" +} + +func (*MsgApplyUserDeposit) Route() string { + return ModuleName +} + +var _ sdktypes.Msg = (*MsgSetL1Attributes)(nil) + +func (m *MsgSetL1Attributes) ValidateBasic() error { return nil } -func (*MsgApplyL1Txs) Type() string { - return "l1txs" +func (*MsgSetL1Attributes) Type() string { + return "set_l1_attributes" } -func (*MsgApplyL1Txs) Route() string { - return "rollup" +func (*MsgSetL1Attributes) Route() string { + return ModuleName } var _ sdktypes.Msg = (*MsgInitiateWithdrawal)(nil) @@ -52,5 +78,5 @@ func (*MsgInitiateWithdrawal) Type() string { } func (*MsgInitiateWithdrawal) Route() string { - return "rollup" + return ModuleName } diff --git a/x/rollup/types/tx.pb.go b/x/rollup/types/tx.pb.go index 48642b4f..7130cbe5 100644 --- a/x/rollup/types/tx.pb.go +++ b/x/rollup/types/tx.pb.go @@ -32,8 +32,10 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// DepositsTx is the Cosmos SDK transaction type that wraps OP Stack deposit transactions. type DepositsTx struct { - Deposits *MsgApplyL1Txs `protobuf:"bytes,1,opt,name=deposits,proto3" json:"deposits,omitempty"` + L1Attributes *MsgSetL1Attributes `protobuf:"bytes,1,opt,name=l1_attributes,json=l1Attributes,proto3" json:"l1_attributes,omitempty"` + UserDeposits []*MsgApplyUserDeposit `protobuf:"bytes,2,rep,name=user_deposits,json=userDeposits,proto3" json:"user_deposits,omitempty"` } func (m *DepositsTx) Reset() { *m = DepositsTx{} } @@ -69,31 +71,38 @@ func (m *DepositsTx) XXX_DiscardUnknown() { var xxx_messageInfo_DepositsTx proto.InternalMessageInfo -func (m *DepositsTx) GetDeposits() *MsgApplyL1Txs { +func (m *DepositsTx) GetL1Attributes() *MsgSetL1Attributes { if m != nil { - return m.Deposits + return m.L1Attributes } return nil } -// DepositTx is a eth deposit tx. -type EthDepositTx struct { - // tx is the marshaled Ethereum Deposit tx. - Tx []byte `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"` +func (m *DepositsTx) GetUserDeposits() []*MsgApplyUserDeposit { + if m != nil { + return m.UserDeposits + } + return nil } -func (m *EthDepositTx) Reset() { *m = EthDepositTx{} } -func (m *EthDepositTx) String() string { return proto.CompactTextString(m) } -func (*EthDepositTx) ProtoMessage() {} -func (*EthDepositTx) Descriptor() ([]byte, []int) { +// MsgSetL1Attributes is the l1 attributes message. +type MsgSetL1Attributes struct { + L1BlockInfo *L1BlockInfo `protobuf:"bytes,1,opt,name=l1_block_info,json=l1BlockInfo,proto3" json:"l1_block_info,omitempty"` + EthTx []byte `protobuf:"bytes,2,opt,name=eth_tx,json=ethTx,proto3" json:"eth_tx,omitempty"` +} + +func (m *MsgSetL1Attributes) Reset() { *m = MsgSetL1Attributes{} } +func (m *MsgSetL1Attributes) String() string { return proto.CompactTextString(m) } +func (*MsgSetL1Attributes) ProtoMessage() {} +func (*MsgSetL1Attributes) Descriptor() ([]byte, []int) { return fileDescriptor_106533843870de0f, []int{1} } -func (m *EthDepositTx) XXX_Unmarshal(b []byte) error { +func (m *MsgSetL1Attributes) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *EthDepositTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSetL1Attributes) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_EthDepositTx.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSetL1Attributes.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -103,43 +112,87 @@ func (m *EthDepositTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *EthDepositTx) XXX_Merge(src proto.Message) { - xxx_messageInfo_EthDepositTx.Merge(m, src) +func (m *MsgSetL1Attributes) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetL1Attributes.Merge(m, src) } -func (m *EthDepositTx) XXX_Size() int { +func (m *MsgSetL1Attributes) XXX_Size() int { return m.Size() } -func (m *EthDepositTx) XXX_DiscardUnknown() { - xxx_messageInfo_EthDepositTx.DiscardUnknown(m) +func (m *MsgSetL1Attributes) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetL1Attributes.DiscardUnknown(m) } -var xxx_messageInfo_EthDepositTx proto.InternalMessageInfo +var xxx_messageInfo_MsgSetL1Attributes proto.InternalMessageInfo -func (m *EthDepositTx) GetTx() []byte { +func (m *MsgSetL1Attributes) GetL1BlockInfo() *L1BlockInfo { if m != nil { - return m.Tx + return m.L1BlockInfo + } + return nil +} + +func (m *MsgSetL1Attributes) GetEthTx() []byte { + if m != nil { + return m.EthTx } return nil } -// MsgApplyL1Txs defines the message for applying all L1 system and user deposit txs. -type MsgApplyL1Txs struct { - // txs are all of the system and user deposit txs. - Txs []*EthDepositTx `protobuf:"bytes,1,rep,name=txs,proto3" json:"txs,omitempty"` +// MsgSetL1AttributesResponse defines the SetL1Attributes response type. +type MsgSetL1AttributesResponse struct { } -func (m *MsgApplyL1Txs) Reset() { *m = MsgApplyL1Txs{} } -func (m *MsgApplyL1Txs) String() string { return proto.CompactTextString(m) } -func (*MsgApplyL1Txs) ProtoMessage() {} -func (*MsgApplyL1Txs) Descriptor() ([]byte, []int) { +func (m *MsgSetL1AttributesResponse) Reset() { *m = MsgSetL1AttributesResponse{} } +func (m *MsgSetL1AttributesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetL1AttributesResponse) ProtoMessage() {} +func (*MsgSetL1AttributesResponse) Descriptor() ([]byte, []int) { return fileDescriptor_106533843870de0f, []int{2} } -func (m *MsgApplyL1Txs) XXX_Unmarshal(b []byte) error { +func (m *MsgSetL1AttributesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetL1AttributesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetL1AttributesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetL1AttributesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetL1AttributesResponse.Merge(m, src) +} +func (m *MsgSetL1AttributesResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetL1AttributesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetL1AttributesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetL1AttributesResponse proto.InternalMessageInfo + +// MsgApplyUserDeposit is a eth deposit tx. +type MsgApplyUserDeposit struct { + // tx is the marshaled Ethereum Deposit tx. + Tx []byte `protobuf:"bytes,1,opt,name=tx,proto3" json:"tx,omitempty"` +} + +func (m *MsgApplyUserDeposit) Reset() { *m = MsgApplyUserDeposit{} } +func (m *MsgApplyUserDeposit) String() string { return proto.CompactTextString(m) } +func (*MsgApplyUserDeposit) ProtoMessage() {} +func (*MsgApplyUserDeposit) Descriptor() ([]byte, []int) { + return fileDescriptor_106533843870de0f, []int{3} +} +func (m *MsgApplyUserDeposit) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgApplyL1Txs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgApplyUserDeposit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgApplyL1Txs.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgApplyUserDeposit.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -149,41 +202,41 @@ func (m *MsgApplyL1Txs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return b[:n], nil } } -func (m *MsgApplyL1Txs) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgApplyL1Txs.Merge(m, src) +func (m *MsgApplyUserDeposit) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgApplyUserDeposit.Merge(m, src) } -func (m *MsgApplyL1Txs) XXX_Size() int { +func (m *MsgApplyUserDeposit) XXX_Size() int { return m.Size() } -func (m *MsgApplyL1Txs) XXX_DiscardUnknown() { - xxx_messageInfo_MsgApplyL1Txs.DiscardUnknown(m) +func (m *MsgApplyUserDeposit) XXX_DiscardUnknown() { + xxx_messageInfo_MsgApplyUserDeposit.DiscardUnknown(m) } -var xxx_messageInfo_MsgApplyL1Txs proto.InternalMessageInfo +var xxx_messageInfo_MsgApplyUserDeposit proto.InternalMessageInfo -func (m *MsgApplyL1Txs) GetTxs() []*EthDepositTx { +func (m *MsgApplyUserDeposit) GetTx() []byte { if m != nil { - return m.Txs + return m.Tx } return nil } -// MsgApplyL1TxsResponse defines the Msg/ApplyL1Txs response type. -type MsgApplyL1TxsResponse struct { +// MsgApplyUserDepositResponse defines the ApplyUserDeposit response type. +type MsgApplyUserDepositResponse struct { } -func (m *MsgApplyL1TxsResponse) Reset() { *m = MsgApplyL1TxsResponse{} } -func (m *MsgApplyL1TxsResponse) String() string { return proto.CompactTextString(m) } -func (*MsgApplyL1TxsResponse) ProtoMessage() {} -func (*MsgApplyL1TxsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_106533843870de0f, []int{3} +func (m *MsgApplyUserDepositResponse) Reset() { *m = MsgApplyUserDepositResponse{} } +func (m *MsgApplyUserDepositResponse) String() string { return proto.CompactTextString(m) } +func (*MsgApplyUserDepositResponse) ProtoMessage() {} +func (*MsgApplyUserDepositResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_106533843870de0f, []int{4} } -func (m *MsgApplyL1TxsResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgApplyUserDepositResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgApplyL1TxsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgApplyUserDepositResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgApplyL1TxsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgApplyUserDepositResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -193,17 +246,17 @@ func (m *MsgApplyL1TxsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *MsgApplyL1TxsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgApplyL1TxsResponse.Merge(m, src) +func (m *MsgApplyUserDepositResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgApplyUserDepositResponse.Merge(m, src) } -func (m *MsgApplyL1TxsResponse) XXX_Size() int { +func (m *MsgApplyUserDepositResponse) XXX_Size() int { return m.Size() } -func (m *MsgApplyL1TxsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgApplyL1TxsResponse.DiscardUnknown(m) +func (m *MsgApplyUserDepositResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgApplyUserDepositResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgApplyL1TxsResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgApplyUserDepositResponse proto.InternalMessageInfo // MsgInitiateWithdrawal defines the message for initiating an L2 withdrawal. type MsgInitiateWithdrawal struct { @@ -223,7 +276,7 @@ func (m *MsgInitiateWithdrawal) Reset() { *m = MsgInitiateWithdrawal{} } func (m *MsgInitiateWithdrawal) String() string { return proto.CompactTextString(m) } func (*MsgInitiateWithdrawal) ProtoMessage() {} func (*MsgInitiateWithdrawal) Descriptor() ([]byte, []int) { - return fileDescriptor_106533843870de0f, []int{4} + return fileDescriptor_106533843870de0f, []int{5} } func (m *MsgInitiateWithdrawal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -288,7 +341,7 @@ func (m *MsgInitiateWithdrawalResponse) Reset() { *m = MsgInitiateWithdr func (m *MsgInitiateWithdrawalResponse) String() string { return proto.CompactTextString(m) } func (*MsgInitiateWithdrawalResponse) ProtoMessage() {} func (*MsgInitiateWithdrawalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_106533843870de0f, []int{5} + return fileDescriptor_106533843870de0f, []int{6} } func (m *MsgInitiateWithdrawalResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -327,7 +380,7 @@ func (m *MsgInitiateFeeWithdrawal) Reset() { *m = MsgInitiateFeeWithdraw func (m *MsgInitiateFeeWithdrawal) String() string { return proto.CompactTextString(m) } func (*MsgInitiateFeeWithdrawal) ProtoMessage() {} func (*MsgInitiateFeeWithdrawal) Descriptor() ([]byte, []int) { - return fileDescriptor_106533843870de0f, []int{6} + return fileDescriptor_106533843870de0f, []int{7} } func (m *MsgInitiateFeeWithdrawal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -371,7 +424,7 @@ func (m *MsgInitiateFeeWithdrawalResponse) Reset() { *m = MsgInitiateFee func (m *MsgInitiateFeeWithdrawalResponse) String() string { return proto.CompactTextString(m) } func (*MsgInitiateFeeWithdrawalResponse) ProtoMessage() {} func (*MsgInitiateFeeWithdrawalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_106533843870de0f, []int{7} + return fileDescriptor_106533843870de0f, []int{8} } func (m *MsgInitiateFeeWithdrawalResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -413,7 +466,7 @@ func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} } func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParams) ProtoMessage() {} func (*MsgUpdateParams) Descriptor() ([]byte, []int) { - return fileDescriptor_106533843870de0f, []int{8} + return fileDescriptor_106533843870de0f, []int{9} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -464,7 +517,7 @@ func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateParamsResponse) ProtoMessage() {} func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_106533843870de0f, []int{9} + return fileDescriptor_106533843870de0f, []int{10} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -495,9 +548,10 @@ var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo func init() { proto.RegisterType((*DepositsTx)(nil), "rollup.v1.DepositsTx") - proto.RegisterType((*EthDepositTx)(nil), "rollup.v1.EthDepositTx") - proto.RegisterType((*MsgApplyL1Txs)(nil), "rollup.v1.MsgApplyL1Txs") - proto.RegisterType((*MsgApplyL1TxsResponse)(nil), "rollup.v1.MsgApplyL1TxsResponse") + proto.RegisterType((*MsgSetL1Attributes)(nil), "rollup.v1.MsgSetL1Attributes") + proto.RegisterType((*MsgSetL1AttributesResponse)(nil), "rollup.v1.MsgSetL1AttributesResponse") + proto.RegisterType((*MsgApplyUserDeposit)(nil), "rollup.v1.MsgApplyUserDeposit") + proto.RegisterType((*MsgApplyUserDepositResponse)(nil), "rollup.v1.MsgApplyUserDepositResponse") proto.RegisterType((*MsgInitiateWithdrawal)(nil), "rollup.v1.MsgInitiateWithdrawal") proto.RegisterType((*MsgInitiateWithdrawalResponse)(nil), "rollup.v1.MsgInitiateWithdrawalResponse") proto.RegisterType((*MsgInitiateFeeWithdrawal)(nil), "rollup.v1.MsgInitiateFeeWithdrawal") @@ -509,47 +563,53 @@ func init() { func init() { proto.RegisterFile("rollup/v1/tx.proto", fileDescriptor_106533843870de0f) } var fileDescriptor_106533843870de0f = []byte{ - // 630 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4f, 0x4f, 0x13, 0x41, - 0x14, 0xef, 0xb6, 0xd0, 0xd0, 0x57, 0xc4, 0x30, 0x01, 0xba, 0xac, 0x71, 0x21, 0xeb, 0x05, 0x51, - 0x76, 0xa1, 0x12, 0x0f, 0xdc, 0x68, 0x94, 0x48, 0x02, 0xc6, 0x54, 0x8c, 0xd1, 0x0b, 0x0e, 0xec, - 0x64, 0x3a, 0x71, 0x77, 0x67, 0xb3, 0x33, 0xc5, 0xed, 0xcd, 0xf8, 0x05, 0xf4, 0x63, 0x78, 0xe4, - 0xc0, 0x87, 0xe0, 0x48, 0x38, 0x19, 0x0f, 0xc4, 0xc0, 0x81, 0x0f, 0xe0, 0x17, 0x30, 0x3b, 0x3b, - 0x94, 0x16, 0xdb, 0x60, 0xe2, 0xa5, 0xd9, 0xf7, 0xde, 0xef, 0xcf, 0xeb, 0x7b, 0x2f, 0x03, 0x28, - 0xe1, 0x41, 0xd0, 0x8e, 0xbd, 0x83, 0x15, 0x4f, 0xa6, 0x6e, 0x9c, 0x70, 0xc9, 0x51, 0x25, 0xcf, - 0xb9, 0x07, 0x2b, 0xd6, 0x24, 0x0e, 0x59, 0xc4, 0x3d, 0xf5, 0x9b, 0x57, 0xad, 0xda, 0x3e, 0x17, - 0x21, 0x17, 0x5e, 0x28, 0x68, 0xc6, 0x0a, 0x05, 0xd5, 0x85, 0xd9, 0xbc, 0xb0, 0xab, 0x22, 0x2f, - 0x0f, 0x74, 0x69, 0x8a, 0x72, 0xca, 0xf3, 0x7c, 0xf6, 0xa5, 0xb3, 0x33, 0xd7, 0xde, 0xda, 0x51, - 0xe5, 0x9d, 0x06, 0xc0, 0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1, - 0x07, 0xb2, 0x1e, 0xfd, 0x03, 0xa8, 0x6b, 0xf5, 0x12, 0xc6, 0xfb, 0xf6, 0x68, 0xf5, 0x93, 0x7b, - 0x6b, 0x96, 0x33, 0xbc, 0x76, 0xa5, 0x67, 0x8d, 0x7e, 0xce, 0x16, 0xd5, 0xd8, 0x38, 0x3e, 0xb7, - 0x8d, 0x93, 0x73, 0xdb, 0xf8, 0x75, 0x6e, 0x1b, 0xdf, 0x2e, 0xec, 0xc2, 0xc9, 0x85, 0x5d, 0xf8, - 0x71, 0x61, 0x17, 0xde, 0x3f, 0xa6, 0x4c, 0xb6, 0xda, 0x7b, 0xee, 0x3e, 0x0f, 0xbd, 0x98, 0x07, - 0x9d, 0x90, 0x24, 0x3e, 0xe6, 0x5e, 0xc8, 0x23, 0x1e, 0x92, 0xc4, 0x4b, 0xf5, 0x6b, 0xe5, 0xc9, - 0x4e, 0x4c, 0xc4, 0x5e, 0x59, 0x3d, 0x5a, 0x4f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x79, 0xed, - 0x71, 0xf2, 0x4a, 0x05, 0x00, 0x00, + // 727 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcf, 0x4e, 0xdb, 0x4c, + 0x10, 0x8f, 0x13, 0x12, 0x7d, 0x99, 0x04, 0xf8, 0xd8, 0x8f, 0x80, 0x31, 0x1f, 0x21, 0x72, 0x45, + 0x15, 0xd1, 0x12, 0x93, 0xb4, 0xea, 0x81, 0x1b, 0x69, 0x85, 0x14, 0x89, 0x54, 0x95, 0x01, 0xa1, + 0x72, 0x49, 0x37, 0x78, 0x71, 0x2c, 0x6c, 0xaf, 0xe5, 0xdd, 0xd0, 0xe4, 0x56, 0xf5, 0x05, 0xda, + 0x4b, 0xdf, 0xa1, 0x47, 0x0e, 0x3c, 0x04, 0x47, 0xc4, 0xa9, 0xea, 0x01, 0x55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0x31, + 0x04, 0x52, 0x9e, 0xfd, 0x01, 0xa8, 0x27, 0xf5, 0x16, 0xd2, 0x43, 0x23, 0xa3, 0x0c, 0x27, 0x0f, + 0xc6, 0x14, 0xf5, 0xe1, 0x58, 0x97, 0x4f, 0x89, 0x7f, 0xea, 0xcc, 0x44, 0x79, 0xeb, 0xfc, 0x3a, + 0x2b, 0x5d, 0x5c, 0x67, 0xa5, 0x5f, 0xd7, 0x59, 0xe9, 0xeb, 0x4d, 0x36, 0x72, 0x71, 0x93, 0x8d, + 0xfc, 0xb8, 0xc9, 0x46, 0x0e, 0x9e, 0x9b, 0x16, 0x6f, 0x34, 0xeb, 0x85, 0x43, 0xea, 0x68, 0x1e, + 0xb5, 0xdb, 0x0e, 0xf1, 0x0d, 0x4c, 0x35, 0x87, 0xba, 0xd4, 0x21, 0xbe, 0xd6, 0x12, 0x8f, 0xb8, + 0xc6, 0xdb, 0x1e, 0x61, 0xf5, 0x44, 0xf0, 0x96, 0xbf, 0xf8, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x14, + 0xe6, 0x85, 0x5e, 0x61, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -564,8 +624,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // ApplyL1Txs defines a method for applying applying all L1 system and user deposit txs. - ApplyL1Txs(ctx context.Context, in *MsgApplyL1Txs, opts ...grpc.CallOption) (*MsgApplyL1TxsResponse, error) + // SetL1Attributes sets the l1 attributes in the L2 state. + SetL1Attributes(ctx context.Context, in *MsgSetL1Attributes, opts ...grpc.CallOption) (*MsgSetL1AttributesResponse, error) + // ApplyUserDeposit defines a method for applying a user deposit tx. + ApplyUserDeposit(ctx context.Context, in *MsgApplyUserDeposit, opts ...grpc.CallOption) (*MsgApplyUserDepositResponse, error) // InitiateWithdrawal defines a method for initiating a withdrawal from L2 to L1. InitiateWithdrawal(ctx context.Context, in *MsgInitiateWithdrawal, opts ...grpc.CallOption) (*MsgInitiateWithdrawalResponse, error) // InitiateFeeWithdrawal defines a method for initiating a withdrawal of fees from L2 to the L1 fee recipient address. @@ -582,9 +644,18 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) ApplyL1Txs(ctx context.Context, in *MsgApplyL1Txs, opts ...grpc.CallOption) (*MsgApplyL1TxsResponse, error) { - out := new(MsgApplyL1TxsResponse) - err := c.cc.Invoke(ctx, "/rollup.v1.Msg/ApplyL1Txs", in, out, opts...) +func (c *msgClient) SetL1Attributes(ctx context.Context, in *MsgSetL1Attributes, opts ...grpc.CallOption) (*MsgSetL1AttributesResponse, error) { + out := new(MsgSetL1AttributesResponse) + err := c.cc.Invoke(ctx, "/rollup.v1.Msg/SetL1Attributes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ApplyUserDeposit(ctx context.Context, in *MsgApplyUserDeposit, opts ...grpc.CallOption) (*MsgApplyUserDepositResponse, error) { + out := new(MsgApplyUserDepositResponse) + err := c.cc.Invoke(ctx, "/rollup.v1.Msg/ApplyUserDeposit", in, out, opts...) if err != nil { return nil, err } @@ -620,8 +691,10 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts // MsgServer is the server API for Msg service. type MsgServer interface { - // ApplyL1Txs defines a method for applying applying all L1 system and user deposit txs. - ApplyL1Txs(context.Context, *MsgApplyL1Txs) (*MsgApplyL1TxsResponse, error) + // SetL1Attributes sets the l1 attributes in the L2 state. + SetL1Attributes(context.Context, *MsgSetL1Attributes) (*MsgSetL1AttributesResponse, error) + // ApplyUserDeposit defines a method for applying a user deposit tx. + ApplyUserDeposit(context.Context, *MsgApplyUserDeposit) (*MsgApplyUserDepositResponse, error) // InitiateWithdrawal defines a method for initiating a withdrawal from L2 to L1. InitiateWithdrawal(context.Context, *MsgInitiateWithdrawal) (*MsgInitiateWithdrawalResponse, error) // InitiateFeeWithdrawal defines a method for initiating a withdrawal of fees from L2 to the L1 fee recipient address. @@ -634,8 +707,11 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) ApplyL1Txs(ctx context.Context, req *MsgApplyL1Txs) (*MsgApplyL1TxsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ApplyL1Txs not implemented") +func (*UnimplementedMsgServer) SetL1Attributes(ctx context.Context, req *MsgSetL1Attributes) (*MsgSetL1AttributesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetL1Attributes not implemented") +} +func (*UnimplementedMsgServer) ApplyUserDeposit(ctx context.Context, req *MsgApplyUserDeposit) (*MsgApplyUserDepositResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ApplyUserDeposit not implemented") } func (*UnimplementedMsgServer) InitiateWithdrawal(ctx context.Context, req *MsgInitiateWithdrawal) (*MsgInitiateWithdrawalResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method InitiateWithdrawal not implemented") @@ -651,20 +727,38 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_ApplyL1Txs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgApplyL1Txs) +func _Msg_SetL1Attributes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetL1Attributes) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetL1Attributes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rollup.v1.Msg/SetL1Attributes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetL1Attributes(ctx, req.(*MsgSetL1Attributes)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ApplyUserDeposit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgApplyUserDeposit) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).ApplyL1Txs(ctx, in) + return srv.(MsgServer).ApplyUserDeposit(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rollup.v1.Msg/ApplyL1Txs", + FullMethod: "/rollup.v1.Msg/ApplyUserDeposit", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ApplyL1Txs(ctx, req.(*MsgApplyL1Txs)) + return srv.(MsgServer).ApplyUserDeposit(ctx, req.(*MsgApplyUserDeposit)) } return interceptor(ctx, in, info, handler) } @@ -728,8 +822,12 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "ApplyL1Txs", - Handler: _Msg_ApplyL1Txs_Handler, + MethodName: "SetL1Attributes", + Handler: _Msg_SetL1Attributes_Handler, + }, + { + MethodName: "ApplyUserDeposit", + Handler: _Msg_ApplyUserDeposit_Handler, }, { MethodName: "InitiateWithdrawal", @@ -768,9 +866,23 @@ func (m *DepositsTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Deposits != nil { + if len(m.UserDeposits) > 0 { + for iNdEx := len(m.UserDeposits) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UserDeposits[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.L1Attributes != nil { { - size, err := m.Deposits.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.L1Attributes.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -783,7 +895,7 @@ func (m *DepositsTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *EthDepositTx) Marshal() (dAtA []byte, err error) { +func (m *MsgSetL1Attributes) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -793,27 +905,39 @@ func (m *EthDepositTx) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *EthDepositTx) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSetL1Attributes) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *EthDepositTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSetL1Attributes) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Tx) > 0 { - i -= len(m.Tx) - copy(dAtA[i:], m.Tx) - i = encodeVarintTx(dAtA, i, uint64(len(m.Tx))) + if len(m.EthTx) > 0 { + i -= len(m.EthTx) + copy(dAtA[i:], m.EthTx) + i = encodeVarintTx(dAtA, i, uint64(len(m.EthTx))) + i-- + dAtA[i] = 0x12 + } + if m.L1BlockInfo != nil { + { + size, err := m.L1BlockInfo.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgApplyL1Txs) Marshal() (dAtA []byte, err error) { +func (m *MsgSetL1AttributesResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -823,34 +947,50 @@ func (m *MsgApplyL1Txs) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgApplyL1Txs) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSetL1AttributesResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgApplyL1Txs) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSetL1AttributesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Txs) > 0 { - for iNdEx := len(m.Txs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Txs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + return len(dAtA) - i, nil +} + +func (m *MsgApplyUserDeposit) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgApplyUserDeposit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgApplyUserDeposit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Tx) > 0 { + i -= len(m.Tx) + copy(dAtA[i:], m.Tx) + i = encodeVarintTx(dAtA, i, uint64(len(m.Tx))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *MsgApplyL1TxsResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgApplyUserDepositResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -860,12 +1000,12 @@ func (m *MsgApplyL1TxsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgApplyL1TxsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgApplyUserDepositResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgApplyL1TxsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgApplyUserDepositResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1090,42 +1230,59 @@ func (m *DepositsTx) Size() (n int) { } var l int _ = l - if m.Deposits != nil { - l = m.Deposits.Size() + if m.L1Attributes != nil { + l = m.L1Attributes.Size() n += 1 + l + sovTx(uint64(l)) } + if len(m.UserDeposits) > 0 { + for _, e := range m.UserDeposits { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } return n } -func (m *EthDepositTx) Size() (n int) { +func (m *MsgSetL1Attributes) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Tx) + if m.L1BlockInfo != nil { + l = m.L1BlockInfo.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.EthTx) if l > 0 { n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgApplyL1Txs) Size() (n int) { +func (m *MsgSetL1AttributesResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Txs) > 0 { - for _, e := range m.Txs { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } + return n +} + +func (m *MsgApplyUserDeposit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Tx) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } return n } -func (m *MsgApplyL1TxsResponse) Size() (n int) { +func (m *MsgApplyUserDepositResponse) Size() (n int) { if m == nil { return 0 } @@ -1253,7 +1410,7 @@ func (m *DepositsTx) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Deposits", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field L1Attributes", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1280,10 +1437,44 @@ func (m *DepositsTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Deposits == nil { - m.Deposits = &MsgApplyL1Txs{} + if m.L1Attributes == nil { + m.L1Attributes = &MsgSetL1Attributes{} + } + if err := m.L1Attributes.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserDeposits", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF } - if err := m.Deposits.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.UserDeposits = append(m.UserDeposits, &MsgApplyUserDeposit{}) + if err := m.UserDeposits[len(m.UserDeposits)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1308,7 +1499,7 @@ func (m *DepositsTx) Unmarshal(dAtA []byte) error { } return nil } -func (m *EthDepositTx) Unmarshal(dAtA []byte) error { +func (m *MsgSetL1Attributes) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1331,15 +1522,51 @@ func (m *EthDepositTx) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EthDepositTx: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSetL1Attributes: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EthDepositTx: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSetL1Attributes: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tx", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field L1BlockInfo", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.L1BlockInfo == nil { + m.L1BlockInfo = &L1BlockInfo{} + } + if err := m.L1BlockInfo.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EthTx", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -1366,9 +1593,9 @@ func (m *EthDepositTx) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Tx = append(m.Tx[:0], dAtA[iNdEx:postIndex]...) - if m.Tx == nil { - m.Tx = []byte{} + m.EthTx = append(m.EthTx[:0], dAtA[iNdEx:postIndex]...) + if m.EthTx == nil { + m.EthTx = []byte{} } iNdEx = postIndex default: @@ -1392,7 +1619,57 @@ func (m *EthDepositTx) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgApplyL1Txs) Unmarshal(dAtA []byte) error { +func (m *MsgSetL1AttributesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetL1AttributesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetL1AttributesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgApplyUserDeposit) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1415,17 +1692,17 @@ func (m *MsgApplyL1Txs) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgApplyL1Txs: wiretype end group for non-group") + return fmt.Errorf("proto: MsgApplyUserDeposit: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgApplyL1Txs: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgApplyUserDeposit: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Txs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Tx", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1435,24 +1712,24 @@ func (m *MsgApplyL1Txs) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Txs = append(m.Txs, &EthDepositTx{}) - if err := m.Txs[len(m.Txs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Tx = append(m.Tx[:0], dAtA[iNdEx:postIndex]...) + if m.Tx == nil { + m.Tx = []byte{} } iNdEx = postIndex default: @@ -1476,7 +1753,7 @@ func (m *MsgApplyL1Txs) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgApplyL1TxsResponse) Unmarshal(dAtA []byte) error { +func (m *MsgApplyUserDepositResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1499,10 +1776,10 @@ func (m *MsgApplyL1TxsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgApplyL1TxsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgApplyUserDepositResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgApplyL1TxsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgApplyUserDepositResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: