From dd5881d020f8ca9d82adf2ec75e040e3cf388c11 Mon Sep 17 00:00:00 2001 From: Arkadiusz Konior Date: Wed, 29 May 2024 10:15:49 +0200 Subject: [PATCH 1/2] get_log binary --- .github/workflows/circuits_e2e.yaml | 2 ++ .github/workflows/contract_test.yml | 1 + .github/workflows/e2e_test.yaml | 2 ++ .github/workflows/static_checks.yaml | 3 +++ Nargo.toml | 1 + ethereum/circuits/get_log/Nargo.toml | 8 ++++++++ ethereum/circuits/get_log/Prover.toml | 4 ++++ ethereum/circuits/get_log/Verifier.toml | 18 ++++++++++++++++++ ethereum/circuits/get_log/src/main.nr | 13 +++++++++++++ ethereum/circuits/lib/src/log.nr | 6 +++--- ethereum/scripts/e2e_prep.sh | 5 +++++ 11 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 ethereum/circuits/get_log/Nargo.toml create mode 100644 ethereum/circuits/get_log/Prover.toml create mode 100644 ethereum/circuits/get_log/Verifier.toml create mode 100644 ethereum/circuits/get_log/src/main.nr diff --git a/.github/workflows/circuits_e2e.yaml b/.github/workflows/circuits_e2e.yaml index 274e27fd3..e2b4650f7 100644 --- a/.github/workflows/circuits_e2e.yaml +++ b/.github/workflows/circuits_e2e.yaml @@ -50,6 +50,7 @@ jobs: nargo prove --package get_storage --oracle-resolver=http://localhost:5555 nargo prove --package get_receipt --oracle-resolver=http://localhost:5555 nargo prove --package get_transaction --oracle-resolver=http://localhost:5555 + nargo prove --package get_log --oracle-resolver=http://localhost:5555 nargo prove --package is_dao_worthy --oracle-resolver=http://localhost:5555 nargo prove --package is_ape_owner --oracle-resolver=http://localhost:5555 @@ -60,6 +61,7 @@ jobs: nargo verify --package get_storage nargo verify --package get_receipt nargo verify --package get_transaction + nargo verify --package get_log nargo verify --package is_dao_worthy nargo verify --package is_ape_owner diff --git a/.github/workflows/contract_test.yml b/.github/workflows/contract_test.yml index 12a9fc80d..e0de86d72 100644 --- a/.github/workflows/contract_test.yml +++ b/.github/workflows/contract_test.yml @@ -34,6 +34,7 @@ jobs: nargo codegen-verifier --package get_header nargo codegen-verifier --package get_receipt nargo codegen-verifier --package get_transaction + nargo codegen-verifier --package get_log - name: Run Forge build run: | diff --git a/.github/workflows/e2e_test.yaml b/.github/workflows/e2e_test.yaml index cd4f0e2a3..2df52d030 100644 --- a/.github/workflows/e2e_test.yaml +++ b/.github/workflows/e2e_test.yaml @@ -50,6 +50,7 @@ jobs: nargo prove --package get_storage --oracle-resolver=http://localhost:5555 nargo prove --package get_receipt --oracle-resolver=http://localhost:5555 nargo prove --package get_transaction --oracle-resolver=http://localhost:5555 + nargo prove --package get_log --oracle-resolver=http://localhost:5555 - name: Run nargo codegen-verifier run: | @@ -58,6 +59,7 @@ jobs: nargo codegen-verifier --package get_storage nargo codegen-verifier --package get_receipt nargo codegen-verifier --package get_transaction + nargo codegen-verifier --package get_log - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 diff --git a/.github/workflows/static_checks.yaml b/.github/workflows/static_checks.yaml index 8a2d24065..1580e24d0 100644 --- a/.github/workflows/static_checks.yaml +++ b/.github/workflows/static_checks.yaml @@ -37,6 +37,7 @@ jobs: echo '{ "abi": [] }' > target/get_header.json echo '{ "abi": [] }' > target/get_receipt.json echo '{ "abi": [] }' > target/get_transaction.json + echo '{ "abi": [] }' > target/get_log.json - name: Create fake smart contract build artefacts working-directory: . @@ -51,6 +52,8 @@ jobs: echo '{ "abi": [], "bytecode": { "object": "" } }' > ethereum/contracts/out/GetReceiptUltraPLONKVerifier.sol/UltraVerifier.json mkdir -p ethereum/contracts/out/GetTransactionUltraPLONKVerifier.sol echo '{ "abi": [], "bytecode": { "object": "" } }' > ethereum/contracts/out/GetTransactionUltraPLONKVerifier.sol/UltraVerifier.json + mkdir -p ethereum/contracts/out/GetLogUltraPLONKVerifier.sol + echo '{ "abi": [], "bytecode": { "object": "" } }' > ethereum/contracts/out/GetLogUltraPLONKVerifier.sol/UltraVerifier.json - name: Run TypeScript Build run: yarn build diff --git a/Nargo.toml b/Nargo.toml index 1d1920228..d9c4dc107 100644 --- a/Nargo.toml +++ b/Nargo.toml @@ -7,6 +7,7 @@ members = [ "ethereum/circuits/get_account", "ethereum/circuits/get_header", "ethereum/circuits/get_transaction", + "ethereum/circuits/get_log", "vlayer/ethereum/circuits/lib", "vlayer/examples/circuits/is_dao_worthy", "vlayer/examples/circuits/is_ape_owner", diff --git a/ethereum/circuits/get_log/Nargo.toml b/ethereum/circuits/get_log/Nargo.toml new file mode 100644 index 000000000..2884daa6d --- /dev/null +++ b/ethereum/circuits/get_log/Nargo.toml @@ -0,0 +1,8 @@ +[package] +name = "get_log" +type = "bin" +authors = [""] +compiler_version = ">=0.30.0" + +[dependencies] +ethereum = { path = "../lib" } diff --git a/ethereum/circuits/get_log/Prover.toml b/ethereum/circuits/get_log/Prover.toml new file mode 100644 index 000000000..2c145ef10 --- /dev/null +++ b/ethereum/circuits/get_log/Prover.toml @@ -0,0 +1,4 @@ +chain_id = "1" +block_number = "19421720" +tx_idx = "291" +log_idx = "0" diff --git a/ethereum/circuits/get_log/Verifier.toml b/ethereum/circuits/get_log/Verifier.toml new file mode 100644 index 000000000..5a62a1508 --- /dev/null +++ b/ethereum/circuits/get_log/Verifier.toml @@ -0,0 +1,18 @@ +block_number = "0x0000000000000000000000000000000000000000000000000000000001285a18" +chain_id = "0x0000000000000000000000000000000000000000000000000000000000000001" +log_idx = "0x0000000000000000000000000000000000000000000000000000000000000000" +tx_idx = "0x0000000000000000000000000000000000000000000000000000000000000123" + +[return] +block_hash = ["0x00000000000000000000000000000000000000000000000000000000000000cd", "0x00000000000000000000000000000000000000000000000000000000000000bb", "0x00000000000000000000000000000000000000000000000000000000000000f2", "0x00000000000000000000000000000000000000000000000000000000000000bf", "0x0000000000000000000000000000000000000000000000000000000000000017", "0x0000000000000000000000000000000000000000000000000000000000000020", "0x0000000000000000000000000000000000000000000000000000000000000048", "0x00000000000000000000000000000000000000000000000000000000000000ba", "0x0000000000000000000000000000000000000000000000000000000000000004", "0x000000000000000000000000000000000000000000000000000000000000004c", "0x00000000000000000000000000000000000000000000000000000000000000eb", "0x00000000000000000000000000000000000000000000000000000000000000f2", "0x0000000000000000000000000000000000000000000000000000000000000064", "0x000000000000000000000000000000000000000000000000000000000000000d", "0x00000000000000000000000000000000000000000000000000000000000000b2", "0x000000000000000000000000000000000000000000000000000000000000003b", "0x00000000000000000000000000000000000000000000000000000000000000d5", "0x00000000000000000000000000000000000000000000000000000000000000d5", "0x00000000000000000000000000000000000000000000000000000000000000d6", "0x00000000000000000000000000000000000000000000000000000000000000d2", "0x00000000000000000000000000000000000000000000000000000000000000e5", "0x00000000000000000000000000000000000000000000000000000000000000fe", "0x000000000000000000000000000000000000000000000000000000000000008e", "0x00000000000000000000000000000000000000000000000000000000000000e0", "0x00000000000000000000000000000000000000000000000000000000000000eb", "0x0000000000000000000000000000000000000000000000000000000000000036", "0x0000000000000000000000000000000000000000000000000000000000000045", "0x00000000000000000000000000000000000000000000000000000000000000f7", "0x0000000000000000000000000000000000000000000000000000000000000060", "0x00000000000000000000000000000000000000000000000000000000000000ee", "0x0000000000000000000000000000000000000000000000000000000000000096", "0x000000000000000000000000000000000000000000000000000000000000002e"] + +[return.log] +address = ["0x00000000000000000000000000000000000000000000000000000000000000c0", "0x000000000000000000000000000000000000000000000000000000000000002a", "0x00000000000000000000000000000000000000000000000000000000000000aa", "0x0000000000000000000000000000000000000000000000000000000000000039", "0x00000000000000000000000000000000000000000000000000000000000000b2", "0x0000000000000000000000000000000000000000000000000000000000000023", "0x00000000000000000000000000000000000000000000000000000000000000fe", "0x000000000000000000000000000000000000000000000000000000000000008d", "0x000000000000000000000000000000000000000000000000000000000000000a", "0x000000000000000000000000000000000000000000000000000000000000000e", "0x000000000000000000000000000000000000000000000000000000000000005c", "0x000000000000000000000000000000000000000000000000000000000000004f", "0x0000000000000000000000000000000000000000000000000000000000000027", "0x00000000000000000000000000000000000000000000000000000000000000ea", "0x00000000000000000000000000000000000000000000000000000000000000d9", "0x0000000000000000000000000000000000000000000000000000000000000008", "0x000000000000000000000000000000000000000000000000000000000000003c", "0x0000000000000000000000000000000000000000000000000000000000000075", "0x000000000000000000000000000000000000000000000000000000000000006c", "0x00000000000000000000000000000000000000000000000000000000000000c2"] + +[return.log.data] +len = "0x0000000000000000000000000000000000000000000000000000000000000020" +storage = ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000037", "0x0000000000000000000000000000000000000000000000000000000000000082", "0x00000000000000000000000000000000000000000000000000000000000000da", "0x00000000000000000000000000000000000000000000000000000000000000ce", "0x000000000000000000000000000000000000000000000000000000000000009d", "0x0000000000000000000000000000000000000000000000000000000000000090", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"] + +[return.log.topics] +len = "0x0000000000000000000000000000000000000000000000000000000000000002" +storage = [["0x00000000000000000000000000000000000000000000000000000000000000e1", "0x00000000000000000000000000000000000000000000000000000000000000ff", "0x00000000000000000000000000000000000000000000000000000000000000fc", "0x00000000000000000000000000000000000000000000000000000000000000c4", "0x0000000000000000000000000000000000000000000000000000000000000092", "0x000000000000000000000000000000000000000000000000000000000000003d", "0x0000000000000000000000000000000000000000000000000000000000000004", "0x00000000000000000000000000000000000000000000000000000000000000b5", "0x0000000000000000000000000000000000000000000000000000000000000059", "0x00000000000000000000000000000000000000000000000000000000000000f4", "0x00000000000000000000000000000000000000000000000000000000000000d2", "0x000000000000000000000000000000000000000000000000000000000000009a", "0x000000000000000000000000000000000000000000000000000000000000008b", "0x00000000000000000000000000000000000000000000000000000000000000fc", "0x000000000000000000000000000000000000000000000000000000000000006c", "0x00000000000000000000000000000000000000000000000000000000000000da", "0x0000000000000000000000000000000000000000000000000000000000000004", "0x00000000000000000000000000000000000000000000000000000000000000eb", "0x000000000000000000000000000000000000000000000000000000000000005b", "0x000000000000000000000000000000000000000000000000000000000000000d", "0x000000000000000000000000000000000000000000000000000000000000003c", "0x0000000000000000000000000000000000000000000000000000000000000046", "0x0000000000000000000000000000000000000000000000000000000000000007", "0x0000000000000000000000000000000000000000000000000000000000000051", "0x00000000000000000000000000000000000000000000000000000000000000c2", "0x0000000000000000000000000000000000000000000000000000000000000040", "0x000000000000000000000000000000000000000000000000000000000000002c", "0x000000000000000000000000000000000000000000000000000000000000005c", "0x000000000000000000000000000000000000000000000000000000000000005c", "0x00000000000000000000000000000000000000000000000000000000000000c9", "0x0000000000000000000000000000000000000000000000000000000000000010", "0x000000000000000000000000000000000000000000000000000000000000009c"], ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x00000000000000000000000000000000000000000000000000000000000000a6", "0x0000000000000000000000000000000000000000000000000000000000000060", "0x00000000000000000000000000000000000000000000000000000000000000f1", "0x000000000000000000000000000000000000000000000000000000000000008e", "0x00000000000000000000000000000000000000000000000000000000000000f5", "0x000000000000000000000000000000000000000000000000000000000000000e", "0x0000000000000000000000000000000000000000000000000000000000000073", "0x000000000000000000000000000000000000000000000000000000000000009f", "0x00000000000000000000000000000000000000000000000000000000000000d6", "0x000000000000000000000000000000000000000000000000000000000000004f", "0x0000000000000000000000000000000000000000000000000000000000000048", "0x0000000000000000000000000000000000000000000000000000000000000049", "0x000000000000000000000000000000000000000000000000000000000000009e", "0x000000000000000000000000000000000000000000000000000000000000006a", "0x000000000000000000000000000000000000000000000000000000000000005d", "0x000000000000000000000000000000000000000000000000000000000000009e", "0x00000000000000000000000000000000000000000000000000000000000000f0", "0x000000000000000000000000000000000000000000000000000000000000000d", "0x0000000000000000000000000000000000000000000000000000000000000026", "0x000000000000000000000000000000000000000000000000000000000000008c"], ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"], ["0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000"]] diff --git a/ethereum/circuits/get_log/src/main.nr b/ethereum/circuits/get_log/src/main.nr new file mode 100644 index 000000000..a2a0c2a07 --- /dev/null +++ b/ethereum/circuits/get_log/src/main.nr @@ -0,0 +1,13 @@ +use dep::ethereum::log::{get_log, LogWithinBlock}; + +global MAX_LOG_DATA_LEN = 32; +global MAX_LOGS_COUNT = 1; + +fn main( + chain_id: pub Field, + block_number: pub u64, + tx_idx: pub Field, + log_idx: pub u64 +) -> pub LogWithinBlock { + get_log::(chain_id, block_number, tx_idx, log_idx) +} diff --git a/ethereum/circuits/lib/src/log.nr b/ethereum/circuits/lib/src/log.nr index 06417fccc..1ed18b2f7 100644 --- a/ethereum/circuits/lib/src/log.nr +++ b/ethereum/circuits/lib/src/log.nr @@ -93,8 +93,8 @@ fn extract_log_fragment( logs_fragment: Fragment, log_idx: u64 ) -> Fragment { - let logs_rlp_list = decode_list::(logs_fragment); - rlp_subfragment::(logs_fragment, logs_rlp_list.get(log_idx)) + let logs_rlp_list: RlpList = decode_list(logs_fragment); + rlp_subfragment(logs_fragment, logs_rlp_list.get(log_idx)) } fn extract_address( @@ -123,7 +123,7 @@ fn extract_data( rlp_subfragment(log_fragment, log_values_rlp_list.get(LOG_DATA_INDEX)) } -fn rlp_subfragment( +fn rlp_subfragment( fragment: Fragment, rlp_fragment: RlpFragment ) -> Fragment { diff --git a/ethereum/scripts/e2e_prep.sh b/ethereum/scripts/e2e_prep.sh index c04083796..c06366dc2 100755 --- a/ethereum/scripts/e2e_prep.sh +++ b/ethereum/scripts/e2e_prep.sh @@ -3,6 +3,7 @@ nargo compile --package get_account nargo compile --package get_storage nargo compile --package get_receipt nargo compile --package get_transaction +nargo compile --package get_log echo "Prove get_header" nargo prove --package get_header --oracle-resolver=http://localhost:5555 @@ -14,6 +15,8 @@ echo "Prove get_receipt" nargo prove --package get_receipt --oracle-resolver=http://localhost:5555 echo "Prove get_transaction" nargo prove --package get_transaction --oracle-resolver=http://localhost:5555 +echo "Prove get_log" +nargo prove --package get_log --oracle-resolver=http://localhost:5555 echo "Codegen get_header" nargo codegen-verifier --package get_header @@ -25,3 +28,5 @@ echo "Codegen get_receipt" nargo codegen-verifier --package get_receipt echo "Codegen get_transaction" nargo codegen-verifier --package get_transaction +echo "Codegen get_log" +nargo codegen-verifier --package get_log From 94557ab4a3bd0062137ee9bd90d9bca671686916 Mon Sep 17 00:00:00 2001 From: Arkadiusz Konior Date: Wed, 29 May 2024 11:56:08 +0200 Subject: [PATCH 2/2] remove authors --- ethereum/circuits/get_log/Nargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/ethereum/circuits/get_log/Nargo.toml b/ethereum/circuits/get_log/Nargo.toml index 2884daa6d..36c7db549 100644 --- a/ethereum/circuits/get_log/Nargo.toml +++ b/ethereum/circuits/get_log/Nargo.toml @@ -1,7 +1,6 @@ [package] name = "get_log" type = "bin" -authors = [""] compiler_version = ">=0.30.0" [dependencies]