-
Notifications
You must be signed in to change notification settings - Fork 8
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
SetConfig optimization + billing config improvements #36
Conversation
contracts/ocr2/src/contract.rs
Outdated
base_gas: None, | ||
gas_per_signature: None, | ||
gas_adjustment: None, |
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.
These are now settable via setBilling
but can also be nil
to use the built-in default
contracts/ocr2/src/contract.rs
Outdated
let gas_per_signature = decimal(config.gas_per_signature.unwrap_or(17_000)); | ||
let base_gas = decimal(config.base_gas.unwrap_or(84_000)); | ||
let gas_adjustment = Decimal::percent(u64::from(config.gas_adjustment.unwrap_or(140))); |
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.
Adjusted based on devnet values. We seemed to over-estimate by almost exactly 4x. The amount charged is also the "gas allocated", not "gas used" and the difference seems to be about 1.4x
32845a2
to
b97e842
Compare
contracts/ocr2/src/state.rs
Outdated
pub struct Billing { | ||
/// Should match https://fcd.terra.dev/v1/txs/gas_prices | ||
/// NOTE: needs to be scaled to the same amount of decimals places as LINK token | ||
pub recommended_gas_price: u64, | ||
pub observation_payment: u64, | ||
pub transmission_payment: u64, | ||
pub base_gas: Option<u64>, |
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.
I'd suggest we rename this as gas_base
to be consistent with other args.
a94ab2e
to
d32ce28
Compare
contracts/ocr2/src/contract.rs
Outdated
@@ -929,11 +931,15 @@ pub fn execute_set_billing( | |||
Event::new("set_billing") | |||
.add_attribute( | |||
"recommended_gas_price", |
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.
Should we rename this attribute as recommended_gas_price_uluna
to keep it consistent?
contracts/ocr2/src/contract.rs
Outdated
// + transmitter gas reimbursement | ||
.checked_add(transmitter.payment)?) | ||
Ok( | ||
Uint128::new(u128::from(config.billing.observation_payment_gjuels) * 10u128.pow(9)) // scale to juels |
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.
Consider extracting this scale factor 10u128.pow(9)
as a constant.
57f6c0f
to
8ef78a7
Compare
That's converting/unwrapping from the |
observation_payment: new BN(input.observationPaymentGjuels).toNumber(), | ||
observation_payment_gjuels: new BN(input.observationPaymentGjuels).toNumber(), | ||
transmission_payment_gjuels: new BN(input.transmissionPaymentGjuels).toNumber(), | ||
recommended_gas_price_uluna: input.recommendedGasPriceUluna |
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.
This should be of Decimal type (https://github.com/smartcontractkit/chainlink-terra/pull/36/files#diff-7593d1da79e988b58adce267ba96df185c0abebbfc17323f0de5e749e6419134R56)
@archseer Which format should we be applying here?
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.
It's a string, you can pass through the value from https://fcd.terra.dev/v1/txs/gas_prices without modifying it
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.
This info comes from the RDD, so we can expect it to come in the right format
This is so we can fit more data into the 4kb payload
Co-authored-by: Kristijan Rebernisak <[email protected]>
Code existed, but wasn't present in ExecuteMsg
version of deployed contracts
55f4dbf
to
02ebdce
Compare
@@ -33,7 +33,7 @@ const makeContractInput = async (input: CommandInput): Promise<ContractInput> => | |||
config: { | |||
observation_payment_gjuels: new BN(input.observationPaymentGjuels).toNumber(), | |||
transmission_payment_gjuels: new BN(input.transmissionPaymentGjuels).toNumber(), | |||
recommended_gas_price_uluna: input.recommendedGasPriceUluna | |||
recommended_gas_price_uluna: new BN(input.recommendedGasPriceUluna).toString(), |
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.
If this works, I think it will have the effect of converting the decimal to an integer, either by truncating or rounding I suppose. Is that really what we want to do?
From: https://github.com/indutny/bn.js/
"Note: decimals are not supported in this library."
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.
Ah, agreed. RDD should store this as a string to avoid losing precision. @RodrigoAD
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.
You're completely right. I'll open a fix
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.
Looks like it's handled in #76
Need to fit each call into 4kb
[please don't squash]