Change EXIT_PROCESSOR_SLA_MARGIN to EXIT_PROCESSOR_SLA_SECONDS#1491
Change EXIT_PROCESSOR_SLA_MARGIN to EXIT_PROCESSOR_SLA_SECONDS#1491souradeep-das wants to merge 34 commits intomasterfrom
Conversation
| invalid_exits | ||
| |> Enum.filter(fn {_, %ExitInfo{eth_height: eth_height}} -> eth_height + sla_margin <= eth_height_now end) | ||
| |> Enum.filter(fn {_, %ExitInfo{eth_height: eth_height}} -> | ||
| eth_height + sla_seconds / ethereum_block_time_seconds <= eth_height_now |
There was a problem hiding this comment.
Is this a good way or should the timestamp of each exit be stored in the DB and retrieved here to check if sla_seconds is elapsed
There was a problem hiding this comment.
I think this is fine for this PR since it's still the existing behaviour, but could you maybe raise this discussion separately in the engineering channel?
There was a problem hiding this comment.
will change the logic to exit_timestamp + sla_seconds <= time_now when #1495 is merged
| use OMG.Utils.LoggerExt | ||
|
|
||
| @default_sla_margin 10 | ||
| @default_sla_seconds 10 |
There was a problem hiding this comment.
Not sure should the value reflect the original value, which I think should be 10 block * 15s per block = 150?
There was a problem hiding this comment.
I guess this only takes place on tests. @souradeep-das can we confirm this - raise a value and whether tests fails?
There was a problem hiding this comment.
true, I think these are for tests. Fails when sla_seconds is >10
There was a problem hiding this comment.
if this is for tests then let's remove it. we should also remove the default setting below:
sla_seconds \\ @default_sla_seconds
| invalid_exits | ||
| |> Enum.filter(fn {_, %ExitInfo{eth_height: eth_height}} -> eth_height + sla_margin <= eth_height_now end) | ||
| |> Enum.filter(fn {_, %ExitInfo{eth_height: eth_height}} -> | ||
| eth_height + sla_seconds / ethereum_block_time_seconds <= eth_height_now |
There was a problem hiding this comment.
I think this is fine for this PR since it's still the existing behaviour, but could you maybe raise this discussion separately in the engineering channel?
| late_invalid_exits = | ||
| invalid_exits | ||
| |> Enum.filter(fn {_, %ExitInfo{eth_height: eth_height}} -> eth_height + sla_margin <= eth_height_now end) | ||
| |> Enum.filter(fn {_, %ExitInfo{eth_height: eth_height}} -> |
There was a problem hiding this comment.
We're moving away from single pipes. Could you update invalid_exits |> Enum.filter(fn... to Enum.filter(invalid_exits, fn...? Thanks!
|
|
||
| @system_env_name_margin "EXIT_PROCESSOR_SLA_MARGIN" | ||
| @app_env_name_margin :exit_processor_sla_margin | ||
| @system_env_name_margin "EXIT_PROCESSOR_SLA_SECONDS" |
There was a problem hiding this comment.
Note that before merging this PR, we'll need to update our infra to have this environment variable so we don't break the CI/CD environment.
|
Also, could you add this change to https://github.com/omisego/elixir-omg/blob/master/CHANGELOG.md under the Unreleased header? |
| use OMG.Utils.LoggerExt | ||
|
|
||
| @default_sla_margin 10 | ||
| @default_sla_seconds 10 |
There was a problem hiding this comment.
I guess this only takes place on tests. @souradeep-das can we confirm this - raise a value and whether tests fails?
| exits_invalid_by_ife = get_invalid_exits_based_on_ifes(active_exits, tx_appendix) | ||
| invalid_exits = active_exits |> Map.take(invalid_exit_positions) |> Enum.concat(exits_invalid_by_ife) |> Enum.uniq() | ||
|
|
||
| ethereum_block_time_seconds = OMG.Eth.Configuration.ethereum_block_time_seconds() |
There was a problem hiding this comment.
Only here we introduce this antipattern ;)
Please restore it as init param - which will be set where others are - and pass it to the Core's init (Core module serves usually as GenServer state). So you could retrieve its value as you do with sla_seconds
| @system_env_name_margin "EXIT_PROCESSOR_SLA_MARGIN" | ||
| @app_env_name_margin :exit_processor_sla_margin | ||
| @system_env_name_margin "EXIT_PROCESSOR_SLA_SECONDS" | ||
| @app_env_name_margin :exit_processor_sla_seconds |
There was a problem hiding this comment.
Too verbose I think :)
| @app_env_name_margin :exit_processor_sla_seconds | |
| @app_env_name :exit_processor_sla_seconds |
| exit_processor_sla_margin_forced: exit_processor_sla_margin_forced, | ||
| metrics_collection_interval: metrics_collection_interval, | ||
| min_exit_period_seconds: min_exit_period_seconds, | ||
| ethereum_block_time_seconds: ethereum_block_time_seconds |
There was a problem hiding this comment.
Restore this and pass through as I suggested in exit_processor/standard_exit.ex
config/test.exs
Outdated
| # NOTE `exit_processor_sla_margin` can't be made shorter. At 3 it sometimes | ||
| # causes :unchallenged_exit because `geth --dev` is too fast | ||
| exit_processor_sla_margin: 5, | ||
| exit_processor_sla_seconds: 75, |
There was a problem hiding this comment.
But this is test - prev we had 1 secs blocks - is it OK?
There was a problem hiding this comment.
yes yes 1 sec blocks. Updating!
…_margin to @app_env_name
|
|
||
| _ethereum_block_time_seconds = OMG.Eth.Configuration.ethereum_block_time_seconds() | ||
| # get exits which are still invalid and after the SLA margin | ||
| # temporarily assigning ethereum_block_time_seconds= 1, will be removed on merge of #1495 |
There was a problem hiding this comment.
Thanks O! Updating.
| DevHelper.wait_for_root_chain_block(eth_height + exit_processor_sla_margin, @timeout) | ||
| exit_processor_sla_seconds = Application.fetch_env!(:omg_watcher, :exit_processor_sla_seconds) | ||
| exit_processor_sla_ms = exit_processor_sla_seconds * 1000 | ||
| Process.sleep(exit_processor_sla_ms) |
There was a problem hiding this comment.
Is this fine? 🙇
There was a problem hiding this comment.
Looks fine to me, we're really waiting for the seconds to come
|
Also @pnowosie asking for a re-review to confirm the latest changes. Thanks 🙇 |
|
Adding |
| DevHelper.wait_for_root_chain_block(eth_height + exit_processor_sla_margin, @timeout) | ||
| exit_processor_sla_seconds = Application.fetch_env!(:omg_watcher, :exit_processor_sla_seconds) | ||
| exit_processor_sla_ms = exit_processor_sla_seconds * 1000 | ||
| Process.sleep(exit_processor_sla_ms) |
There was a problem hiding this comment.
Looks fine to me, we're really waiting for the seconds to come
config/test.exs
Outdated
| # NOTE `exit_processor_sla_margin` can't be made shorter. At 8 it sometimes | ||
| # causes unchallenged exits events because `geth --dev` is too fast | ||
| exit_processor_sla_margin: 10, | ||
| # NOTE `exit_processor_sla_margin` can't be made shorter. At 3 it sometimes |
There was a problem hiding this comment.
Nice that you also checked and updated this 👍 🙏
|
@unnawut do we need to update any env vars? |
Yeah the ones you have in the infra PR should suffice |
| %__MODULE__{} = state | ||
| ) | ||
| when not is_nil(eth_height_now) do | ||
| when not is_nil(eth_timestamp_now) do |
There was a problem hiding this comment.
this guard is irrelevant and should be removed!
There was a problem hiding this comment.
removed 96d9e31
| defp sla_seconds_safe?(exit_processor_sla_seconds, min_exit_period_seconds), | ||
| do: exit_processor_sla_seconds < min_exit_period_seconds |
There was a problem hiding this comment.
| defp sla_seconds_safe?(exit_processor_sla_seconds, min_exit_period_seconds), | |
| do: exit_processor_sla_seconds < min_exit_period_seconds | |
| defp sla_seconds_safe?(exit_processor_sla_seconds, min_exit_period_seconds) do | |
| exit_processor_sla_seconds < min_exit_period_seconds | |
| end |
There was a problem hiding this comment.
the function spreads over multiple lines, let's allow it to do so.
| def get_invalid( | ||
| %Core{sla_seconds: sla_seconds} = state, | ||
| utxo_exists?, | ||
| eth_timestamp_now | ||
| ) do |
There was a problem hiding this comment.
| def get_invalid( | |
| %Core{sla_seconds: sla_seconds} = state, | |
| utxo_exists?, | |
| eth_timestamp_now | |
| ) do | |
| def get_invalid(state, utxo_exists?, eth_timestamp_now) do | |
| state.sla_seconds |
| %{processor_filled: processor} do | ||
| assert {:ok, []} = | ||
| %ExitProcessor.Request{blknum_now: 1000, eth_height_now: 5} | ||
| %ExitProcessor.Request{blknum_now: 1000, eth_timestamp_now: 5} |
There was a problem hiding this comment.
hm... how does this make sense? what is eth_timestamp_now 5?
|
|
||
| exit_processor_sla_margin = Application.fetch_env!(:omg_watcher, :exit_processor_sla_margin) | ||
| DevHelper.wait_for_root_chain_block(eth_height + exit_processor_sla_margin, @timeout) | ||
| exit_processor_sla_seconds = Application.fetch_env!(:omg_watcher, :exit_processor_sla_seconds) |
There was a problem hiding this comment.
| exit_processor_sla_seconds = Application.fetch_env!(:omg_watcher, :exit_processor_sla_seconds) | |
| exit_processor_sla_seconds = OMG.Watcher.Configuraion.exit_processor_sla_seconds() |
InoMurko
left a comment
There was a problem hiding this comment.
Few things:
- this PR changes a API endpoint (cc @T-Dnzt @unnawut ). A property is removed and replaced with a different one, the new one has a different meaning.
- I've seen
eth_timestamp_now. I don't exactly understand what it means and how it's used. The tests use values like 5,13,... What is this? Seems like a very odd timestamp.
|
Hey @InoMurko! Thanks for the review 🙇 Previously we had - late_invalid_exits =
Enum.filter(invalid_exits, fn {_, %ExitInfo{eth_height: eth_height}} ->
eth_height + sla_margin <= eth_height_now
Since, we added the exit timestamp already, using it for the check and checking with late_invalid_exits =
Enum.filter(invalid_exits, fn {_, %ExitInfo{block_timestamp: block_timestamp}} ->
block_timestamp + sla_seconds <= eth_timestamp_now
assigning the actual timestamp of the block here, For the tests, Should |
@T-Dnzt @achiurizo I think we should get a thumbs up from either of you for any API breaking change. It's the watcher & watcher_info So I guess either:
I recommend 2 for consistency with the contracts outweighs dropping this key from |
#1399
Overview
This unifies
sla_marginto hold values in seconds instead of the number of blocks and renamesEXIT_PROCESSOR_SLA_MARGINtoEXIT_PROCESSOR_SLA_SECONDS. The internal logic to detect invalid exits has also been changed to use timestamps instead of number of blocksEXIT_PROCESSOR_SLA_MARGIN_FORCEDhasn't been renamedChanges
EXIT_PROCESSOR_SLA_MARGINtoEXIT_PROCESSOR_SLA_SECONDSeth_height_nowtoeth_timestamp_nowEXIT_PROCESSOR_SLA_MARGIN_FORCEDis unchanged till now