Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust default gas settings #566

Closed
ethanfrey opened this issue Jul 27, 2021 · 1 comment · Fixed by #636
Closed

Adjust default gas settings #566

ethanfrey opened this issue Jul 27, 2021 · 1 comment · Fixed by #636

Comments

@ethanfrey
Copy link
Member

ethanfrey commented Jul 27, 2021

See the constants here. Many may warrant some adjustments. Especially the default gas multiplier.

const (
// DefaultGasMultiplier is how many cosmwasm gas points = 1 sdk gas point
// SDK reference costs can be found here: https://github.com/cosmos/cosmos-sdk/blob/02c6c9fafd58da88550ab4d7d494724a477c8a68/store/types/gas.go#L153-L164
// A write at ~3000 gas and ~200us = 10 gas per us (microsecond) cpu/io
// Rough timing have 88k gas at 90us, which is equal to 1k sdk gas... (one read)
//
// Please note that all gas prices returned to the wasmer engine should have this multiplied
DefaultGasMultiplier uint64 = 100
// DefaultInstanceCost is how much SDK gas we charge each time we load a WASM instance.
// Creating a new instance is costly, and this helps put a recursion limit to contracts calling contracts.
DefaultInstanceCost uint64 = 40_000
// DefaultCompileCost is how much SDK gas is charged *per byte* for compiling WASM code.
DefaultCompileCost uint64 = 2
// DefaultEventAttributeDataCost is how much SDK gas is charged *per byte* for attribute data in events.
// This is used with len(key) + len(value)
DefaultEventAttributeDataCost uint64 = 1
// DefaultContractMessageDataCost is how much SDK gas is charged *per byte* of the message that goes to the contract
// This is used with len(msg)
DefaultContractMessageDataCost uint64 = 1
// DefaultPerAttributeCost is how much SDK gas we charge per attribute count.
DefaultPerAttributeCost uint64 = 10
// DefaultPerCustomEventCost is how much SDK gas we charge per event count.
DefaultPerCustomEventCost uint64 = 20
// DefaultEventAttributeDataFreeTier number of bytes of total attribute data we do not charge.
DefaultEventAttributeDataFreeTier = 100
)

I would also revisit some of the algorithms, like how the pricing works on Reply, which is a bit different charge for events than other items.

@ethanfrey ethanfrey modified the milestones: v0.18.0, v1.0.0 Jul 27, 2021
@ethanfrey
Copy link
Member Author

Let's benchmark the default gas multiplier and the instantiate cost.

There is a new 1Terragas/ms definition for wasm gas. If we benchmark the secp256k1 sig verification (1000 sdk gas) we can find a proper conversion ratio there.

We can also benchmark non-cached instantiation and use the 1000 gas/sig verification comparison to get a proper number there.

And maybe even benchmark the compilation step and see if we want to make uploading code more expensive (this is done once per project, so not really an issue if this ends up as 10 million gas, real contracts will be worth that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant