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

Fix bootstrap node view #940

Merged

Conversation

Neylix
Copy link
Member

@Neylix Neylix commented Mar 15, 2023

Description

Fix some errors when a node boostrap.
Sometimes it does not have the right P2P view and self repair fall in invalid election error

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Start multiple nodes, disconnect some and reconnect them after.
Do the same thing but deleting database before reconnecting

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Neylix Neylix added bug Something isn't working bootstrap labels Mar 15, 2023
Copy link
Member

@samuelmanzanera samuelmanzanera left a comment

Choose a reason for hiding this comment

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

Nice additions !

Copy link
Member

@bchamagne bchamagne left a comment

Choose a reason for hiding this comment

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

I had few errors but I don't know if related to this PR or not.

the scenario I tested is just 3 nodes started one after each other.

after starting node1, the explorer is inaccessible (phoenix error ui):

2023-03-20 08:43:18.100 [error] #PID<0.5663.0> running ArchethicWeb.Endpoint (connection #PID<0.5662.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function ArchethicWeb.ExplorerRootController.init/1 is undefined (module ArchethicWeb.ExplorerRootController is not available)
        (archethic 1.0.7) ArchethicWeb.ExplorerRootController.init(:index)
        (phoenix 1.6.15) lib/phoenix/router.ex:354: Phoenix.Router.__call__/2
        (archethic 1.0.7) lib/archethic_web/endpoint.ex:1: ArchethicWeb.Endpoint.plug_builder_call/2
        (archethic 1.0.7) lib/plug/debugger.ex:136: ArchethicWeb.Endpoint."call (overridable 3)"/2
        (archethic 1.0.7) lib/archethic_web/endpoint.ex:1: ArchethicWeb.Endpoint.call/2
        (phoenix 1.6.15) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy 2.9.0) /home/bastien/Chamagne/archethic/archethic-node/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
        (cowboy 2.9.0) /home/bastien/Chamagne/archethic/archethic-node/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
        (cowboy 2.9.0) /home/bastien/Chamagne/archethic/archethic-node/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
        (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

but the error fixes itself after few seconds (I saved entire logs if needed)

after starting them all and then restarting node 2, I get these errors:

2023-03-20 08:48:31.483 [error] GenStateMachine #PID<0.6248.0> terminating
** (KeyError) key :timestamp not found in: %Archethic.P2P.Message.TransactionSummaryMessage{transaction_summary: %Archethic.TransactionChain.TransactionSummary{timestamp: ~U[2023-03-20 08:48:18.625Z], address: <<0, 0, 74, 48, 143, 82, 9, 28, 110, 225, 104, 123, 141, 99, 220, 252, 91, 27, 211, 151, 2, 104, 97, 93, 240, 53, 17, 122, 67, 152, 137, 176, 51, 108>>, type: :oracle, fee: 0, movements_addresses: []}}
    (archethic 1.0.7) lib/archethic/mining/pending_transaction_validation.ex:122: anonymous fn/1 in Archethic.Mining.PendingTransactionValidation.valid_not_exists/1
    (elixir 1.14.1) lib/enum.ex:3264: anonymous fn/2 in Enum.sort_by/3
    (elixir 1.14.1) lib/enum.ex:1658: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.14.1) lib/enum.ex:3264: Enum.sort_by/3
    (archethic 1.0.7) lib/archethic/mining/pending_transaction_validation.ex:122: anonymous fn/1 in Archethic.Mining.PendingTransactionValidation.valid_not_exists/1
    (archethic 1.0.7) lib/archethic/p2p.ex:729: Archethic.P2P.do_quorum_read/7
    (archethic 1.0.7) lib/archethic/mining/pending_transaction_validation.ex:127: Archethic.Mining.PendingTransactionValidation.valid_not_exists/1
    (archethic 1.0.7) lib/archethic/mining/pending_transaction_validation.ex:75: Archethic.Mining.PendingTransactionValidation.validate/2
    (archethic 1.0.7) lib/archethic/mining/distributed_workflow.ex:257: Archethic.Mining.DistributedWorkflow.handle_event/4
    (stdlib 4.1.1) gen_statem.erl:1428: :gen_statem.loop_state_callback/11
    (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3


2023-03-20 08:49:06.518 [error] GenStateMachine Archethic.OracleChain.Scheduler terminating
** (FunctionClauseError) no function clause matching in Archethic.OracleChain.Scheduler.handle_event/4
    (archethic 1.0.7) lib/archethic/oracle_chain/scheduler.ex:99: Archethic.OracleChain.Scheduler.handle_event(:info, {:new_transaction, <<0, 0, 74, 48, 143, 82, 9, 28, 110, 225, 104, 123, 141, 99, 220, 252, 91, 27, 211, 151, 2, 104, 97, 93, 240, 53, 17, 122, 67, 152, 137, 176, 51, 108>>, :oracle, ~U[2023-03-20 08:48:18.625Z]}, :triggered, %{indexes: %{~U[2023-03-20 08:50:00Z] => 0}, next_address: <<0, 0, 230, 198, 70, 35, 39, 195, 210, 224, 195, 176, 148, 108, 201, 48, 245, 1, 8, 95, 71, 254, 79, 241, 150, 243, 77, 101, 34, 202, 204, 243, 229, 150>>, polling_date: ~U[2023-03-20 08:49:00Z], polling_interval: "*/10 * * * * * *", polling_timer: #Reference<0.3911116363.2941779971.155000>, summary_date: ~U[2023-03-20 08:50:00Z], summary_interval: "0 * * * * * *", watcher: #PID<0.13895.0>})
    (stdlib 4.1.1) gen_statem.erl:1428: :gen_statem.loop_state_callback/11
    (stdlib 4.1.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3

lib/archethic/bootstrap/sync.ex Show resolved Hide resolved
lib/archethic/bootstrap/sync.ex Outdated Show resolved Hide resolved
@samuelmanzanera samuelmanzanera merged commit 448bb6f into archethic-foundation:develop Mar 21, 2023
@Neylix Neylix deleted the Fix-bootstrap-node-view branch March 21, 2023 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bootstrap bug Something isn't working
Projects
Status: Done 🍻
Development

Successfully merging this pull request may close these issues.

None yet

3 participants