diff --git a/builder/builder.go b/builder/builder.go index ec9a65ec..38acafe0 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -291,8 +291,9 @@ func (b *Builder) parseWithdrawalMessages( } for _, msg := range cosmosTx.GetBody().GetMessages() { userWithdrawalMsgType := cdctypes.MsgTypeURL(new(rolluptypes.MsgInitiateWithdrawal)) + erc20WithdrawalMsgType := cdctypes.MsgTypeURL(new(rolluptypes.MsgInitiateERC20Withdrawal)) feeWithdrawalMsgType := cdctypes.MsgTypeURL(new(rolluptypes.MsgInitiateFeeWithdrawal)) - if msg.TypeUrl == userWithdrawalMsgType || msg.TypeUrl == feeWithdrawalMsgType { + if msg.TypeUrl == userWithdrawalMsgType || msg.TypeUrl == feeWithdrawalMsgType || msg.TypeUrl == erc20WithdrawalMsgType { // Store the withdrawal message hash in the monomer EVM state db and populate the nonce in the event data. err := b.storeWithdrawalMsgInEVM(execTxResult, ethState, header) if err != nil { @@ -362,11 +363,17 @@ func parseWithdrawalEventAttributes(withdrawalEvent *abcitypes.Event) (*crossdom for _, attr := range withdrawalEvent.Attributes { switch attr.Key { case rolluptypes.AttributeKeySender: - senderCosmosAddress, err := sdk.AccAddressFromBech32(attr.Value) - if err != nil { - return nil, fmt.Errorf("convert sender to cosmos address: %v", err) + // check whether the sender address should be encoded as an Ethereum address or a Cosmos address + var sender common.Address + if common.IsHexAddress(attr.Value) { + sender = common.HexToAddress(attr.Value) + } else { + senderCosmosAddress, err := sdk.AccAddressFromBech32(attr.Value) + if err != nil { + return nil, fmt.Errorf("convert sender to cosmos address: %v", err) + } + sender = common.BytesToAddress(senderCosmosAddress.Bytes()) } - sender := common.BytesToAddress(senderCosmosAddress.Bytes()) params.Sender = &sender case rolluptypes.AttributeKeyL1Target: target := common.HexToAddress(attr.Value) diff --git a/proto/rollup/v1/tx.proto b/proto/rollup/v1/tx.proto index 8036b9e9..3efef77f 100644 --- a/proto/rollup/v1/tx.proto +++ b/proto/rollup/v1/tx.proto @@ -20,9 +20,12 @@ service Msg { // 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. + // InitiateWithdrawal defines a method for initiating an ETH withdrawal from L2 to L1. rpc InitiateWithdrawal(MsgInitiateWithdrawal) returns (MsgInitiateWithdrawalResponse); + // InitiateERC20Withdrawal defines a method for initiating an ERC-20 withdrawal from L2 to L1. + rpc InitiateERC20Withdrawal(MsgInitiateERC20Withdrawal) returns (MsgInitiateERC20WithdrawalResponse); + // InitiateFeeWithdrawal defines a method for initiating a withdrawal of fees from L2 to the L1 fee recipient address. rpc InitiateFeeWithdrawal(MsgInitiateFeeWithdrawal) returns (MsgInitiateFeeWithdrawalResponse); @@ -54,7 +57,7 @@ message MsgApplyUserDeposit { // MsgApplyUserDepositResponse defines the ApplyUserDeposit response type. message MsgApplyUserDepositResponse {} -// MsgInitiateWithdrawal defines the message for initiating an L2 withdrawal. +// MsgInitiateWithdrawal defines the message for initiating an L2 ETH withdrawal. message MsgInitiateWithdrawal { option (cosmos.msg.v1.signer) = "sender"; @@ -78,6 +81,32 @@ message MsgInitiateWithdrawal { // MsgInitiateWithdrawalResponse defines the Msg/InitiateWithdrawal response type. message MsgInitiateWithdrawalResponse {} +// MsgInitiateERC20Withdrawal defines the message for initiating an L2 ERC-20 withdrawal. +message MsgInitiateERC20Withdrawal { + option (cosmos.msg.v1.signer) = "sender"; + + // The cosmos address of the user who wants to withdraw from L2. + string sender = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + // The ethereum address on L1 that the user wants to withdraw to. + string target = 2; + // The address of the ERC-20 token contract on L1. + string token_address = 3; + // The amount of ERC-20 tokens that the user wants to withdraw. + string value = 4 [ + (cosmos_proto.scalar) = "cosmos.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true + ]; + // Minimum gas limit for executing the message on L1. + bytes gas_limit = 5; + // Extra data to forward to L1 target. + bytes extra_data = 6; +} + +// MsgInitiateERC20WithdrawalResponse defines the Msg/InitiateERC20Withdrawal response type. +message MsgInitiateERC20WithdrawalResponse {} + // MsgInitiateFeeWithdrawal defines the message for initiating an L2 fee withdrawal to the L1 fee recipient address. message MsgInitiateFeeWithdrawal { option (cosmos.msg.v1.signer) = "sender"; diff --git a/x/rollup/keeper/deposits.go b/x/rollup/keeper/deposits.go index 6c1a7308..ae3a2f30 100644 --- a/x/rollup/keeper/deposits.go +++ b/x/rollup/keeper/deposits.go @@ -246,7 +246,7 @@ func (k *Keeper) mintERC20( amount sdkmath.Int, ) (*sdk.Event, error) { // use the "erc20/{l1erc20addr}" format for the coin denom - coin := sdk.NewCoin("erc20/"+erc20addr[2:], amount) + coin := sdk.NewCoin(getERC20Denom(erc20addr), amount) if err := k.bankkeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(coin)); err != nil { return nil, fmt.Errorf("failed to mint ERC-20 deposit coins to the rollup module: %v", err) } diff --git a/x/rollup/keeper/keeper.go b/x/rollup/keeper/keeper.go index ec2e8ed2..6bcd2756 100644 --- a/x/rollup/keeper/keeper.go +++ b/x/rollup/keeper/keeper.go @@ -102,3 +102,9 @@ func (k *Keeper) SetParams(ctx sdk.Context, params *types.Params) error { //noli } return nil } + +// getERC20Denom returns the Monomer L2 coin denom for the given ERC-20 L1 address. +// The "erc20/{l1erc20addr}" format is used for the L2 coin denom. +func getERC20Denom(erc20Addr string) string { + return "erc20/" + erc20Addr[2:] +} diff --git a/x/rollup/keeper/keeper_test.go b/x/rollup/keeper/keeper_test.go index 492ac493..3f75f158 100644 --- a/x/rollup/keeper/keeper_test.go +++ b/x/rollup/keeper/keeper_test.go @@ -61,12 +61,12 @@ func (s *KeeperTestSuite) setup() { s.eventManger = sdkCtx.EventManager() } -func (s *KeeperTestSuite) mockBurnETH() { +func (s *KeeperTestSuite) mockBurn() { s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(s.ctx, gomock.Any(), types.ModuleName, gomock.Any()).Return(nil).AnyTimes() s.bankKeeper.EXPECT().BurnCoins(s.ctx, types.ModuleName, gomock.Any()).Return(nil).AnyTimes() } -func (s *KeeperTestSuite) mockMintETH() { +func (s *KeeperTestSuite) mockMint() { s.bankKeeper.EXPECT().MintCoins(s.ctx, types.ModuleName, gomock.Any()).Return(nil).AnyTimes() s.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(s.ctx, types.ModuleName, gomock.Any(), gomock.Any()).Return(nil).AnyTimes() } diff --git a/x/rollup/keeper/msg_server.go b/x/rollup/keeper/msg_server.go index f09dc056..4fc9a25c 100644 --- a/x/rollup/keeper/msg_server.go +++ b/x/rollup/keeper/msg_server.go @@ -4,10 +4,15 @@ import ( "context" "fmt" "math/big" + "strings" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + opbindings "github.com/ethereum-optimism/optimism/op-bindings/bindings" + "github.com/ethereum-optimism/optimism/op-bindings/predeploys" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/polymerdao/monomer/x/rollup/types" ) @@ -47,7 +52,7 @@ func (k *Keeper) InitiateWithdrawal( msg *types.MsgInitiateWithdrawal, ) (*types.MsgInitiateWithdrawalResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - ctx.Logger().Debug("Withdrawing L2 assets", "sender", msg.Sender, "value", msg.Value) + ctx.Logger().Debug("Withdrawing ETH L2 assets", "sender", msg.Sender, "value", msg.Value) cosmAddr, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { @@ -80,6 +85,96 @@ func (k *Keeper) InitiateWithdrawal( return &types.MsgInitiateWithdrawalResponse{}, nil } +func (k *Keeper) InitiateERC20Withdrawal( + goCtx context.Context, + msg *types.MsgInitiateERC20Withdrawal, +) (*types.MsgInitiateERC20WithdrawalResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + ctx.Logger().Debug("Withdrawing ERC-20 L2 assets", "sender", msg.Sender, "value", msg.Value, "tokenAddress", msg.TokenAddress) + + cosmAddr, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, types.WrapError(types.ErrInvalidSender, "failed to create cosmos address for sender: %v; error: %v", msg.Sender, err) + } + + if err = k.burnERC20(ctx, cosmAddr, msg.TokenAddress, msg.Value); err != nil { + return nil, types.WrapError( + types.ErrInitiateERC20Withdrawal, + "failed to burn ERC-20 for cosmosAddress: %v, tokenAddress: %v; err: %v", + cosmAddr, + msg.TokenAddress, + err, + ) + } + + params, err := k.GetParams(ctx) + if err != nil { + return nil, types.WrapError(types.ErrInitiateERC20Withdrawal, "failed to get params: %v", err) + } + + // Pack the finalizeBridgeERC20 message to forward to the L1StandardBridge contract on Ethereum. + // see https://github.com/ethereum-optimism/optimism/blob/24a8d3e/packages/contracts-bedrock/src/universal/StandardBridge.sol#L267 + standardBridgeABI, err := abi.JSON(strings.NewReader(opbindings.StandardBridgeMetaData.ABI)) + if err != nil { + return nil, types.WrapError(types.ErrInitiateERC20Withdrawal, "failed to parse StandardBridge ABI: %v", err) + } + finalizeBridgeERC20Bz, err := standardBridgeABI.Pack( + "finalizeBridgeERC20", + common.HexToAddress(msg.TokenAddress), // local token + common.HexToAddress(msg.TokenAddress), // remote token + common.HexToAddress(msg.Sender), // from + common.HexToAddress(msg.Target), // to + msg.Value.BigInt(), // amount + msg.ExtraData, // extra data + ) + if err != nil { + return nil, types.WrapError(types.ErrInitiateERC20Withdrawal, "failed to pack finalizeBridgeERC20: %v", err) + } + + // Pack the relayMessage to forward to the L1CrossDomainMessenger contract on Ethereum. + // see https://github.com/ethereum-optimism/optimism/blob/24a8d3e/packages/contracts-bedrock/src/universal/CrossDomainMessenger.sol#L207 + crossDomainMessengerABI, err := abi.JSON(strings.NewReader(opbindings.CrossDomainMessengerMetaData.ABI)) + if err != nil { + return nil, types.WrapError(types.ErrInitiateERC20Withdrawal, "failed to parse CrossDomainMessenger ABI: %v", err) + } + relayMessageBz, err := crossDomainMessengerABI.Pack( + "relayMessage", + big.NewInt(0), // nonce + common.HexToAddress(predeploys.L2StandardBridge), // sender + common.HexToAddress(params.L1StandardBridge), // target + big.NewInt(0), // value + big.NewInt(0), // min gas limit + finalizeBridgeERC20Bz, // message + ) + if err != nil { + return nil, types.WrapError(types.ErrInitiateERC20Withdrawal, "failed to pack relayMessage: %v", err) + } + + withdrawalValueHex := hexutil.EncodeBig(msg.Value.BigInt()) + k.EmitEvents(ctx, sdk.Events{ + sdk.NewEvent( + types.EventTypeWithdrawalInitiated, + // To forward the ERC-20 withdrawal to L1, we need to use the L2CrossDomainMessenger address as the msg.sender + sdk.NewAttribute(types.AttributeKeySender, predeploys.L2CrossDomainMessenger), + sdk.NewAttribute(types.AttributeKeyL1Target, params.L1CrossDomainMessenger), + // The ERC-20 withdrawal value is stored in the data field + sdk.NewAttribute(types.AttributeKeyValue, hexutil.EncodeBig(big.NewInt(0))), + sdk.NewAttribute(types.AttributeKeyGasLimit, hexutil.EncodeBig(new(big.Int).SetBytes(msg.GasLimit))), + sdk.NewAttribute(types.AttributeKeyData, hexutil.Encode(relayMessageBz)), + // The nonce attribute will be set by Monomer + ), + sdk.NewEvent( + types.EventTypeBurnERC20, + sdk.NewAttribute(types.AttributeKeyL2WithdrawalTx, types.EventTypeWithdrawalInitiated), + sdk.NewAttribute(types.AttributeKeyFromCosmosAddress, msg.Sender), + sdk.NewAttribute(types.AttributeKeyERC20Address, msg.TokenAddress), + sdk.NewAttribute(types.AttributeKeyValue, withdrawalValueHex), + ), + }) + + return &types.MsgInitiateERC20WithdrawalResponse{}, nil +} + func (k *Keeper) InitiateFeeWithdrawal( goCtx context.Context, _ *types.MsgInitiateFeeWithdrawal, diff --git a/x/rollup/keeper/msg_server_test.go b/x/rollup/keeper/msg_server_test.go index c20b9fa2..29decf26 100644 --- a/x/rollup/keeper/msg_server_test.go +++ b/x/rollup/keeper/msg_server_test.go @@ -104,7 +104,7 @@ func (s *KeeperTestSuite) TestApplyUserDeposit() { if test.setupMocks != nil { test.setupMocks() } - s.mockMintETH() + s.mockMint() resp, err := s.rollupKeeper.ApplyUserDeposit(s.ctx, &types.MsgApplyUserDeposit{ Tx: test.txBytes, @@ -131,6 +131,7 @@ func (s *KeeperTestSuite) TestInitiateWithdrawal() { l1Target := "0x12345abcde" withdrawalAmount := math.NewInt(1000000) + //nolint:dupl tests := map[string]struct { sender string setupMocks func() @@ -146,14 +147,14 @@ func (s *KeeperTestSuite) TestInitiateWithdrawal() { }, "bank keeper insufficient funds failure": { setupMocks: func() { - s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(s.ctx, gomock.Any(), types.ModuleName, gomock.Any()).Return(types.ErrBurnETH) + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(s.ctx, gomock.Any(), types.ModuleName, gomock.Any()).Return(types.ErrBurnETH).AnyTimes() }, sender: sender, shouldError: true, }, "bank keeper burn coins failure": { setupMocks: func() { - s.bankKeeper.EXPECT().BurnCoins(s.ctx, types.ModuleName, gomock.Any()).Return(sdkerrors.ErrUnknownRequest) + s.bankKeeper.EXPECT().BurnCoins(s.ctx, types.ModuleName, gomock.Any()).Return(sdkerrors.ErrUnknownRequest).AnyTimes() }, sender: sender, shouldError: true, @@ -165,7 +166,7 @@ func (s *KeeperTestSuite) TestInitiateWithdrawal() { if test.setupMocks != nil { test.setupMocks() } - s.mockBurnETH() + s.mockBurn() resp, err := s.rollupKeeper.InitiateWithdrawal(s.ctx, &types.MsgInitiateWithdrawal{ Sender: test.sender, @@ -194,6 +195,77 @@ func (s *KeeperTestSuite) TestInitiateWithdrawal() { } } +func (s *KeeperTestSuite) TestInitiateERC20Withdrawal() { + sender := sdk.AccAddress("addr").String() + l1Target := "0x12345abcde" + erc20TokenAddress := "0x0123456789abcdef" + withdrawalAmount := math.NewInt(1000000) + + //nolint:dupl + tests := map[string]struct { + sender string + setupMocks func() + shouldError bool + }{ + "successful message": { + sender: sender, + shouldError: false, + }, + "invalid sender addr": { + sender: "invalid", + shouldError: true, + }, + "bank keeper insufficient funds failure": { + setupMocks: func() { + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(s.ctx, gomock.Any(), types.ModuleName, gomock.Any()).Return(sdkerrors.ErrUnknownRequest).AnyTimes() + }, + sender: sender, + shouldError: true, + }, + "bank keeper burn coins failure": { + setupMocks: func() { + s.bankKeeper.EXPECT().BurnCoins(s.ctx, types.ModuleName, gomock.Any()).Return(sdkerrors.ErrUnknownRequest).AnyTimes() + }, + sender: sender, + shouldError: true, + }, + } + + for name, test := range tests { + s.Run(name, func() { + if test.setupMocks != nil { + test.setupMocks() + } + s.mockBurn() + + resp, err := s.rollupKeeper.InitiateERC20Withdrawal(s.ctx, &types.MsgInitiateERC20Withdrawal{ + Sender: test.sender, + Target: l1Target, + TokenAddress: erc20TokenAddress, + Value: withdrawalAmount, + }) + + if test.shouldError { + s.Require().Error(err) + s.Require().Nil(resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + + // Verify that the expected event types are emitted + expectedEventTypes := []string{ + sdk.EventTypeMessage, + types.EventTypeWithdrawalInitiated, + types.EventTypeBurnERC20, + } + for i, event := range s.eventManger.Events() { + s.Require().Equal(expectedEventTypes[i], event.Type) + } + } + }) + } +} + func (s *KeeperTestSuite) TestInitiateFeeWithdrawal() { tests := map[string]struct { setupMocks func() diff --git a/x/rollup/keeper/withdrawals.go b/x/rollup/keeper/withdrawals.go index 711fdb63..f7eb0fdc 100644 --- a/x/rollup/keeper/withdrawals.go +++ b/x/rollup/keeper/withdrawals.go @@ -24,3 +24,24 @@ func (k *Keeper) burnETH(ctx sdk.Context, addr sdk.AccAddress, amount sdkmath.In return nil } + +// burnERC20 burns a bridged ERC-20 token from an L2 account. +func (k *Keeper) burnERC20( + ctx sdk.Context, //nolint:gocritic // hugeParam + userAddr sdk.AccAddress, + erc20addr string, + amount sdkmath.Int, +) error { + coins := sdk.NewCoins(sdk.NewCoin(getERC20Denom(erc20addr), amount)) + + // Transfer the coins to withdraw from the user account to the rollup module + if err := k.bankkeeper.SendCoinsFromAccountToModule(ctx, userAddr, types.ModuleName, coins); err != nil { + return fmt.Errorf("failed to send withdrawal coins from user account %v to rollup module: %v", userAddr, err) + } + + if err := k.bankkeeper.BurnCoins(ctx, types.ModuleName, coins); err != nil { + return fmt.Errorf("failed to burn ERC-20 coins from the rollup module: %v", err) + } + + return nil +} diff --git a/x/rollup/tests/integration/rollup_test.go b/x/rollup/tests/integration/rollup_test.go index 313ed132..1f204792 100644 --- a/x/rollup/tests/integration/rollup_test.go +++ b/x/rollup/tests/integration/rollup_test.go @@ -107,7 +107,7 @@ func TestRollup(t *testing.T) { // query the user's ERC20 balance and assert it's equal to the deposit amount require.Equal(t, erc20depositAmount, queryERC20Balance(t, bankQueryClient, erc20userCosmosAddr, erc20tokenAddr, integrationApp).BigInt()) - // try to withdraw more than deposited and assert error + // try to withdraw more ETH than deposited and assert error _, err = integrationApp.RunMsg(&rolluptypes.MsgInitiateWithdrawal{ Sender: userCosmosAddr, Target: l1WithdrawalAddr, @@ -127,9 +127,22 @@ func TestRollup(t *testing.T) { }) require.NoError(t, err) - // query the recipient address ETH balance and assert it's zero + // query the sender's ETH balance and assert it's zero require.Equal(t, math.ZeroInt(), queryETHBalance(t, bankQueryClient, userCosmosAddr, integrationApp)) + // send a successful MsgInitiateERC20Withdrawal + _, err = integrationApp.RunMsg(&rolluptypes.MsgInitiateERC20Withdrawal{ + Sender: erc20userCosmosAddr, + Target: l1WithdrawalAddr, + TokenAddress: erc20tokenAddr.String(), + Value: math.NewIntFromBigInt(erc20depositAmount), + GasLimit: new(big.Int).SetUint64(100_000_000).Bytes(), + }) + require.NoError(t, err) + + // query the sender's ERC20 balance and assert it's zero + require.Equal(t, math.ZeroInt(), queryERC20Balance(t, bankQueryClient, erc20userCosmosAddr, erc20tokenAddr, integrationApp)) + // query the fee collector's ETH balance and assert it's equal to the initial mint amount require.Equal(t, math.NewInt(initialFeeCollectorBalance), queryETHBalance(t, bankQueryClient, feeCollectorAddr, integrationApp)) diff --git a/x/rollup/types/errors.go b/x/rollup/types/errors.go index 741eda91..1f183f5e 100644 --- a/x/rollup/types/errors.go +++ b/x/rollup/types/errors.go @@ -19,7 +19,8 @@ var ( ErrProcessL1UserDepositTxs = registerErr("failed to process L1 user deposit txs") ErrProcessL1SystemDepositTx = registerErr("failed to process L1 system deposit tx") ErrInitiateFeeWithdrawal = registerErr("failed to initiate fee withdrawal") - ErrUpdateParams = registerErr("failed to updated params") + ErrInitiateERC20Withdrawal = registerErr("failed to initiate ERC-20 withdrawal") + ErrUpdateParams = registerErr("failed to update params") ) // register new errors without hard-coding error codes diff --git a/x/rollup/types/events.go b/x/rollup/types/events.go index 2e604cc2..dfe96e78 100644 --- a/x/rollup/types/events.go +++ b/x/rollup/types/events.go @@ -21,5 +21,6 @@ const ( EventTypeMintETH = "mint_eth" EventTypeMintERC20 = "mint_erc20" EventTypeBurnETH = "burn_eth" + EventTypeBurnERC20 = "burn_erc20" EventTypeWithdrawalInitiated = "withdrawal_initiated" ) diff --git a/x/rollup/types/msgs.go b/x/rollup/types/msgs.go index 4f4a5f1c..87a63ee3 100644 --- a/x/rollup/types/msgs.go +++ b/x/rollup/types/msgs.go @@ -74,9 +74,39 @@ func (m *MsgInitiateWithdrawal) ValidateBasic() error { } func (*MsgInitiateWithdrawal) Type() string { - return "l2withdrawal" + return "l2_eth_withdrawal" } func (*MsgInitiateWithdrawal) Route() string { return ModuleName } + +var _ sdktypes.Msg = (*MsgInitiateERC20Withdrawal)(nil) + +func (m *MsgInitiateERC20Withdrawal) ValidateBasic() error { + // Check if the target Ethereum address is valid + if !common.IsHexAddress(m.Target) { + return fmt.Errorf("invalid target address: %s", m.Target) + } + // Check if the token address is valid + if !common.IsHexAddress(m.TokenAddress) { + return fmt.Errorf("invalid token address: %s", m.TokenAddress) + } + // Check if the gas limit is within the allowed range. + gasLimit := new(big.Int).SetBytes(m.GasLimit).Uint64() + if gasLimit < MinTxGasLimit || gasLimit > MaxTxGasLimit { + return fmt.Errorf("gas limit must be between %d and %d: %d", MinTxGasLimit, MaxTxGasLimit, gasLimit) + } + + return nil +} + +func (*MsgInitiateERC20Withdrawal) Type() string { + return "l2_erc20_withdrawal" +} + +func (*MsgInitiateERC20Withdrawal) Route() string { + return ModuleName +} + +// TODO: Add validations for MsgUpdateParams and MsgInitiateFeeWithdrawal diff --git a/x/rollup/types/params.go b/x/rollup/types/params.go index 80ad61e4..7acf642c 100644 --- a/x/rollup/types/params.go +++ b/x/rollup/types/params.go @@ -12,7 +12,7 @@ func DefaultParams() Params { defaultL1FeeRecipient string = "0x000000000000000000000000000000000000dEaD" // defaultL1CrossDomainMessenger uses the devnet address of the L1 cross domain messenger contract as the default value. defaultL1CrossDomainMessenger string = "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE" - // defaultL1CrossDomainMessenger uses the devnet address of the L1 standard bridge contract as the default value. + // defaultL1StandardBridge uses the devnet address of the L1 standard bridge contract as the default value. defaultL1StandardBridge string = "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1" defaultMinFeeWithdrawalAmount uint64 = 400_000 defaultFeeWithdrawalGasLimit uint64 = 400_000 @@ -36,7 +36,7 @@ func (p *Params) Validate() error { return fmt.Errorf("validate L1 cross domain messenger address: %w", err) } if err := validateEthAddress(p.L1StandardBridge); err != nil { - return fmt.Errorf("validate L1 cross domain messenger address: %w", err) + return fmt.Errorf("validate L1 standard bridge address: %w", err) } return nil diff --git a/x/rollup/types/tx.pb.go b/x/rollup/types/tx.pb.go index 7130cbe5..4c2a42cd 100644 --- a/x/rollup/types/tx.pb.go +++ b/x/rollup/types/tx.pb.go @@ -258,7 +258,7 @@ func (m *MsgApplyUserDepositResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgApplyUserDepositResponse proto.InternalMessageInfo -// MsgInitiateWithdrawal defines the message for initiating an L2 withdrawal. +// MsgInitiateWithdrawal defines the message for initiating an L2 ETH withdrawal. type MsgInitiateWithdrawal struct { // The cosmos address of the user who wants to withdraw from L2. Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` @@ -370,6 +370,127 @@ func (m *MsgInitiateWithdrawalResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgInitiateWithdrawalResponse proto.InternalMessageInfo +// MsgInitiateERC20Withdrawal defines the message for initiating an L2 ERC-20 withdrawal. +type MsgInitiateERC20Withdrawal struct { + // The cosmos address of the user who wants to withdraw from L2. + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // The ethereum address on L1 that the user wants to withdraw to. + Target string `protobuf:"bytes,2,opt,name=target,proto3" json:"target,omitempty"` + // The address of the ERC-20 token contract on L1. + TokenAddress string `protobuf:"bytes,3,opt,name=token_address,json=tokenAddress,proto3" json:"token_address,omitempty"` + // The amount of ERC-20 tokens that the user wants to withdraw. + Value cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value"` + // Minimum gas limit for executing the message on L1. + GasLimit []byte `protobuf:"bytes,5,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + // Extra data to forward to L1 target. + ExtraData []byte `protobuf:"bytes,6,opt,name=extra_data,json=extraData,proto3" json:"extra_data,omitempty"` +} + +func (m *MsgInitiateERC20Withdrawal) Reset() { *m = MsgInitiateERC20Withdrawal{} } +func (m *MsgInitiateERC20Withdrawal) String() string { return proto.CompactTextString(m) } +func (*MsgInitiateERC20Withdrawal) ProtoMessage() {} +func (*MsgInitiateERC20Withdrawal) Descriptor() ([]byte, []int) { + return fileDescriptor_106533843870de0f, []int{7} +} +func (m *MsgInitiateERC20Withdrawal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgInitiateERC20Withdrawal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgInitiateERC20Withdrawal.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 *MsgInitiateERC20Withdrawal) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInitiateERC20Withdrawal.Merge(m, src) +} +func (m *MsgInitiateERC20Withdrawal) XXX_Size() int { + return m.Size() +} +func (m *MsgInitiateERC20Withdrawal) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInitiateERC20Withdrawal.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgInitiateERC20Withdrawal proto.InternalMessageInfo + +func (m *MsgInitiateERC20Withdrawal) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgInitiateERC20Withdrawal) GetTarget() string { + if m != nil { + return m.Target + } + return "" +} + +func (m *MsgInitiateERC20Withdrawal) GetTokenAddress() string { + if m != nil { + return m.TokenAddress + } + return "" +} + +func (m *MsgInitiateERC20Withdrawal) GetGasLimit() []byte { + if m != nil { + return m.GasLimit + } + return nil +} + +func (m *MsgInitiateERC20Withdrawal) GetExtraData() []byte { + if m != nil { + return m.ExtraData + } + return nil +} + +// MsgInitiateERC20WithdrawalResponse defines the Msg/InitiateERC20Withdrawal response type. +type MsgInitiateERC20WithdrawalResponse struct { +} + +func (m *MsgInitiateERC20WithdrawalResponse) Reset() { *m = MsgInitiateERC20WithdrawalResponse{} } +func (m *MsgInitiateERC20WithdrawalResponse) String() string { return proto.CompactTextString(m) } +func (*MsgInitiateERC20WithdrawalResponse) ProtoMessage() {} +func (*MsgInitiateERC20WithdrawalResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_106533843870de0f, []int{8} +} +func (m *MsgInitiateERC20WithdrawalResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgInitiateERC20WithdrawalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgInitiateERC20WithdrawalResponse.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 *MsgInitiateERC20WithdrawalResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgInitiateERC20WithdrawalResponse.Merge(m, src) +} +func (m *MsgInitiateERC20WithdrawalResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgInitiateERC20WithdrawalResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgInitiateERC20WithdrawalResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgInitiateERC20WithdrawalResponse proto.InternalMessageInfo + // MsgInitiateFeeWithdrawal defines the message for initiating an L2 fee withdrawal to the L1 fee recipient address. type MsgInitiateFeeWithdrawal struct { // The signer address of the user initiating the fee withdrawal. @@ -380,7 +501,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{7} + return fileDescriptor_106533843870de0f, []int{9} } func (m *MsgInitiateFeeWithdrawal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -424,7 +545,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{8} + return fileDescriptor_106533843870de0f, []int{10} } func (m *MsgInitiateFeeWithdrawalResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -466,7 +587,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{9} + return fileDescriptor_106533843870de0f, []int{11} } func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -517,7 +638,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{10} + return fileDescriptor_106533843870de0f, []int{12} } func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -554,6 +675,8 @@ func init() { proto.RegisterType((*MsgApplyUserDepositResponse)(nil), "rollup.v1.MsgApplyUserDepositResponse") proto.RegisterType((*MsgInitiateWithdrawal)(nil), "rollup.v1.MsgInitiateWithdrawal") proto.RegisterType((*MsgInitiateWithdrawalResponse)(nil), "rollup.v1.MsgInitiateWithdrawalResponse") + proto.RegisterType((*MsgInitiateERC20Withdrawal)(nil), "rollup.v1.MsgInitiateERC20Withdrawal") + proto.RegisterType((*MsgInitiateERC20WithdrawalResponse)(nil), "rollup.v1.MsgInitiateERC20WithdrawalResponse") proto.RegisterType((*MsgInitiateFeeWithdrawal)(nil), "rollup.v1.MsgInitiateFeeWithdrawal") proto.RegisterType((*MsgInitiateFeeWithdrawalResponse)(nil), "rollup.v1.MsgInitiateFeeWithdrawalResponse") proto.RegisterType((*MsgUpdateParams)(nil), "rollup.v1.MsgUpdateParams") @@ -563,53 +686,59 @@ func init() { func init() { proto.RegisterFile("rollup/v1/tx.proto", fileDescriptor_106533843870de0f) } var fileDescriptor_106533843870de0f = []byte{ - // 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, 0x70, 0xe0, 0x35, - 0xaa, 0xd8, 0x9b, 0x7f, 0x10, 0x48, 0xa5, 0x5e, 0x2c, 0xcf, 0xcc, 0x6f, 0x7e, 0xbf, 0x99, 0xdd, - 0x99, 0x05, 0xe4, 0x53, 0xdb, 0x6e, 0x7a, 0xda, 0x49, 0x51, 0xe3, 0xad, 0x82, 0xe7, 0x53, 0x4e, - 0x51, 0x32, 0xf4, 0x15, 0x4e, 0x8a, 0xca, 0x0c, 0x76, 0x2c, 0x97, 0x6a, 0xc1, 0x37, 0x8c, 0x2a, - 0xf3, 0x87, 0x94, 0x39, 0x94, 0x69, 0x0e, 0x33, 0x3b, 0x59, 0x0e, 0x33, 0x45, 0x60, 0x21, 0x0c, - 0xd4, 0x02, 0x4b, 0x0b, 0x0d, 0x11, 0x9a, 0x35, 0xa9, 0x49, 0x43, 0x7f, 0xe7, 0x4f, 0x78, 0xe7, - 0xfa, 0xda, 0x42, 0x31, 0xf0, 0xab, 0xdf, 0x24, 0x80, 0x37, 0xc4, 0xa3, 0xcc, 0xe2, 0x6c, 0xb7, - 0x85, 0xca, 0x30, 0x69, 0x17, 0x6b, 0x98, 0x73, 0xdf, 0xaa, 0x37,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0x02, 0xbb, 0x31, 0xd5, 0x29, 0xb9, 0xcf, 0xa2, 0x2e, 0xc0, 0xfc, - 0x9d, 0x82, 0xba, 0xc5, 0x96, 0xae, 0x62, 0x10, 0xab, 0x32, 0x13, 0xed, 0xc3, 0xf4, 0xdd, 0x45, - 0x78, 0x7c, 0x21, 0x95, 0x95, 0xc7, 0xf7, 0x55, 0x08, 0xa0, 0x03, 0xf8, 0xf7, 0xde, 0x68, 0x8f, - 0x59, 0x53, 0xe5, 0xe9, 0x98, 0x35, 0xee, 0x72, 0x7f, 0x00, 0x34, 0x62, 0xde, 0x73, 0xc3, 0xd9, - 0xf7, 0x11, 0x4a, 0x7e, 0x1c, 0xa2, 0xa7, 0x60, 0x41, 0x66, 0xf4, 0x1c, 0x3d, 0x19, 0x4d, 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, + // 817 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x36, 0x65, 0x4b, 0xa8, 0x46, 0x72, 0xd2, 0x6c, 0x23, 0x9b, 0x61, 0x2a, 0x59, 0x60, 0xea, + 0x42, 0x48, 0x6b, 0xd1, 0x52, 0x8b, 0x1e, 0x7c, 0xb3, 0x92, 0x1a, 0x10, 0x60, 0x15, 0x05, 0x93, + 0x20, 0x68, 0x2e, 0xec, 0xca, 0xdc, 0x50, 0x84, 0x49, 0x2e, 0xc1, 0x5d, 0xb9, 0xd4, 0xad, 0xe8, + 0x0b, 0xb4, 0x97, 0xde, 0xfa, 0x00, 0x3d, 0xe6, 0x90, 0x87, 0xc8, 0xad, 0x41, 0x4e, 0x45, 0x0f, + 0x41, 0x61, 0x1f, 0xfc, 0x1a, 0x85, 0x96, 0x2b, 0xea, 0x8f, 0x8a, 0x02, 0xb4, 0xbd, 0x10, 0x9c, + 0x99, 0x6f, 0xbf, 0x6f, 0xf6, 0xdb, 0xe5, 0x10, 0x50, 0x44, 0x3d, 0x6f, 0x18, 0x1a, 0x17, 0x2d, + 0x83, 0xc7, 0xcd, 0x30, 0xa2, 0x9c, 0xa2, 0x62, 0x92, 0x6b, 0x5e, 0xb4, 0xb4, 0x5b, 0xd8, 0x77, + 0x03, 0x6a, 0x88, 0x67, 0x52, 0xd5, 0x76, 0xcf, 0x28, 0xf3, 0x29, 0x33, 0x7c, 0xe6, 0x8c, 0x57, + 0xf9, 0xcc, 0x91, 0x85, 0x3b, 0x49, 0xc1, 0x12, 0x91, 0x91, 0x04, 0xb2, 0x74, 0xdb, 0xa1, 0x0e, + 0x4d, 0xf2, 0xe3, 0x37, 0x99, 0xdd, 0x99, 0x6a, 0x4b, 0x45, 0x91, 0xd7, 0x7f, 0x55, 0x00, 0x1e, + 0x92, 0x90, 0x32, 0x97, 0xb3, 0xc7, 0x31, 0xea, 0xc0, 0xb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0x9a, 0xbe, 0xba, 0x36, 0xe1, 0xd3, 0xf2, + 0x3f, 0x8e, 0x2f, 0x61, 0xe7, 0xe4, 0xd5, 0x65, 0x4d, 0x79, 0x7d, 0x59, 0x53, 0xfe, 0xbe, 0xac, + 0x29, 0xbf, 0x5c, 0xd5, 0x36, 0x5e, 0x5f, 0xd5, 0x36, 0xfe, 0xbc, 0xaa, 0x6d, 0x3c, 0xfb, 0xdc, + 0x71, 0xf9, 0x60, 0xd8, 0x6f, 0x9e, 0x51, 0xdf, 0x08, 0xa9, 0x37, 0xf2, 0x49, 0x64, 0x63, 0x6a, + 0xf8, 0x34, 0xa0, 0x3e, 0x89, 0x8c, 0x58, 0xfe, 0x7a, 0x0d, 0x3e, 0x0a, 0x09, 0xeb, 0x17, 0xc4, + 0x1f, 0xf8, 0x8b, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x13, 0xda, 0x7b, 0x60, 0x17, 0x08, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -628,8 +757,10 @@ type MsgClient interface { 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 defines a method for initiating an ETH withdrawal from L2 to L1. InitiateWithdrawal(ctx context.Context, in *MsgInitiateWithdrawal, opts ...grpc.CallOption) (*MsgInitiateWithdrawalResponse, error) + // InitiateERC20Withdrawal defines a method for initiating an ERC-20 withdrawal from L2 to L1. + InitiateERC20Withdrawal(ctx context.Context, in *MsgInitiateERC20Withdrawal, opts ...grpc.CallOption) (*MsgInitiateERC20WithdrawalResponse, error) // InitiateFeeWithdrawal defines a method for initiating a withdrawal of fees from L2 to the L1 fee recipient address. InitiateFeeWithdrawal(ctx context.Context, in *MsgInitiateFeeWithdrawal, opts ...grpc.CallOption) (*MsgInitiateFeeWithdrawalResponse, error) // UpdateParams defines a method for updating the x/rollup module parameters. @@ -671,6 +802,15 @@ func (c *msgClient) InitiateWithdrawal(ctx context.Context, in *MsgInitiateWithd return out, nil } +func (c *msgClient) InitiateERC20Withdrawal(ctx context.Context, in *MsgInitiateERC20Withdrawal, opts ...grpc.CallOption) (*MsgInitiateERC20WithdrawalResponse, error) { + out := new(MsgInitiateERC20WithdrawalResponse) + err := c.cc.Invoke(ctx, "/rollup.v1.Msg/InitiateERC20Withdrawal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) InitiateFeeWithdrawal(ctx context.Context, in *MsgInitiateFeeWithdrawal, opts ...grpc.CallOption) (*MsgInitiateFeeWithdrawalResponse, error) { out := new(MsgInitiateFeeWithdrawalResponse) err := c.cc.Invoke(ctx, "/rollup.v1.Msg/InitiateFeeWithdrawal", in, out, opts...) @@ -695,8 +835,10 @@ type MsgServer interface { 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 defines a method for initiating an ETH withdrawal from L2 to L1. InitiateWithdrawal(context.Context, *MsgInitiateWithdrawal) (*MsgInitiateWithdrawalResponse, error) + // InitiateERC20Withdrawal defines a method for initiating an ERC-20 withdrawal from L2 to L1. + InitiateERC20Withdrawal(context.Context, *MsgInitiateERC20Withdrawal) (*MsgInitiateERC20WithdrawalResponse, error) // InitiateFeeWithdrawal defines a method for initiating a withdrawal of fees from L2 to the L1 fee recipient address. InitiateFeeWithdrawal(context.Context, *MsgInitiateFeeWithdrawal) (*MsgInitiateFeeWithdrawalResponse, error) // UpdateParams defines a method for updating the x/rollup module parameters. @@ -716,6 +858,9 @@ func (*UnimplementedMsgServer) ApplyUserDeposit(ctx context.Context, req *MsgApp func (*UnimplementedMsgServer) InitiateWithdrawal(ctx context.Context, req *MsgInitiateWithdrawal) (*MsgInitiateWithdrawalResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method InitiateWithdrawal not implemented") } +func (*UnimplementedMsgServer) InitiateERC20Withdrawal(ctx context.Context, req *MsgInitiateERC20Withdrawal) (*MsgInitiateERC20WithdrawalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method InitiateERC20Withdrawal not implemented") +} func (*UnimplementedMsgServer) InitiateFeeWithdrawal(ctx context.Context, req *MsgInitiateFeeWithdrawal) (*MsgInitiateFeeWithdrawalResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method InitiateFeeWithdrawal not implemented") } @@ -781,6 +926,24 @@ func _Msg_InitiateWithdrawal_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Msg_InitiateERC20Withdrawal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgInitiateERC20Withdrawal) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).InitiateERC20Withdrawal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/rollup.v1.Msg/InitiateERC20Withdrawal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).InitiateERC20Withdrawal(ctx, req.(*MsgInitiateERC20Withdrawal)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_InitiateFeeWithdrawal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgInitiateFeeWithdrawal) if err := dec(in); err != nil { @@ -833,6 +996,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "InitiateWithdrawal", Handler: _Msg_InitiateWithdrawal_Handler, }, + { + MethodName: "InitiateERC20Withdrawal", + Handler: _Msg_InitiateERC20Withdrawal_Handler, + }, { MethodName: "InitiateFeeWithdrawal", Handler: _Msg_InitiateFeeWithdrawal_Handler, @@ -1097,6 +1264,97 @@ func (m *MsgInitiateWithdrawalResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgInitiateERC20Withdrawal) 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 *MsgInitiateERC20Withdrawal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgInitiateERC20Withdrawal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ExtraData) > 0 { + i -= len(m.ExtraData) + copy(dAtA[i:], m.ExtraData) + i = encodeVarintTx(dAtA, i, uint64(len(m.ExtraData))) + i-- + dAtA[i] = 0x32 + } + if len(m.GasLimit) > 0 { + i -= len(m.GasLimit) + copy(dAtA[i:], m.GasLimit) + i = encodeVarintTx(dAtA, i, uint64(len(m.GasLimit))) + i-- + dAtA[i] = 0x2a + } + { + size := m.Value.Size() + i -= size + if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.TokenAddress) > 0 { + i -= len(m.TokenAddress) + copy(dAtA[i:], m.TokenAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.TokenAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.Target) > 0 { + i -= len(m.Target) + copy(dAtA[i:], m.Target) + i = encodeVarintTx(dAtA, i, uint64(len(m.Target))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgInitiateERC20WithdrawalResponse) 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 *MsgInitiateERC20WithdrawalResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgInitiateERC20WithdrawalResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgInitiateFeeWithdrawal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1327,6 +1585,46 @@ func (m *MsgInitiateWithdrawalResponse) Size() (n int) { return n } +func (m *MsgInitiateERC20Withdrawal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Target) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TokenAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Value.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.GasLimit) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ExtraData) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgInitiateERC20WithdrawalResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgInitiateFeeWithdrawal) Size() (n int) { if m == nil { return 0 @@ -2069,6 +2367,304 @@ func (m *MsgInitiateWithdrawalResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgInitiateERC20Withdrawal) 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: MsgInitiateERC20Withdrawal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInitiateERC20Withdrawal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Target", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Target = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TokenAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TokenAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.GasLimit = append(m.GasLimit[:0], dAtA[iNdEx:postIndex]...) + if m.GasLimit == nil { + m.GasLimit = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExtraData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ExtraData = append(m.ExtraData[:0], dAtA[iNdEx:postIndex]...) + if m.ExtraData == nil { + m.ExtraData = []byte{} + } + iNdEx = postIndex + 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 *MsgInitiateERC20WithdrawalResponse) 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: MsgInitiateERC20WithdrawalResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgInitiateERC20WithdrawalResponse: 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 *MsgInitiateFeeWithdrawal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0