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

Commit

Permalink
feat: set registry gas costs (ethereum-optimism#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
therealbytes committed Sep 2, 2023
1 parent be3f484 commit 7d24f80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions concrete/precompiles/precompile_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ var PrecompileRegistryMetadata = PrecompileMetadata{
}

var (
GetFrameworkGas = uint64(10)
GetPrecompileGas = uint64(10)
GetPrecompileByNameGas = uint64(10)
GetPrecompiledAddressesGas = uint64(10)
GetPrecompilesGas = uint64(10)
GetFrameworkGas = uint64(15)
GetPrecompileGas = uint64(50)
GetPrecompileByNameGas = uint64(5)
GetPrecompiledAddressesPerPrecompileGas = uint64(5)
GetPrecompilesPrePrecompileGas = uint64(50)
)

func init() {
Expand Down Expand Up @@ -128,7 +128,7 @@ type getPrecompiledAddresses struct {
}

func (p *getPrecompiledAddresses) RequiredGas(input []byte) uint64 {
return GetPrecompiledAddressesGas
return GetPrecompiledAddressesPerPrecompileGas * uint64(len(precompiledAddresses))
}

func (p *getPrecompiledAddresses) Run(API api.API, input []byte) ([]byte, error) {
Expand All @@ -142,7 +142,7 @@ type getPrecompiles struct {
}

func (p *getPrecompiles) RequiredGas(input []byte) uint64 {
return GetPrecompilesGas
return GetPrecompilesPrePrecompileGas * uint64(len(precompileMetadata))
}

func (p *getPrecompiles) Run(concrete api.API, input []byte) ([]byte, error) {
Expand Down
24 changes: 12 additions & 12 deletions concrete/precompiles/preimage_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ var (
}
DefaultPreimageRegistryGasTable = PreimageRegistryGasTable{
FailGas: 10,
AddPreimageGas: 10,
AddPreimagePerByteGas: 10,
HasPreimageGas: 10,
GetPreimageSizeGas: 10,
GetPreimageGas: 10,
GetPreimagePerByteGas: 10,
AddPreimageGas: 20000,
AddPreimagePerByteGas: 100,
HasPreimageGas: 1000,
GetPreimageSizeGas: 1000,
GetPreimageGas: 1000,
GetPreimagePerByteGas: 50,
}
DefaultBigPreimageRegistryGasTable = PreimageRegistryGasTable{
FailGas: 10,
AddPreimageGas: 10,
AddPreimagePerByteGas: 10,
HasPreimageGas: 10,
GetPreimageSizeGas: 10,
GetPreimageGas: 10,
GetPreimagePerByteGas: 10,
AddPreimageGas: 20000,
AddPreimagePerByteGas: 250,
HasPreimageGas: 1000,
GetPreimageSizeGas: 1000,
GetPreimageGas: 1000,
GetPreimagePerByteGas: 125,
}
)

Expand Down

0 comments on commit 7d24f80

Please sign in to comment.