anoma / green

https://anoma.github.io/anoma/
MIT License
7 stars 0 forks source link

BUG Not enough information in a node to send a message back to a foreign node #463

Closed mariari closed 2 months ago

mariari commented 6 months ago

customer: performer: deadline: null estimated: null started: null actual: null completed: null confirmed: null dependencies:


The Router.cast(caller, :snapshot_done) here fails IFF the caller is external

  def handle_cast(:snapshot, caller, config = %__MODULE__{}) do
    configuration = config.configuration

    if configuration do
      spawn(fn ->
        Anoma.Dump.dump_full_path(
          configuration["dump"]["dump"],
          configuration["node"]["name"] |> String.to_atom()
        )

        IEx.pry()
        Router.cast(caller, :snapshot_done)
      end)
    else
      log_info({:no_config, config.logger})
    end

    {:noreply, config}
  end

Prying the data we get

iex(mariari@Gensokyo)1> caller
%Anoma.Node.Router.Addr{
  server: nil,
  id: %Anoma.Crypto.Id.Extern{
    encrypt: <<249, 43, 160, 8, 213, 107, 110, 222, 134, 183, 85, 25, 200, 250,
      112, 137, 125, 185, 224, 31, 204, 8, 199, 107, 0, 200, 223, 171, 60, 61,
      161, 26>>,
    sign: <<37, 105, 170, 158, 128, 107, 115, 211, 196, 81, 147, 74, 195, 22,
      57, 156, 127, 190, 228, 121, 103, 11, 126, 89, 58, 125, 242, 75, 229, 52,
      9, 88>>
  },
  router: :"Anoma.Node.Router ctjMb+4ELaZSDElyuvbxUluPuGJQ0i0Ox9lJQnK6acM="
}

The error is saying the key doesn't exist

13:14:34.881 [error] GenServer :"Anoma.Node.Router ctjMb+4ELaZSDElyuvbxUluPuGJQ0i0Ox9lJQnK6acM=" terminating
** (KeyError) key nil not found in: %{
  %Anoma.Crypto.Id.Extern{
    encrypt: <<235, 32, 179, 64, 225, 77, 173, 30, 241, 129, 52, 62, 163, 182,
      55, 229, 171, 89, 178, 157, 11, 75, 46, 175, 179, 95, 183, 66, 132, 156,
      37, 73>>,
    sign: <<83, 12, 136, 40, 77, 254, 53, 51, 98, 118, 52, 32, 53, 77, 200, 86,
      243, 73, 60, 147, 237, 232, 43, 122, 86, 130, 196, 159, 44, 204, 184,
      213>>
  } => {%Anoma.Crypto.Id{
....
karbyshev commented 4 months ago

In the current implementation on the Configuration engine, the docs say

@doc """
  I am the snapshot function.

  I take a snapshots of the current state. The topic sends back a message
  to the caller saying `:snapshot_done`.

but the message is never sent. Is that on purpose?

UPD I see, sending a message back was disabled in https://github.com/anoma/anoma/commit/b8e57d973c703015b554a6b135f55d396e23b780

karbyshev commented 3 months ago

@mariari Is the issue captured by a test? If yes, which one? I have restored the phoning-back functionality locally, but do not observe any problems in the tests.

mariari commented 2 months ago

This now works, however the code is in a lambda, meaning that it's not being sent from the right router, but this all works

mariari commented 2 months ago

We will retool this to send a message back to the transport when the snapshot is done.