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

Configurator versioning #908

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Nico-Sanchez
Copy link
Collaborator

@Nico-Sanchez Nico-Sanchez commented Sep 9, 2024

Warning

This won't be used until client's PR gets merged -> https://github.com/lambdaclass/champions_of_mirra/pull/2134

Motivation

Closes #918
We need a way to differentiate between configs.
If we change a map configuration (e.g. delete an obstacle or edit its size/position) the version should change to alert the clients.

Summary of changes

How to test it?

Make your client (https://github.com/lambdaclass/champions_of_mirra/pull/2134) point to localhost or central testing.
Then, update the version to match the configuration's.
Play a bit with map configuration params, it should ONLY change the version when something we take into account is changed (like an obstacle position, or a circle radius).

Checklist

  • Tested the changes locally.
  • Reviewed the changes on GitHub, line by line.
  • This change requires new documentation.
    • Documentation has been added/updated.

@Nico-Sanchez Nico-Sanchez force-pushed the add-configurator-hash-to-arena-version branch from f65a08e to 38ae9a4 Compare September 10, 2024 18:22
@Nico-Sanchez Nico-Sanchez force-pushed the add-configurator-hash-to-arena-version branch from 38ae9a4 to f02d8f6 Compare September 10, 2024 18:25
@Nico-Sanchez Nico-Sanchez marked this pull request as ready for review September 10, 2024 18:30
iex> get_configuration_hash_version()
"A6F0CC6917D195AB8A03129ACBE1FA48364845B8"
"""
def get_configuration_hash_version do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not :erlang.term_to_binary/1 the map configuration (or whatever subfields we actually want)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the query order of everything changes the hash everytime, and we only want to change the hash when the desired values change.
We can discuss a better approach in Slack.

|> Enum.map(fn config -> sum_shape_coordinates(config) end)
|> Enum.reduce(fn coordinates_last, coordinates_current -> Decimal.add(coordinates_last, coordinates_current) end)
|> Decimal.to_string()
|> (fn coordinates -> :crypto.hash(:sha, coordinates) |> Base.encode16() end).()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why base16?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just selected one at random. Any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, was just curious. Also, don't think is worth discussing for this use case

tvillegas98
tvillegas98 previously approved these changes Sep 12, 2024
manucamejo
manucamejo previously approved these changes Sep 12, 2024
@manucamejo manucamejo added the waiting on PR Waiting on another PR in this repo or in the client repo label Sep 12, 2024
@manucamejo manucamejo marked this pull request as draft September 13, 2024 14:58
@manucamejo manucamejo dismissed stale reviews from tvillegas98 and themself via 651b5e8 September 13, 2024 15:50
@@ -8,8 +8,11 @@ defmodule ArenaWeb.HealthController do
end

def version(conn, _params) do
arena_version = Application.spec(:arena, :vsn) |> to_string()
configurator_version = GameBackend.Configuration.get_configuration_hash_version()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful, this controller is duplicated in both arena and gateway apps.
We should distinct them somehow or see if both are needed.

Copy link
Collaborator

@manucamejo manucamejo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not working properly because this PR is trying to access to a module in another app.
It works locally, but it doesn't in the servers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting on PR Waiting on another PR in this repo or in the client repo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Configurator versioning
4 participants