Skip to content

Commit

Permalink
Fix validator can specify gas limit
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain committed Dec 13, 2024
1 parent d93a1b6 commit f7c8ab8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Fix segmentation fault in E2E when light-client feature flag is enabled. [PR](https://github.com/prysmaticlabs/prysm/pull/14699)
- Fix `searchForPeers` infinite loop in small networks.
- Fix slashing pool behavior to enforce MaxAttesterSlashings limit in Electra version.
- Fix validator gas limit usage through flag and file.

### Security

Expand Down
1 change: 1 addition & 0 deletions config/proposer/loader/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_test(
"//config/proposer:go_default_library",
"//consensus-types/validator:go_default_library",
"//encoding/bytesutil:go_default_library",
"//proto/prysm/v1alpha1/validator-client:go_default_library",
"//testing/assert:go_default_library",
"//testing/require:go_default_library",
"//validator/db/iface:go_default_library",
Expand Down
3 changes: 3 additions & 0 deletions config/proposer/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ func (psl *settingsLoader) processProposerSettings(loadedSettings, dbSettings *v
// process any overrides for proposer config
for _, option := range newSettings.ProposerConfig {
if option != nil {
if loadedSettings != nil && option.Builder != nil {
gasLimitOnly = &option.Builder.GasLimit
}
option.Builder = processBuilderConfig(option.Builder, builderConfig, gasLimitOnly)
}
}
Expand Down
27 changes: 26 additions & 1 deletion config/proposer/loader/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/prysmaticlabs/prysm/v5/config/proposer"
"github.com/prysmaticlabs/prysm/v5/consensus-types/validator"
"github.com/prysmaticlabs/prysm/v5/encoding/bytesutil"
validatorpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1/validator-client"
"github.com/prysmaticlabs/prysm/v5/testing/assert"
"github.com/prysmaticlabs/prysm/v5/testing/require"
"github.com/prysmaticlabs/prysm/v5/validator/db/iface"
Expand Down Expand Up @@ -499,7 +500,7 @@ func TestProposerSettingsLoader(t *testing.T) {
},
BuilderConfig: &proposer.BuilderConfig{
Enabled: true,
GasLimit: 50000000,
GasLimit: 40000000,
},
},
},
Expand Down Expand Up @@ -1003,3 +1004,27 @@ func Test_ProposerSettingsLoaderWithOnlyBuilder_DoesNotSaveInDB(t *testing.T) {
})
}
}

func Test_settingsLoader_processProposerSettings(t *testing.T) {
limit := validator.Uint64(30_000_000)
psl := &settingsLoader{
options: &flagOptions{
gasLimit: &limit,
},
}
loaded := &validatorpb.ProposerSettingsPayload{
ProposerConfig: map[string]*validatorpb.ProposerOptionPayload{
"bob": {
Builder: &validatorpb.BuilderConfig{
GasLimit: 40_000_000,
},
},
},
}
var db *validatorpb.ProposerSettingsPayload
got := psl.processProposerSettings(loaded, db)
require.NotNil(t, got)
for _, payload := range got.ProposerConfig {
require.Equal(t, validator.Uint64(40_000_000), payload.Builder.GasLimit)
}
}

0 comments on commit f7c8ab8

Please sign in to comment.