From ac1ab50f7f783ff20da0037c8973a5daedeea9a6 Mon Sep 17 00:00:00 2001 From: Nate Beauregard Date: Fri, 6 Dec 2024 13:28:52 -0500 Subject: [PATCH] Add L1StandardBridge address to x/rollup params --- proto/rollup/v1/rollup.proto | 6 +- x/rollup/tests/integration/rollup_test.go | 1 + x/rollup/types/params.go | 6 + x/rollup/types/rollup.pb.go | 129 +++++++++++++++------- 4 files changed, 102 insertions(+), 40 deletions(-) diff --git a/proto/rollup/v1/rollup.proto b/proto/rollup/v1/rollup.proto index fb358889..5058f628 100644 --- a/proto/rollup/v1/rollup.proto +++ b/proto/rollup/v1/rollup.proto @@ -11,10 +11,12 @@ message Params { string l1_fee_recipient = 1; // L1 address of the cross-domain messenger contract. string l1_cross_domain_messenger = 2; + // L1 address of the standard bridge contract. + string l1_standard_bridge = 3; // Minimum amount of L2 fees that the FeeCollector account must have before they can be withdrawn. - uint64 min_fee_withdrawal_amount = 3; + uint64 min_fee_withdrawal_amount = 4; // L1 gas limit for withdrawing fees to the L1 recipient address. - uint64 fee_withdrawal_gas_limit = 4; + uint64 fee_withdrawal_gas_limit = 5; } // L1BlockInfo represents information about an L1 block and associated L2 data. diff --git a/x/rollup/tests/integration/rollup_test.go b/x/rollup/tests/integration/rollup_test.go index 3f75a0d8..313ed132 100644 --- a/x/rollup/tests/integration/rollup_test.go +++ b/x/rollup/tests/integration/rollup_test.go @@ -151,6 +151,7 @@ func TestRollup(t *testing.T) { updatedParams := rolluptypes.Params{ L1FeeRecipient: common.HexToAddress("0x123456abcdef").String(), L1CrossDomainMessenger: common.HexToAddress("0xabcdef123456").String(), + L1StandardBridge: common.HexToAddress("0xa1b2c3d4e5f6").String(), MinFeeWithdrawalAmount: 5, FeeWithdrawalGasLimit: 5, } diff --git a/x/rollup/types/params.go b/x/rollup/types/params.go index 486a592f..80ad61e4 100644 --- a/x/rollup/types/params.go +++ b/x/rollup/types/params.go @@ -12,6 +12,8 @@ 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 string = "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1" defaultMinFeeWithdrawalAmount uint64 = 400_000 defaultFeeWithdrawalGasLimit uint64 = 400_000 ) @@ -19,6 +21,7 @@ func DefaultParams() Params { return Params{ L1FeeRecipient: defaultL1FeeRecipient, L1CrossDomainMessenger: defaultL1CrossDomainMessenger, + L1StandardBridge: defaultL1StandardBridge, MinFeeWithdrawalAmount: defaultMinFeeWithdrawalAmount, FeeWithdrawalGasLimit: defaultFeeWithdrawalGasLimit, } @@ -32,6 +35,9 @@ func (p *Params) Validate() error { if err := validateEthAddress(p.L1CrossDomainMessenger); err != nil { 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 nil } diff --git a/x/rollup/types/rollup.pb.go b/x/rollup/types/rollup.pb.go index 60a88342..fb8a5585 100644 --- a/x/rollup/types/rollup.pb.go +++ b/x/rollup/types/rollup.pb.go @@ -29,10 +29,12 @@ type Params struct { L1FeeRecipient string `protobuf:"bytes,1,opt,name=l1_fee_recipient,json=l1FeeRecipient,proto3" json:"l1_fee_recipient,omitempty"` // L1 address of the cross-domain messenger contract. L1CrossDomainMessenger string `protobuf:"bytes,2,opt,name=l1_cross_domain_messenger,json=l1CrossDomainMessenger,proto3" json:"l1_cross_domain_messenger,omitempty"` + // L1 address of the standard bridge contract. + L1StandardBridge string `protobuf:"bytes,3,opt,name=l1_standard_bridge,json=l1StandardBridge,proto3" json:"l1_standard_bridge,omitempty"` // Minimum amount of L2 fees that the FeeCollector account must have before they can be withdrawn. - MinFeeWithdrawalAmount uint64 `protobuf:"varint,3,opt,name=min_fee_withdrawal_amount,json=minFeeWithdrawalAmount,proto3" json:"min_fee_withdrawal_amount,omitempty"` + MinFeeWithdrawalAmount uint64 `protobuf:"varint,4,opt,name=min_fee_withdrawal_amount,json=minFeeWithdrawalAmount,proto3" json:"min_fee_withdrawal_amount,omitempty"` // L1 gas limit for withdrawing fees to the L1 recipient address. - FeeWithdrawalGasLimit uint64 `protobuf:"varint,4,opt,name=fee_withdrawal_gas_limit,json=feeWithdrawalGasLimit,proto3" json:"fee_withdrawal_gas_limit,omitempty"` + FeeWithdrawalGasLimit uint64 `protobuf:"varint,5,opt,name=fee_withdrawal_gas_limit,json=feeWithdrawalGasLimit,proto3" json:"fee_withdrawal_gas_limit,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -82,6 +84,13 @@ func (m *Params) GetL1CrossDomainMessenger() string { return "" } +func (m *Params) GetL1StandardBridge() string { + if m != nil { + return m.L1StandardBridge + } + return "" +} + func (m *Params) GetMinFeeWithdrawalAmount() uint64 { if m != nil { return m.MinFeeWithdrawalAmount @@ -229,39 +238,40 @@ func init() { func init() { proto.RegisterFile("rollup/v1/rollup.proto", fileDescriptor_b51d0d5c8e6e30d5) } var fileDescriptor_b51d0d5c8e6e30d5 = []byte{ - // 499 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0x4f, 0x6f, 0xd3, 0x30, - 0x14, 0x6f, 0x58, 0xe8, 0x56, 0xb7, 0x5d, 0xc1, 0x1a, 0x55, 0x40, 0x22, 0x2b, 0x3d, 0x8c, 0x1e, - 0xd0, 0xa2, 0x88, 0x03, 0xe2, 0xb8, 0x82, 0x0a, 0x48, 0xe3, 0x8f, 0xc2, 0x01, 0x89, 0x8b, 0xe5, - 0x24, 0xaf, 0x4d, 0x84, 0x1d, 0x17, 0x3b, 0xed, 0xd8, 0xb7, 0xe0, 0xc0, 0x87, 0xda, 0x71, 0x47, - 0x4e, 0x08, 0xda, 0x2f, 0x82, 0xf2, 0xe2, 0x4c, 0x85, 0xdb, 0xf3, 0xef, 0xdf, 0x7b, 0xcf, 0x36, - 0x19, 0x6a, 0x25, 0xc4, 0x6a, 0x19, 0xac, 0xc3, 0xa0, 0xae, 0x4e, 0x97, 0x5a, 0x95, 0x8a, 0x76, - 0xec, 0x69, 0x1d, 0x3e, 0x38, 0x5a, 0xa8, 0x85, 0x42, 0x34, 0xa8, 0xaa, 0x5a, 0x30, 0xfe, 0xe3, - 0x90, 0xf6, 0x07, 0xae, 0xb9, 0x34, 0x74, 0x42, 0xee, 0x88, 0x90, 0xcd, 0x01, 0x98, 0x86, 0x24, - 0x5f, 0xe6, 0x50, 0x94, 0x9e, 0x33, 0x72, 0x26, 0x9d, 0xe8, 0x50, 0x84, 0x33, 0x80, 0xa8, 0x41, - 0xe9, 0x73, 0x72, 0x5f, 0x84, 0x2c, 0xd1, 0xca, 0x18, 0x96, 0x2a, 0xc9, 0xf3, 0x82, 0x49, 0x30, - 0x06, 0x8a, 0x05, 0x68, 0xef, 0x16, 0x5a, 0x86, 0x22, 0x7c, 0x51, 0xf1, 0x2f, 0x91, 0x7e, 0xdb, - 0xb0, 0x95, 0x55, 0xe6, 0x05, 0x76, 0xb9, 0xc8, 0xcb, 0x2c, 0xd5, 0xfc, 0x82, 0x0b, 0xc6, 0xa5, - 0x5a, 0x15, 0xa5, 0xb7, 0x37, 0x72, 0x26, 0x6e, 0x34, 0x94, 0x79, 0x31, 0x03, 0xf8, 0x74, 0x43, - 0x9f, 0x21, 0x4b, 0x9f, 0x11, 0xef, 0x3f, 0xdb, 0x82, 0x1b, 0x26, 0x72, 0x99, 0x97, 0x9e, 0x8b, - 0xce, 0x7b, 0xf3, 0x5d, 0xdb, 0x2b, 0x6e, 0xce, 0x2b, 0x72, 0xfc, 0x63, 0x8f, 0x74, 0xcf, 0xc3, - 0xa9, 0x50, 0xc9, 0x97, 0x37, 0xc5, 0x5c, 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, 0xc6, 0x77, 0xae, - 0x37, 0xbe, 0xf3, 0x7b, 0xe3, 0x3b, 0xdf, 0xb7, 0x7e, 0xeb, 0x7a, 0xeb, 0xb7, 0x7e, 0x6e, 0xfd, - 0xd6, 0xe7, 0x27, 0x8b, 0xbc, 0xcc, 0x56, 0xf1, 0x69, 0xa2, 0x64, 0xb0, 0x54, 0xe2, 0x52, 0x82, - 0x4e, 0xb9, 0x0a, 0xa4, 0x2a, 0x94, 0x04, 0x1d, 0x7c, 0xb3, 0x7f, 0x3c, 0x28, 0x2f, 0x97, 0x60, - 0xe2, 0x36, 0xfe, 0xe4, 0xa7, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xbe, 0xdd, 0x12, 0x17, 0x04, - 0x03, 0x00, 0x00, + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x53, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0x6e, 0xb6, 0xd0, 0xad, 0x6e, 0xbb, 0x0e, 0x6b, 0x54, 0x01, 0x89, 0xac, 0xf4, 0x30, 0x7a, + 0x98, 0x16, 0x45, 0x1c, 0x10, 0xc7, 0x15, 0x54, 0x40, 0x1a, 0x1f, 0xca, 0x0e, 0x48, 0x5c, 0x2c, + 0x27, 0x79, 0x9b, 0x44, 0xf8, 0xa3, 0xd8, 0x69, 0xc7, 0x7e, 0x05, 0x1c, 0xf8, 0x51, 0x3b, 0xee, + 0xc8, 0x09, 0xa1, 0xf6, 0x8f, 0xa0, 0x38, 0xce, 0x54, 0xb8, 0xd9, 0xcf, 0x97, 0xdf, 0xc7, 0x4e, + 0xd0, 0x50, 0x49, 0xc6, 0x96, 0x8b, 0x60, 0x15, 0x06, 0xf5, 0xea, 0x6c, 0xa1, 0x64, 0x29, 0x71, + 0xc7, 0xee, 0x56, 0xe1, 0xa3, 0xa3, 0x4c, 0x66, 0xd2, 0xa0, 0x41, 0xb5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, 0xf1, 0x5b, 0x9f, 0x4f, 0xb3, 0xa2, 0xcc, + 0x97, 0xf1, 0x59, 0x22, 0x79, 0xb0, 0x90, 0xec, 0x9a, 0x83, 0x4a, 0xa9, 0x0c, 0xb8, 0x14, 0x92, + 0x83, 0x0a, 0xbe, 0xd9, 0x3f, 0x22, 0x28, 0xaf, 0x17, 0xa0, 0xe3, 0xb6, 0xf9, 0xee, 0x9f, 0xfd, + 0x0d, 0x00, 0x00, 0xff, 0xff, 0xf2, 0xbc, 0xef, 0xa7, 0x32, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -287,12 +297,19 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.FeeWithdrawalGasLimit != 0 { i = encodeVarintRollup(dAtA, i, uint64(m.FeeWithdrawalGasLimit)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } if m.MinFeeWithdrawalAmount != 0 { i = encodeVarintRollup(dAtA, i, uint64(m.MinFeeWithdrawalAmount)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 + } + if len(m.L1StandardBridge) > 0 { + i -= len(m.L1StandardBridge) + copy(dAtA[i:], m.L1StandardBridge) + i = encodeVarintRollup(dAtA, i, uint64(len(m.L1StandardBridge))) + i-- + dAtA[i] = 0x1a } if len(m.L1CrossDomainMessenger) > 0 { i -= len(m.L1CrossDomainMessenger) @@ -426,6 +443,10 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovRollup(uint64(l)) } + l = len(m.L1StandardBridge) + if l > 0 { + n += 1 + l + sovRollup(uint64(l)) + } if m.MinFeeWithdrawalAmount != 0 { n += 1 + sovRollup(uint64(m.MinFeeWithdrawalAmount)) } @@ -583,6 +604,38 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.L1CrossDomainMessenger = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field L1StandardBridge", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRollup + } + 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 ErrInvalidLengthRollup + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRollup + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.L1StandardBridge = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MinFeeWithdrawalAmount", wireType) } @@ -601,7 +654,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field FeeWithdrawalGasLimit", wireType) }