-
Notifications
You must be signed in to change notification settings - Fork 158
Warp gas costs granite #1306
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
base: master
Are you sure you want to change the base?
Warp gas costs granite #1306
Changes from all commits
66d6ec8
9f79801
f4b571a
03ca047
fd4ea40
17b9c34
f69660b
d0ce926
61cd823
07eec20
30cc067
aee99ec
ed3c81c
4cd6e7c
a10c938
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,11 @@ func (a accessibleState) GetChainConfig() precompileconfig.ChainConfig { | |
return GetExtra(a.env.ChainConfig()) | ||
} | ||
|
||
func (a accessibleState) GetRules() precompileconfig.Rules { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for refactoring this. |
||
extra := GetExtra(a.GetPrecompileEnv().ChainConfig()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can we rename this to |
||
return extra.GetAvalancheRules(a.GetBlockContext().Timestamp()) | ||
} | ||
|
||
func (a accessibleState) GetSnowContext() *snow.Context { | ||
return GetExtra(a.env.ChainConfig()).SnowCtx | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ import ( | |
|
||
"github.com/ava-labs/coreth/accounts/abi" | ||
"github.com/ava-labs/coreth/precompile/contract" | ||
"github.com/ava-labs/coreth/precompile/precompileconfig" | ||
) | ||
|
||
const ( | ||
|
@@ -31,12 +32,17 @@ const ( | |
SendWarpMessageGasCost uint64 = contract.LogGas + 3*contract.LogTopicGas + AddWarpMessageGasCost + contract.WriteGasCostPerSlot | ||
// SendWarpMessageGasCostPerByte cost accounts for producing a signed message of a given size | ||
SendWarpMessageGasCostPerByte uint64 = contract.LogDataGas | ||
|
||
GasCostPerWarpSigner uint64 = 500 | ||
GasCostPerWarpMessageChunk uint64 = 3_200 | ||
GasCostPerSignatureVerification uint64 = 200_000 | ||
) | ||
|
||
type GasConfig struct { | ||
// Gas cost per warp signer in the validator set | ||
PerWarpSigner uint64 | ||
// Gas cost per chunk of the warp message (each chunk is 128 bytes) | ||
PerWarpMessageChunk uint64 | ||
// Gas cost to verify a BLS signature | ||
PerSignatureVerification uint64 | ||
} | ||
|
||
var ( | ||
errInvalidSendInput = errors.New("invalid sendWarpMessage input") | ||
errInvalidIndexInput = errors.New("invalid index to specify warp message") | ||
|
@@ -343,3 +349,18 @@ func createWarpPrecompile() contract.StatefulPrecompiledContract { | |
} | ||
return statefulContract | ||
} | ||
|
||
func CurrentGasConfig(rules precompileconfig.Rules) GasConfig { | ||
if rules.IsGraniteActivated() { | ||
return GasConfig{ | ||
PerWarpSigner: 250, | ||
PerWarpMessageChunk: 3_200, | ||
PerSignatureVerification: 100_000, | ||
} | ||
Comment on lines
+355
to
+359
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we can just define them as constants just for a better visibility |
||
} | ||
return GasConfig{ | ||
PerWarpSigner: 500, | ||
PerWarpMessageChunk: 3_200, | ||
PerSignatureVerification: 200_000, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a comment why this is required (to make it clear this is called from precompile environment etc)