Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Sep 24, 2023
1 parent f095683 commit 2a73ec8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 42 deletions.
32 changes: 4 additions & 28 deletions cosmos/x/evm/plugins/precompile/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ import (
// Plugin is the interface that must be implemented by the plugin.
type Plugin interface {
core.PrecompilePlugin

// KVGasConfig returns the gas config for
KVGasConfig() storetypes.GasConfig
SetKVGasConfig(storetypes.GasConfig)
TransientKVGasConfig() storetypes.GasConfig
SetTransientKVGasConfig(storetypes.GasConfig)
}

// polarisStateDB is the interface that must be implemented by the state DB.
Expand All @@ -71,8 +65,10 @@ type plugin struct {
// NewPlugin creates and returns a plugin with the default KV store gas configs.
func NewPlugin(precompiles []ethprecompile.Registrable) Plugin {
return &plugin{
Registry: registry.NewMap[common.Address, vm.PrecompileContainer](),
precompiles: precompiles,
Registry: registry.NewMap[common.Address, vm.PrecompileContainer](),
precompiles: precompiles,
// NOTE: these are hardcoded as they are also hardcoded in the sdk.
// This should be updated if it ever changes.
kvGasConfig: storetypes.KVGasConfig(),
transientKVGasConfig: storetypes.TransientGasConfig(),
}
Expand All @@ -96,26 +92,6 @@ func (p *plugin) GetActive(rules *params.Rules) []common.Address {
return active
}

// KVGasConfig implements Plugin.
func (p *plugin) KVGasConfig() storetypes.GasConfig {
return p.kvGasConfig
}

// SetKVGasConfig implements Plugin.
func (p *plugin) SetKVGasConfig(kvGasConfig storetypes.GasConfig) {
p.kvGasConfig = kvGasConfig
}

// TransientKVGasConfig implements Plugin.
func (p *plugin) TransientKVGasConfig() storetypes.GasConfig {
return p.transientKVGasConfig
}

// SetTransientKVGasConfig implements Plugin.
func (p *plugin) SetTransientKVGasConfig(transientKVGasConfig storetypes.GasConfig) {
p.transientKVGasConfig = transientKVGasConfig
}

// Run runs the a precompile container and returns the remaining gas after execution by injecting
// a Cosmos SDK `GasMeter`. This function returns an error if the precompile execution returns an
// error or insufficient gas is provided.
Expand Down
14 changes: 0 additions & 14 deletions cosmos/x/evm/plugins/precompile/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,6 @@ var _ = Describe("plugin", func() {
Expect(err).To(MatchError("out of gas"))
})

It("should plug in custom gas configs", func() {
Expect(p.KVGasConfig().DeleteCost).To(Equal(uint64(1000)))
Expect(p.TransientKVGasConfig().DeleteCost).To(Equal(uint64(100)))

p.SetKVGasConfig(storetypes.GasConfig{
DeleteCost: 2,
})
Expect(p.KVGasConfig().DeleteCost).To(Equal(uint64(2)))
p.SetTransientKVGasConfig(storetypes.GasConfig{
DeleteCost: 3,
})
Expect(p.TransientKVGasConfig().DeleteCost).To(Equal(uint64(3)))
})

It("should handle read-only static calls", func() {
ms := utils.MustGetAs[tmock.MultiStore](ctx.MultiStore())
cem := utils.MustGetAs[state.ControllableEventManager](ctx.EventManager())
Expand Down

0 comments on commit 2a73ec8

Please sign in to comment.