diff --git a/.formatter.exs b/.formatter.exs index e2a0268..8e4c520 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 [ inputs: ["mix.exs", "evmbench.exs", "{config,lib,test,client}/**/*.{ex,exs}"] diff --git a/NOTES.md b/NOTES.md index cac39ce..c23aa8b 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,3 +1,203 @@ +# Scratchpade February 16th 2024 + +m1bns = Hash.to_address(0x75140F88B0F4B2FBC6DADC16CC51203ADB07FE36) +Moonbeam.get_storage_at(Base16.encode(m1bns), Base16.encode(3, false)) + +# Scratchpade February 14th 2024 + +block_Wait = 175200 +now = 6808809 +end_stake = 6984009 ~ March 14th + +## Sending 50k Diode from US1 to US2 +addr = "0x7e4cd38d266902444dc9c8f7c0aa716a32497d0b" |> Base16.decode +Shell.transfer_from(Diode.miner, addr, value: Shell.ether(50_000)) + +## Staking 50k Diode on US2 +Shell.call_from(Diode.miner, Diode.registry_address, "MinerStake", [], [], value: Shell.ether(50_000)) +Shell.submit_from(Diode.miner, Diode.registry_address, "MinerStake", [], [], value: Shell.ether(50_000)) + +## Unstaking on US1 + +Shell.call_from(Diode.miner, Diode.registry_address, "MinerUnstake", ["uint256"], [Shell.ether(2_380_000)]) +Shell.submit_from(Diode.miner, Diode.registry_address, "MinerUnstake", ["uint256"], [Shell.ether(2_380_000)]) + +## Checking pending funds +miner_value = for i <- 0..3, do: Contract.Registry.miner_value(i, Diode.miner, Chain.peak) + +## Unstaking on EU1 +Shell.call_from(Diode.miner, Diode.registry_address, "MinerUnstake", ["uint256"], [Shell.ether(2_050_000)]) +Shell.submit_from(Diode.miner, Diode.registry_address, "MinerUnstake", ["uint256"], [Shell.ether(2_050_000)]) +miner_value = for i <- 0..3, do: Contract.Registry.miner_value(i, Diode.miner, Chain.peak) + +## Sending 50k Diode from AS1 to AS2 +addr = "0x1350d3b501d6842ed881b59de4b95b27372bfae8" |> Base16.decode +Shell.transfer_from(Diode.miner, addr, value: Shell.ether(50_000)) + +## Unstaking on AS1 +Shell.call_from(Diode.miner, Diode.registry_address, "MinerUnstake", ["uint256"], [Shell.ether(2_000_000)]) +Shell.submit_from(Diode.miner, Diode.registry_address, "MinerUnstake", ["uint256"], [Shell.ether(2_000_000)]) +miner_value = for i <- 0..3, do: Contract.Registry.miner_value(i, Diode.miner, Chain.peak) + +## Sending 50k from fc1 to EU2 +Shell.transfer_from(fc1, eu2, value: Shell.ether(50_000)) + +## Staking 50k on EU2 +Shell.call_from(Diode.miner, Diode.registry_address, "MinerStake", [], [], value: Shell.ether(50_000)) +Shell.submit_from(Diode.miner, Diode.registry_address, "MinerStake", [], [], value: Shell.ether(50_000)) + +# Scratchpade January 29th 2024 +state_a = Model.ChainSql.state(hd(BlockProcess.fetch(6729001, [:hash]))) +state_b = Model.ChainSql.state(hd(BlockProcess.fetch(6729128, [:hash]))) + +state_a.accounts |> Enum.count(fn {_, acc} -> acc.root_hash == nil end) +state_b.accounts |> Enum.count(fn {_, acc} -> acc.root_hash == nil end) + +diff = Chain.State.difference(state_a, state_b) +state_b2 = Chain.State.apply_difference(state_a, diff) +state_b2.accounts |> Enum.count(fn {_, acc} -> acc.root_hash == nil end) + + +block_number = 6729001 +[hash] = BlockProcess.fetch(block_number, [:hash]) +state = Model.ChainSql.state(hash) +state.accounts |> Enum.count(fn {_, acc} -> acc.root_hash == nil end) + +:timer.tc(fn -> state |> Chain.State.tree() |> MerkleTree.merkle() end) |> elem(0) + + + + + +# Scratchpad January 27th 2024 + +for x <- 1..500 do + Process.sleep(10) + spawn(fn -> + child = self() + spawn(fn -> + Chain.with_peak(fn _b -> + send(child, {:pid, self()}) + receive do + :stop -> :ok + end + IO.puts("#{x}") + end) + end) + pid = receive do + {:pid, pid} -> pid + end + receive do + :stop -> send(pid, :stop) + end + end) +end |> Enum.map(fn pid -> + send(pid, :stop) +end) + +# Scratchpad January 25th 2024 + +SC[31m13:41:59.140 [error] GenServer Chain terminating +** (stop) exited in: GenServer.call(BlockProcess, {:with_worker, <<0, 0, 128, 211, 98, 25, 154, 120, 93, 11, 95, 143, 242, 25, 139, 175, 232, 235, 65, 124, 184, 158, + 146, 15, 145, 160, 52, 84, 116, 139, 33, 220>>, #Function<15.48600449/1 in Model.ChainSql.set_normative/2>}, 120000) + ** (EXIT) time out + (elixir 1.13.4) lib/gen_server.ex:1030: GenServer.call/3 + (Elixir.Diode 1.0.8) lib/block_process.ex:355: BlockProcess.do_with_worker/2 + (Elixir.Diode 1.0.8) lib/model/chainsql.ex:261: Model.ChainSql.set_normative/2 + (Elixir.Diode 1.0.8) lib/chain.ex:332: anonymous fn/5 in Chain.handle_call/3 + (stdlib 4.3) timer.erl:235: :timer.tc/1 + (Elixir.Diode 1.0.8) lib/stats.ex:44: Stats.tc!/2 + (Elixir.Diode 1.0.8) lib/stats.ex:35: Stats.tc/2 + (stdlib 4.3) gen_server.erl:1149: :gen_server.try_handle_call/4 + (stdlib 4.3) gen_server.erl:1178: :gen_server.handle_msg/6 + (stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3 +Last message (from :active_sync_job): {:add_block, <<0, 0, 39, 150, 176, 117, 236, 98, 243, 22, 91, 46, 195, 213, 15, 212, 171, 222, 34, 109, 197, 216, 76, 83, 210, +68, 251, 168, 151, 213, 140, 108>>, <<0, 0, 128, 211, 98, + + +# Scratchpad January 18th 2024 + +bns = BlockProcess.with_account(peak, Contract.BNS.address(), fn acc -> acc end) + +peak = Chain.peak() +accounts = BlockProcess.with_state(peak, fn state -> Map.keys(Chain.State.accounts(state)) end) +File.write!("accounts.csv", Enum.map(accounts, &Base16.encode/1) |> Enum.join("\n")) + + +all = Chain.Account.tree(bns) |> MerkleTree.to_list |> Map.new() + +add = fn bin, n -> + n = :binary.decode_unsigned(bin) + n + <> +end + +names = Enum.map(all, fn {key, <>} -> {key, String.trim(value, <<0>>)} end) |> Enum.filter(fn {_, value} -> byte_size(value) > 7 and List.ascii_printable?(:binary.bin_to_list(value)) end) |> Enum.map(fn {addr, name} -> %{ + addr: addr, + name: name, + owner: Map.get(all, add.(addr, -1)), + destination: Map.get(all, add.(addr, -2)), +} end) |> Enum.filter(fn %{owner: owner} -> owner != nil end) + + +devices = Model.Sql.query!(Model.KademliaSql, "SELECT object FROM p2p_objects", []) |> Enum.map(fn [object: obj] -> BertInt.decode!(obj) |> Object.decode!() end) |> Enum.filter(fn obj -> elem(obj, 0) == :ticket end) |> Enum.map(fn obj -> Object.Ticket.device_address(obj) end) + +devices_v2 = Model.Sql.query!(Model.KademliaSql, "SELECT object FROM p2p_objects", []) |> Enum.map(fn [object: obj] -> BertInt.decode!(obj) |> Object.decode!() end) |> Enum.filter(fn obj -> elem(obj, 0) == :ticket end) |> Enum.map(fn obj -> {Object.Ticket.device_address(obj), case Object.Ticket.local_address(obj) do + <> when b in [0, 1] -> "diode_drive" + "spam" -> "test" + _ -> "diode_cli" +end} end) + +File.write!("devices.csv", Enum.map(devices_v2, fn {addr, type} -> Base16.encode(addr) <> " #{type}\n" end) |> Enum.join("")) + +for x in {as,us,eu}{1,2} as3; do scp -C $x:/opt/diode/devices.csv devices-$x.csv; done +cat devices-* | sort | uniq > devices.csv + + + +# Scratchpad January 9th 2024 + +```elixir +peak = Chain.peak() +balances = BlockProcess.with_state(peak, fn state -> + for {key, account} <- state.accounts do + {key, account.balance} + end +end) + +stakes = for {address, balance} <- balances do + miner_value = for i <- 0..3, do: Contract.Registry.miner_value(i, address, peak) + fleet_value = for i <- 0..3, do: Contract.Registry.fleet_value(i, address, peak) + {address, balance, miner_value, fleet_value} +end + + +print = fn str -> File.write!("accounts.csv", str <> "\n", [:append]) end + +print.("Address, Balance, MStaked, MPending, MLocked, MClaimable, FStaked, FPending, FLocked, FClaimable") + +for {address, balance, [m0,m1,m2,m3], [f0,f1,f2,f3]} <- stakes do + z = [balance, m0,m1,m2,m3, f0,f1,f2,f3] + if Enum.any?(z, fn n -> n > 0 end) do + print.("#{Base16.encode(address)}, #{balance}, #{m0}, #{m1}, #{m2}, #{m3}, #{f0}, #{f1}, #{f2}, #{f3}") + end +end + +``` + +# Scratchpad Dec 19th + +alias Chain.Block +block = BlockProcess.with_block(6512534, fn block -> block end) +Diode.hash(Block.encode_transactions(Block.transactions(block))) == Block.txhash(block) + +# Scratchpad Nov 20th + +Process.exit(Process.whereis(BlockProcess), :random) + + +bp = :sys.get_state(Process.whereis(BlockProcess)) +Map.values(bp.waiting) |> List.flatten |> Enum.map(fn {pid, _ref} -> Process.alive?(pid) end) + # Command line perf testing reference ## 21. Feb 2022 - e97191192cc022452d2167beea24f06939cac6f8 diff --git a/client b/client index 1e67e0a..b1ee5ad 100755 --- a/client +++ b/client @@ -1,5 +1,5 @@ #!/bin/bash # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 exec mix run --no-start client_lib/client.exs diff --git a/client_lib/client.exs b/client_lib/client.exs index 2be3941..ff26102 100755 --- a/client_lib/client.exs +++ b/client_lib/client.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 alias Object.Ticket, as: Ticket import Ticket diff --git a/config/config.exs b/config/config.exs index 901df5e..0a5bc18 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,43 +1,24 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 import Config # Configures Elixir's Logger config :logger, - handle_otp_reports: true, - handle_sasl_reports: true, + # handle_otp_reports: true, + # handle_sasl_reports: true, backends: [:console], truncate: 8000, format: "$time $metadata[$level] $message" config :logger, :console, format: "$time $metadata[$level] $message\n" -case Mix.env() do - :benchmark -> - System.put_env("SEED", "none") - System.put_env("WORKER_MODE", "disabled") - - :test -> - System.put_env("SEED", "none") - System.put_env("WORKER_MODE", "poll") - - if System.get_env("RPC_PORT") == nil do - System.put_env("RPC_PORT", "18001") - System.put_env("EDGE2_PORT", "18003") - System.put_env("PEER_PORT", "18004") - end - - :dev -> - System.put_env("WORKER_MODE", "poll") - System.put_env("SEED", "none") - - # :prod -> - # Manually input your public IP address here if behind NAT - # System.put_env("HOST", "") - - _env -> - :ok +if Mix.env() == :test do + if System.get_env("RPC_PORT") == nil do + System.put_env("RPC_PORT", "18001") + System.put_env("EDGE2_PORT", "18003") + System.put_env("PEER2_PORT", "18004") + end end if Mix.env() != :test and File.exists?("config/diode.exs") do diff --git a/config/diode.sample.exs b/config/diode.sample.exs index 9a7b2c1..b1db06b 100644 --- a/config/diode.sample.exs +++ b/config/diode.sample.exs @@ -1,4 +1,4 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 use Mix.Config diff --git a/deployment/diode.service b/deployment/diode.service index b09d404..b800213 100644 --- a/deployment/diode.service +++ b/deployment/diode.service @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 [Unit] Description=Diode service diff --git a/deployment/fabfile.py b/deployment/fabfile.py index 5143482..5d6380a 100644 --- a/deployment/fabfile.py +++ b/deployment/fabfile.py @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 import binascii import os diff --git a/dev b/dev index 7f0f159..67a1101 100755 --- a/dev +++ b/dev @@ -1,6 +1,6 @@ #!/bin/sh # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 rm -rf data_dev/ export MIX_ENV=dev diff --git a/lib/chain/node_proxy.ex b/lib/chain/node_proxy.ex index 2ff67e0..943a04a 100644 --- a/lib/chain/node_proxy.ex +++ b/lib/chain/node_proxy.ex @@ -2,22 +2,61 @@ defmodule Chain.NodeProxy do @moduledoc """ Manage websocket connections to the given chain rpc node """ + use GenServer, restart: :permanent alias Chain.NodeProxy require Logger - defstruct [:chain, :connections] + defstruct [:chain, connections: %{}, req: 0, requests: %{}, lastblocks: %{}] def start_link(chain) do GenServer.start_link(__MODULE__, %NodeProxy{chain: chain, connections: %{}}, - name: {__MODULE__, chain} + name: {:global, {__MODULE__, chain}} ) end + @impl true def init(state) do {:ok, ensure_connections(state)} end + def rpc(chain, method, params) do + GenServer.call({:global, {__MODULE__, chain}}, {:rpc, method, params}) + end + + @impl true + def handle_call({:rpc, method, params}, from, state) do + conn = Enum.random(Map.values(state.connections)) + id = state.req + 1 + + request = + %{ + "jsonrpc" => "2.0", + "id" => id, + "method" => method, + "params" => params + } + |> Poison.encode!() + + {:ok, binary_frame} = WebSockex.Frame.encode_frame({:text, request}) + WebSockex.Conn.socket_send(conn, binary_frame) + {:noreply, %{state | req: id}, requests: Map.put(state.requests, id, from)} + end + @security_level 2 + @impl true + def handle_info( + {:new_block, ws_url, block_number}, + state = %NodeProxy{chain: chain, lastblocks: lastblocks} + ) do + lastblocks = Map.put(lastblocks, ws_url, block_number) + + if Enum.count(lastblocks, fn {_, block} -> block == block_number end) >= @security_level do + Chain.RPCCache.set_block_number(chain, block_number) + end + + {:noreply, %{state | lastblocks: lastblocks}} + end + defp ensure_connections(state = %NodeProxy{chain: chain, connections: connections}) when map_size(connections) < @security_level do urls = MapSet.new(chain.ws_endpoints()) @@ -25,7 +64,7 @@ defmodule Chain.NodeProxy do new_urls = MapSet.difference(urls, existing) new_url = MapSet.to_list(new_urls) |> List.first() - pid = Chain.WSConn.start(chain, new_url) + pid = Chain.WSConn.start(self(), chain, new_url) Process.monitor(pid) state = %{state | connections: Map.put(connections, new_url, pid)} ensure_connections(state) diff --git a/lib/chain/rpc.ex b/lib/chain/rpc.ex index 94b2333..39cb82c 100644 --- a/lib/chain/rpc.ex +++ b/lib/chain/rpc.ex @@ -1,113 +1,71 @@ +# Diode Server +# Copyright 2021-2024 Diode +# Licensed under the Diode License, Version 1.1 defmodule Chain.RPC do require Logger - def get_proof(address, keys, block \\ "latest") do + def get_proof(chain, address, keys, block \\ "latest") do # requires https://eips.ethereum.org/EIPS/eip-1186 - rpc!("eth_getProof", [address, keys, block]) + rpc!(chain, "eth_getProof", [address, keys, block]) end - def block_number() do - rpc!("eth_blockNumber") + def block_number(chain) do + rpc!(chain, "eth_blockNumber") end - def get_block_by_number(block \\ "latest", with_transactions \\ false) do - rpc!("eth_getBlockByNumber", [block, with_transactions]) + def get_block_by_number(chain, block \\ "latest", with_transactions \\ false) do + rpc!(chain, "eth_getBlockByNumber", [block, with_transactions]) end - def get_storage_at(address, slot, block \\ "latest") do - rpc!("eth_getStorageAt", [address, slot, block]) + def get_storage_at(chain, address, slot, block \\ "latest") do + rpc!(chain, "eth_getStorageAt", [address, slot, block]) end - def get_code(address, block \\ "latest") do - rpc!("eth_getCode", [address, block]) + def get_code(chain, address, block \\ "latest") do + rpc!(chain, "eth_getCode", [address, block]) end - def get_transaction_count(address, block \\ "latest") do - rpc!("eth_getTransactionCount", [address, block]) + def get_transaction_count(chain, address, block \\ "latest") do + rpc!(chain, "eth_getTransactionCount", [address, block]) end - def get_balance(address, block \\ "latest") do - rpc!("eth_getBalance", [address, block]) + def get_balance(chain, address, block \\ "latest") do + rpc!(chain, "eth_getBalance", [address, block]) end - def send_raw_transaction(tx) do - case rpc("eth_sendRawTransaction", [tx]) do + def send_raw_transaction(chain, tx) do + case rpc(chain, "eth_sendRawTransaction", [tx]) do {:ok, tx_hash} -> tx_hash {:error, %{"code" => -32603, "message" => "already known"}} -> :already_known {:error, error} -> raise "RPC error: #{inspect(error)}" end end - def gas_price() do - rpc!("eth_gasPrice") + def gas_price(chain) do + rpc!(chain, "eth_gasPrice") end - def rpc(method, params \\ []) do - request = %{ - jsonrpc: "2.0", - method: method, - params: params, - id: 1 - } - - case post(request) do - %{"result" => result} -> {:ok, result} - %{"error" => error} -> {:error, error} - end - end - - @dialyzer {:nowarn_function, post: 1, post: 2} - defp post(request, retry \\ true) do - url = endpoint() - - case HTTPoison.post(url, Poison.encode!(request), [ - {"Content-Type", "application/json"} - ]) do - {:ok, %{body: body}} -> - case Poison.decode(body) do - {:ok, response} -> - response - - {:error, error} -> - maybe_retry( - retry, - "Poison error: #{inspect(error)} @ #{url} in #{inspect(body)}", - request - ) - end - - {:error, error} -> - maybe_retry(retry, "HTTPoison error: #{inspect(error)} @ #{url}", request) - end - end - - defp maybe_retry(retry, error, request) do - if retry do - Logger.error("#{error} swapping endpoint() once") - # swap_endpoint() - post(request, false) - else - raise error - end - end - - def rpc!(method, params \\ []) do - case rpc(method, params) do + def rpc!(chain, method, params \\ []) do + case rpc(chain, method, params) do {:ok, result} -> result {:error, error} -> raise "RPC error: #{inspect(error)}" end end - def call(to, from, data, block \\ "latest") do - rpc("eth_call", [%{to: to, data: data, from: from}, block]) + def rpc(chain, method, params) do + Chain.NodeProxy.rpc(chain, method, params) + end + + def call(chain, to, from, data, block \\ "latest") do + rpc(chain, "eth_call", [%{to: to, data: data, from: from}, block]) end - def call!(to, from, data, block \\ "latest") do - {:ok, ret} = call(to, from, data, block) + def call!(chain, to, from, data, block \\ "latest") do + {:ok, ret} = call(chain, to, from, data, block) ret end - def estimate_gas(to, data, block \\ "latest") do - rpc!("eth_estimateGas", [%{to: to, data: data}, block]) + def estimate_gas(chain, to, data, block \\ "latest") do + rpc!(chain, "eth_estimateGas", [%{to: to, data: data}, block]) end end diff --git a/lib/chain/rpc_cache.ex b/lib/chain/rpc_cache.ex index 3785142..4ab6308 100644 --- a/lib/chain/rpc_cache.ex +++ b/lib/chain/rpc_cache.ex @@ -1,12 +1,18 @@ +# Diode Server +# Copyright 2021-2024 Diode +# Licensed under the Diode License, Version 1.1 defmodule Chain.RPCCache do use GenServer, restart: :permanent require Logger alias Chain.RPCCache - defstruct [:chain, :lru, :block_number, :block_number_timestamp] + defstruct [:chain, :lru, :block_number] def start_link(chain) do - GenServer.start_link(__MODULE__, chain, name: __MODULE__, hibernate_after: 5_000) + GenServer.start_link(__MODULE__, chain, + name: {:global, {__MODULE__, chain}}, + hibernate_after: 5_000 + ) end @impl true @@ -14,56 +20,46 @@ defmodule Chain.RPCCache do {:ok, %__MODULE__{chain: chain, lru: Lru.new(1000), block_number: nil}} end - def block_number() do - GenServer.call(__MODULE__, :block_number) + def set_block_number(chain, block_number) do + GenServer.cast({:global, {__MODULE__, chain}}, {:block_number, block_number}) end - def get_block_by_number(block \\ "latest", with_transactions \\ false) do + def block_number(chain) do + case GenServer.call({:global, {__MODULE__, chain}}, :block_number) do + nil -> raise "no block_number yet" + number -> number + end + end + + def get_block_by_number(chain, block \\ "latest", with_transactions \\ false) do block = if block == "latest" do - block_number() + block_number(chain) else block end - get("eth_getBlockByNumber", [block, with_transactions]) + get(chain, "eth_getBlockByNumber", [block, with_transactions]) end - def get_storage_at(address, slot, block \\ "latest") do + def get_storage_at(chain, address, slot, block \\ "latest") do block = if block == "latest" do - block_number() + block_number(chain) else block end - get("eth_getStorageAt", [address, slot, block]) + get(chain, "eth_getStorageAt", [address, slot, block]) end - def get(method, args) do - GenServer.call(__MODULE__, {:get, method, args}) + def get(chain, method, args) do + GenServer.call({:global, {__MODULE__, chain}}, {:get, chain, method, args}) end @impl true - def handle_call(:block_number, _from, state = %RPCCache{block_number: nil}) do - number = Moonbeam.block_number() - time = System.os_time(:second) - {:reply, number, %RPCCache{state | block_number: number, block_number_timestamp: time}} - end - - def handle_call( - :block_number, - _from, - state = %RPCCache{block_number: number, block_number_timestamp: time} - ) do - now = System.os_time(:second) - - if now - time > 5 do - number = Moonbeam.block_number() - {:reply, number, %RPCCache{state | block_number: number, block_number_timestamp: now}} - else - {:reply, number, state} - end + def handle_call(:block_number, _from, state = %RPCCache{block_number: number}) do + {:reply, number, state} end def handle_call({:get, method, args}, _from, state = %RPCCache{lru: lru}) do diff --git a/lib/chain/sup.ex b/lib/chain/sup.ex index c7a2bf1..9327f9f 100644 --- a/lib/chain/sup.ex +++ b/lib/chain/sup.ex @@ -6,7 +6,7 @@ defmodule Chain.Sup do use Supervisor def start_link(chain) do - Supervisor.start_link(__MODULE__, [chain], name: __MODULE__) + Supervisor.start_link(__MODULE__, chain, name: __MODULE__) end def init(chain) do diff --git a/lib/chain/ws_conn.ex b/lib/chain/ws_conn.ex index 38c60f8..bfc0c0f 100644 --- a/lib/chain/ws_conn.ex +++ b/lib/chain/ws_conn.ex @@ -1,21 +1,34 @@ +# Diode Server +# Copyright 2021-2024 Diode +# Licensed under the Diode License, Version 1.1 defmodule Chain.WSConn do @moduledoc """ Manage websocket connections to the given chain rpc node """ use WebSockex + alias Chain.WSConn require Logger - defstruct [:chain, :conn, lastblock_at: DateTime.utc_now(), lastblock_number: 0] + defstruct [ + :owner, + :chain, + :ws_url, + :conn, + lastblock_at: DateTime.utc_now(), + lastblock_number: 0 + ] - def start(chain, ws_url) do - state = %__MODULE__{chain: chain} + def start(owner, chain, ws_url) do + state = %__MODULE__{owner: owner, chain: chain, ws_url: ws_url} {:ok, pid} = WebSockex.start(ws_url, __MODULE__, state, async: true) - :timer.send_interval(chain.expected_block_interval() * 2, pid, :ping) + :timer.send_interval(chain.expected_block_intervall() * 2, pid, :ping) pid end @impl true def handle_connect(conn, state) do + Process.monitor(state.owner) + request = %{ "jsonrpc" => "2.0", @@ -23,7 +36,7 @@ defmodule Chain.WSConn do "method" => "eth_subscribe", "params" => ["newHeads"] } - |> Jason.encode!() + |> Poison.encode!() {:ok, binary_frame} = WebSockex.Frame.encode_frame({:text, request}) WebSockex.Conn.socket_send(conn, binary_frame) @@ -31,19 +44,18 @@ defmodule Chain.WSConn do end @impl true - def handle_frame({:text, json}, state = %{chain: chain}) do - case Jason.decode!(json) do + def handle_frame({:text, json}, state = %{ws_url: ws_url}) do + case Poison.decode!(json) do %{"id" => 1, "result" => subscription_id} when is_binary(subscription_id) -> {:ok, state} %{"params" => %{"result" => %{"number" => hex_number}}} -> - {:ok, state |> reset_poll_counter() |> broadcast(hex_number)} - - unexpected_response -> - Logger.warning( - "WSConn(#{chain}) received unexpected message: #{inspect(unexpected_response)}" - ) + block_number = String.to_integer(hex_number, 16) + send(state.owner, {:new_block, ws_url, block_number}) + {:ok, %{state | lastblock_at: DateTime.utc_now(), lastblock_number: block_number}} + other -> + send(state.owner, {:response, ws_url, other}) {:ok, state} end end diff --git a/lib/chains/chains.ex b/lib/chains/chains.ex index 8beb208..57dcd94 100644 --- a/lib/chains/chains.ex +++ b/lib/chains/chains.ex @@ -1,6 +1,6 @@ defmodule Chains.Diode do def chain_id(), do: 15 - def expected_chain_intervall(), do: 15 + def expected_block_intervall(), do: 15 def chain_prefix(), do: "diode" def rpc_endpoints(), do: ["https://prenet.diode.io:8443"] def ws_endpoints(), do: ["wss://prenet.diode.io:8443/ws"] @@ -10,7 +10,7 @@ end defmodule Chains.DiodeStaging do def chain_id(), do: 13 - def expected_chain_intervall(), do: 15 + def expected_block_intervall(), do: 15 def chain_prefix(), do: "diodestg" def rpc_endpoints(), do: ["https://staging.diode.io:8443"] def ws_endpoints(), do: ["wss://staging.diode.io:8443/ws"] @@ -20,7 +20,7 @@ end defmodule Chains.Moonbeam do def chain_id(), do: 1284 - def expected_chain_intervall(), do: 15 + def expected_block_intervall(), do: 15 def chain_prefix(), do: "moon" def rpc_endpoints(), @@ -51,7 +51,7 @@ end defmodule Chains.MoonbaseAlpha do def chain_id(), do: 1287 - def expected_chain_intervall(), do: 15 + def expected_block_intervall(), do: 15 def chain_prefix(), do: "m1" def rpc_endpoints(), diff --git a/lib/diode.ex b/lib/diode.ex index 37c5c5b..07b3cda 100644 --- a/lib/diode.ex +++ b/lib/diode.ex @@ -6,23 +6,14 @@ require Logger defmodule Diode do use Application - # Ignoring all info level sasl messages - def filter_function(event, _) do - case event do - %{level: :info, meta: %{domain: [:otp, :sasl]}} -> :stop - _other -> :ignore - end - end - def start(_type, args) do :persistent_term.put(:env, Mix.env()) :erlang.system_flag(:backtrace_depth, 30) - :logger.add_primary_filter(:ignore_supervisor_infos, {&filter_function/2, []}) puts("====== ENV #{Mix.env()} ======") puts("Build : #{version()}") puts("Edge Port: #{Enum.join(edge2_ports(), ",")}") - puts("Peer Port: #{peer_port()}") + puts("Peer Port: #{peer2_port()}") puts("RPC Port: #{rpc_port()}") if ssl?() do @@ -62,32 +53,23 @@ defmodule Diode do puts("") - base_children = [ - worker(Stats, []), - supervisor(Model.Sql), - supervisor(Channels), - supervisor(Moonbeam.Sup), - worker(PubSub, [args]), - worker(Chain.Pool, [args]), - worker(TicketStore, []), - Enum.map(Chain.chains(), fn chain -> worker(Chain.Sup, [chain]) end) - ] - children = - if Mix.env() == :benchmark do - base_children - else - network_children = [ - # Starting External Interfaces - Network.Server.child(peer_port(), Network.PeerHandler), - worker(Kademlia, [args]), - worker(Stages) + [ + worker(Stats, []), + supervisor(Model.Sql), + supervisor(Channels), + worker(PubSub, [args]), + worker(TicketStore, []) + | Enum.map(Chain.chains(), fn chain -> + supervisor(Chain.Sup, [chain], {Chain.Sup, chain}) + end) + ] ++ + [ + # External Interfaces + Network.Server.child(peer2_port(), Network.PeerHandler), + worker(Kademlia, [args]) ] - base_children ++ network_children - end - - children = children ++ [worker(Chain.Worker, [worker_mode()])] {:ok, pid} = Supervisor.start_link(children, strategy: :rest_for_one, name: Diode.Supervisor) start_client_network() {:ok, pid} @@ -114,13 +96,13 @@ defmodule Diode do Supervisor.terminate_child(Diode.Supervisor, Network.EdgeV2) end - defp worker(module, args \\ []) do + defp worker(module, args) do %{id: module, start: {Diode, :start_worker, [module, args]}} end - defp supervisor(module, args \\ []) do + defp supervisor(module, args \\ [], id \\ nil) do %{ - id: module, + id: id || module, start: {Diode, :start_worker, [module, args]}, shutdown: :infinity, type: :supervisor @@ -290,9 +272,9 @@ defmodule Diode do |> Enum.map(fn port -> decode_int(String.trim(port)) end) end - @spec peer_port() :: integer() - def peer_port() do - get_env_int("PEER_PORT", 51054) + @spec peer2_port() :: integer() + def peer2_port() do + get_env_int("PEER2_PORT", 51055) end def seeds() do @@ -314,15 +296,6 @@ defmodule Diode do end end - @spec worker_mode() :: :disabled | :poll | integer() - def worker_mode() do - case get_env("WORKER_MODE", "run") do - "poll" -> :poll - "disabled" -> :disabled - _number -> get_env_int("WORKER_MODE", 75) - end - end - @spec memory_mode() :: :normal | :minimal def memory_mode() do case get_env("MEMORY_MODE", "normal") do @@ -341,7 +314,7 @@ defmodule Diode do def self(), do: self(host()) def self(hostname) do - Object.Server.new(hostname, hd(edge2_ports()), peer_port(), version(), [ + Object.Server.new(hostname, hd(edge2_ports()), peer2_port(), version(), [ ["tickets", TicketStore.value(TicketStore.epoch())], ["uptime", Diode.uptime()], ["time", System.os_time()] diff --git a/lib/kademlia.ex b/lib/kademlia.ex index b2387b6..254475f 100644 --- a/lib/kademlia.ex +++ b/lib/kademlia.ex @@ -432,7 +432,7 @@ defmodule Kademlia do Network.PeerHandler, node_id, "localhost", - Diode.peer_port() + Diode.peer2_port() ) else server = KBuckets.object(item) diff --git a/lib/model/credsql.ex b/lib/model/credsql.ex index d82a39a..0681e04 100644 --- a/lib/model/credsql.ex +++ b/lib/model/credsql.ex @@ -14,23 +14,17 @@ defmodule Model.CredSql do GenServer.start_link(__MODULE__, :ok, name: __MODULE__) end - defp query!(sql, params) do + defp query!(sql, params \\ []) do Sql.query!(__MODULE__, sql, params) end - defp with_transaction(fun) do - Sql.with_transaction(__MODULE__, fun) - end - def init(_args) do - with_transaction(fn db -> - Sql.query!(db, """ - CREATE TABLE IF NOT EXISTS config ( - key TEXT PRIMARY KEY, - value BLOB - ) - """) - end) + query!(""" + CREATE TABLE IF NOT EXISTS config ( + key TEXT PRIMARY KEY, + value BLOB + ) + """) case Diode.get_env_int("PRIVATE", 0) do # Decode env parameter such as @@ -65,7 +59,7 @@ defmodule Model.CredSql do def put_config(key, value) when is_binary(key) do value_data = BertInt.encode!(value) - query!("REPLACE INTO config (key, value) VALUES(?1, ?2)", bind: [key, value_data]) + query!("REPLACE INTO config (key, value) VALUES(?1, ?2)", [key, value_data]) value end diff --git a/lib/model/kademliasql.ex b/lib/model/kademliasql.ex index e94c844..370f49e 100644 --- a/lib/model/kademliasql.ex +++ b/lib/model/kademliasql.ex @@ -8,19 +8,13 @@ defmodule Model.KademliaSql do Sql.query!(__MODULE__, sql, params) end - defp with_transaction(fun) do - Sql.with_transaction(__MODULE__, fun) - end - def init() do - with_transaction(fn db -> - Sql.query!(db, """ - CREATE TABLE IF NOT EXISTS p2p_objects ( - key BLOB PRIMARY KEY, - object BLOB - ) - """) - end) + query!(""" + CREATE TABLE IF NOT EXISTS p2p_objects ( + key BLOB PRIMARY KEY, + object BLOB + ) + """) end def clear() do @@ -58,11 +52,11 @@ defmodule Model.KademliaSql do def put_object(key, object) do object = BertInt.encode!(object) - query!("REPLACE INTO p2p_objects (key, object) VALUES(?1, ?2)", bind: [key, object]) + query!("REPLACE INTO p2p_objects (key, object) VALUES(?1, ?2)", [key, object]) end def delete_object(key) do - query!("DELETE FROM p2p_objects WHERE key = ?1", bind: [key]) + query!("DELETE FROM p2p_objects WHERE key = ?1", [key]) end def object(key) do @@ -71,7 +65,7 @@ defmodule Model.KademliaSql do def scan() do query!("SELECT key, object FROM p2p_objects") - |> Enum.map(fn [key: key, object: obj] -> + |> Enum.map(fn [key, obj] -> obj = BertInt.decode!(obj) |> Object.decode!() {key, obj} end) @@ -83,15 +77,17 @@ defmodule Model.KademliaSql do bend = <> if range_start < range_end do - query!("SELECT key, object FROM p2p_objects WHERE key >= ?1 AND key <= ?2", - bind: [bstart, bend] + query!( + "SELECT key, object FROM p2p_objects WHERE key >= ?1 AND key <= ?2", + [bstart, bend] ) else - query!("SELECT key, object FROM p2p_objects WHERE key >= ?1 OR key <= ?2", - bind: [bstart, bend] + query!( + "SELECT key, object FROM p2p_objects WHERE key >= ?1 OR key <= ?2", + [bstart, bend] ) end - |> Enum.map(fn [key: key, object: obj] -> {key, BertInt.decode!(obj)} end) + |> Enum.map(fn [key, obj] -> {key, BertInt.decode!(obj)} end) |> Enum.filter(fn {key, value} -> # After a chain fork some signatures might have become invalid hash = @@ -100,7 +96,7 @@ defmodule Model.KademliaSql do |> Kademlia.hash() if key != hash do - query!("DELETE FROM p2p_objects WHERE key = ?1", bind: [key]) + query!("DELETE FROM p2p_objects WHERE key = ?1", [key]) false else true diff --git a/lib/model/merklesql.ex b/lib/model/merklesql.ex deleted file mode 100644 index 6c5397d..0000000 --- a/lib/model/merklesql.ex +++ /dev/null @@ -1,481 +0,0 @@ -# Diode Server -# Copyright 2021-2024 Diode -# Licensed under the Diode License, Version 1.1 -defmodule Model.MerkleSql do - alias Model.Sql - @type key_type :: binary() | integer() - @type value_type :: term() - - @type item :: {key_type(), value_type()} - @type hash_type :: <<_::256>> - - @type proof_type :: {proof_type, proof_type} | [any()] - - @type sql_key :: binary() - @type hash_count :: {[binary()], non_neg_integer()} - @type tree_leaf :: {:leaf, hash_count() | nil, binary(), map()} - @type tree_node :: {:node, hash_count() | nil, binary(), tree(), tree()} - @type tree :: tree_leaf() | tree_node() | sql_key() - @type merkle :: {__MODULE__, %{}, sql_key() | tree()} - - @spec new() :: merkle() - def new() do - store({__MODULE__, %{}, {:leaf, nil, "", %{}}}) - end - - @spec normalize(merkle()) :: merkle() - def normalize(merkle) do - {__MODULE__, %{}, normalized_tree(merkle)} - end - - @spec store(merkle()) :: merkle() - def store(merkle) do - tree = - normalized_tree(merkle) - |> sql_store() - - {__MODULE__, %{}, tree} - end - - @doc """ - null() returns the default empty tree for comparison - """ - def null() do - {__MODULE__, %{}, - <<67, 138, 144, 64, 93, 170, 135, 101, 57, 8, 44, 208, 186, 246, 205, 218, 163, 191, 136, 15, - 28, 138, 240, 192, 56, 31, 0, 66, 219, 147, 8, 138>>} - end - - def restore(sql_key) do - with_transaction(fn db -> - case Sql.query!(db, "SELECT data FROM mtree WHERE hash = ?1", bind: [sql_key]) do - [[data: data]] -> {:ok, {__MODULE__, %{}, sql_decode(data)}} - [] -> {:error, :not_found} - end - end) - end - - @spec root_hash(merkle()) :: hash_type() - def root_hash(merkle) do - root_hashes(merkle) - |> signature() - end - - @spec root_hashes(merkle()) :: [hash_type()] - def root_hashes(merkle) do - with_transaction(fn db -> merkle_hashes(db, normalized_tree(merkle)) end) - end - - @spec get_proofs(merkle(), key_type()) :: proof_type() - def get_proofs(merkle, key) do - bkey = to_binary(key) - with_transaction(fn db -> do_get_proofs(db, normalized_tree(merkle), bkey, hash(bkey)) end) - end - - @spec get(merkle(), key_type()) :: value_type() - def get({__MODULE__, _options, tree}, key) do - bkey = to_binary(key) - with_transaction(fn db -> do_get(db, tree, bkey, hash(bkey)) end) - end - - @spec size(merkle()) :: non_neg_integer() - def size({__MODULE__, _options, tree}) do - with_transaction(fn db -> do_size(db, tree) end) - end - - @spec bucket_count(merkle()) :: pos_integer() - def bucket_count(merkle) do - with_transaction(fn db -> do_bucket_count(db, normalized_tree(merkle)) end) - end - - @spec to_list(merkle()) :: [item()] - def to_list({__MODULE__, _options, tree}) do - with_transaction(fn db -> do_to_list(db, tree) end) - end - - @spec delete(merkle(), key_type()) :: merkle() - def delete({__MODULE__, options, tree}, key) do - bkey = to_binary(key) - - tree = - with_transaction(fn db -> - update_bucket(db, tree, hash(bkey), fn {:leaf, _hash_count, prefix, bucket} -> - {:leaf, nil, prefix, Map.delete(bucket, bkey)} - end) - end) - - {__MODULE__, options, tree} - end - - @spec member?(merkle(), key_type()) :: boolean() - def member?(tree, key) do - nil != get(tree, key) - end - - @spec insert(merkle(), key_type(), value_type()) :: merkle() - def insert(tree, key, value) do - insert_items(tree, [{key, value}]) - end - - @spec insert_item(merkle(), item()) :: merkle() - def insert_item(tree, item) do - insert_items(tree, [item]) - end - - @spec insert_items(merkle(), [item()]) :: merkle() - def insert_items({__MODULE__, options, tree}, items) do - tree = - with_transaction(fn db -> - Enum.reduce(items, tree, fn {key, value}, acc -> - bkey = to_binary(key) - - update_bucket(db, acc, hash(bkey), fn {:leaf, _hash_count, prefix, bucket} -> - bucket = - case to_binary(value) do - <<0::unsigned-size(256)>> -> Map.delete(bucket, bkey) - value -> Map.put(bucket, bkey, value) - end - - {:leaf, nil, prefix, bucket} - end) - end) - end) - - {__MODULE__, options, tree} - end - - # ======================================================== - # Internal SQL Specific - # ======================================================== - def init() do - {:ok, _ret} = - Sql.query(__MODULE__, """ - CREATE TABLE IF NOT EXISTS mtree ( - hash BLOB PRIMARY KEY, - data BLOB - ) - """) - - __MODULE__.new() - end - - defp with_transaction(fun) do - fun.(__MODULE__) - end - - defp normalized_tree({__MODULE__, _options, tree}) do - with_transaction(fn db -> update_merkle_hash_count(db, tree) end) - end - - defp sql_key(db, tree) do - signature(merkle_hashes(db, tree)) - end - - defp sql_store(sql_key) when is_binary(sql_key) do - sql_key - end - - # sql_store does the actual mnesia_storage - defp sql_store(tree) when is_tuple(tree) do - with_transaction(fn db -> - tree = update_merkle_hash_count(db, tree) - do_sql_store(db, tree) - end) - end - - defp sql_exists(db, sql_key) do - case Sql.query(db, "SELECT hash FROM mtree WHERE hash = ?1", bind: [sql_key]) do - {:ok, []} -> false - {:ok, [[hash: ^sql_key]]} -> true - end - end - - defp do_sql_store(_db, sql_key) when is_binary(sql_key) do - sql_key - end - - defp do_sql_store(db, tree) do - sql_key = sql_key(db, tree) - - if not sql_exists(db, sql_key) do - :ok = do_sql_store(db, sql_key, tree) - end - - sql_key - end - - defp do_sql_store(db, sql_key, {:leaf, _hash_count, prefix, bucket}) do - sql_write(db, sql_key, {:leaf, nil, prefix, bucket}) - end - - defp do_sql_store(db, sql_key, {:node, hashcount = {_hash, count}, prefix, left, right}) do - hashcount = - if count > 16 do - hashcount - else - nil - end - - sql_write( - db, - sql_key, - {:node, hashcount, prefix, do_sql_store(db, left), do_sql_store(db, right)} - ) - end - - defp sql_write(db, key, val) do - data = BertInt.encode!(val) - Sql.query!(db, "REPLACE INTO mtree (hash, data) VALUES(?1, ?2)", bind: [key, data]) - :ok - end - - defp sql_decode(val) do - BertInt.decode!(val) - end - - defp from_key(db, sql_key) when is_binary(sql_key) do - [[data: data]] = Sql.query!(db, "SELECT data FROM mtree WHERE hash = ?1", bind: [sql_key]) - - update_merkle_hash_count(db, sql_decode(data)) - end - - # ======================================================== - # Internal - # ======================================================== - @leaf_size 16 - @left <<0::size(1)>> - @right <<1::size(1)>> - - @spec do_get(pid(), tree(), binary(), binary()) :: any() - defp do_get(db, sql_key, key, hash) when is_binary(sql_key) do - do_get(db, from_key(db, sql_key), key, hash) - end - - defp do_get(db, {:node, _hash_count, prefix, left, right}, key, hash) do - case decide(hash, prefix) do - true -> do_get(db, left, key, hash) - false -> do_get(db, right, key, hash) - end - end - - defp do_get(_db, {:leaf, _hash_count, _prefix, bucket}, key, _hash) do - Map.get(bucket, key) - end - - @spec do_get_proofs(pid(), tree(), binary(), binary()) :: any() - defp do_get_proofs(db, sql_key, key, hash) when is_binary(sql_key) do - do_get_proofs(db, from_key(db, sql_key), key, hash) - end - - defp do_get_proofs(db, {:node, _hash_count, prefix, left, right}, key, hash) do - case decide(hash, prefix) do - true -> {do_get_proofs(db, left, key, hash), merkle_hash(db, right, hash)} - false -> {merkle_hash(db, left, hash), do_get_proofs(db, right, key, hash)} - end - end - - defp do_get_proofs(_db, {:leaf, _hash_count, prefix, bucket}, key, _hash) do - bucket_to_leaf(bucket, prefix, key) - end - - defp do_size(db, sql_key) when is_binary(sql_key) do - do_size(db, from_key(db, sql_key)) - end - - defp do_size(_db, {:leaf, _hash_count, _prefix, bucket}) do - map_size(bucket) - end - - defp do_size(db, {:node, nil, _prefix, left, right}) do - do_size(db, left) + do_size(db, right) - end - - defp do_size(_db, {:node, {_hashes, count}, _prefix, _left, _right}) do - count - end - - defp do_bucket_count(db, sql_key) when is_binary(sql_key) do - do_bucket_count(db, from_key(db, sql_key)) - end - - defp do_bucket_count(_db, {:leaf, _hash_count, _prefix, _bucket}) do - 1 - end - - defp do_bucket_count(db, {:node, _hash_count, _prefix, left, right}) do - do_bucket_count(db, left) + do_bucket_count(db, right) - end - - defp do_to_list(db, sql_key) when is_binary(sql_key) do - do_to_list(db, from_key(db, sql_key)) - end - - defp do_to_list(_db, {:leaf, _hash_count, _prefix, bucket}) do - Map.to_list(bucket) - end - - defp do_to_list(db, {:node, _hash_count, _prefix, left, right}) do - do_to_list(db, left) ++ do_to_list(db, right) - end - - defp hash(value) when is_binary(value) do - Diode.hash(value) - end - - @spec key(item()) :: binary() - defp key({key, _value}) do - hash(key) - end - - defp decide(hash, prefix) do - x = bit_size(prefix) - - case hash do - <<^prefix::bitstring-size(x), @left::bitstring, _::bitstring>> -> - true - - <<^prefix::bitstring-size(x), @right::bitstring, _::bitstring>> -> - false - end - end - - @spec update_bucket(pid(), tree(), binary(), fun()) :: tree() - defp update_bucket(db, {:node, _hash_count, prefix, left, right}, key, fun) do - case decide(key, prefix) do - true -> - {:node, nil, prefix, update_bucket(db, left, key, fun), right} - - false -> - {:node, nil, prefix, left, update_bucket(db, right, key, fun)} - end - end - - defp update_bucket(_db, {:leaf, _hash_count, prefix, bucket}, _key, fun) do - fun.({:leaf, nil, prefix, bucket}) - end - - defp update_bucket(db, sql_key, key, fun) when is_binary(sql_key) do - update_bucket(db, from_key(db, sql_key), key, fun) - end - - defp merkle_hash_count(tree) when is_tuple(tree) do - elem(tree, 1) - end - - defp merkle_hashes(_db, tree) when is_tuple(tree) do - {hashes, _count} = merkle_hash_count(tree) - hashes - end - - defp merkle_hashes(db, sql_key) when is_binary(sql_key) do - merkle_hashes(db, from_key(db, sql_key)) - end - - defp merkle_hash(db, tree, hash) do - hashes = merkle_hashes(db, tree) - Enum.at(hashes, hash_to_leafindex(hash)) - end - - defp hash_to_leafindex(hash) do - <> = binary_part(hash, byte_size(hash), -1) - rem(lastb, @leaf_size) - end - - @spec update_merkle_hash_count(pid(), tree()) :: tree() - defp update_merkle_hash_count(db, {:node, nil, prefix, left, right}) do - left = update_merkle_hash_count(db, left) - {hashesl, countl} = merkle_hash_count(left) - - right = update_merkle_hash_count(db, right) - {hashesr, countr} = merkle_hash_count(right) - - count = countl + countr - # Need to merge - if count <= @leaf_size do - items = do_to_list(db, {:node, nil, prefix, left, right}) - - tree = {:leaf, nil, prefix, Map.new(items)} - update_merkle_hash_count(db, tree) - else - hashes = - :lists.zipwith( - fn hashl, hashr -> - signature([hashl, hashr]) - end, - hashesl, - hashesr - ) - - {:node, {hashes, count}, prefix, left, right} - end - end - - defp update_merkle_hash_count(db, {:leaf, nil, prefix, bucket}) do - count = map_size(bucket) - # Need to split - if count > @leaf_size do - {left, right} = Enum.split_with(bucket, fn item -> decide(key(item), prefix) end) - - tree = - {:node, nil, prefix, {:leaf, nil, <>, Map.new(left)}, - {:leaf, nil, <>, Map.new(right)}} - - update_merkle_hash_count(db, tree) - else - hashes = - bucket_to_leafes(bucket, prefix) - |> Enum.map(&signature/1) - - {:leaf, {hashes, count}, prefix, bucket} - end - end - - # Loading reduced nodes (where hash_count = nil because it was skipped during storage) - defp update_merkle_hash_count(db, sql_key) when is_binary(sql_key) do - update_merkle_hash_count(db, from_key(db, sql_key)) - end - - defp update_merkle_hash_count(_db, tree) when is_tuple(tree) do - tree - end - - defp bucket_to_leafes(bucket, prefix) do - l0 = - Enum.map(1..@leaf_size, fn num -> - [num - 1, prefix] - end) - - Enum.reduce(bucket, l0, fn item, list -> - pos = hash_to_leafindex(key(item)) - value = [item | Enum.at(list, pos)] - List.replace_at(list, pos, value) - end) - |> Enum.map(&Enum.reverse/1) - end - - defp bucket_to_leaf(bucket, prefix, key) do - pos = hash_to_leafindex(hash(key)) - l0 = [pos, prefix] - - Enum.reduce(bucket, l0, fn item, list -> - if hash_to_leafindex(key(item)) == pos do - [item | list] - else - list - end - end) - |> Enum.reverse() - end - - defp signature(list) when is_list(list) do - hash(BertExt.encode!(list)) - end - - defp to_binary(binary) when is_binary(binary) do - binary - end - - defp to_binary(int) when is_integer(int) do - <> - end -end diff --git a/lib/model/sql.ex b/lib/model/sql.ex index 1124eab..b39714c 100644 --- a/lib/model/sql.ex +++ b/lib/model/sql.ex @@ -5,7 +5,7 @@ defmodule Model.Sql do # Automatically defines child_spec/1 use Supervisor # esqlite doesn't support :infinity - @infinity 300_000_000 + # @infinity 300_000_000 defp databases() do [ @@ -14,23 +14,14 @@ defmodule Model.Sql do ] end - defp map_mod(Model.CredSql), do: Db.Creds - defp map_mod(Model.TicketSql), do: Db.Tickets - defp map_mod(Model.KademliaSql), do: Db.Tickets - defp map_mod(pid) when is_pid(pid), do: pid - defp map_mod(_), do: Db.Tickets + defp map_mod(ref) when is_reference(ref), do: ref + defp map_mod(Model.CredSql), do: :persistent_term.get(Db.Creds) + defp map_mod(_), do: :persistent_term.get(Db.Tickets) def start_link() do - Application.put_env(:sqlitex, :call_timeout, 300_000) Supervisor.start_link(__MODULE__, [], name: __MODULE__) end - defp init_connection(conn) do - query!(conn, "PRAGMA journal_mode = WAL") - query!(conn, "PRAGMA synchronous = NORMAL") - # query!(conn, "PRAGMA OPTIMIZE", call_timeout: @infinity) - end - defmodule Init do use GenServer @@ -49,48 +40,46 @@ defmodule Model.Sql do def init(_args) do File.mkdir(Diode.data_dir()) - children = - databases() - |> Keyword.keys() - |> Enum.map(fn name -> - %{id: name, start: {__MODULE__, :start_database, [name, name]}} - end) + for {atom, file} <- databases() do + start_database(atom, file) + end - children = children ++ [Model.CredSql, Init] + children = [Model.CredSql, Init] Supervisor.init(children, strategy: :one_for_one) end - @spec start_database(atom(), atom() | nil) :: {:ok, pid()} - def start_database(db, name \\ nil) do - path = - Keyword.fetch!(databases(), db) - |> Diode.data_dir() - |> to_charlist() - - opts = [name: name, db_timeout: @infinity, stmt_cache_size: 50] - - {:ok, pid} = Sqlitex.Server.start_link(path, opts) - init_connection(pid) - {:ok, pid} + def start_database(atom, file) do + path = Diode.data_dir(file) + {:ok, conn} = Exqlite.Sqlite3.open(path) + :persistent_term.put(atom, conn) + query!(conn, "PRAGMA journal_mode = WAL") + query!(conn, "PRAGMA synchronous = NORMAL") end def query(mod, sql, params \\ []) do - params = Keyword.put_new(params, :call_timeout, @infinity) + conn = map_mod(mod) Stats.tc(:query, fn -> - Sqlitex.Server.query(map_mod(mod), sql, params) + {:ok, stmt} = Exqlite.Sqlite3.prepare(conn, sql) + :ok = Exqlite.Sqlite3.bind(conn, stmt, params) + ret = collect(conn, stmt, []) |> Enum.reverse() + :ok = Exqlite.Sqlite3.release(conn, stmt) + {:ok, ret} end) end + defp collect(conn, stmt, acc) do + case Exqlite.Sqlite3.step(conn, stmt) do + {:row, row} -> collect(conn, stmt, [row | acc]) + :done -> acc + end + end + def query!(mod, sql, params \\ []) do {:ok, ret} = query(mod, sql, params) ret end - def query_async!(mod, sql, params \\ []) do - Sqlitex.Server.query_async(map_mod(mod), sql, params) - end - def fetch!(mod, sql, param1) do case lookup!(mod, sql, param1) do nil -> nil @@ -99,14 +88,9 @@ defmodule Model.Sql do end def lookup!(mod, sql, param1 \\ [], default \\ nil) do - case query!(mod, sql, bind: List.wrap(param1)) do + case query!(mod, sql, List.wrap(param1)) do [] -> default - [[{_key, value}]] -> value + [[value]] -> value end end - - def with_transaction(mod, fun) do - {:ok, result} = Sqlitex.Server.with_transaction(map_mod(mod), fun, call_timeout: @infinity) - result - end end diff --git a/lib/model/ticketsql.ex b/lib/model/ticketsql.ex index d0bd6f3..efaa50f 100644 --- a/lib/model/ticketsql.ex +++ b/lib/model/ticketsql.ex @@ -9,35 +9,30 @@ defmodule Model.TicketSql do Sql.query!(__MODULE__, sql, params) end - defp with_transaction(fun) do - Sql.with_transaction(__MODULE__, fun) - end - def init() do - with_transaction(fn db -> - Sql.query!(db, """ - CREATE TABLE IF NOT EXISTS tickets ( - device BLOB, - fleet BLOB, - epoch INTEGER, - ticket BLOB, - PRIMARY KEY (device, fleet, epoch) - ) - """) - - Sql.query!(db, """ - CREATE INDEX IF NOT EXISTS tck_epoch ON tickets ( - epoch - ) - """) - end) + query!(""" + CREATE TABLE IF NOT EXISTS tickets ( + device BLOB, + fleet BLOB, + epoch INTEGER, + ticket BLOB, + PRIMARY KEY (device, fleet, epoch) + ) + """) + + query!(""" + CREATE INDEX IF NOT EXISTS tck_epoch ON tickets ( + epoch + ) + """) end def put_ticket(ticket) do ticket_data = BertInt.encode!(ticket) - query!("REPLACE INTO tickets (device, fleet, epoch, ticket) VALUES(?1, ?2, ?3, ?4)", - bind: [ + query!( + "REPLACE INTO tickets (device, fleet, epoch, ticket) VALUES(?1, ?2, ?3, ?4)", + [ TicketV2.device_address(ticket), TicketV2.fleet_contract(ticket), TicketV2.epoch(ticket), @@ -50,14 +45,14 @@ defmodule Model.TicketSql do def tickets_raw() do query!("SELECT device, fleet, epoch, ticket FROM tickets") - |> Enum.map(fn [device: dev, fleet: fleet, epoch: epoch, ticket: ticket] -> + |> Enum.map(fn [dev, fleet, epoch, ticket] -> {dev, fleet, epoch, BertInt.decode!(ticket)} end) end def tickets(epoch) do - query!("SELECT ticket FROM tickets WHERE epoch = ?1", bind: [epoch]) - |> Enum.map(fn [ticket: ticket] -> BertInt.decode!(ticket) end) + query!("SELECT ticket FROM tickets WHERE epoch = ?1", [epoch]) + |> Enum.map(fn [ticket] -> BertInt.decode!(ticket) end) end def find(tck) do @@ -79,12 +74,12 @@ defmodule Model.TicketSql do def delete(device = <<_::160>>, fleet = <<_fl::160>>, epoch) when is_integer(epoch) do query!( "DELETE FROM tickets WHERE device = ?1 AND fleet = ?2 AND epoch = ?3", - bind: [device, fleet, epoch] + [device, fleet, epoch] ) end def delete_old(epoch) do - query!("DELETE FROM tickets WHERE epoch < ?1", bind: [epoch]) + query!("DELETE FROM tickets WHERE epoch < ?1", [epoch]) end def delete_all() do @@ -92,7 +87,7 @@ defmodule Model.TicketSql do end def count(epoch) do - [[c: c]] = query!("SELECT COUNT(*) as c FROM tickets WHERE epoch = ?1", bind: [epoch]) + [[c]] = query!("SELECT COUNT(*) as c FROM tickets WHERE epoch = ?1", [epoch]) c end end diff --git a/lib/network/server.ex b/lib/network/server.ex index f40b7ee..f469a02 100644 --- a/lib/network/server.ex +++ b/lib/network/server.ex @@ -186,7 +186,7 @@ defmodule Network.Server do if client != nil do {:reply, client, state} else - worker = start_worker!(state, [:connect, node_id, "localhost", Diode.peer_port()]) + worker = start_worker!(state, [:connect, node_id, "localhost", Diode.peer2_port()]) {:reply, worker, %{state | self_conns: [worker]}} end else diff --git a/lib/ticketstore.ex b/lib/ticketstore.ex index f7e238a..b35744e 100644 --- a/lib/ticketstore.ex +++ b/lib/ticketstore.ex @@ -10,16 +10,16 @@ defmodule TicketStore do @ticket_value_cache :ticket_value_cache - def start_link(ets_extra) do - GenServer.start_link(__MODULE__, ets_extra, name: __MODULE__) + def start_link() do + GenServer.start_link(__MODULE__, [], name: __MODULE__) end def epoch() do System.os_time(:second) |> TicketV2.time_to_epoch() end - def init(ets_extra) do - Ets.init(__MODULE__, ets_extra) + def init([]) do + Ets.init(__MODULE__) EtsLru.new(@ticket_value_cache, 1024) {:ok, nil} end diff --git a/mix.exs b/mix.exs index 20f7277..f3854c8 100644 --- a/mix.exs +++ b/mix.exs @@ -1,11 +1,11 @@ # Diode Server -# Copyright 2024 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule Diode.Mixfile do use Mix.Project @vsn "1.1.0" - @full_vsn "v1.1.0" + @full_vsn "v1.1.0-5-g6b9baab-dirty" @url "https://github.com/diodechain/diode_server" def project do @@ -31,20 +31,7 @@ defmodule Diode.Mixfile do defp elixirc_paths(_), do: ["lib"] def application do - [ - mod: {Diode, []}, - extra_applications: [ - :debouncer, - :keccakf1600, - :libsecp256k1, - :logger, - :mix, - :observer, - :runtime_tools, - :sqlitex, - :os_mon - ] - ] + [mod: {Diode, []}, extra_applications: [:logger, :observer, :runtime_tools]] end defp aliases do @@ -85,7 +72,6 @@ defmodule Diode.Mixfile do defp deps do [ {:websockex, "~> 0.4.3"}, - {:benchee, "~> 1.0", only: :benchmark}, {:debouncer, "~> 0.1"}, {:ex_doc, "~> 0.28", only: :dev, runtime: false}, {:keccakf1600, github: "diodechain/erlang-keccakf1600"}, @@ -93,9 +79,8 @@ defmodule Diode.Mixfile do {:plug_cowboy, "~> 2.5"}, {:poison, "~> 3.0"}, {:profiler, github: "dominicletz/profiler"}, - {:sqlitex, github: "diodechain/sqlitex"}, + {:exqlite, "~> 0.17"}, {:niffler, "~> 0.1"}, - {:while, "~> 0.2"}, {:httpoison, "~> 2.0"}, {:oncrash, "~> 0.0"}, diff --git a/mix.lock b/mix.lock index d4b63db..d2dfcd5 100644 --- a/mix.lock +++ b/mix.lock @@ -1,52 +1,51 @@ %{ - "benchee": {:hex, :benchee, "1.0.1", "66b211f9bfd84bd97e6d1beaddf8fc2312aaabe192f776e8931cb0c16f53a521", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}], "hexpm", "3ad58ae787e9c7c94dd7ceda3b587ec2c64604563e049b2a0e8baafae832addb"}, - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"}, + "benchee": {:hex, :benchee, "1.3.0", "f64e3b64ad3563fa9838146ddefb2d2f94cf5b473bdfd63f5ca4d0657bf96694", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "34f4294068c11b2bd2ebf2c59aac9c7da26ffa0068afdf3419f1b176e16c5f81"}, + "bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"}, + "cc_precompiler": {:hex, :cc_precompiler, "0.1.10", "47c9c08d8869cf09b41da36538f62bc1abd3e19e41701c2cea2675b53c704258", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f6e046254e53cd6b41c6bacd70ae728011aa82b2742a80d6e2214855c6e06b22"}, "certifi": {:hex, :certifi, "2.12.0", "2d1cca2ec95f59643862af91f001478c9863c2ac9cb6e2f89780bfd8de987329", [:rebar3], [], "hexpm", "ee68d85df22e554040cdb4be100f33873ac6051387baf6a8f6ce82272340ff1c"}, - "cowboy": {:hex, :cowboy, "2.9.0", "865dd8b6607e14cf03282e10e934023a1bd8be6f6bacf921a7e2a96d800cd452", [:make, :rebar3], [{:cowlib, "2.11.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "2c729f934b4e1aa149aff882f57c6372c15399a20d54f65c8d67bef583021bde"}, + "cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, - "cowlib": {:hex, :cowlib, "2.11.0", "0b9ff9c346629256c42ebe1eeb769a83c6cb771a6ee5960bd110ab0b9b872063", [:make, :rebar3], [], "hexpm", "2b3e9da0b21c4565751a6d4901c20d1b4cc25cbb7fd50d91d2ab6dd287bc86a9"}, - "credo": {:hex, :credo, "1.6.3", "0a9f8925dbc8f940031b789f4623fc9a0eea99d3eed600fe831e403eb96c6a83", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1167cde00e6661d740fc54da2ee268e35d3982f027399b64d3e2e83af57a1180"}, - "debouncer": {:hex, :debouncer, "0.1.5", "1d993bd01400585a6bf463d36ea50386deea2c09bc6e55d613b7b6c0b4ccb4f9", [:mix], [], "hexpm", "cecc2a4c4e9b51c7fbc5474c317a50cd5870334eb3e2b95d85d578ed58c4fa24"}, + "cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"}, + "credo": {:hex, :credo, "1.7.5", "643213503b1c766ec0496d828c90c424471ea54da77c8a168c725686377b9545", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "f799e9b5cd1891577d8c773d245668aa74a2fcd15eb277f51a0131690ebfb3fd"}, + "db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"}, + "debouncer": {:hex, :debouncer, "0.1.8", "ab7f6eef7c9f029929bb2b737de6dc4bf12ac4ddedb49194ba00f4240b226b5a", [:mix], [], "hexpm", "77c4be1d10f984aec0dfbc50d43c16d7512605cabe6d79cadc0c8f4ba95d4906"}, "decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"}, "deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"}, "dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"}, - "earmark": {:hex, :earmark, "1.4.20", "d5097b1c7417a03c73a2985fcf01c3f72192c427b8a498719737dca5273938cb", [:mix], [{:earmark_parser, "== 1.4.18", [hex: :earmark_parser, repo: "hexpm", optional: false]}], "hexpm", "7be744242dbde74c858279f4a65d9d31f37d163190d739340015c30038c1edb3"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.19", "de0d033d5ff9fc396a24eadc2fcf2afa3d120841eb3f1004d138cbf9273210e8", [:mix], [], "hexpm", "527ab6630b5c75c3a3960b75844c314ec305c76d9899bb30f71cb85952a9dc45"}, - "elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"}, + "elixir_make": {:hex, :elixir_make, "0.8.2", "cd4a5a75891362e9207adaac7e66223fd256ec2518ae013af7f10c9c85b50b5c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "9d9607d640c372a7291e5a56ce655aa2351897929be20bd211648fdb79e725dc"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "esqlite": {:git, "https://github.com/mmzeeman/esqlite.git", "c764204c23d5a5ea9cb17eee5529b2dad253bedb", []}, - "ex_doc": {:hex, :ex_doc, "0.28.0", "7eaf526dd8c80ae8c04d52ac8801594426ae322b52a6156cd038f30bafa8226f", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "e55cdadf69a5d1f4cfd8477122ebac5e1fadd433a8c1022dafc5025e48db0131"}, - "file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"}, - "hackney": {:hex, :hackney, "1.19.1", "59de4716e985dd2b5cbd4954fa1ae187e2b610a9c4520ffcb0b1653c3d6e5559", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "8aa08234bdefc269995c63c2282cf3cd0e36febe3a6bfab11b610572fdd1cad0"}, - "hex2bin": {:hex, :hex2bin, "1.0.0", "aac26eab998ae80eacee1c7607c629ab503ebf77a62b9242bae2b94d47dcb71e", [:rebar3], [], "hexpm"}, - "httpoison": {:hex, :httpoison, "2.1.0", "655fd9a7b0b95ee3e9a3b535cf7ac8e08ef5229bab187fa86ac4208b122d934b", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "fc455cb4306b43827def4f57299b2d5ac8ac331cb23f517e734a4b78210a160c"}, + "esqlite": {:hex, :esqlite, "0.8.6", "7852d506eb12bd519c1084f03c467f364f8ddff69227154e5e6df9cc6346fbbf", [:rebar3], [], "hexpm", "607e45f4da42601d8f530979417f57a4cd629ab49085891849302057e68ea188"}, + "ex_doc": {:hex, :ex_doc, "0.31.2", "8b06d0a5ac69e1a54df35519c951f1f44a7b7ca9a5bb7a260cd8a174d6322ece", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "317346c14febaba9ca40fd97b5b5919f7751fb85d399cc8e7e8872049f37e0af"}, + "exqlite": {:hex, :exqlite, "0.19.0", "0f3ee29e35bed38552dd0ed59600aa81c78f867f5b5ff0e17d330148e0465483", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "55a8fbb0443f03d4a256e3458bd1203eff5037a6624b76460eaaa9080f462b06"}, + "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, + "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"}, + "httpoison": {:hex, :httpoison, "2.2.1", "87b7ed6d95db0389f7df02779644171d7319d319178f6680438167d7b69b1f3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "51364e6d2f429d80e14fe4b5f8e39719cacd03eb3f9a9286e61e216feac2d2df"}, "idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"}, - "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, + "jason": {:hex, :jason, "1.4.1", "af1504e35f629ddcdd6addb3513c3853991f694921b1b9368b0bd32beb9f1b63", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fbb01ecdfd565b56261302f7e1fcc27c4fb8f32d56eab74db621fc154604a7a1"}, "keccakf1600": {:git, "https://github.com/diodechain/erlang-keccakf1600.git", "d121a7828a2d217112e55a8815ba575a6261f8c5", []}, - "libsecp256k1": {:git, "https://github.com/diodechain/libsecp256k1.git", "3a52d0ebb2d8f1e5a18c9b02e8f3160523755ee6", []}, - "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, - "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, + "libsecp256k1": {:git, "https://github.com/diodechain/libsecp256k1.git", "9315960e03002a0ad73611875061d80e112644bc", []}, + "makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.16.2", "627e84b8e8bf22e60a2579dad15067c755531fea049ae26ef1020cad58fe9578", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "41193978704763f6bbe6cc2758b84909e62984c7752b3784bd3c218bb341706b"}, + "makeup_erlang": {:hex, :makeup_erlang, "0.1.5", "e0ff5a7c708dda34311f7522a8758e23bfcd7d8d8068dc312b5eb41c6fd76eba", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "94d2e986428585a21516d7d7149781480013c56e30c6a233534bedf38867a59a"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, - "mime": {:hex, :mime, "2.0.1", "0de4c81303fe07806ebc2494d5321ce8fb4df106e34dd5f9d787b637ebadc256", [:mix], [], "hexpm", "7a86b920d2aedce5fb6280ac8261ac1a739ae6c1a1ad38f5eadf910063008942"}, + "mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, - "mix_erlang_tasks": {:hex, :mix_erlang_tasks, "0.1.0", "36819fec60b80689eb1380938675af215565a89320a9e29c72c70d97512e4649", [:mix], [], "hexpm", "95d2839c422c482a70c08a8702da8242f86b773f8ab6e8602a4eb72da8da04ed"}, "mix_rebar3": {:hex, :mix_rebar3, "0.2.0", "b33656ef3047f21a19fac3254cb30a1d2c75ea419a3ad28c4b88f42c62a4202d", [:mix], [], "hexpm", "11eabb70c0a7ead9aa3631f048c3d7d5e868172b87b6493d0dc6f6d591c1afae"}, "niffler": {:hex, :niffler, "0.3.0", "e82b5d348ed22060b5200ca381f4102b749d9fd238002e703d005d8e22ccf33d", [:mix, :rebar3], [{:mix_rebar3, "~> 0.2", [hex: :mix_rebar3, repo: "hexpm", optional: false]}], "hexpm", "abf45448f88d3fbb74797883397931e2940cbbb1b400d938658affb4fb2a5ff1"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.4.0", "51f9b613ea62cfa97b25ccc2c1b4216e81df970acd8e16e8d1bdc58fef21370d", [:mix], [], "hexpm", "9c565862810fb383e9838c1dd2d7d2c437b3d13b267414ba6af33e50d2d1cf28"}, "oncrash": {:hex, :oncrash, "0.1.0", "9cf4ae8eba4ea250b579470172c5e9b8c75418b2264de7dbcf42e408d62e30fb", [:mix], [], "hexpm", "6968e775491cd857f9b6ff940bf2574fd1c2fab84fa7e14d5f56c39174c00018"}, "parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"}, - "plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"}, - "plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"}, - "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, + "plug": {:hex, :plug, "1.15.3", "712976f504418f6dff0a3e554c40d705a9bcf89a7ccef92fc6a5ef8f16a30a97", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "cc4365a3c010a56af402e0809208873d113e9c38c401cabd88027ef4f5c01fd2"}, + "plug_cowboy": {:hex, :plug_cowboy, "2.7.0", "3ae9369c60641084363b08fe90267cbdd316df57e3557ea522114b30b63256ea", [:mix], [{:cowboy, "~> 2.7.0 or ~> 2.8.0 or ~> 2.9.0 or ~> 2.10.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "d85444fb8aa1f2fc62eabe83bbe387d81510d773886774ebdcb429b3da3c1a4a"}, + "plug_crypto": {:hex, :plug_crypto, "2.0.0", "77515cc10af06645abbfb5e6ad7a3e9714f805ae118fa1a70205f80d2d70fe73", [:mix], [], "hexpm", "53695bae57cc4e54566d993eb01074e4d894b65a3766f1c43e2c61a1b0f45ea9"}, "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"}, - "profiler": {:git, "https://github.com/dominicletz/profiler.git", "51ded399aef1b7ed8e4d52a9e69892dfd31569c1", []}, + "profiler": {:git, "https://github.com/dominicletz/profiler.git", "ae90bea721a751b8850e8c00b971e1d8b99a7fcf", []}, "ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"}, - "sha3": {:hex, :sha3, "2.0.0", "fbe5db75a8389fdc810b682446c053b91e591d38d5422808f3a702ed2b270515", [:rebar3], [{:hex2bin, "1.0.0", [hex: :hex2bin, repo: "hexpm", optional: false]}], "hexpm"}, - "sqlitex": {:git, "https://github.com/diodechain/sqlitex.git", "17bc3cb6ca1fe7ff7ebb65dd24ff97b1630f3df1", []}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, - "telemetry": {:hex, :telemetry, "1.0.0", "0f453a102cdf13d506b7c0ab158324c337c41f1cc7548f0bc0e130bbf0ae9452", [:rebar3], [], "hexpm", "73bc09fa59b4a0284efb4624335583c528e07ec9ae76aca96ea0673850aec57a"}, + "statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"}, + "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"}, "websockex": {:hex, :websockex, "0.4.3", "92b7905769c79c6480c02daacaca2ddd49de936d912976a4d3c923723b647bf0", [:mix], [], "hexpm", "95f2e7072b85a3a4cc385602d42115b73ce0b74a9121d0d6dbbf557645ac53e4"}, - "while": {:hex, :while, "0.2.3", "71a85cca7c979baad2d2968d390dda41527056b81c22a5b422e8cc4d02697f30", [:mix], [], "hexpm", "49e40bd15c219325e2586d1d7166b561e74b90bc02f2ad35890b0346d37ebadb"}, + "while": {:hex, :while, "0.2.4", "f4d10d39704f9ed257d13054f64ccdd6de4b3068e0ce6ecc6ce6d3f0b3b4b6e3", [:mix], [], "hexpm", "62659f89c2cdb4b90d48eadc2fb967c59c96bdeff6506f345139f0558eedb9d5"}, } diff --git a/remsh b/remsh index 0f76eb8..0902b57 100755 --- a/remsh +++ b/remsh @@ -1,6 +1,6 @@ #!/bin/sh # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 export ERL_EPMD_ADDRESS=127.0.0.1 export MIX_ENV=prod diff --git a/run b/run index 0170067..7dd7b97 100755 --- a/run +++ b/run @@ -1,6 +1,6 @@ #!/bin/sh # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 ulimit -n 120000 export ERL_CRASH_DUMP_BYTES=5000000000 diff --git a/scripts/Dockerfile b/scripts/Dockerfile index e911835..606d916 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 FROM elixir:1.14.4 diff --git a/scripts/clean.sh b/scripts/clean.sh index 0f1e0b7..2ea5854 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -1,6 +1,6 @@ #!/bin/bash # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 find ./clones/* ./data_*/blockchain.sq3* ./data_*/cache.sq3 -maxdepth 1 -type f -delete make clean diff --git a/scripts/docker b/scripts/docker index e07d23e..246c3e3 100755 --- a/scripts/docker +++ b/scripts/docker @@ -1,6 +1,6 @@ #!/bin/bash # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 set -e mkdir -p data_prod diff --git a/scripts/evmbench.exs b/scripts/evmbench.exs index b975fef..48a5c24 100644 --- a/scripts/evmbench.exs +++ b/scripts/evmbench.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 Benchee.run( %{ diff --git a/scripts/evmbench.sh b/scripts/evmbench.sh index 1c68731..84d7259 100755 --- a/scripts/evmbench.sh +++ b/scripts/evmbench.sh @@ -1,5 +1,5 @@ #!/bin/bash # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 MIX_ENV=benchmark mix run evmbench.exs diff --git a/scripts/run_beta b/scripts/run_beta index 2d95a64..a5f18ff 100755 --- a/scripts/run_beta +++ b/scripts/run_beta @@ -1,6 +1,6 @@ #!/bin/bash # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 export RPC_PORT=11000 export EDGE2_PORT=12000 diff --git a/scripts/run_offline b/scripts/run_offline index 52444e8..93c23f9 100755 --- a/scripts/run_offline +++ b/scripts/run_offline @@ -1,6 +1,6 @@ #!/bin/sh # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 rm data_prod/kademlia.etf export SEED= diff --git a/scripts/run_perf b/scripts/run_perf index b5f9a89..70ecbc7 100755 --- a/scripts/run_perf +++ b/scripts/run_perf @@ -1,6 +1,6 @@ #!/bin/sh # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 ulimit -n 120000 export ERL_CRASH_DUMP_BYTES=5000000000 diff --git a/scripts/run_test b/scripts/run_test index 019538f..8b29d92 100755 --- a/scripts/run_test +++ b/scripts/run_test @@ -1,6 +1,6 @@ #!/bin/sh # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 rm -rf data_test/ export MIX_ENV=test diff --git a/staging b/staging index 799eae4..23d91d8 100755 --- a/staging +++ b/staging @@ -1,6 +1,6 @@ #!/bin/bash # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 n=$1 if [[ "$n" == "" ]]; then diff --git a/test/abi_test.exs b/test/abi_test.exs index 0e686bc..1c1dc1f 100644 --- a/test/abi_test.exs +++ b/test/abi_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule ABITest do use ExUnit.Case diff --git a/test/blockquick_test.exs b/test/blockquick_test.exs index b036805..1ae7e8d 100644 --- a/test/blockquick_test.exs +++ b/test/blockquick_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule BlockQuickTest do use ExUnit.Case, async: false diff --git a/test/broadcast_test.exs b/test/broadcast_test.exs index 96a5bf8..01e030b 100644 --- a/test/broadcast_test.exs +++ b/test/broadcast_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule BroadcastTest do use ExUnit.Case, async: false diff --git a/test/chain_test.exs b/test/chain_test.exs index fea07ba..60cd95b 100644 --- a/test/chain_test.exs +++ b/test/chain_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule ChainTest do use ExUnit.Case, async: false diff --git a/test/curl/do b/test/curl/do index c8821e7..1dfc62b 100755 --- a/test/curl/do +++ b/test/curl/do @@ -1,6 +1,6 @@ #!/bin/bash # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 if [[ $1 == "" ]]; then echo "Need a host parameter" diff --git a/test/curl_rpc.sh b/test/curl_rpc.sh index e222080..a3ac9c8 100755 --- a/test/curl_rpc.sh +++ b/test/curl_rpc.sh @@ -1,6 +1,6 @@ #!/bin/bash # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 if [[ $1 == "" ]]; then echo "Need host parameter" diff --git a/test/edge2_test.exs b/test/edge2_test.exs index a46f5f2..44d28d7 100644 --- a/test/edge2_test.exs +++ b/test/edge2_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule Edge2Test do use ExUnit.Case, async: false diff --git a/test/etslru_test.exs b/test/etslru_test.exs index 1c398ba..dcf5a25 100644 --- a/test/etslru_test.exs +++ b/test/etslru_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule EtsLruTest do use ExUnit.Case diff --git a/test/evm_test.exs b/test/evm_test.exs index 1149f2d..b945970 100644 --- a/test/evm_test.exs +++ b/test/evm_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule EvmTest do use ExUnit.Case diff --git a/test/kademlia_test.exs b/test/kademlia_test.exs index 7428a22..63c4e81 100644 --- a/test/kademlia_test.exs +++ b/test/kademlia_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule KademliaTest do use ExUnit.Case, async: false diff --git a/test/kbuckets_test.exs b/test/kbuckets_test.exs index 3d7e5d4..3a24ab8 100644 --- a/test/kbuckets_test.exs +++ b/test/kbuckets_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule KBucketsTest do use Bitwise diff --git a/test/lru_test.exs b/test/lru_test.exs index f79e559..cabd127 100644 --- a/test/lru_test.exs +++ b/test/lru_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule LruTest do use ExUnit.Case diff --git a/test/mapmerkletree_test.exs b/test/mapmerkletree_test.exs index d8cc8c6..114f8fe 100644 --- a/test/mapmerkletree_test.exs +++ b/test/mapmerkletree_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule MapMerkleTreeTest do use ExUnit.Case diff --git a/test/merkletree_test.exs b/test/merkletree_test.exs index 2766f75..7b1c442 100644 --- a/test/merkletree_test.exs +++ b/test/merkletree_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule MerkleTreeTest do use ExUnit.Case diff --git a/test/object_test.exs b/test/object_test.exs index 93566e2..964a3d5 100644 --- a/test/object_test.exs +++ b/test/object_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule TicketTest do use ExUnit.Case diff --git a/test/peer_test.exs b/test/peer_test.exs index 2b11a8a..d2986b8 100644 --- a/test/peer_test.exs +++ b/test/peer_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule PeerTest do use ExUnit.Case, async: false diff --git a/test/processlru_test.exs b/test/processlru_test.exs index 9e39583..5efda81 100644 --- a/test/processlru_test.exs +++ b/test/processlru_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule ProcessLruTest do use ExUnit.Case diff --git a/test/pubsub_test.exs b/test/pubsub_test.exs index de6cbe1..9b1a390 100644 --- a/test/pubsub_test.exs +++ b/test/pubsub_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule PubSubTest do use ExUnit.Case diff --git a/test/registry_test.exs b/test/registry_test.exs index 08772c8..1b7df42 100644 --- a/test/registry_test.exs +++ b/test/registry_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule RegistryTest do alias Object.Ticket diff --git a/test/rlp_test.exs b/test/rlp_test.exs index 81d435d..da4b302 100644 --- a/test/rlp_test.exs +++ b/test/rlp_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule RlpTest do use ExUnit.Case diff --git a/test/rpc_test.exs b/test/rpc_test.exs index 5a0d08f..1d8704c 100644 --- a/test/rpc_test.exs +++ b/test/rpc_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule RpcTest do use ExUnit.Case, async: false diff --git a/test/secp256k1_test.exs b/test/secp256k1_test.exs index 86a6700..7d086a2 100644 --- a/test/secp256k1_test.exs +++ b/test/secp256k1_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule Secp256k1Test do use ExUnit.Case diff --git a/test/sqlmerkletree_test.exs b/test/sqlmerkletree_test.exs index e26e8d3..00d1a5f 100644 --- a/test/sqlmerkletree_test.exs +++ b/test/sqlmerkletree_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule Model.MerkleSqlTest do use ExUnit.Case diff --git a/test/test_helper.exs b/test/test_helper.exs index 4a425e0..58ece3e 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 import While diff --git a/test/ticket_test.exs b/test/ticket_test.exs index 4f5719d..5d6d7c4 100644 --- a/test/ticket_test.exs +++ b/test/ticket_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule TicketTest do use ExUnit.Case diff --git a/test/transaction_test.exs b/test/transaction_test.exs index 88decac..c126507 100644 --- a/test/transaction_test.exs +++ b/test/transaction_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule TransactionTest do use ExUnit.Case diff --git a/test/wallet_test.exs b/test/wallet_test.exs index de44136..b6e5b6e 100644 --- a/test/wallet_test.exs +++ b/test/wallet_test.exs @@ -1,5 +1,5 @@ # Diode Server -# Copyright 2021 Diode +# Copyright 2021-2024 Diode # Licensed under the Diode License, Version 1.1 defmodule WalletTest do use ExUnit.Case