-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(guardian-prover-health-check): Guardian prover rework (#15375)
- Loading branch information
1 parent
7dfc298
commit 975c882
Showing
19 changed files
with
590 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
HTTP_PORT=4103 | ||
PROMETHEUS_HTTP_PORT=6062 | ||
METRICS_HTTP_PORT=6062 | ||
DATABASE_USER=root | ||
DATABASE_PASSWORD=root | ||
DATABASE_NAME=healthcheck | ||
DATABASE_HOST=localhost:3306 | ||
DATABASE_MAX_IDLE_CONNS=50 | ||
DATABASE_MAX_OPEN_CONNS=3000 | ||
DATABASE_CONN_MAX_LIFETIME_IN_MS=100000 | ||
GUARDIAN_PROVER_CONTRACT_ADDRESS=0x0E801D84Fa97b50751Dbf25036d067dCf18858bF | ||
GUARDIAN_PROVER_ENDPOINTS=https://guardian-prover-1.internal.taiko.xyz,https://guardian-prover-2.internal.taiko.xyz,https://guardian-prover-3.internal.taiko.xyz,https://guardian-prover-4.internal.taiko.xyz,https://guardian-prover-5.internal.taiko.xyz | ||
RPC_URL=wss://l1ws.internal.taiko.xyz | ||
GUARDIAN_PROVER_CONTRACT_ADDRESS=0xDf8038e9f4535040D7421A89ead398b3A38366EC | ||
L1_RPC_URL=wss://l1ws.internal.taiko.xyz | ||
L2_RPC_URL=wss://ws.internal.taiko.xyz | ||
INTERVAL=12s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,44 @@ | ||
package guardianproverhealthcheck | ||
|
||
import ( | ||
"encoding/base64" | ||
"errors" | ||
"math/big" | ||
"net/url" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/crypto" | ||
) | ||
|
||
type GuardianProver struct { | ||
Address common.Address | ||
ID *big.Int | ||
Endpoint *url.URL | ||
Address common.Address | ||
ID *big.Int | ||
} | ||
|
||
func SignatureToGuardianProver( | ||
msg []byte, | ||
b64EncodedSig string, | ||
guardianProvers []GuardianProver, | ||
) (*GuardianProver, error) { | ||
b64DecodedSig, err := base64.StdEncoding.DecodeString(b64EncodedSig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// recover the public key from the signature | ||
r, err := crypto.SigToPub(msg, b64DecodedSig) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// convert it to address type | ||
recoveredAddr := crypto.PubkeyToAddress(*r) | ||
|
||
// see if any of our known guardian provers have that recovered address | ||
for _, p := range guardianProvers { | ||
if recoveredAddr.Cmp(p.Address) == 0 { | ||
return &p, nil | ||
} | ||
} | ||
|
||
return nil, errors.New("signature does not recover to known guardian prover") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.