Skip to content

Commit

Permalink
fix: fetch the bls public key on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosNicolau committed Nov 25, 2024
1 parent 0df3a3b commit 7fe06ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion telemetry_api/lib/telemetry_api/bls_signature_verifier.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule BlsSignatureVerifier do
defmodule BLSSignatureVerifier do
def verify(signature, public_key, message) do
# Encode the args as hex
args = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule BlsApkRegistry do
defmodule BLSApkRegistry do
require Logger

@aligned_config_file System.get_env("ALIGNED_CONFIG_FILE")
Expand Down Expand Up @@ -34,7 +34,7 @@ defmodule BlsApkRegistry do
end

def get_operator_bls_pubkey(operator_address) do
case BlsApkRegistry.get_registered_pubkey(operator_address)
case BLSApkRegistry.get_registered_pubkey(operator_address)
|> Ethers.call() do
{:ok, data} ->
data
Expand Down
8 changes: 5 additions & 3 deletions telemetry_api/lib/telemetry_api/operators.ex
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ defmodule TelemetryApi.Operators do
{:error, :bad_request, "Provided address does not correspond to any registered operator"}

operator ->
with {:ok, _} <-
BLSSignatureVerifier.verify(signature, bls_public_key, message_hash) do
update_operator(operator, changes)
with {:ok, bls_public_key} <- BLSApkRegistry.get_operator_bls_pubkey(address) do
with {:ok, _} <-
BLSSignatureVerifier.verify(signature, bls_public_key, message_hash) do
update_operator(operator, changes)
end
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions telemetry_api/lib/telemetry_api/operators/operator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ defmodule TelemetryApi.Operators.Operator do
field :eth_rpc_url_fallback, :string
field :eth_ws_url, :string
field :eth_ws_url_fallback, :string
field :bls_public_key, :string

timestamps(type: :utc_datetime)
end
Expand All @@ -32,9 +31,8 @@ defmodule TelemetryApi.Operators.Operator do
:eth_rpc_url_fallback,
:eth_ws_url,
:eth_ws_url_fallback,
:bls_public_key
])
|> validate_required([:address, :id, :name, :stake, :bls_public_key])
|> validate_required([:address, :id, :name, :stake])
end
end

Expand Down

0 comments on commit 7fe06ca

Please sign in to comment.