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
Add endpoint to get recent gas prices #4277
Conversation
apps/aehttp/src/aehttp_logic.erl
Outdated
MinGasPrices -> | ||
MinPriceN = fun(N) -> | ||
case lists:min(lists:sublist(MinGasPrices, N)) of | ||
undefined -> 0; |
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.
In OTP25 lists:min([]) throws an exception, but never undefined?
Oh, I see the hack now:
7> lists:min([undefined, 1,3]).
1
😃
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.
Moreover, minimum should then possibly be the consensus defined minimum?
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.
Returning 0 works for me as a way to distinguish
- is there empty space in blocks (then SDK should use minimum gas price)
- all blocks full, but transactions using minimum gas price (then SDK should increase the gas price a bit to ensure tx would be mined)
Otherwise I would ask for a flag indicating that.
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.
Not sure you should use 0 as minimum instead of consensus minimum, but that would not be a problem in practise
#{ <<"blocks">> := 120, <<"min_gas_price">> := MinGasPrice120 }, | ||
#{ <<"blocks">> := 480, <<"min_gas_price">> := MinGasPrice480 } | ||
]} = http_request(Host, get, "recent-gas-prices", []), | ||
MinGasPrice = 1000000000, |
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.
Not very convincing test :)
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.
Hmm, no... Didn't look at it, just updated it to pass 😅
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.
Same concern as @ThomasArts about protocol minimums
Why not, if the client solely relies on this result and the last X blocks are empty? 🤔 |
I think 0 would signal quite well that we don't have any data - the alternative would be protocol minimum, but there is no miner accepting that so that would be equally broken. |
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.
@hanssv In the latest version, I can't distinguish if blocks are full and I should use min gas price + 1 or if there is space in blocks and I can use 1e9 (default min gas price). If sdk would always do min gas price + 1 then multiple sdk instances can increase the gas price without reason.
Another issue:
|
As Dincho explained somewhere - 1e9 is not a fixed value, it can be set by the miner, so wether there is space or not is actually not relevant. If there are Txs in an interval you'll get the min gas price found, otherwise 0. |
Microseconds and milliseconds were mixed-up, so you'd have to wait for 1000 minutes to see the effect 🙈 Fixed now. |
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.
Missed that in review before, but indeed, times 1000
So we decided on sticking to this approach (reporting minimum gas price that made it on chain in the last X, Y and Z minutes) - but we'll also add a congestions metric (basically how many percent of of the available gas that was used in the the given time). I will also sort out the caching properly - probably by an actual caching lib 😅 |
fef8d99
to
44e3579
Compare
apps/aehttp/src/aehttp_logic.erl
Outdated
Cache -> | ||
case kache:get(Cache, Hash) of | ||
{ok, _} -> | ||
lager:info("ZZZ: ~p in cache", [Hash]); |
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.
possibly real log message or debug message that the cache was hit?
Replaces #4191 - with a branch in this repo for easier collaboration.
There are a few things to consider here.
This PR is supported by Æternity Foundation and Æternity Crypto Foundation