diff --git a/Makefile b/Makefile index fdb19ffe..b4a308c5 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ lint: .PHONY: gen-proto gen-proto: - ${GOBIN}/buf generate --template buf.gen.yaml + ${SCRIPTS_PATH}/gen-proto.sh .PHONY: install-gofumpt install-gofumpt: diff --git a/x/rollup/types/adapters.go b/adapters.go similarity index 94% rename from x/rollup/types/adapters.go rename to adapters.go index 5b5d61e9..bd8b2fbd 100644 --- a/x/rollup/types/adapters.go +++ b/adapters.go @@ -1,4 +1,4 @@ -package types +package monomer import ( "errors" @@ -9,7 +9,7 @@ import ( sdktx "github.com/cosmos/cosmos-sdk/types/tx" "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" - rollupv1 "github.com/polymerdao/monomer/gen/rollup/v1" + rolluptypes "github.com/polymerdao/monomer/x/rollup/types" ) var errL1AttributesNotFound = errors.New("L1 attributes tx not found") @@ -44,7 +44,7 @@ func AdaptPayloadTxsToCosmosTxs(ethTxs []hexutil.Bytes, signTx txSigner, from st for _, depositTx := range ethTxs[:numDepositTxs] { depositTxsBytes = append(depositTxsBytes, depositTx) } - msgAny, err := codectypes.NewAnyWithValue(&rollupv1.ApplyL1TxsRequest{ + msgAny, err := codectypes.NewAnyWithValue(&rolluptypes.ApplyL1TxsRequest{ TxBytes: depositTxsBytes, FromAddress: from, }) @@ -99,7 +99,7 @@ func AdaptCosmosTxsToEthTxs(cosmosTxs bfttypes.Txs) (ethtypes.Transactions, erro if num := len(msgs); num != 1 { return nil, fmt.Errorf("unexpected number of msgs in Eth Cosmos tx: want 1, got %d", num) } - msg := new(rollupv1.ApplyL1TxsRequest) + msg := new(rolluptypes.ApplyL1TxsRequest) if err := msg.Unmarshal(msgs[0].GetValue()); err != nil { return nil, fmt.Errorf("unmarshal MsgL1Txs smsg: %v", err) } diff --git a/buf.gen.yaml b/buf.gen.yaml index a92c20c1..c3a9b8e4 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,20 +1,9 @@ version: v2 -managed: - enabled: true - disable: - - file_option: go_package - module: buf.build/googleapis/googleapis - - file_option: go_package - module: buf.build/cosmos/gogo-proto - - file_option: go_package - module: buf.build/cosmos/cosmos-proto - override: - - file_option: go_package_prefix - value: github.com/polymerdao/monomer/gen - - file_option: go_package_prefix - module: buf.build/cosmos/cosmos-sdk - value: cosmossdk.io/api plugins: - local: protoc-gen-gocosmos out: gen - opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types,paths=source_relative + opt: + - plugins=grpc + - paths=source_relative + - Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types + - Mcosmos/app/v1alpha1/module.proto=cosmossdk.io/api/cosmos/app/v1alpha1 diff --git a/builder/builder.go b/builder/builder.go index 41c34261..61058549 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -17,7 +17,6 @@ import ( "github.com/polymerdao/monomer/app/peptide/txstore" "github.com/polymerdao/monomer/bindings" "github.com/polymerdao/monomer/evm" - "github.com/polymerdao/monomer/gen/rollup/v1" "github.com/polymerdao/monomer/mempool" rolluptypes "github.com/polymerdao/monomer/x/rollup/types" ) @@ -255,7 +254,7 @@ func (b *Builder) parseWithdrawalMessages( return nil, fmt.Errorf("unmarshal cosmos tx: %v", err) } for _, msg := range cosmosTx.GetBody().GetMessages() { - withdrawalMsg := new(rollupv1.InitiateWithdrawalRequest) + withdrawalMsg := new(rolluptypes.InitiateWithdrawalRequest) if msg.TypeUrl == cdctypes.MsgTypeURL(withdrawalMsg) { if err := withdrawalMsg.Unmarshal(msg.GetValue()); err != nil { return nil, fmt.Errorf("unmarshal InitiateWithdrawalRequest: %v", err) @@ -285,7 +284,7 @@ func (b *Builder) parseWithdrawalMessages( // storeWithdrawalMsgInEVM stores the withdrawal message hash in the monomer evm state db and returns the L2ToL1MessagePasser // message nonce used for the withdrawal. This is used for proving withdrawals. func (b *Builder) storeWithdrawalMsgInEVM( - withdrawalMsg *rollupv1.InitiateWithdrawalRequest, + withdrawalMsg *rolluptypes.InitiateWithdrawalRequest, ethState *state.StateDB, header *monomer.Header, ) (*big.Int, error) { diff --git a/engine/engine.go b/engine/engine.go index 42868957..063026aa 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -18,7 +18,6 @@ import ( "github.com/polymerdao/monomer/builder" "github.com/polymerdao/monomer/engine/signer" "github.com/polymerdao/monomer/monomerdb" - rolluptypes "github.com/polymerdao/monomer/x/rollup/types" ) type DB interface { @@ -182,7 +181,7 @@ func (e *EngineAPI) ForkchoiceUpdatedV3( return nil, engine.InvalidPayloadAttributes.With(errors.New("gas limit not provided")) } - cosmosTxs, err := rolluptypes.AdaptPayloadTxsToCosmosTxs( + cosmosTxs, err := monomer.AdaptPayloadTxsToCosmosTxs( pa.Transactions, e.signer.Sign, e.signer.AccountAddress().String(), @@ -276,7 +275,7 @@ func (e *EngineAPI) GetPayloadV3(ctx context.Context, payloadID engine.PayloadID panic(fmt.Errorf("build block: %v", err)) } - txs, err := rolluptypes.AdaptCosmosTxsToEthTxs(block.Txs) + txs, err := monomer.AdaptCosmosTxsToEthTxs(block.Txs) if err != nil { return nil, engine.GenericServerError.With(fmt.Errorf("convert cosmos txs to eth txs: %v", err)) } diff --git a/gen/rollup/module/v1/module.pb.go b/gen/rollup/module/v1/module.pb.go index f729ce01..67f2ca43 100644 --- a/gen/rollup/module/v1/module.pb.go +++ b/gen/rollup/module/v1/module.pb.go @@ -66,7 +66,7 @@ func init() { func init() { proto.RegisterFile("rollup/module/v1/module.proto", fileDescriptor_5510ebceb64c57ed) } var fileDescriptor_5510ebceb64c57ed = []byte{ - // 255 bytes of a gzipped FileDescriptorProto + // 180 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xca, 0xcf, 0xc9, 0x29, 0x2d, 0xd0, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0xd5, 0x2f, 0x33, 0x84, 0xb2, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0x20, 0xd2, 0x7a, 0x50, 0xc1, 0x32, 0x43, 0x29, 0x85, 0xe4, @@ -74,15 +74,11 @@ var fileDescriptor_5510ebceb64c57ed = []byte{ 0x44, 0x54, 0x3d, 0x4a, 0x16, 0x5c, 0x6c, 0xbe, 0x60, 0xbe, 0x95, 0xde, 0xae, 0x03, 0xd3, 0x6e, 0x31, 0x6a, 0x70, 0xa9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x17, 0xe4, 0xe7, 0x54, 0xe6, 0xa6, 0x16, 0xa5, 0x24, 0xe6, 0xeb, 0xe7, 0xe6, 0xe7, 0xe5, 0xe7, 0xa6, - 0x16, 0xe9, 0x57, 0xe8, 0x43, 0x6c, 0x71, 0xba, 0xc5, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, - 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, - 0xc7, 0x72, 0x0c, 0x5c, 0x22, 0xc9, 0xf9, 0xb9, 0x7a, 0xe8, 0x8e, 0x71, 0xe2, 0x86, 0x58, 0x14, - 0x00, 0xb2, 0x37, 0x80, 0x31, 0xca, 0x1a, 0xbf, 0x3d, 0xe9, 0xa9, 0x79, 0xfa, 0xe8, 0xde, 0xb5, - 0x86, 0xb0, 0xca, 0x0c, 0x17, 0x31, 0x31, 0x07, 0xf9, 0x46, 0xac, 0x62, 0x12, 0x08, 0x82, 0x58, - 0x02, 0x31, 0x59, 0x2f, 0xcc, 0xf0, 0x14, 0x4c, 0x28, 0x06, 0x22, 0x14, 0x13, 0x66, 0xf8, 0x88, - 0x49, 0x06, 0x5d, 0x28, 0xc6, 0x3d, 0xc0, 0xc9, 0x37, 0xb5, 0x24, 0x31, 0x25, 0xb1, 0x24, 0xf1, - 0x15, 0x93, 0x10, 0x44, 0xda, 0xca, 0x0a, 0x1a, 0x10, 0x56, 0x61, 0x86, 0x49, 0x6c, 0xe0, 0xd0, - 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x9d, 0x0b, 0x30, 0xec, 0x72, 0x01, 0x00, 0x00, + 0x16, 0xe9, 0x57, 0xe8, 0x43, 0x6c, 0x71, 0x0a, 0x3d, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, + 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, + 0x39, 0x86, 0x28, 0x6b, 0xfc, 0x26, 0xa4, 0xa7, 0xe6, 0xe9, 0xa3, 0x7b, 0xc4, 0x1a, 0xc2, 0x2a, + 0x33, 0x4c, 0x62, 0x03, 0xbb, 0xcb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x67, 0xf2, 0xe5, 0x98, + 0xec, 0x00, 0x00, 0x00, } func (m *Module) Marshal() (dAtA []byte, err error) { diff --git a/gen/rollup/v1/helpers.go b/gen/rollup/v1/helpers.go deleted file mode 100644 index 0f3a420b..00000000 --- a/gen/rollup/v1/helpers.go +++ /dev/null @@ -1,30 +0,0 @@ -package rollupv1 - -import ( - "errors" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdktypes "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" -) - -var _ sdktypes.Msg = (*ApplyL1TxsRequest)(nil) - -func (m *ApplyL1TxsRequest) ValidateBasic() error { - if len(m.TxBytes) < 1 { - return errors.New("expected TxBytes to contain at least one deposit transaction") - } - return nil -} - -func (*ApplyL1TxsRequest) Type() string { - return "l1txs" -} - -func (*ApplyL1TxsRequest) Route() string { - return "rollup" -} - -func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - msgservice.RegisterMsgServiceDesc(registry, &_MsgService_serviceDesc) -} diff --git a/gen/testapp/module/v1/module.pb.go b/gen/testapp/module/v1/module.pb.go index 2e204df2..7d47fd9f 100644 --- a/gen/testapp/module/v1/module.pb.go +++ b/gen/testapp/module/v1/module.pb.go @@ -66,7 +66,7 @@ func init() { func init() { proto.RegisterFile("testapp/module/v1/module.proto", fileDescriptor_ce29f2acf5bde665) } var fileDescriptor_ce29f2acf5bde665 = []byte{ - // 256 bytes of a gzipped FileDescriptorProto + // 182 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x49, 0x2d, 0x2e, 0x49, 0x2c, 0x28, 0xd0, 0xcf, 0xcd, 0x4f, 0x29, 0xcd, 0x49, 0xd5, 0x2f, 0x33, 0x84, 0xb2, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x04, 0xa1, 0xf2, 0x7a, 0x50, 0xd1, 0x32, 0x43, 0x29, 0x85, @@ -74,15 +74,11 @@ var fileDescriptor_ce29f2acf5bde665 = []byte{ 0x54, 0x4d, 0x4a, 0x2e, 0x5c, 0x6c, 0xbe, 0x60, 0xbe, 0x95, 0xd5, 0xae, 0x03, 0xd3, 0x6e, 0x31, 0x9a, 0x70, 0x19, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x17, 0xe4, 0xe7, 0x54, 0xe6, 0xa6, 0x16, 0xa5, 0x24, 0xe6, 0xeb, 0xe7, 0xe6, 0xe7, 0xe5, 0xe7, 0xa6, 0x16, - 0xe9, 0xc3, 0x1c, 0x51, 0x01, 0x66, 0x41, 0xcc, 0x72, 0x7a, 0xc0, 0x78, 0xe2, 0x91, 0x1c, 0xe3, - 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0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, 0x00, 0x00, 0x00, } func (m *Module) Marshal() (dAtA []byte, err error) { diff --git a/gen/testapp/v1/get.pb.go b/gen/testapp/v1/get.pb.go index 5b419670..299b43fc 100644 --- a/gen/testapp/v1/get.pb.go +++ b/gen/testapp/v1/get.pb.go @@ -123,7 +123,7 @@ func init() { func init() { proto.RegisterFile("testapp/v1/get.proto", fileDescriptor_f739a5cb60b1de9f) } var fileDescriptor_f739a5cb60b1de9f = []byte{ - // 284 bytes of a gzipped FileDescriptorProto + // 220 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x49, 0x2d, 0x2e, 0x49, 0x2c, 0x28, 0xd0, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0x2d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x82, 0x8a, 0xea, 0x95, 0x19, 0x2a, 0xc9, 0x71, 0x71, 0xb9, 0xa7, 0x96, 0x04, 0xa5, @@ -132,16 +132,12 @@ var fileDescriptor_f739a5cb60b1de9f = []byte{ 0x54, 0x21, 0x11, 0x2e, 0xd6, 0xb2, 0xc4, 0x9c, 0xd2, 0x54, 0x09, 0x26, 0xb0, 0x12, 0x08, 0xc7, 0xc8, 0x0d, 0x6c, 0x48, 0x70, 0x6a, 0x51, 0x59, 0x66, 0x72, 0xaa, 0x90, 0x05, 0x17, 0xb3, 0x7b, 0x6a, 0x89, 0x90, 0x98, 0x1e, 0xc2, 0x1a, 0x3d, 0x84, 0x1d, 0x52, 0xe2, 0x18, 0xe2, 0x10, 0xb3, - 0x95, 0x18, 0x9c, 0x36, 0x33, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, - 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x03, 0x17, - 0x5f, 0x72, 0x7e, 0x2e, 0x92, 0x46, 0x27, 0x0e, 0xf7, 0xd4, 0x92, 0x00, 0x90, 0x6f, 0x02, 0x18, - 0xa3, 0xcc, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x0b, 0xf2, 0x73, - 0x2a, 0x73, 0x53, 0x8b, 0x52, 0x12, 0xf3, 0xf5, 0x73, 0xf3, 0xf3, 0xf2, 0x73, 0x53, 0x8b, 0xf4, - 0xd3, 0x53, 0xf3, 0xf4, 0x11, 0xe1, 0x60, 0x0d, 0x65, 0x96, 0x19, 0x2e, 0x62, 0x62, 0x0e, 0x89, - 0x88, 0x58, 0xc5, 0xc4, 0x15, 0x02, 0x35, 0x36, 0xcc, 0xf0, 0x14, 0x9c, 0x13, 0x13, 0x66, 0xf8, - 0x88, 0x49, 0x0c, 0xc1, 0x89, 0x71, 0x0f, 0x70, 0xf2, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, - 0x7c, 0xc5, 0xc4, 0x0d, 0x95, 0xb0, 0xb2, 0x0a, 0x33, 0x4c, 0x62, 0x03, 0x87, 0xaa, 0x31, 0x20, - 0x00, 0x00, 0xff, 0xff, 0x7e, 0xad, 0x53, 0xb7, 0x6d, 0x01, 0x00, 0x00, + 0x95, 0x18, 0x9c, 0x02, 0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, + 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x2c, + 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0xbf, 0x20, 0x3f, 0xa7, 0x32, 0x37, + 0xb5, 0x28, 0x25, 0x31, 0x5f, 0x3f, 0x37, 0x3f, 0x2f, 0x3f, 0x37, 0xb5, 0x48, 0x3f, 0x3d, 0x35, + 0x4f, 0x1f, 0xe1, 0x55, 0x6b, 0x28, 0xb3, 0xcc, 0x30, 0x89, 0x0d, 0xec, 0x63, 0x63, 0x40, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xe5, 0x5d, 0xf4, 0x31, 0x09, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/gen/testapp/v1/set.pb.go b/gen/testapp/v1/set.pb.go index 5f20d980..841ef3a7 100644 --- a/gen/testapp/v1/set.pb.go +++ b/gen/testapp/v1/set.pb.go @@ -5,8 +5,8 @@ package testappv1 import ( context "context" - _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" grpc "google.golang.org/grpc" @@ -132,7 +132,7 @@ func init() { func init() { proto.RegisterFile("testapp/v1/set.proto", fileDescriptor_00dc24396718b2df) } var fileDescriptor_00dc24396718b2df = []byte{ - // 338 bytes of a gzipped FileDescriptorProto + // 273 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x49, 0x2d, 0x2e, 0x49, 0x2c, 0x28, 0xd0, 0x2f, 0x33, 0xd4, 0x2f, 0x4e, 0x2d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x82, 0x8a, 0xea, 0x95, 0x19, 0x4a, 0x89, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0xeb, @@ -144,17 +144,13 @@ var fileDescriptor_00dc24396718b2df = []byte{ 0x58, 0x09, 0x36, 0x3d, 0xdf, 0xa0, 0x85, 0x62, 0x9a, 0x12, 0x2f, 0x17, 0x37, 0xd8, 0xae, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x23, 0x37, 0xb0, 0xd5, 0xc1, 0xa9, 0x45, 0x65, 0x99, 0xc9, 0xa9, 0x42, 0x16, 0x5c, 0xcc, 0xc1, 0xa9, 0x25, 0x42, 0x62, 0x7a, 0x08, 0x57, 0xeb, 0x21, 0x5c, 0x26, - 0x25, 0x8e, 0x21, 0x0e, 0x31, 0x45, 0x89, 0xc1, 0x69, 0x33, 0xe3, 0x89, 0x47, 0x72, 0x8c, 0x17, - 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, - 0x37, 0x1e, 0xcb, 0x31, 0x70, 0xf1, 0x25, 0xe7, 0xe7, 0x22, 0x69, 0x74, 0xe2, 0x08, 0x4e, 0x2d, - 0x09, 0x00, 0xf9, 0x3b, 0x80, 0x31, 0xca, 0x2c, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, - 0x3f, 0x57, 0xbf, 0x20, 0x3f, 0xa7, 0x32, 0x37, 0xb5, 0x28, 0x25, 0x31, 0x5f, 0x3f, 0x37, 0x3f, - 0x2f, 0x3f, 0x37, 0xb5, 0x48, 0x3f, 0x3d, 0x35, 0x4f, 0x1f, 0x11, 0xac, 0xd6, 0x50, 0x66, 0x99, - 0xe1, 0x22, 0x26, 0xe6, 0x90, 0x88, 0x88, 0x55, 0x4c, 0x5c, 0x21, 0x50, 0x63, 0xc3, 0x0c, 0x4f, - 0xc1, 0x39, 0x31, 0x61, 0x86, 0x8f, 0x98, 0xc4, 0x10, 0x9c, 0x18, 0xf7, 0x00, 0x27, 0xdf, 0xd4, - 0x92, 0xc4, 0x94, 0xc4, 0x92, 0xc4, 0x57, 0x4c, 0xdc, 0x50, 0x09, 0x2b, 0xab, 0x30, 0xc3, 0x24, - 0x36, 0x70, 0xf8, 0x1b, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x07, 0x57, 0xec, 0x4f, 0xbc, 0x01, - 0x00, 0x00, + 0x25, 0x8e, 0x21, 0x0e, 0x31, 0x45, 0x89, 0xc1, 0x29, 0xe0, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, + 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, + 0x8f, 0xe5, 0x18, 0xa2, 0xcc, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, + 0x0b, 0xf2, 0x73, 0x2a, 0x73, 0x53, 0x8b, 0x52, 0x12, 0xf3, 0xf5, 0x73, 0xf3, 0xf3, 0xf2, 0x73, + 0x53, 0x8b, 0xf4, 0xd3, 0x53, 0xf3, 0xf4, 0x11, 0x21, 0x67, 0x0d, 0x65, 0x96, 0x19, 0x26, 0xb1, + 0x81, 0xc3, 0xc6, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xd0, 0x29, 0x51, 0x58, 0x01, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/monomer.go b/monomer.go index 785d3fdf..0f7a4ca8 100644 --- a/monomer.go +++ b/monomer.go @@ -19,7 +19,6 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/trie" - rolluptypes "github.com/polymerdao/monomer/x/rollup/types" ) type Application interface { @@ -123,7 +122,7 @@ func (b *Block) ToEth() (*ethtypes.Block, error) { return nil, errors.New("converted a nil block") } - txs, err := rolluptypes.AdaptCosmosTxsToEthTxs(b.Txs) + txs, err := AdaptCosmosTxsToEthTxs(b.Txs) if err != nil { return nil, fmt.Errorf("adapt txs: %v", err) } diff --git a/proto/rollup/module/v1/module.proto b/proto/rollup/module/v1/module.proto index 0431ba90..05d3c8b4 100644 --- a/proto/rollup/module/v1/module.proto +++ b/proto/rollup/module/v1/module.proto @@ -4,6 +4,8 @@ package rollup.module.v1; import "cosmos/app/v1alpha1/module.proto"; +option go_package = "github.com/polymerdao/monomer/gen/rollup/module/v1;modulev1"; + message Module { option (cosmos.app.v1alpha1.module) = { go_import: "github.com/polymerdao/monomer/x/rollup" diff --git a/proto/rollup/v1/msg.proto b/proto/rollup/v1/tx.proto similarity index 92% rename from proto/rollup/v1/msg.proto rename to proto/rollup/v1/tx.proto index 24b8fb3a..99c06809 100644 --- a/proto/rollup/v1/msg.proto +++ b/proto/rollup/v1/tx.proto @@ -7,6 +7,8 @@ import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; +option go_package = "github.com/polymerdao/monomer/x/rollup/types"; + // MsgService defines all tx endpoints for the rollup module. service MsgService { rpc ApplyL1Txs(ApplyL1TxsRequest) returns (ApplyL1TxsResponse); @@ -26,7 +28,6 @@ message ApplyL1TxsRequest { message ApplyL1TxsResponse {} -// TODO: add validations in the x/rollup module to ensure that the target address and gas limit are valid before burning the users ETH // InitiateWithdrawalRequest defines a message for all L2 withdrawal txs message InitiateWithdrawalRequest { option (cosmos.msg.v1.signer) = "sender"; diff --git a/scripts/gen-proto.sh b/scripts/gen-proto.sh new file mode 100755 index 00000000..3ef38d10 --- /dev/null +++ b/scripts/gen-proto.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +SCRIPTS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +MONOMER_DIR=$(cd "$SCRIPTS_DIR/.." && pwd) +GEN_DIR=$(cd "$MONOMER_DIR/gen" && pwd) +ROLLUP_DIR=$(cd "$MONOMER_DIR/x/rollup" && pwd) + +# generate cosmos proto code +buf generate + +# move the generated rollup module message types to the x/rollup module +cp -r $GEN_DIR/rollup/v1/* $ROLLUP_DIR/types +rm -rf $GEN_DIR/rollup/v1 + +# TODO: move the testapp module message types to the testapp/x/testmodule module diff --git a/testapp/proto/testapp/module/v1/module.proto b/testapp/proto/testapp/module/v1/module.proto index 0901ad1e..a016dcca 100644 --- a/testapp/proto/testapp/module/v1/module.proto +++ b/testapp/proto/testapp/module/v1/module.proto @@ -4,6 +4,8 @@ package testapp.module.v1; import "cosmos/app/v1alpha1/module.proto"; +option go_package = "github.com/polymerdao/monomer/gen/testapp/module/v1;modulev1"; + message Module { option (cosmos.app.v1alpha1.module) = { go_import: "github.com/polymerdao/monomer/testapp/x/testmodule" diff --git a/testapp/proto/testapp/v1/get.proto b/testapp/proto/testapp/v1/get.proto index beb4536a..ffe32ebb 100644 --- a/testapp/proto/testapp/v1/get.proto +++ b/testapp/proto/testapp/v1/get.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package testapp.v1; +option go_package = "github.com/polymerdao/monomer/gen/testapp/v1;testappv1"; + message GetRequest { string key = 1; } diff --git a/testapp/proto/testapp/v1/set.proto b/testapp/proto/testapp/v1/set.proto index 831ba8f0..780ac97c 100644 --- a/testapp/proto/testapp/v1/set.proto +++ b/testapp/proto/testapp/v1/set.proto @@ -4,6 +4,8 @@ package testapp.v1; import "cosmos/msg/v1/msg.proto"; +option go_package = "github.com/polymerdao/monomer/gen/testapp/v1;testappv1"; + message SetRequest { option (cosmos.msg.v1.signer) = "from_address"; diff --git a/testutils/utils.go b/testutils/utils.go index c7d0ea01..262d20ae 100644 --- a/testutils/utils.go +++ b/testutils/utils.go @@ -21,7 +21,6 @@ import ( "github.com/ethereum/go-ethereum/trie" "github.com/polymerdao/monomer" "github.com/polymerdao/monomer/monomerdb/localdb" - rolluptypes "github.com/polymerdao/monomer/x/rollup/types" "github.com/stretchr/testify/require" ) @@ -82,7 +81,7 @@ func GenerateEthTxs(t *testing.T) (*gethtypes.Transaction, *gethtypes.Transactio rng := rand.New(rand.NewSource(1234)) depositTx := gethtypes.NewTx(testutils.GenerateDeposit(testutils.RandomHash(rng), rng)) - cosmosEthTx := rolluptypes.AdaptNonDepositCosmosTxToEthTx([]byte{1}) + cosmosEthTx := monomer.AdaptNonDepositCosmosTxToEthTx([]byte{1}) return l1InfoTx, depositTx, cosmosEthTx } @@ -100,7 +99,7 @@ func GenerateBlockFromEthTxs(t *testing.T, l1InfoTx *gethtypes.Transaction, depo require.NoError(t, err) ethTxBytes = append(ethTxBytes, cosmosEthTxBytes) } - cosmosTxs, err := rolluptypes.AdaptPayloadTxsToCosmosTxs(ethTxBytes, nil, "") + cosmosTxs, err := monomer.AdaptPayloadTxsToCosmosTxs(ethTxBytes, nil, "") require.NoError(t, err) block, err := monomer.MakeBlock(&monomer.Header{}, cosmosTxs) require.NoError(t, err) diff --git a/x/rollup/README.md b/x/rollup/README.md index 7553c382..d3ddcd37 100644 --- a/x/rollup/README.md +++ b/x/rollup/README.md @@ -2,11 +2,19 @@ This module implements rollup-chain specific logic. -Unlike other cosmos-sdk module, its state mutation doesn't go through regular tx flow. Instead, states are mutated in +## Deposits + +Unlike other cosmos-sdk modules, its state mutation doesn't go through regular tx flow. Instead, states are mutated in response to L1 deposit txs, and do not need L2 tx signatures. Sequencer and verifiers must include L1 deposit txs in L2 blocks without any modification. +## Withdrawals + +Withdrawals are initiated by L2 users through the rollup module. If a valid withdrawal request is submitted, the user's +L2 ETH is burnt through the bank module. Monomer will then send an L2 state commitment to L1 through the OP Stack and +the user will be able to prove and finalize their withdrawal. + ## State L1 system info are stored in this module. Other L2 clients can reference this module to get L1 info for their verifications. diff --git a/x/rollup/keeper/deposits.go b/x/rollup/keeper/deposits.go new file mode 100644 index 00000000..f256d7b5 --- /dev/null +++ b/x/rollup/keeper/deposits.go @@ -0,0 +1,127 @@ +package keeper + +import ( + "context" + "encoding/json" + "fmt" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum-optimism/optimism/op-node/rollup/derive" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/polymerdao/monomer/x/rollup/types" + "github.com/samber/lo" +) + +// setL1BlockInfo sets the L1 block info to the app state +// +// Persisted data conforms to optimism specs on L1 attributes: +// https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#l1-attributes-predeployed-contract +func (k *Keeper) setL1BlockInfo(ctx sdk.Context, info derive.L1BlockInfo) error { //nolint:gocritic + infoBytes, err := json.Marshal(info) + if err != nil { + return types.WrapError(err, "marshal L1 block info") + } + if err := k.storeService.OpenKVStore(ctx).Set([]byte(types.KeyL1BlockInfo), infoBytes); err != nil { + return types.WrapError(err, "set") + } + return nil +} + +// setL1BlockHistory sets the L1 block info to the app state, with the key being the blockhash, so we can look it up easily later. +func (k *Keeper) setL1BlockHistory(ctx context.Context, info *derive.L1BlockInfo) error { + infoBytes, err := json.Marshal(info) + if err != nil { + return types.WrapError(err, "marshal L1 block info") + } + if err := k.storeService.OpenKVStore(ctx).Set(info.BlockHash.Bytes(), infoBytes); err != nil { + return types.WrapError(err, "set") + } + return nil +} + +// processL1SystemDepositTx processes the L1 Attributes deposit tx and returns the L1 block info. +func (k *Keeper) processL1SystemDepositTx(ctx sdk.Context, txBytes []byte) (*derive.L1BlockInfo, error) { //nolint:gocritic // hugeParam + var tx ethtypes.Transaction + if err := tx.UnmarshalBinary(txBytes); err != nil { + ctx.Logger().Error("Failed to unmarshal system deposit transaction", "index", 0, "err", err, "txBytes", txBytes) + return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to unmarshal system deposit transaction: %v", err) + } + if !tx.IsDepositTx() { + ctx.Logger().Error("First L1 tx must be a system deposit tx", "type", tx.Type()) + return nil, types.WrapError(types.ErrInvalidL1Txs, "first L1 tx must be a system deposit tx, but got type %d", tx.Type()) + } + l1blockInfo, err := derive.L1BlockInfoFromBytes(k.rollupCfg, 0, tx.Data()) + if err != nil { + ctx.Logger().Error("Failed to derive L1 block info from L1 Info Deposit tx", "err", err, "txBytes", txBytes) + return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to derive L1 block info from L1 Info Deposit tx: %v", err) + } + return l1blockInfo, nil +} + +// processL1UserDepositTxs processes the L1 user deposit txs and mints ETH to the user's cosmos address. +func (k *Keeper) processL1UserDepositTxs(ctx sdk.Context, txs [][]byte) error { //nolint:gocritic // hugeParam + for i := 1; i < len(txs); i++ { + txBytes := txs[i] + var tx ethtypes.Transaction + if err := tx.UnmarshalBinary(txBytes); err != nil { + ctx.Logger().Error("Failed to unmarshal user deposit transaction", "index", i, "err", err, "txBytes", txBytes) + return types.WrapError(types.ErrInvalidL1Txs, "failed to unmarshal user deposit transaction", "index", i, "err", err) + } + if !tx.IsDepositTx() { + ctx.Logger().Error("L1 tx must be a user deposit tx", "index", i, "type", tx.Type()) + return types.WrapError(types.ErrInvalidL1Txs, "L1 tx must be a user deposit tx, index:%d, type:%d", i, tx.Type()) + } + if tx.IsSystemTx() { + ctx.Logger().Error("L1 tx must be a user deposit tx", "type", tx.Type()) + return 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()))) + to := tx.To() + // 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 to == nil { + ctx.Logger().Error("Contract creation txs are not supported", "index", i) + return types.WrapError(types.ErrInvalidL1Txs, "Contract creation txs are not supported, index:%d", i) + } + cosmAddr := evmToCosmos(*to) + mintAmount := sdkmath.NewIntFromBigInt(tx.Value()) + err := k.mintETH(ctx, cosmAddr, mintAmount) + if err != nil { + ctx.Logger().Error("Failed to mint ETH", "evmAddress", to, "cosmosAddress", cosmAddr, "err", err) + return types.WrapError(types.ErrMintETH, "failed to mint ETH for cosmosAddress: %v; err: %v", cosmAddr, err) + } + } + return nil +} + +// mintETH mints ETH to an account where the amount is in wei. +func (k *Keeper) mintETH(ctx sdk.Context, addr sdk.AccAddress, amount sdkmath.Int) error { //nolint:gocritic // hugeParam + coin := sdk.NewCoin(types.ETH, amount) + if err := k.mintKeeper.MintCoins(ctx, sdk.NewCoins(coin)); err != nil { + return fmt.Errorf("failed to mint deposit coins from mint module: %v", err) + } + if err := k.bankkeeper.SendCoinsFromModuleToAccount(ctx, types.MintModule, addr, sdk.NewCoins(coin)); err != nil { + return fmt.Errorf("failed to send deposit coins from mint module to user account %v: %v", addr, err) + } + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + sdk.NewEvent( + types.EventTypeMintETH, + sdk.NewAttribute(types.AttributeKeyL1DepositTxType, types.L1UserDepositTxType), + sdk.NewAttribute(types.AttributeKeyToCosmosAddress, addr.String()), + sdk.NewAttribute(types.AttributeKeyValue, hexutil.Encode(amount.BigInt().Bytes())), + ), + }) + return nil +} + +// evmToCosmos converts an EVM address to a sdk.AccAddress +func evmToCosmos(addr common.Address) sdk.AccAddress { + return addr.Bytes() +} diff --git a/x/rollup/keeper/msg_server.go b/x/rollup/keeper/msg_server.go index 2665d126..1df70640 100644 --- a/x/rollup/keeper/msg_server.go +++ b/x/rollup/keeper/msg_server.go @@ -3,66 +3,40 @@ package keeper import ( "context" "encoding/json" - "fmt" - "math/big" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum-optimism/optimism/op-node/rollup/derive" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/params" - rollupv1 "github.com/polymerdao/monomer/gen/rollup/v1" "github.com/polymerdao/monomer/x/rollup/types" "github.com/samber/lo" ) -const ( - MinTxGasLimit = params.TxGas - MaxTxGasLimit = params.MaxGasLimit -) - type msgServer struct { *Keeper } // NewMsgServerImpl returns an implementation of the MsgServer interface // for the provided Keeper. -func NewMsgServerImpl(keeper *Keeper) rollupv1.MsgServiceServer { +func NewMsgServerImpl(keeper *Keeper) types.MsgServiceServer { return &msgServer{Keeper: keeper} } -var _ rollupv1.MsgServiceServer = msgServer{} +var _ types.MsgServiceServer = msgServer{} // ApplyL1Txs implements types.MsgServer. -func (k *Keeper) ApplyL1Txs(goCtx context.Context, msg *rollupv1.ApplyL1TxsRequest) (*rollupv1.ApplyL1TxsResponse, error) { - if msg.TxBytes == nil || len(msg.TxBytes) < 1 { - return nil, types.WrapError(types.ErrInvalidL1Txs, "must have at least one L1 Info Deposit tx") - } +func (k *Keeper) ApplyL1Txs(goCtx context.Context, msg *types.ApplyL1TxsRequest) (*types.ApplyL1TxsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) ctx.Logger().Debug("Processing L1 txs", "txCount", len(msg.TxBytes)) - // process L1 system deposit tx - txBytes := msg.TxBytes[0] - var tx ethtypes.Transaction - if err := tx.UnmarshalBinary(txBytes); err != nil { - ctx.Logger().Error("Failed to unmarshal system deposit transaction", "index", 0, "err", err, "txBytes", txBytes) - return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to unmarshal system deposit transaction: %v", err) - } - if !tx.IsDepositTx() { - ctx.Logger().Error("First L1 tx must be a system deposit tx", "type", tx.Type()) - return nil, types.WrapError(types.ErrInvalidL1Txs, "first L1 tx must be a system deposit tx, but got type %d", tx.Type()) - } - l1blockInfo, err := derive.L1BlockInfoFromBytes(k.rollupCfg, 0, tx.Data()) + // process L1 system deposit tx and get L1 block info + l1blockInfo, err := k.processL1SystemDepositTx(ctx, msg.TxBytes[0]) if err != nil { - ctx.Logger().Error("Failed to derive L1 block info from L1 Info Deposit tx", "err", err, "txBytes", txBytes) - return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to derive L1 block info from L1 Info Deposit tx: %v", err) + ctx.Logger().Error("Failed to process L1 system deposit tx", "err", err) + return nil, types.WrapError(types.ErrProcessL1SystemDepositTx, "err: %v", err) } // save L1 block info to AppState - if err := k.SetL1BlockInfo(ctx, *l1blockInfo); err != nil { + if err = k.setL1BlockInfo(ctx, *l1blockInfo); err != nil { ctx.Logger().Error("Failed to save L1 block info to AppState", "err", err) return nil, types.WrapError(types.ErrL1BlockInfo, "save error: %v", err) } @@ -70,7 +44,7 @@ func (k *Keeper) ApplyL1Txs(goCtx context.Context, msg *rollupv1.ApplyL1TxsReque ctx.Logger().Info("Save L1 block info", "l1blockInfo", string(lo.Must(json.Marshal(l1blockInfo)))) // save L1 block History to AppState - if err := k.SetL1BlockHistory(&ctx, l1blockInfo); err != nil { + if err = k.setL1BlockHistory(&ctx, l1blockInfo); err != nil { ctx.Logger().Error("Failed to save L1 block history info to AppState", "err", err) return nil, types.WrapError(types.ErrL1BlockInfo, "save error: %v", err) } @@ -78,44 +52,18 @@ func (k *Keeper) ApplyL1Txs(goCtx context.Context, msg *rollupv1.ApplyL1TxsReque ctx.Logger().Info("Save L1 block history info", "l1blockHistoryInfo", string(lo.Must(json.Marshal(l1blockInfo)))) // process L1 user deposit txs - for i := 1; i < len(msg.TxBytes); i++ { - txBytes := msg.TxBytes[i] - var tx ethtypes.Transaction - if err := tx.UnmarshalBinary(txBytes); err != nil { - ctx.Logger().Error("Failed to unmarshal user deposit transaction", "index", i, "err", err, "txBytes", txBytes) - return nil, types.WrapError(types.ErrInvalidL1Txs, "failed to unmarshal user deposit transaction", "index", i, "err", err) - } - if !tx.IsDepositTx() { - ctx.Logger().Error("L1 tx must be a user deposit tx", "index", i, "type", tx.Type()) - return nil, types.WrapError(types.ErrInvalidL1Txs, "L1 tx must be a user deposit tx, index:%d, type:%d", i, tx.Type()) - } - if tx.IsSystemTx() { - ctx.Logger().Error("L1 tx must be a user deposit tx", "type", tx.Type()) - 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()))) - to := tx.To() - // 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 to == nil { - ctx.Logger().Error("Contract creation txs are not supported", "index", i) - return nil, types.WrapError(types.ErrInvalidL1Txs, "Contract creation txs are not supported, index:%d", i) - } - cosmAddr := evmToCosmos(*to) - mintAmount := sdkmath.NewIntFromBigInt(tx.Value()) - err := k.MintETH(ctx, cosmAddr, mintAmount) - if err != nil { - ctx.Logger().Error("Failed to mint ETH", "evmAddress", to, "cosmosAddress", cosmAddr, "err", err) - return nil, types.WrapError(types.ErrMintETH, "failed to mint ETH for cosmosAddress: %v; err: %v", cosmAddr, err) - } + if err = k.processL1UserDepositTxs(ctx, msg.TxBytes); err != nil { + ctx.Logger().Error("Failed to process L1 user deposit txs", "err", err) + return nil, types.WrapError(types.ErrProcessL1UserDepositTxs, "err: %v", err) } - return &rollupv1.ApplyL1TxsResponse{}, nil + + return &types.ApplyL1TxsResponse{}, nil } func (k *Keeper) InitiateWithdrawal( goCtx context.Context, - msg *rollupv1.InitiateWithdrawalRequest, -) (*rollupv1.InitiateWithdrawalResponse, error) { + msg *types.InitiateWithdrawalRequest, +) (*types.InitiateWithdrawalResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) ctx.Logger().Debug("Withdrawing L2 assets", "sender", msg.Sender, "value", msg.Value) @@ -125,11 +73,12 @@ func (k *Keeper) InitiateWithdrawal( return nil, types.WrapError(types.ErrInvalidSender, "failed to create cosmos address for sender: %v; error: %v", msg.Sender, err) } - if err := k.BurnETH(ctx, cosmAddr, msg.Value); err != nil { + if err := k.burnETH(ctx, cosmAddr, msg.Value); err != nil { ctx.Logger().Error("Failed to burn ETH", "cosmosAddress", cosmAddr, "evmAddress", msg.Target, "err", err) return nil, types.WrapError(types.ErrBurnETH, "failed to burn ETH for cosmosAddress: %v; err: %v", cosmAddr, err) } + withdrawalValueHex := hexutil.Encode(msg.Value.BigInt().Bytes()) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( sdk.EventTypeMessage, @@ -139,114 +88,18 @@ func (k *Keeper) InitiateWithdrawal( types.EventTypeWithdrawalInitiated, sdk.NewAttribute(types.AttributeKeySender, msg.Sender), sdk.NewAttribute(types.AttributeKeyL1Target, msg.Target), - sdk.NewAttribute(types.AttributeKeyValue, hexutil.Encode(msg.Value.BigInt().Bytes())), + sdk.NewAttribute(types.AttributeKeyValue, withdrawalValueHex), sdk.NewAttribute(types.AttributeKeyGasLimit, hexutil.Encode(msg.GasLimit)), sdk.NewAttribute(types.AttributeKeyData, hexutil.Encode(msg.Data)), // The nonce attribute will be set by Monomer ), - }) - - return &rollupv1.InitiateWithdrawalResponse{}, nil -} - -// MintETH mints ETH to an account where the amount is in wei, the smallest unit of ETH -func (k *Keeper) MintETH(ctx sdk.Context, addr sdk.AccAddress, amount sdkmath.Int) error { //nolint:gocritic // hugeParam - coin := sdk.NewCoin(types.ETH, amount) - if err := k.mintKeeper.MintCoins(ctx, sdk.NewCoins(coin)); err != nil { - return fmt.Errorf("failed to mint deposit coins from mint module: %v", err) - } - if err := k.bankkeeper.SendCoinsFromModuleToAccount(ctx, types.MintModule, addr, sdk.NewCoins(coin)); err != nil { - return fmt.Errorf("failed to send deposit coins from mint module to user account %v: %v", addr, err) - } - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - ), - sdk.NewEvent( - types.EventTypeMintETH, - sdk.NewAttribute(types.AttributeKeyL1DepositTxType, types.L1UserDepositTxType), - sdk.NewAttribute(types.AttributeKeyToCosmosAddress, addr.String()), - sdk.NewAttribute(types.AttributeKeyValue, hexutil.Encode(amount.BigInt().Bytes())), - ), - }) - return nil -} - -// BurnETH burns ETH from an account where the amount is in wei -func (k *Keeper) BurnETH(ctx sdk.Context, addr sdk.AccAddress, amount sdkmath.Int) error { //nolint:gocritic // hugeParam - coins := sdk.NewCoins(sdk.NewCoin(types.ETH, amount)) - - // Transfer the coins to withdraw from the user account to the mint module - err := k.bankkeeper.SendCoinsFromAccountToModule(ctx, addr, types.MintModule, coins) - if err != nil { - return fmt.Errorf("failed to send withdrawal coins from user account %v to mint module: %v", addr, err) - } - - // Burn the ETH coins from the mint module - if err := k.bankkeeper.BurnCoins(ctx, types.MintModule, coins); err != nil { - return fmt.Errorf("failed to burn withdrawal coins from mint module: %v", err) - } - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - ), sdk.NewEvent( types.EventTypeBurnETH, sdk.NewAttribute(types.AttributeKeyL2WithdrawalTx, types.EventTypeWithdrawalInitiated), - sdk.NewAttribute(types.AttributeKeyFromCosmosAddress, addr.String()), - sdk.NewAttribute(types.AttributeKeyValue, hexutil.Encode(amount.BigInt().Bytes())), + sdk.NewAttribute(types.AttributeKeyFromCosmosAddress, msg.Sender), + sdk.NewAttribute(types.AttributeKeyValue, withdrawalValueHex), ), }) - return nil -} - -// SetL1BlockInfo sets the L1 block info to the app state -// -// Persisted data conforms to optimism specs on L1 attributes: -// https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#l1-attributes-predeployed-contract -func (k *Keeper) SetL1BlockInfo(ctx sdk.Context, info derive.L1BlockInfo) error { //nolint:gocritic - infoBytes, err := json.Marshal(info) - if err != nil { - return types.WrapError(err, "marshal L1 block info") - } - if err := k.storeService.OpenKVStore(ctx).Set([]byte(types.KeyL1BlockInfo), infoBytes); err != nil { - return types.WrapError(err, "set") - } - return nil -} - -// SetL1BlockHistory sets the L1 block info to the app state, with the key being the blockhash, so we can look it up easily later. -func (k *Keeper) SetL1BlockHistory(ctx context.Context, info *derive.L1BlockInfo) error { - infoBytes, err := json.Marshal(info) - if err != nil { - return types.WrapError(err, "marshal L1 block info") - } - if err := k.storeService.OpenKVStore(ctx).Set(info.BlockHash.Bytes(), infoBytes); err != nil { - return types.WrapError(err, "set") - } - return nil -} - -// evmToCosmos converts an EVM address to a sdk.AccAddress -func evmToCosmos(addr common.Address) sdk.AccAddress { - return addr.Bytes() -} - -// TODO: This is a temporary change while the rollup module refactor is being done. Change when possible -// ValidateBasic validates the given InitiateWithdrawalRequest -func ValidateBasic(m *rollupv1.InitiateWithdrawalRequest) error { - // Check if the Ethereum address is valid - if !common.IsHexAddress(m.Target) { - return fmt.Errorf("invalid Ethereum address: %s", m.Target) - } - // 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 + return &types.InitiateWithdrawalResponse{}, nil } diff --git a/x/rollup/keeper/withdrawals.go b/x/rollup/keeper/withdrawals.go new file mode 100644 index 00000000..20e8ec10 --- /dev/null +++ b/x/rollup/keeper/withdrawals.go @@ -0,0 +1,26 @@ +package keeper + +import ( + "fmt" + + sdkmath "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/polymerdao/monomer/x/rollup/types" +) + +// burnETH burns ETH from an account where the amount is in wei. +func (k *Keeper) burnETH(ctx sdk.Context, addr sdk.AccAddress, amount sdkmath.Int) error { //nolint:gocritic // hugeParam + coins := sdk.NewCoins(sdk.NewCoin(types.ETH, amount)) + + // Transfer the coins to withdraw from the user account to the mint module + if err := k.bankkeeper.SendCoinsFromAccountToModule(ctx, addr, types.MintModule, coins); err != nil { + return fmt.Errorf("failed to send withdrawal coins from user account %v to mint module: %v", addr, err) + } + + // Burn the ETH coins from the mint module + if err := k.bankkeeper.BurnCoins(ctx, types.MintModule, coins); err != nil { + return fmt.Errorf("failed to burn withdrawal coins from mint module: %v", err) + } + + return nil +} diff --git a/x/rollup/module.go b/x/rollup/module.go index 9196b492..81e82569 100644 --- a/x/rollup/module.go +++ b/x/rollup/module.go @@ -16,7 +16,6 @@ import ( "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/polymerdao/monomer/gen/rollup/module/v1" - "github.com/polymerdao/monomer/gen/rollup/v1" "github.com/polymerdao/monomer/x/rollup/keeper" "github.com/polymerdao/monomer/x/rollup/types" "github.com/spf13/cobra" @@ -81,7 +80,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) { // RegisterInterfaces registers the module's interface types func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { - rollupv1.RegisterInterfaces(reg) + types.RegisterInterfaces(reg) } // DefaultGenesis returns the capability module's default genesis state. @@ -151,7 +150,7 @@ func (AppModule) QuerierRoute() string { return types.QuerierRoute } // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - rollupv1.RegisterMsgServiceServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterMsgServiceServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) } // RegisterInvariants registers the capability module's invariants. diff --git a/x/rollup/types/codec.go b/x/rollup/types/codec.go new file mode 100644 index 00000000..77d16cc6 --- /dev/null +++ b/x/rollup/types/codec.go @@ -0,0 +1,10 @@ +package types + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + msgservice.RegisterMsgServiceDesc(registry, &_MsgService_serviceDesc) +} diff --git a/x/rollup/types/errors.go b/x/rollup/types/errors.go index 9143dca5..48595e7c 100644 --- a/x/rollup/types/errors.go +++ b/x/rollup/types/errors.go @@ -9,12 +9,14 @@ var WrapError = sdkerrors.Wrapf var ( // error codes starting from 1 - registerErr = newErrRegistry(ModuleName, 1) - ErrInvalidL1Txs = registerErr("invalid L1 txs") - ErrMintETH = registerErr("failed to mint ETH") - ErrBurnETH = registerErr("failed to burn ETH") - ErrInvalidSender = registerErr("invalid sender address") - ErrL1BlockInfo = registerErr("L1 block info") + registerErr = newErrRegistry(ModuleName, 1) + ErrInvalidL1Txs = registerErr("invalid L1 txs") + ErrMintETH = registerErr("failed to mint ETH") + ErrBurnETH = registerErr("failed to burn ETH") + ErrInvalidSender = registerErr("invalid sender address") + ErrL1BlockInfo = registerErr("L1 block info") + ErrProcessL1UserDepositTxs = registerErr("failed to process L1 user deposit txs") + ErrProcessL1SystemDepositTx = registerErr("failed to process L1 system deposit tx") ) // register new errors without hard-coding error codes diff --git a/x/rollup/types/events.go b/x/rollup/types/events.go index 7c0de630..6704f31b 100644 --- a/x/rollup/types/events.go +++ b/x/rollup/types/events.go @@ -3,9 +3,6 @@ package types const ( AttributeKeyL1DepositTxType = "l1_deposit_tx_type" AttributeKeyL2WithdrawalTx = "l2_withdrawal_tx" - AttributeKeyBridgedTokenType = "bridged_token_type" - AttributeKeyFromEvmAddress = "from_evm_address" - AttributeKeyToEvmAddress = "to_evm_address" AttributeKeyFromCosmosAddress = "from_cosmos_address" AttributeKeyToCosmosAddress = "to_cosmos_address" AttributeKeySender = "sender" @@ -15,8 +12,7 @@ const ( AttributeKeyData = "data" AttributeKeyNonce = "nonce" - L1SystemDepositTxType = "l1_system_deposit" - L1UserDepositTxType = "l1_user_deposit" + L1UserDepositTxType = "l1_user_deposit" EventTypeMintETH = "mint_eth" EventTypeBurnETH = "burn_eth" diff --git a/x/rollup/types/msgs.go b/x/rollup/types/msgs.go new file mode 100644 index 00000000..951a921c --- /dev/null +++ b/x/rollup/types/msgs.go @@ -0,0 +1,56 @@ +package types + +import ( + "fmt" + "math/big" + + sdktypes "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/params" +) + +const ( + MinTxGasLimit = params.TxGas + MaxTxGasLimit = params.MaxGasLimit +) + +var _ sdktypes.Msg = (*ApplyL1TxsRequest)(nil) + +func (m *ApplyL1TxsRequest) ValidateBasic() error { + if m.TxBytes == nil || len(m.TxBytes) < 1 { + return WrapError(ErrInvalidL1Txs, "must have at least one L1 Info Deposit tx") + } + return nil +} + +func (*ApplyL1TxsRequest) Type() string { + return "l1txs" +} + +func (*ApplyL1TxsRequest) Route() string { + return "rollup" +} + +var _ sdktypes.Msg = (*InitiateWithdrawalRequest)(nil) + +func (m *InitiateWithdrawalRequest) ValidateBasic() error { + // Check if the Ethereum address is valid + if !common.IsHexAddress(m.Target) { + return fmt.Errorf("invalid Ethereum address: %s", m.Target) + } + // 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 (*InitiateWithdrawalRequest) Type() string { + return "l2withdrawal" +} + +func (*InitiateWithdrawalRequest) Route() string { + return "rollup" +} diff --git a/x/rollup/keeper/msg_server_test.go b/x/rollup/types/msgs_test.go similarity index 59% rename from x/rollup/keeper/msg_server_test.go rename to x/rollup/types/msgs_test.go index c0af5e12..1909a2e1 100644 --- a/x/rollup/keeper/msg_server_test.go +++ b/x/rollup/types/msgs_test.go @@ -1,42 +1,41 @@ -package keeper_test +package types_test import ( "fmt" "math/big" "testing" - rollupv1 "github.com/polymerdao/monomer/gen/rollup/v1" - "github.com/polymerdao/monomer/x/rollup/keeper" + "github.com/polymerdao/monomer/x/rollup/types" "github.com/stretchr/testify/require" ) -func TestValidateBasic(t *testing.T) { +func TestInitiateWithdrawalRequestValidateBasic(t *testing.T) { validAddress := "0x311d373126EFAE95E261DefF004FF245021739d1" invalidAddress := "invalid address" invalidAddressErrorMsg := "invalid Ethereum address" - validGasLimit := new(big.Int).SetUint64(keeper.MinTxGasLimit/2 + keeper.MaxTxGasLimit/2).Bytes() // avoid overflow - belowRangeGasLimit := new(big.Int).SetUint64(keeper.MinTxGasLimit - 1).Bytes() - aboveRangeGasLimit := new(big.Int).SetUint64(keeper.MaxTxGasLimit + 1).Bytes() + validGasLimit := new(big.Int).SetUint64(types.MinTxGasLimit/2 + types.MaxTxGasLimit/2).Bytes() // avoid overflow + belowRangeGasLimit := new(big.Int).SetUint64(types.MinTxGasLimit - 1).Bytes() + aboveRangeGasLimit := new(big.Int).SetUint64(types.MaxTxGasLimit + 1).Bytes() - outOfRangeGasLimitErrorMsg := fmt.Sprintf("gas limit must be between %d and %d:", keeper.MinTxGasLimit, keeper.MaxTxGasLimit) + outOfRangeGasLimitErrorMsg := fmt.Sprintf("gas limit must be between %d and %d:", types.MinTxGasLimit, types.MaxTxGasLimit) testCases := []struct { name string - request *rollupv1.InitiateWithdrawalRequest + request *types.InitiateWithdrawalRequest errMsg string }{ { name: "Valid request", - request: &rollupv1.InitiateWithdrawalRequest{ + request: &types.InitiateWithdrawalRequest{ Target: validAddress, GasLimit: validGasLimit, }, }, { name: "Invalid Ethereum address", - request: &rollupv1.InitiateWithdrawalRequest{ + request: &types.InitiateWithdrawalRequest{ Target: invalidAddress, GasLimit: validGasLimit, }, @@ -44,7 +43,7 @@ func TestValidateBasic(t *testing.T) { }, { name: "Gas limit below the allowed range", - request: &rollupv1.InitiateWithdrawalRequest{ + request: &types.InitiateWithdrawalRequest{ Target: validAddress, GasLimit: belowRangeGasLimit, }, @@ -52,7 +51,7 @@ func TestValidateBasic(t *testing.T) { }, { name: "Gas limit above the allowed range", - request: &rollupv1.InitiateWithdrawalRequest{ + request: &types.InitiateWithdrawalRequest{ Target: validAddress, GasLimit: aboveRangeGasLimit, }, @@ -62,7 +61,7 @@ func TestValidateBasic(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - err := keeper.ValidateBasic(tc.request) + err := tc.request.ValidateBasic() if tc.errMsg == "" { require.NoError(t, err) } else { diff --git a/gen/rollup/v1/msg.pb.go b/x/rollup/types/tx.pb.go similarity index 79% rename from gen/rollup/v1/msg.pb.go rename to x/rollup/types/tx.pb.go index 2bb71396..f7d0f00d 100644 --- a/gen/rollup/v1/msg.pb.go +++ b/x/rollup/types/tx.pb.go @@ -1,15 +1,15 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: rollup/v1/msg.proto +// source: rollup/v1/tx.proto -package rollupv1 +package types import ( context "context" - _ "cosmossdk.io/api/amino" - _ "cosmossdk.io/api/cosmos/msg/v1" cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -44,7 +44,7 @@ func (m *ApplyL1TxsRequest) Reset() { *m = ApplyL1TxsRequest{} } func (m *ApplyL1TxsRequest) String() string { return proto.CompactTextString(m) } func (*ApplyL1TxsRequest) ProtoMessage() {} func (*ApplyL1TxsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7931bdc190f4c36d, []int{0} + return fileDescriptor_106533843870de0f, []int{0} } func (m *ApplyL1TxsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -94,7 +94,7 @@ func (m *ApplyL1TxsResponse) Reset() { *m = ApplyL1TxsResponse{} } func (m *ApplyL1TxsResponse) String() string { return proto.CompactTextString(m) } func (*ApplyL1TxsResponse) ProtoMessage() {} func (*ApplyL1TxsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7931bdc190f4c36d, []int{1} + return fileDescriptor_106533843870de0f, []int{1} } func (m *ApplyL1TxsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -123,7 +123,6 @@ func (m *ApplyL1TxsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_ApplyL1TxsResponse proto.InternalMessageInfo -// TODO: add validations in the x/rollup module to ensure that the target address and gas limit are valid before burning the users ETH // InitiateWithdrawalRequest defines a message for all L2 withdrawal txs type InitiateWithdrawalRequest struct { // The cosmos address of the user who wants to withdraw from L2. @@ -142,7 +141,7 @@ func (m *InitiateWithdrawalRequest) Reset() { *m = InitiateWithdrawalReq func (m *InitiateWithdrawalRequest) String() string { return proto.CompactTextString(m) } func (*InitiateWithdrawalRequest) ProtoMessage() {} func (*InitiateWithdrawalRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_7931bdc190f4c36d, []int{2} + return fileDescriptor_106533843870de0f, []int{2} } func (m *InitiateWithdrawalRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -206,7 +205,7 @@ func (m *InitiateWithdrawalResponse) Reset() { *m = InitiateWithdrawalRe func (m *InitiateWithdrawalResponse) String() string { return proto.CompactTextString(m) } func (*InitiateWithdrawalResponse) ProtoMessage() {} func (*InitiateWithdrawalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_7931bdc190f4c36d, []int{3} + return fileDescriptor_106533843870de0f, []int{3} } func (m *InitiateWithdrawalResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -242,45 +241,41 @@ func init() { proto.RegisterType((*InitiateWithdrawalResponse)(nil), "rollup.v1.InitiateWithdrawalResponse") } -func init() { proto.RegisterFile("rollup/v1/msg.proto", fileDescriptor_7931bdc190f4c36d) } +func init() { proto.RegisterFile("rollup/v1/tx.proto", fileDescriptor_106533843870de0f) } -var fileDescriptor_7931bdc190f4c36d = []byte{ - // 557 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xce, 0xa6, 0x7f, 0x7e, 0xc9, 0x36, 0xbf, 0x43, 0x96, 0x14, 0x1c, 0x53, 0xdc, 0x10, 0x81, - 0x14, 0x55, 0xaa, 0x5d, 0x03, 0xa7, 0x70, 0x6a, 0x0e, 0xa0, 0x48, 0x8d, 0x14, 0xb9, 0x28, 0x54, - 0xa8, 0x52, 0xb4, 0x89, 0x17, 0xc7, 0xc2, 0xeb, 0x35, 0xbb, 0x9b, 0x90, 0x5c, 0x79, 0x02, 0x9e, - 0x81, 0x13, 0x42, 0x1c, 0x7a, 0xe8, 0x89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 0x06, 0xf8, 0x39, 0x35, 0xc0, 0x87, 0x99, 0x91, 0x39, 0x9e, 0x19, 0x99, - 0xef, 0x33, 0x23, 0x03, 0xff, 0xef, 0x33, 0x7a, 0x41, 0xd2, 0xc8, 0xb5, 0x84, 0xd7, 0x8e, 0x0f, - 0xaf, 0x0d, 0x5e, 0x3d, 0xf1, 0x7c, 0x39, 0x18, 0xf6, 0xcc, 0x3e, 0xa3, 0x56, 0xc4, 0x82, 0x09, - 0x25, 0xdc, 0xc5, 0xcc, 0xa2, 0x2c, 0x64, 0x94, 0x70, 0xcb, 0x23, 0xa1, 0x35, 0xff, 0x33, 0x9e, - 0x2a, 0x6b, 0x64, 0x7f, 0xcc, 0x2e, 0x38, 0x7b, 0x7b, 0x9f, 0xb3, 0x79, 0x47, 0x71, 0x76, 0xec, - 0x6f, 0xe7, 0xf6, 0x7e, 0xc7, 0x9e, 0x66, 0x57, 0xe7, 0xf6, 0xfe, 0xf3, 0x76, 0xa3, 0x45, 0x24, - 0x8e, 0x37, 0xf1, 0x2b, 0x0b, 0x15, 0x5e, 0xaf, 0x77, 0xec, 0xde, 0x72, 0x72, 0xfa, 0x8f, 0xff, - 0x04, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x8d, 0xca, 0xc3, 0x79, 0x03, 0x00, 0x00, +var fileDescriptor_106533843870de0f = []byte{ + // 490 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0x31, 0x6f, 0x13, 0x31, + 0x14, 0x8e, 0x69, 0x1b, 0x1a, 0x37, 0x4b, 0xac, 0x00, 0x97, 0xa3, 0x5c, 0x43, 0x04, 0x52, 0x54, + 0xd1, 0x73, 0x03, 0x5b, 0xb7, 0x66, 0xa8, 0x14, 0xa9, 0x2c, 0x57, 0x24, 0x24, 0x96, 0xc8, 0xc9, + 0x19, 0xc7, 0xe2, 0x7c, 0x3e, 0x6c, 0x27, 0x5c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e, 0xd1, 0xf9, 0x22, 0x00, 0x17, 0x8b, 0x00, 0x7c, 0x5f, 0x04, 0xe0, 0xd3, + 0x32, 0xa8, 0x5c, 0x2c, 0x83, 0xca, 0xd7, 0x65, 0x50, 0x79, 0xf3, 0x8c, 0x71, 0x33, 0x99, 0x8e, + 0xc2, 0xb1, 0x14, 0x38, 0x93, 0xc9, 0x5c, 0x50, 0x15, 0x13, 0x89, 0x85, 0x4c, 0xa5, 0xa0, 0x0a, + 0xe7, 0xd8, 0xad, 0xbe, 0x99, 0x67, 0x54, 0x8f, 0xaa, 0xe5, 0x4e, 0xbe, 0xf8, 0x19, 0x00, 0x00, + 0xff, 0xff, 0xee, 0x34, 0x5a, 0x78, 0x11, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -396,7 +391,7 @@ var _MsgService_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "rollup/v1/msg.proto", + Metadata: "rollup/v1/tx.proto", } func (m *ApplyL1TxsRequest) Marshal() (dAtA []byte, err error) { @@ -422,7 +417,7 @@ func (m *ApplyL1TxsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.FromAddress) > 0 { i -= len(m.FromAddress) copy(dAtA[i:], m.FromAddress) - i = encodeVarintMsg(dAtA, i, uint64(len(m.FromAddress))) + i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) i-- dAtA[i] = 0x12 } @@ -430,7 +425,7 @@ func (m *ApplyL1TxsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.TxBytes) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.TxBytes[iNdEx]) copy(dAtA[i:], m.TxBytes[iNdEx]) - i = encodeVarintMsg(dAtA, i, uint64(len(m.TxBytes[iNdEx]))) + i = encodeVarintTx(dAtA, i, uint64(len(m.TxBytes[iNdEx]))) i-- dAtA[i] = 0xa } @@ -484,14 +479,14 @@ func (m *InitiateWithdrawalRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro if len(m.Data) > 0 { i -= len(m.Data) copy(dAtA[i:], m.Data) - i = encodeVarintMsg(dAtA, i, uint64(len(m.Data))) + i = encodeVarintTx(dAtA, i, uint64(len(m.Data))) i-- dAtA[i] = 0x2a } if len(m.GasLimit) > 0 { i -= len(m.GasLimit) copy(dAtA[i:], m.GasLimit) - i = encodeVarintMsg(dAtA, i, uint64(len(m.GasLimit))) + i = encodeVarintTx(dAtA, i, uint64(len(m.GasLimit))) i-- dAtA[i] = 0x22 } @@ -501,21 +496,21 @@ func (m *InitiateWithdrawalRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i = encodeVarintMsg(dAtA, i, uint64(size)) + i = encodeVarintTx(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a if len(m.Target) > 0 { i -= len(m.Target) copy(dAtA[i:], m.Target) - i = encodeVarintMsg(dAtA, i, uint64(len(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 = encodeVarintMsg(dAtA, i, uint64(len(m.Sender))) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) i-- dAtA[i] = 0xa } @@ -545,8 +540,8 @@ func (m *InitiateWithdrawalResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func encodeVarintMsg(dAtA []byte, offset int, v uint64) int { - offset -= sovMsg(v) +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -565,12 +560,12 @@ func (m *ApplyL1TxsRequest) Size() (n int) { if len(m.TxBytes) > 0 { for _, b := range m.TxBytes { l = len(b) - n += 1 + l + sovMsg(uint64(l)) + n += 1 + l + sovTx(uint64(l)) } } l = len(m.FromAddress) if l > 0 { - n += 1 + l + sovMsg(uint64(l)) + n += 1 + l + sovTx(uint64(l)) } return n } @@ -592,21 +587,21 @@ func (m *InitiateWithdrawalRequest) Size() (n int) { _ = l l = len(m.Sender) if l > 0 { - n += 1 + l + sovMsg(uint64(l)) + n += 1 + l + sovTx(uint64(l)) } l = len(m.Target) if l > 0 { - n += 1 + l + sovMsg(uint64(l)) + n += 1 + l + sovTx(uint64(l)) } l = m.Value.Size() - n += 1 + l + sovMsg(uint64(l)) + n += 1 + l + sovTx(uint64(l)) l = len(m.GasLimit) if l > 0 { - n += 1 + l + sovMsg(uint64(l)) + n += 1 + l + sovTx(uint64(l)) } l = len(m.Data) if l > 0 { - n += 1 + l + sovMsg(uint64(l)) + n += 1 + l + sovTx(uint64(l)) } return n } @@ -620,11 +615,11 @@ func (m *InitiateWithdrawalResponse) Size() (n int) { return n } -func sovMsg(x uint64) (n int) { +func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozMsg(x uint64) (n int) { - return sovMsg(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *ApplyL1TxsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -634,7 +629,7 @@ func (m *ApplyL1TxsRequest) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -662,7 +657,7 @@ func (m *ApplyL1TxsRequest) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -675,11 +670,11 @@ func (m *ApplyL1TxsRequest) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF @@ -694,7 +689,7 @@ func (m *ApplyL1TxsRequest) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -708,11 +703,11 @@ func (m *ApplyL1TxsRequest) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF @@ -721,12 +716,12 @@ func (m *ApplyL1TxsRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipMsg(dAtA[iNdEx:]) + skippy, err := skipTx(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -748,7 +743,7 @@ func (m *ApplyL1TxsResponse) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -771,12 +766,12 @@ func (m *ApplyL1TxsResponse) Unmarshal(dAtA []byte) error { switch fieldNum { default: iNdEx = preIndex - skippy, err := skipMsg(dAtA[iNdEx:]) + skippy, err := skipTx(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -798,7 +793,7 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -826,7 +821,7 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -840,11 +835,11 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF @@ -858,7 +853,7 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -872,11 +867,11 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF @@ -890,7 +885,7 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -904,11 +899,11 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF @@ -924,7 +919,7 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -937,11 +932,11 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF @@ -958,7 +953,7 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -971,11 +966,11 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF @@ -987,12 +982,12 @@ func (m *InitiateWithdrawalRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipMsg(dAtA[iNdEx:]) + skippy, err := skipTx(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1014,7 +1009,7 @@ func (m *InitiateWithdrawalResponse) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowMsg + return ErrIntOverflowTx } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1037,12 +1032,12 @@ func (m *InitiateWithdrawalResponse) Unmarshal(dAtA []byte) error { switch fieldNum { default: iNdEx = preIndex - skippy, err := skipMsg(dAtA[iNdEx:]) + skippy, err := skipTx(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthMsg + return ErrInvalidLengthTx } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1056,7 +1051,7 @@ func (m *InitiateWithdrawalResponse) Unmarshal(dAtA []byte) error { } return nil } -func skipMsg(dAtA []byte) (n int, err error) { +func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -1064,7 +1059,7 @@ func skipMsg(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowMsg + return 0, ErrIntOverflowTx } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1081,7 +1076,7 @@ func skipMsg(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowMsg + return 0, ErrIntOverflowTx } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1097,7 +1092,7 @@ func skipMsg(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowMsg + return 0, ErrIntOverflowTx } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1110,14 +1105,14 @@ func skipMsg(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthMsg + return 0, ErrInvalidLengthTx } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupMsg + return 0, ErrUnexpectedEndOfGroupTx } depth-- case 5: @@ -1126,7 +1121,7 @@ func skipMsg(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthMsg + return 0, ErrInvalidLengthTx } if depth == 0 { return iNdEx, nil @@ -1136,7 +1131,7 @@ func skipMsg(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthMsg = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowMsg = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupMsg = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") )