Skip to content

Sequence Diagrams

JamesPiechota edited this page Mar 13, 2023 · 20 revisions

Intent of these diagrams:

  1. Show how different modules fit together
  2. Link to specific functions/files in the codebase
  3. Be easily updatable to limit rot

That 3rd point forced some compromises, namely using Github's mermaid integration for diagrams rather than building the diagram in another tool and uploading an image. Adapting to mermaid's constraints, here's a brief legend:

  • Vertical gray actors are distinct services
  • Black "note" boxes reference specific functions in the codebase
  • Horizontal arrows represent process-to-process communication or message passing
  • opt dotted boxes group related functions and messages for understandability
  • loop dotted boxes are used for loops or repeated processes

VDF Calculation

%%{
  init: {
    'theme': 'neutral'
  }
}%%
sequenceDiagram
participant ar_nonce_limiter
participant ar_nonce_limiter worker
participant ETS
participant ar_events

Note over ar_nonce_limiter: init/1

opt Query the last N blocks
Note over ar_nonce_limiter: ar_node:get_current_block/1
ETS->>ar_nonce_limiter: ets:lookup(node_state, current)
ETS->>ar_nonce_limiter: ets:lookup(node_state, {block, H})
Note over ar_nonce_limiter: ar_node:get_blocks/2
ETS->>ar_nonce_limiter: ets:lookup(node_state, {block, H})
end

Note over ar_nonce_limiter: start_worker/1
ar_nonce_limiter->>ar_nonce_limiter worker: spawn(worker/0)

loop Repeat every second (VDF delay)
Note over ar_nonce_limiter: schedule_step/1
ar_nonce_limiter->>ar_nonce_limiter worker: compute
Note over ar_nonce_limiter worker: compute/2
Note over ar_nonce_limiter worker: ar_vdf:compute/3
Note over ar_nonce_limiter worker: ar_mine_randomx:vdf_sha2_nif/5
Note over ar_nonce_limiter worker: vdf.cpp:vdf_sha2(...)
ar_nonce_limiter worker->>ar_nonce_limiter: computed
ar_nonce_limiter->>ar_events: nonce_limiter, computed_output
end
Loading
Clone this wiki locally