From 5d7ca1999780d781b114a4104415907e9f23e2cd Mon Sep 17 00:00:00 2001 From: Aivaras Ko Date: Wed, 30 Oct 2024 10:58:39 +0200 Subject: [PATCH] Fix default gas limit on execution config --- services/blockrelay/v2/executionconfig.go | 6 +- .../blockrelay/v2/executionconfig_test.go | 56 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/services/blockrelay/v2/executionconfig.go b/services/blockrelay/v2/executionconfig.go index fc877c5..e28b86f 100644 --- a/services/blockrelay/v2/executionconfig.go +++ b/services/blockrelay/v2/executionconfig.go @@ -192,7 +192,11 @@ func (e *ExecutionConfig) setInitialRelayOptions(_ context.Context, } else { configRelay.MinValue = *e.MinValue } - setRelayConfig(configRelay, baseRelayConfig, config.FeeRecipient, fallbackGasLimit) + if e.GasLimit == nil { + setRelayConfig(configRelay, baseRelayConfig, config.FeeRecipient, fallbackGasLimit) + } else { + setRelayConfig(configRelay, baseRelayConfig, config.FeeRecipient, *e.GasLimit) + } config.Relays = append(config.Relays, configRelay) } } diff --git a/services/blockrelay/v2/executionconfig_test.go b/services/blockrelay/v2/executionconfig_test.go index 9cf72a0..528b8f2 100644 --- a/services/blockrelay/v2/executionconfig_test.go +++ b/services/blockrelay/v2/executionconfig_test.go @@ -672,6 +672,62 @@ func TestConfig(t *testing.T) { }, }, }, + { + name: "ExecutionConfigDefaultGasLimit", + executionConfig: &v2.ExecutionConfig{ + GasLimit: &gasLimit4, + Proposers: []*v2.ProposerConfig{}, + FeeRecipient: &feeRecipient3, + Relays: map[string]*v2.BaseRelayConfig{ + "https://relay1.com/": {}, + }, + }, + account: account1, + pubkey: pubkey1, + fallbackFeeRecipient: feeRecipient1, + fallbackGasLimit: gasLimit1, + expected: &beaconblockproposer.ProposerConfig{ + FeeRecipient: feeRecipient3, + Relays: []*beaconblockproposer.RelayConfig{ + { + Address: "https://relay1.com/", + FeeRecipient: feeRecipient3, + GasLimit: gasLimit4, + Grace: grace0, + MinValue: minValue0, + }, + }, + }, + }, + { + name: "ExecutionConfigDefaultAndRelayGasLimit", + executionConfig: &v2.ExecutionConfig{ + GasLimit: &gasLimit4, + Proposers: []*v2.ProposerConfig{}, + FeeRecipient: &feeRecipient3, + Relays: map[string]*v2.BaseRelayConfig{ + "https://relay1.com/": { + GasLimit: &gasLimit3, + }, + }, + }, + account: account1, + pubkey: pubkey1, + fallbackFeeRecipient: feeRecipient1, + fallbackGasLimit: gasLimit1, + expected: &beaconblockproposer.ProposerConfig{ + FeeRecipient: feeRecipient3, + Relays: []*beaconblockproposer.RelayConfig{ + { + Address: "https://relay1.com/", + FeeRecipient: feeRecipient3, + GasLimit: gasLimit3, + Grace: grace0, + MinValue: minValue0, + }, + }, + }, + }, { name: "InvalidProposerConfig", executionConfig: &v2.ExecutionConfig{