From b34b3396f9a29baf82c2ad165984e0730bf0bb25 Mon Sep 17 00:00:00 2001 From: kitti-katy Date: Tue, 30 May 2023 20:38:15 -0400 Subject: [PATCH 1/3] separate proofchain calls by bsp and brp --- .../proof_chain/proof_chain_interactor.ex | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/rudder/proof_chain/proof_chain_interactor.ex b/lib/rudder/proof_chain/proof_chain_interactor.ex index 8faf6812..47d34f7d 100644 --- a/lib/rudder/proof_chain/proof_chain_interactor.ex +++ b/lib/rudder/proof_chain/proof_chain_interactor.ex @@ -20,17 +20,20 @@ defmodule Rudder.ProofChain.Interactor do GenServer.start_link(__MODULE__, [], name: __MODULE__) end - defp get_proofchain() do - proofchain_address = Application.get_env(:rudder, :brp_proofchain_address) + defp get_bsp_proofchain() do + proofchain_address = Application.get_env(:rudder, :bsp_proofchain_address) Rudder.RPC.PublicKeyHash.parse(proofchain_address) end - defp make_call(data) do - {:ok, to} = get_proofchain() + defp get_brp_proofchain() do + proofchain_address = Application.get_env(:rudder, :brp_proofchain_address) + Rudder.RPC.PublicKeyHash.parse(proofchain_address) + end + defp make_call(data, proofchain) do tx = [ from: nil, - to: to, + to: proofchain, value: 0, data: data ] @@ -44,7 +47,8 @@ defmodule Rudder.ProofChain.Interactor do def get_urls(hash) do rpc_params = [hash] data = {@get_urls_selector, rpc_params} - make_call(data) + bsp_proofchain = get_bsp_proofchain() + make_call(data, bsp_proofchain) end @spec is_block_result_session_open(binary) :: any @@ -54,7 +58,8 @@ defmodule Rudder.ProofChain.Interactor do chain_id = Application.get_env(:rudder, :block_specimen_chain_id) rpc_params = [chain_id, block_height, operator.address.bytes] data = {@is_session_open_selector, rpc_params} - make_call(data) + brp_proofchain = get_brp_proofchain() + make_call(data, brp_proofchain) end defp get_operator_wallet() do @@ -164,7 +169,7 @@ defmodule Rudder.ProofChain.Interactor do ]) sender = get_operator_wallet() - {:ok, to} = get_proofchain() + {:ok, to} = get_brp_proofchain() {:ok, recent_gas_limit} = Rudder.Network.EthereumMainnet.gas_limit(:latest) From 38e24413778852af4081374315dd4d76b35ff1a3 Mon Sep 17 00:00:00 2001 From: kitti-katy Date: Wed, 31 May 2023 13:29:36 -0400 Subject: [PATCH 2/3] fix proofchain public key hash returned --- lib/rudder/proof_chain/proof_chain_interactor.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/rudder/proof_chain/proof_chain_interactor.ex b/lib/rudder/proof_chain/proof_chain_interactor.ex index 47d34f7d..1e4000d3 100644 --- a/lib/rudder/proof_chain/proof_chain_interactor.ex +++ b/lib/rudder/proof_chain/proof_chain_interactor.ex @@ -22,12 +22,14 @@ defmodule Rudder.ProofChain.Interactor do defp get_bsp_proofchain() do proofchain_address = Application.get_env(:rudder, :bsp_proofchain_address) - Rudder.RPC.PublicKeyHash.parse(proofchain_address) + {:ok, proofchain} = Rudder.RPC.PublicKeyHash.parse(proofchain_address) + proofchain end defp get_brp_proofchain() do proofchain_address = Application.get_env(:rudder, :brp_proofchain_address) - Rudder.RPC.PublicKeyHash.parse(proofchain_address) + {:ok, proofchain} = Rudder.RPC.PublicKeyHash.parse(proofchain_address) + proofchain end defp make_call(data, proofchain) do From facb7b3934e8b8e8c88cae3c680aa36e50a9d788 Mon Sep 17 00:00:00 2001 From: kitti-katy Date: Wed, 31 May 2023 14:17:17 -0400 Subject: [PATCH 3/3] fix proofchain return --- lib/rudder/proof_chain/proof_chain_interactor.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rudder/proof_chain/proof_chain_interactor.ex b/lib/rudder/proof_chain/proof_chain_interactor.ex index 1e4000d3..174df644 100644 --- a/lib/rudder/proof_chain/proof_chain_interactor.ex +++ b/lib/rudder/proof_chain/proof_chain_interactor.ex @@ -171,7 +171,7 @@ defmodule Rudder.ProofChain.Interactor do ]) sender = get_operator_wallet() - {:ok, to} = get_brp_proofchain() + to = get_brp_proofchain() {:ok, recent_gas_limit} = Rudder.Network.EthereumMainnet.gas_limit(:latest)