From f4b00aefb6963dccf83ae6b1951d0c5ff035c06c Mon Sep 17 00:00:00 2001 From: dndll Date: Wed, 27 Mar 2024 15:28:45 +0000 Subject: [PATCH] cleaning deployments --- .gitignore | 2 + api/NEAR Light Client/README.md | 13 ++++ .../Succinct/Deploy/Check Release Status.bru | 54 ++++++++++++++ .../Succinct/Deploy/New Entrypoint.bru | 71 +++++++++++++++++++ .../Succinct/Deploy/Pull Verifying Key.bru | 44 ++++++++++++ .../Succinct/Deploy/Update name.bru | 56 +++++++++++++++ .../Succinct/Deployment new test.bru | 65 +++++++++++++++++ .../Succinct/Get Deployments.bru | 4 +- .../Succinct/Get proof status.bru | 4 +- api/NEAR Light Client/Succinct/Get proofs.bru | 6 +- .../Succinct/Get request status.bru | 4 +- .../Succinct/Release Verify.bru | 46 ++++++++++++ .../Succinct/Release: DEL.bru | 37 ++++++++++ .../Succinct/Req proof (batch).bru | 4 +- .../Succinct/Req proof (sync).bru | 4 +- .../Succinct/Req proof (verify).bru | 4 +- api/NEAR Light Client/environments/local.bru | 3 + .../environments/testnet.bru | 6 +- bin/operator/src/main.rs | 7 +- crates/primitives/src/config.rs | 2 - .../script/DeployAndRegisterVerifier.sol | 28 ++++++++ nearx/contract/script/UpdateParams.s.sol | 1 - 22 files changed, 444 insertions(+), 21 deletions(-) create mode 100644 api/NEAR Light Client/README.md create mode 100644 api/NEAR Light Client/Succinct/Deploy/Check Release Status.bru create mode 100644 api/NEAR Light Client/Succinct/Deploy/New Entrypoint.bru create mode 100644 api/NEAR Light Client/Succinct/Deploy/Pull Verifying Key.bru create mode 100644 api/NEAR Light Client/Succinct/Deploy/Update name.bru create mode 100644 api/NEAR Light Client/Succinct/Deployment new test.bru create mode 100644 api/NEAR Light Client/Succinct/Release Verify.bru create mode 100644 api/NEAR Light Client/Succinct/Release: DEL.bru create mode 100644 api/NEAR Light Client/environments/local.bru create mode 100644 nearx/contract/script/DeployAndRegisterVerifier.sol diff --git a/.gitignore b/.gitignore index 6a2764db..3caaee68 100644 --- a/.gitignore +++ b/.gitignore @@ -16,11 +16,13 @@ nearx/build nearx/contract/cache nearx/contract/out nearx/contract/lib +near/contract/script/FunctionVerifier # Ignores development broadcast logs !**broadcast **broadcast/*/31337/ **broadcast/**/dry-run/ nearx/contract/broadcast +state.json # Dotenv file .env diff --git a/api/NEAR Light Client/README.md b/api/NEAR Light Client/README.md new file mode 100644 index 00000000..9fd7d910 --- /dev/null +++ b/api/NEAR Light Client/README.md @@ -0,0 +1,13 @@ + +TODO: +let token = bru.setEnvVar("access_token", data.token); + +Redeploying dev: +- Deploy entrypoints +- Wait for success +- rename old release to tag +- update nane of new releases +- get verifier, deploy with forge script +- send deployment info to succinct /deployment/new +- execute forge script to update functionIds +- send deployment diff --git a/api/NEAR Light Client/Succinct/Deploy/Check Release Status.bru b/api/NEAR Light Client/Succinct/Deploy/Check Release Status.bru new file mode 100644 index 00000000..b8643334 --- /dev/null +++ b/api/NEAR Light Client/Succinct/Deploy/Check Release Status.bru @@ -0,0 +1,54 @@ +meta { + name: Check Release Status + type: http + seq: 2 +} + +get { + url: {{succinctBaseUrl}}/projects/near/near-light-client/releases/{{release}} + body: text + auth: none +} + +headers { + authority: alpha.succinct.xyz + accept: */* + accept-language: en-GB,en;q=0.9 + origin: https://alpha.succinct.xyz + referer: https://alpha.succinct.xyz/near/near-light-client/releases/new + sec-ch-ua: "Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121" + sec-ch-ua-mobile: ?0 + sec-ch-ua-platform: "Linux" + sec-fetch-dest: empty + sec-fetch-mode: cors + sec-fetch-site: same-origin + sec-gpc: 1 + user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 + content-type: text/plain;charset=UTF-8 +} + +vars:pre-request { + release: 13 +} + +assert { + res.status: eq 200 + res.body.status: eq "success" +} + +script:pre-request { + let entrypoint = bru.getProcessEnv("ENTRYPOINT") + let release = bru.getEnvVar(`${entrypoint}_RELEASE_NUM_NEW`) + if (release != null && entrypoint != null) { + bru.setVar("release", release) + } +} + +script:post-response { + let entrypoint = bru.getProcessEnv("ENTRYPOINT") + if (res.body.status == "success") { + bru.setEnvVar(`${entrypoint}_RELEASE_ID_OLD`, bru.getEnvVar(`${entrypoint}_RELEASE_ID`)) + bru.setEnvVar(`${entrypoint}_RELEASE_NUM`, bru.getEnvVar(`${entrypoint}_RELEASE_NUM_NEW`)) + bru.setEnvVar(`${entrypoint}_RELEASE_ID`, bru.getEnvVar(`${entrypoint}_RELEASE_ID_NEW`)) + } +} diff --git a/api/NEAR Light Client/Succinct/Deploy/New Entrypoint.bru b/api/NEAR Light Client/Succinct/Deploy/New Entrypoint.bru new file mode 100644 index 00000000..fc5cd338 --- /dev/null +++ b/api/NEAR Light Client/Succinct/Deploy/New Entrypoint.bru @@ -0,0 +1,71 @@ +meta { + name: New Entrypoint + type: http + seq: 1 +} + +post { + url: {{succinctBaseUrl}}/release/new + body: text + auth: bearer +} + +headers { + authority: alpha.succinct.xyz + accept: */* + accept-language: en-GB,en;q=0.9 + origin: https://alpha.succinct.xyz + referer: https://alpha.succinct.xyz/near/near-light-client/releases/new + sec-ch-ua: "Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121" + sec-ch-ua-mobile: ?0 + sec-ch-ua-platform: "Linux" + sec-fetch-dest: empty + sec-fetch-mode: cors + sec-fetch-site: same-origin + sec-gpc: 1 + user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 + cookie: session={{succinctSession}} + content-type: text/plain;charset=UTF-8 +} + +auth:bearer { + token: {{succinctAuthToken}} +} + +body:text { + { + "org_name": "near", + "project_name": "near-light-client", + "git_ref": "{{gitRef}}", + "entrypoint": "{{entrypoint}}", + "env_vars": [] + } +} + +vars:pre-request { + gitRef: notused + entrypoint: fake +} + +script:pre-request { + let gitRef = bru.getProcessEnv("GIT_REF") + if (gitRef != null) { + bru.setVar("gitRef", gitRef) + } + let entrypoint = bru.getProcessEnv("ENTRYPOINT") + if (entrypoint != null) { + bru.setVar("entrypoint", entrypoint) + } +} + +script:post-response { + let entrypoint = bru.getProcessEnv("ENTRYPOINT") + bru.setEnvVar(`${entrypoint}_RELEASE_ID_NEW`, res.body.release_id) + bru.setEnvVar(`${entrypoint}_RELEASE_NUM_NEW`, res.body.release_number) + bru.setVar(`${entrypoint}_RELEASE_ID_NEW`, res.body.release_id) + bru.setVar(`${entrypoint}_RELEASE_NUM_NEW`, res.body.release_number) +} + +assert { + res.status: eq 200 +} diff --git a/api/NEAR Light Client/Succinct/Deploy/Pull Verifying Key.bru b/api/NEAR Light Client/Succinct/Deploy/Pull Verifying Key.bru new file mode 100644 index 00000000..777485ab --- /dev/null +++ b/api/NEAR Light Client/Succinct/Deploy/Pull Verifying Key.bru @@ -0,0 +1,44 @@ +meta { + name: Pull Verifying Key + type: http + seq: 4 +} + +get { + url: {{succinctBaseUrl}}/release/{{releaseId}}/download/FunctionVerifier.sol + body: text + auth: none +} + +headers { + authority: alpha.succinct.xyz + accept: */* + accept-language: en-GB,en;q=0.9 + origin: https://alpha.succinct.xyz + referer: https://alpha.succinct.xyz/near/near-light-client/releases/new + sec-ch-ua: "Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121" + sec-ch-ua-mobile: ?0 + sec-ch-ua-platform: "Linux" + sec-fetch-dest: empty + sec-fetch-mode: cors + sec-fetch-site: same-origin + sec-gpc: 1 + user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 + content-type: text/plain;charset=UTF-8 +} + +vars:pre-request { + releaseId: c2829278-6849-4487-ba5f-96ce503837d5 +} + +assert { + res.status: eq 200 +} + +script:pre-request { + let entrypoint = bru.getProcessEnv("ENTRYPOINT") + let releaseId = bru.getEnvVar(`${entrypoint}_RELEASE_ID_NEW`) + if (releaseId != null && entrypoint != null) { + bru.setVar("releaseId", releaseId) + } +} diff --git a/api/NEAR Light Client/Succinct/Deploy/Update name.bru b/api/NEAR Light Client/Succinct/Deploy/Update name.bru new file mode 100644 index 00000000..4a96ed3c --- /dev/null +++ b/api/NEAR Light Client/Succinct/Deploy/Update name.bru @@ -0,0 +1,56 @@ +meta { + name: Update name + type: http + seq: 3 +} + +patch { + url: {{succinctBaseUrl}}/release/{{releaseNum}}/name + body: json + auth: none +} + +headers { + authority: alpha.succinct.xyz + accept: */* + accept-language: en-GB,en;q=0.9 + content-type: application/json + origin: https://alpha.succinct.xyz + referer: https://alpha.succinct.xyz/near/near-light-client/releases/17 + sec-ch-ua: "Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121" + sec-ch-ua-mobile: ?0 + sec-ch-ua-platform: "Linux" + sec-fetch-dest: empty + sec-fetch-mode: cors + sec-fetch-site: same-origin + sec-gpc: 1 + user-agent: Mozilla/5.0 (X11; Linux x86_64) AppMozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 + cookie: session={{succinctSession}} +} + +body:json { + {"name":"{{version}}"} +} + +vars:pre-request { + releaseNum: noop + version: dev +} + +assert { + res.body.status: eq success + res.status: eq 200 +} + +script:pre-request { + let entrypoint = bru.getProcessEnv("ENTRYPOINT") + let releaseNum = bru.getEnvVar(`${entrypoint}_RELEASE_ID`) + if (releaseNum != null && entrypoint != null) { + bru.setVar("releaseNum", releaseNum) + } + + let version = bru.getProcessEnv("VERSION") + if (version != null) { + bru.setVar("version", version) + } +} diff --git a/api/NEAR Light Client/Succinct/Deployment new test.bru b/api/NEAR Light Client/Succinct/Deployment new test.bru new file mode 100644 index 00000000..1372285c --- /dev/null +++ b/api/NEAR Light Client/Succinct/Deployment new test.bru @@ -0,0 +1,65 @@ +meta { + name: Deployment new test + type: http + seq: 11 +} + +post { + url: {{succinctBaseUrl}}/deployment/new + body: json + auth: none +} + +headers { + authority: alpha.succinct.xyz + accept: */* + accept-language: en-GB,en;q=0.9 + content-type: text/plain;charset=UTF-8 + origin: https://alpha.succinct.xyz + referer: https://alpha.succinct.xyz/near/near-light-client/deployments/new + sec-ch-ua: "Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121" + sec-ch-ua-mobile: ?0 + sec-ch-ua-platform: "Linux" + sec-fetch-dest: empty + sec-fetch-mode: cors + sec-fetch-site: same-origin + sec-gpc: 1 + user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 + ~cookie: session=Qa84UBz81dNmH6kV7DTW_de8TtSdeYZExnnngHJoMH8 +} + +body:json { + { + "release_id": "{{release_id}}", + "contract_address": "{{contract_address}}", + "gateway_address": "{{gateway_address}}", + "chain_id": {{chain_id}}, + "function_id": "0x{{function_id}}", + "salt": "0x{{salt}}", + "tx_hash": "0x{{tx_hash}}" + } +} + +body:text { + {"release_id":"870e6490-2a30-4703-9958-646f3945da9c","contract_address":"0x395C22aEC73F7960245afBf6eDD77E086bf908C5","gateway_address":"0x6c7a05e0AE641c6559fD76ac56641778B6eCd776","chain_id":421614,"function_id":"0xf7dc8cfca607134de24309d606b91a4c071b7f6b2a7cf8535da65cef25db520f","salt":"0xd4f4fed64865db8ba82177c0c4528a9eb7ec47ec4fb0ddaf8d56dd7b79537597","tx_hash":"0x5ff9a3899f4716dbe63d21f2dfd1c13ece08ac9751f6509761ca1a510719c2b2"} +} + +vars:pre-request { + salt: d4f4fed64865db8ba82177c0c4528a9eb7ec47ec4fb0ddaf8d56dd7b79537597 + chain_id: 421614 + function_id: + tx_hash: +} + +script:pre-request { + let entrypoint = bru.getProcessEnv("ENTRYPOINT") + let release = bru.getEnvVar(`${entrypoint}_RELEASE_ID`) + let functionId = bru.getEnvVar(`${entrypoint}_FUNCTION_ID`) + let chainId = bru.getProcessEnv("CHAIN_ID") + let salt = bru.getEnvVar(`${entrypoint}_SALT`) + let txHash = bru.getEnvVar(`${entrypoint}_TX_HASH`) + + if (release != null && entrypoint != null) { + bru.setVar("release_id", release) + } +} diff --git a/api/NEAR Light Client/Succinct/Get Deployments.bru b/api/NEAR Light Client/Succinct/Get Deployments.bru index 47d0f32e..591638e5 100644 --- a/api/NEAR Light Client/Succinct/Get Deployments.bru +++ b/api/NEAR Light Client/Succinct/Get Deployments.bru @@ -1,11 +1,11 @@ meta { name: Get Deployments type: http - seq: 6 + seq: 8 } get { - url: {{succintBaseUrl}}/deployments/near/near-light-client + url: {{succinctBaseUrl}}/deployments/near/near-light-client body: none auth: none } diff --git a/api/NEAR Light Client/Succinct/Get proof status.bru b/api/NEAR Light Client/Succinct/Get proof status.bru index cd626aa6..ed252c23 100644 --- a/api/NEAR Light Client/Succinct/Get proof status.bru +++ b/api/NEAR Light Client/Succinct/Get proof status.bru @@ -5,13 +5,13 @@ meta { } get { - url: {{succintBaseUrl}}/proof/{{proof_id}} + url: {{succinctBaseUrl}}/proof/{{proof_id}} body: json auth: bearer } auth:bearer { - token: {{succintAuthToken}} + token: {{succinctAuthToken}} } body:json { diff --git a/api/NEAR Light Client/Succinct/Get proofs.bru b/api/NEAR Light Client/Succinct/Get proofs.bru index 9fd3b83b..2460a07e 100644 --- a/api/NEAR Light Client/Succinct/Get proofs.bru +++ b/api/NEAR Light Client/Succinct/Get proofs.bru @@ -1,11 +1,11 @@ meta { name: Get proofs type: http - seq: 7 + seq: 9 } get { - url: {{succintBaseUrl}}/proofs?project=near/near-light-client + url: {{succinctBaseUrl}}/proofs?project=near/near-light-client body: json auth: bearer } @@ -15,7 +15,7 @@ query { } auth:bearer { - token: {{succintAuthToken}} + token: {{succinctAuthToken}} } body:json { diff --git a/api/NEAR Light Client/Succinct/Get request status.bru b/api/NEAR Light Client/Succinct/Get request status.bru index aa8d9ed0..e45d8cb1 100644 --- a/api/NEAR Light Client/Succinct/Get request status.bru +++ b/api/NEAR Light Client/Succinct/Get request status.bru @@ -5,13 +5,13 @@ meta { } get { - url: {{succintBaseUrl}}/request/{{proof_id}} + url: {{succinctBaseUrl}}/request/{{proof_id}} body: json auth: bearer } auth:bearer { - token: {{succintAuthToken}} + token: {{succinctAuthToken}} } body:json { diff --git a/api/NEAR Light Client/Succinct/Release Verify.bru b/api/NEAR Light Client/Succinct/Release Verify.bru new file mode 100644 index 00000000..14ef0bf9 --- /dev/null +++ b/api/NEAR Light Client/Succinct/Release Verify.bru @@ -0,0 +1,46 @@ +meta { + name: Release Verify + type: http + seq: 10 +} + +post { + url: {{succinctBaseUrl}}/release/new + body: json + auth: bearer +} + +headers { + authority: alpha.succinct.xyz + accept: */* + accept-language: en-GB,en;q=0.9 + content-type: text/plain;charset=UTF-8 + origin: https://alpha.succinct.xyz + referer: https://alpha.succinct.xyz/near/near-light-client/releases/new + sec-ch-ua: "Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121" + sec-ch-ua-mobile: ?0 + sec-ch-ua-platform: "Linux" + sec-fetch-dest: empty + sec-fetch-mode: cors + sec-fetch-site: same-origin + sec-gpc: 1 + user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 +} + +auth:bearer { + token: {{succinctAuthToken}} +} + +body:json { + { + "org_name": "near", + "project_name": "near-light-client", + "git_ref": "{{gitRef}}", + "entrypoint": "verify", + "env_vars": [] + } +} + +body:text { + {"org_name":"near","project_name":"near-light-client","git_ref":"700edd24ac1666307f3f740e36bf4c5808c26e1b","entrypoint":"verify","env_vars":[]} +} diff --git a/api/NEAR Light Client/Succinct/Release: DEL.bru b/api/NEAR Light Client/Succinct/Release: DEL.bru new file mode 100644 index 00000000..712b8460 --- /dev/null +++ b/api/NEAR Light Client/Succinct/Release: DEL.bru @@ -0,0 +1,37 @@ +meta { + name: Delete release + type: http + seq: 6 +} + +delete { + url: {{succinctBaseUrl}}/release/{{id}} + body: none + auth: bearer +} + +headers { + authority: alpha.succinct.xyz + accept: */* + accept-language: en-GB,en;q=0.9 + cookie: session={{succinctSession}} + origin: https://alpha.succinct.xyz + referer: https://alpha.succinct.xyz/near/near-light-client/releases/11 + sec-ch-ua: "Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121" + sec-ch-ua-mobile: ?0 + sec-ch-ua-platform: "Linux" + sec-fetch-dest: empty + sec-fetch-mode: cors + sec-fetch-site: same-origin + sec-gpc: 1 + user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 +} + +auth:bearer { + token: {{succinctAuthToken}} +} + +vars:pre-request { + id: 20b28ab4-b47f-458d-9933-8c7f565f082a + session: {{succinctSession}} +} diff --git a/api/NEAR Light Client/Succinct/Req proof (batch).bru b/api/NEAR Light Client/Succinct/Req proof (batch).bru index f4926c3e..d102676e 100644 --- a/api/NEAR Light Client/Succinct/Req proof (batch).bru +++ b/api/NEAR Light Client/Succinct/Req proof (batch).bru @@ -5,13 +5,13 @@ meta { } post { - url: {{succintBaseUrl}}/proof/batch/new + url: {{succinctBaseUrl}}/proof/batch/new body: json auth: bearer } auth:bearer { - token: {{succintAuthToken}} + token: {{succinctAuthToken}} } body:json { diff --git a/api/NEAR Light Client/Succinct/Req proof (sync).bru b/api/NEAR Light Client/Succinct/Req proof (sync).bru index a72f30d9..4c48a3d8 100644 --- a/api/NEAR Light Client/Succinct/Req proof (sync).bru +++ b/api/NEAR Light Client/Succinct/Req proof (sync).bru @@ -5,13 +5,13 @@ meta { } post { - url: {{succintBaseUrl}}/proof/new + url: {{succinctBaseUrl}}/proof/new body: json auth: bearer } auth:bearer { - token: {{succintAuthToken}} + token: {{succinctAuthToken}} } body:json { diff --git a/api/NEAR Light Client/Succinct/Req proof (verify).bru b/api/NEAR Light Client/Succinct/Req proof (verify).bru index ba163191..ec208edc 100644 --- a/api/NEAR Light Client/Succinct/Req proof (verify).bru +++ b/api/NEAR Light Client/Succinct/Req proof (verify).bru @@ -5,13 +5,13 @@ meta { } post { - url: {{succintBaseUrl}}/proof/batch/new + url: {{succinctBaseUrl}}/proof/batch/new body: json auth: bearer } auth:bearer { - token: {{succintAuthToken}} + token: {{succinctAuthToken}} } body:json { diff --git a/api/NEAR Light Client/environments/local.bru b/api/NEAR Light Client/environments/local.bru new file mode 100644 index 00000000..839baad7 --- /dev/null +++ b/api/NEAR Light Client/environments/local.bru @@ -0,0 +1,3 @@ +vars { + succinctBaseUrl: https://dndll.requestcatcher.com +} diff --git a/api/NEAR Light Client/environments/testnet.bru b/api/NEAR Light Client/environments/testnet.bru index 25d6c5b8..b534d348 100644 --- a/api/NEAR Light Client/environments/testnet.bru +++ b/api/NEAR Light Client/environments/testnet.bru @@ -1,10 +1,12 @@ vars { - succintBaseUrl: https://alpha.succinct.xyz/api + succinctBaseUrl: https://alpha.succinct.xyz/api nearBaseUrl: https://archival-rpc.testnet.near.org lightClientBaseUrl: http://0.0.0.0:3030 operatorBaseUrl: http://0.0.0.0:3030 gitRef: 700edd24ac1666307f3f740e36bf4c5808c26e1b } + vars:secret [ - succintAuthToken + succinctAuthToken, + succinctSession ] diff --git a/bin/operator/src/main.rs b/bin/operator/src/main.rs index 1798698a..925a1917 100644 --- a/bin/operator/src/main.rs +++ b/bin/operator/src/main.rs @@ -11,7 +11,12 @@ pub async fn main() -> anyhow::Result<()> { .add_directive("reqwest=info".parse()?); tracing_subscriber::registry() - .with(fmt::layer().compact().with_line_number(true)) + .with( + fmt::layer() + .compact() + .with_line_number(true) + .with_file(false), + ) .with(filter) .init(); diff --git a/crates/primitives/src/config.rs b/crates/primitives/src/config.rs index be1857e0..238b4afb 100644 --- a/crates/primitives/src/config.rs +++ b/crates/primitives/src/config.rs @@ -55,8 +55,6 @@ where .global(), ); - println!("figment: {figment:#?}"); - figment.extract() } diff --git a/nearx/contract/script/DeployAndRegisterVerifier.sol b/nearx/contract/script/DeployAndRegisterVerifier.sol new file mode 100644 index 00000000..e22c2b2b --- /dev/null +++ b/nearx/contract/script/DeployAndRegisterVerifier.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import "forge-std/Script.sol"; +import "forge-std/Vm.sol"; +import "forge-std/console.sol"; +import {ISuccinctGateway} from "../../src/SuccinctGateway.sol"; +import {FunctionVerifier} from "./FunctionVerifier.sol"; + +contract DeployAndRegisterFunction is Script { + function run() external returns (bytes32, address) { + vm.startBroadcast(); + + bytes memory bytecode = type(FunctionVerifier).creationCode; + + address GATEWAY = vm.envAddress("GATEWAY_ID"); + console.logAddress(GATEWAY); + + bytes32 SALT = vm.envBytes32("CREATE2_SALT"); + + address OWNER = msg.sender; + + (bytes32 functionId, address verifier) = SuccinctGateway(GATEWAY) + .deployAndRegisterFunction(OWNER, bytecode, SALT); + + return (functionId, verifier); + } +} diff --git a/nearx/contract/script/UpdateParams.s.sol b/nearx/contract/script/UpdateParams.s.sol index 349dbc31..604a39af 100644 --- a/nearx/contract/script/UpdateParams.s.sol +++ b/nearx/contract/script/UpdateParams.s.sol @@ -18,7 +18,6 @@ contract UpdateParams is Script { vm.startBroadcast(); NearX lightClient = NearX(payable(proxyAddress)); - // Succinct's goerli gateway address initialGateway = vm.envAddress("GATEWAY_ID"); lightClient.updateGateway(initialGateway);