From 0d21ee0c598a31108b501ca7d8d0be9bdbf7c540 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 15 Jun 2021 18:15:51 +0200 Subject: [PATCH 001/110] better error-reporting in configure --- c/src/core/client/client_init.c | 2 +- c/src/core/client/plugin.h | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/c/src/core/client/client_init.c b/c/src/core/client/client_init.c index bb91a883e..2fdfb7bea 100644 --- a/c/src/core/client/client_init.c +++ b/c/src/core/client/client_init.c @@ -236,7 +236,7 @@ char* in3_configure(in3_t* c, const char* config) { // make sure the json-config is parseable. json_ctx_t* json = parse_json((char*) config); - if (!json || !json->result) return config_err("in3_configure", "parse error"); + if (!json || !json->result) return config_err("in3_configure: parse error", config); // the error-message we will return in case of an error. char* res = NULL; diff --git a/c/src/core/client/plugin.h b/c/src/core/client/plugin.h index 4e6a7524a..4474b88a0 100644 --- a/c/src/core/client/plugin.h +++ b/c/src/core/client/plugin.h @@ -525,6 +525,33 @@ typedef struct { void* data; /**< output param set by plugin code - pointer to data requested. */ void (*cleanup)(void*); /**< output param set by plugin code - if not NULL use it to cleanup the data. */ } in3_get_data_ctx_t; + + + +/** + * raises a error during config by setting the error-message and returning a error-code. + */ +#define CNF_ERROR(msg) \ + { \ + ctx->error_msg = _strdupn(msg, -1); \ + return IN3_EINVAL; \ + } + +/** + * sets the bytes as taken from the given property to the target and raises an error if the len does not fit. + */ +#define CNF_SET_BYTES(dst, token, property, l) \ + { \ + const bytes_t tmp = d_to_bytes(d_get(token, key(property))); \ + if (tmp.data) { \ + if (tmp.len != l) CNF_ERROR(property " must be " #l " bytes") \ + memcpy(dst, tmp.data, l); \ + } \ + } + + + + #ifdef __cplusplus } #endif From 2361472a8f429d02254c5e578f817d2df1cee414 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 15 Jun 2021 18:16:02 +0200 Subject: [PATCH 002/110] fix hanlding json-values in cmd --- c/src/cmd/in3/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/cmd/in3/helper.c b/c/src/cmd/in3/helper.c index c37fa4da2..7128dc6f0 100644 --- a/c/src/cmd/in3/helper.c +++ b/c/src/cmd/in3/helper.c @@ -103,7 +103,7 @@ void configure_opt(in3_t* c, char* name, char* value, int argc, char** argv) { while (p) { char* next = strtok(NULL, "."); if (!next) { - if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0 || is_number(value)) + if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0 || is_number(value) || *value=='{' || *value=='[') sb_print(&sb, "\"%s\":%s", p, value); else sb_print(&sb, "\"%s\":\"%s\"", p, value); From af694624dcb57ff0d231a14bb2953e6c7d24e4f5 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 15 Jun 2021 19:16:49 +0200 Subject: [PATCH 003/110] switch to clang-format 13 --- c/ci-analyse.yml | 4 +- c/include/in3/api_utils.h | 4 +- c/include/in3/btc_api.h | 16 +- c/include/in3/bytes.h | 102 +++--- c/include/in3/client.h | 92 +++--- c/include/in3/colors.h | 42 +-- c/include/in3/core_api.h | 42 +-- c/include/in3/data.h | 80 ++--- c/include/in3/error.h | 54 ++-- c/include/in3/eth_api.h | 42 +-- c/include/in3/eth_basic.h | 42 +-- c/include/in3/eth_full.h | 38 +-- c/include/in3/eth_nano.h | 48 +-- c/include/in3/ethereum_apdu_client.h | 48 +-- c/include/in3/in3_curl.h | 42 +-- c/include/in3/in3_http.h | 44 +-- c/include/in3/in3_init.h | 2 +- c/include/in3/in3_winhttp.h | 40 +-- c/include/in3/ipfs_api.h | 2 +- c/include/in3/ledger_signer.h | 48 +-- c/include/in3/log.h | 4 +- c/include/in3/mem.h | 38 +-- c/include/in3/nodelist.h | 48 +-- c/include/in3/nodeselect_def.h | 6 +- c/include/in3/plugin.h | 86 +++-- c/include/in3/request.h | 132 ++++---- c/include/in3/rpc.h | 40 +-- c/include/in3/scache.h | 38 +-- c/include/in3/signer.h | 40 +-- c/include/in3/stringbuilder.h | 58 ++-- c/include/in3/usn_api.h | 40 +-- c/include/in3/utils.h | 68 ++-- c/include/in3/zksync.h | 43 +-- c/src/api/btc/btc_api.c | 4 +- c/src/api/btc/btc_api.h | 16 +- c/src/api/core/core_api.c | 38 +-- c/src/api/core/core_api.h | 42 +-- c/src/api/eth1/abi.h | 66 ++-- c/src/api/eth1/abi_decode.c | 2 +- c/src/api/eth1/ens.c | 2 +- c/src/api/eth1/ens.h | 38 +-- c/src/api/eth1/eth_api.c | 44 +-- c/src/api/eth1/eth_api.h | 42 +-- c/src/api/eth1/key.c | 38 +-- c/src/api/eth1/rpc_api.c | 38 +-- c/src/api/ipfs/ipfs_api.h | 2 +- c/src/api/usn/usn_api.c | 38 +-- c/src/api/usn/usn_api.h | 40 +-- c/src/api/utils/api_utils.h | 4 +- c/src/api/utils/api_utils_priv.h | 2 +- c/src/cmd/http-server/http_server.c | 48 +-- c/src/cmd/http-server/http_server.h | 38 +-- c/src/cmd/in3/helper.c | 52 +-- c/src/cmd/in3/in3_storage.c | 38 +-- c/src/cmd/in3/in3_storage.h | 40 +-- c/src/cmd/in3/tx.c | 2 +- c/src/cmd/tools/data.c | 40 +-- c/src/cmd/tools/rlp.c | 40 +-- c/src/core/client/client.c | 40 +-- c/src/core/client/client.h | 92 +++--- c/src/core/client/client_init.c | 38 +-- c/src/core/client/execute.c | 38 +-- c/src/core/client/keys.h | 38 +-- c/src/core/client/plugin.h | 65 ++-- c/src/core/client/request.c | 38 +-- c/src/core/client/request.h | 132 ++++---- c/src/core/client/request_internal.h | 2 +- c/src/core/client/version.h | 40 +-- c/src/core/util/bitset.c | 38 +-- c/src/core/util/bitset.h | 40 +-- c/src/core/util/bytes.c | 38 +-- c/src/core/util/bytes.h | 102 +++--- c/src/core/util/colors.h | 42 +-- c/src/core/util/data.c | 40 +-- c/src/core/util/data.h | 80 ++--- c/src/core/util/debug.c | 38 +-- c/src/core/util/debug.h | 42 +-- c/src/core/util/error.h | 54 ++-- c/src/core/util/log.c | 2 +- c/src/core/util/log.h | 4 +- c/src/core/util/mem.c | 38 +-- c/src/core/util/mem.h | 38 +-- c/src/core/util/scache.c | 38 +-- c/src/core/util/scache.h | 38 +-- c/src/core/util/stringbuilder.c | 38 +-- c/src/core/util/stringbuilder.h | 58 ++-- c/src/core/util/utils.c | 40 +-- c/src/core/util/utils.h | 68 ++-- c/src/init/in3_init.h | 2 +- c/src/nodeselect/full/cache.c | 38 +-- c/src/nodeselect/full/cache.h | 52 +-- c/src/nodeselect/full/nodelist.c | 38 +-- c/src/nodeselect/full/nodelist.h | 48 +-- c/src/nodeselect/full/nodeselect_def.c | 6 +- c/src/nodeselect/full/nodeselect_def.h | 6 +- c/src/nodeselect/full/nodeselect_def_cfg.h | 2 +- .../full/nodeselect_def_cfg_template.h | 2 +- c/src/nodeselect/full/registry.c | 38 +-- c/src/nodeselect/full/registry.h | 2 +- c/src/pay/eth/pay_eth.c | 38 +-- c/src/pay/eth/pay_eth.h | 40 +-- c/src/pay/zksync/zk_helper.c | 38 +-- c/src/pay/zksync/zk_helper.h | 38 +-- c/src/pay/zksync/zk_incentive.c | 42 +-- c/src/pay/zksync/zk_message.c | 4 +- c/src/pay/zksync/zk_transfer.c | 2 +- c/src/pay/zksync/zksync.c | 38 +-- c/src/pay/zksync/zksync.h | 40 +-- .../signer/ledger-nano/firmware/src/globals.h | 2 +- c/src/signer/ledger-nano/firmware/src/menu.c | 2 +- .../ledger-nano/firmware/src/operations.c | 10 +- .../ledger-nano/signer/device_apdu_commands.c | 8 +- .../ledger-nano/signer/device_apdu_commands.h | 38 +-- .../ledger-nano/signer/ethereum_apdu_client.c | 4 +- .../ledger-nano/signer/ethereum_apdu_client.h | 48 +-- .../signer/ethereum_apdu_client_priv.h | 38 +-- .../signer/ledger-nano/signer/ledger_signer.c | 4 +- .../signer/ledger-nano/signer/ledger_signer.h | 48 +-- .../ledger-nano/signer/ledger_signer_priv.h | 38 +-- c/src/signer/ledger-nano/signer/types.h | 40 +-- c/src/signer/ledger-nano/signer/utility.c | 2 +- c/src/signer/ledger-nano/signer/utility.h | 38 +-- c/src/signer/multisig/multisig.c | 42 +-- c/src/signer/multisig/multisig.h | 38 +-- c/src/signer/pk-signer/signer.c | 38 +-- c/src/signer/pk-signer/signer.h | 40 +-- c/src/tools/clientdata/client_data.h | 2 +- c/src/tools/swift/swift.h | 2 +- c/src/transport/curl/in3_curl.c | 40 +-- c/src/transport/curl/in3_curl.h | 42 +-- c/src/transport/http/in3_http.c | 48 +-- c/src/transport/http/in3_http.h | 44 +-- c/src/transport/winhttp/in3_winhttp.c | 38 +-- c/src/transport/winhttp/in3_winhttp.h | 40 +-- c/src/verifier/btc/btc.c | 2 +- c/src/verifier/btc/btc_merkle.h | 2 +- c/src/verifier/btc/btc_target.h | 10 +- c/src/verifier/btc/btc_types.c | 2 +- c/src/verifier/eth1/basic/eth_account.c | 40 +-- c/src/verifier/eth1/basic/eth_basic.c | 38 +-- c/src/verifier/eth1/basic/eth_basic.h | 42 +-- c/src/verifier/eth1/basic/eth_getBlock.c | 40 +-- c/src/verifier/eth1/basic/eth_getLog.c | 38 +-- .../verifier/eth1/basic/eth_getTransaction.c | 38 +-- c/src/verifier/eth1/basic/filter.c | 38 +-- c/src/verifier/eth1/basic/filter.h | 40 +-- c/src/verifier/eth1/basic/sign_tx.c | 42 +-- c/src/verifier/eth1/basic/trie.c | 38 +-- c/src/verifier/eth1/basic/trie.h | 38 +-- c/src/verifier/eth1/evm/accounts.c | 38 +-- c/src/verifier/eth1/evm/accounts.h | 38 +-- c/src/verifier/eth1/evm/big.c | 42 +-- c/src/verifier/eth1/evm/big.h | 40 +-- c/src/verifier/eth1/evm/code.c | 38 +-- c/src/verifier/eth1/evm/code.h | 40 +-- c/src/verifier/eth1/evm/env.c | 38 +-- c/src/verifier/eth1/evm/evm.c | 38 +-- c/src/verifier/eth1/evm/evm.h | 52 +-- c/src/verifier/eth1/evm/evm_mem.h | 38 +-- c/src/verifier/eth1/evm/gas.c | 38 +-- c/src/verifier/eth1/evm/gas.h | 40 +-- c/src/verifier/eth1/evm/opcodes.c | 2 +- c/src/verifier/eth1/evm/opcodes.h | 38 +-- c/src/verifier/eth1/evm/pre_blake2.c | 38 +-- c/src/verifier/eth1/evm/pre_ec.c | 38 +-- c/src/verifier/eth1/evm/precompiled.c | 38 +-- c/src/verifier/eth1/evm/precompiled.h | 38 +-- c/src/verifier/eth1/full/eth_full.c | 38 +-- c/src/verifier/eth1/full/eth_full.h | 38 +-- c/src/verifier/eth1/nano/blockheader.c | 38 +-- c/src/verifier/eth1/nano/chains.h | 38 +-- c/src/verifier/eth1/nano/chainspec.c | 38 +-- c/src/verifier/eth1/nano/chainspec.h | 44 +-- c/src/verifier/eth1/nano/eth_nano.c | 38 +-- c/src/verifier/eth1/nano/eth_nano.h | 48 +-- c/src/verifier/eth1/nano/merkle.c | 38 +-- c/src/verifier/eth1/nano/merkle.h | 58 ++-- c/src/verifier/eth1/nano/rlp.c | 42 +-- c/src/verifier/eth1/nano/rlp.h | 96 +++--- c/src/verifier/eth1/nano/serialize.c | 38 +-- c/src/verifier/eth1/nano/serialize.h | 72 ++--- c/src/verifier/eth1/nano/signature.c | 38 +-- c/src/verifier/eth1/nano/txreceipt.c | 38 +-- c/src/verifier/eth1/nano/vhist.c | 38 +-- c/src/verifier/eth1/nano/vhist.h | 40 +-- c/src/verifier/eth1/rpc/rpc.h | 40 +-- c/src/verifier/ipfs/ipfs.h | 2 +- c/src/verifier/ipfs/ipfs.pb.h | 2 +- java/src/in3/IN3.java | 58 ++-- java/src/in3/Loader.java | 38 +-- java/src/in3/NodeList.java | 4 +- java/src/in3/Proof.java | 50 +-- java/src/in3/config/ClientConfiguration.java | 28 +- java/src/in3/config/Configuration.java | 4 +- .../in3/config/NodeRegistryConfiguration.java | 2 +- java/src/in3/eth1/API.java | 298 +++++++++--------- java/src/in3/eth1/Block.java | 40 +-- java/src/in3/eth1/Log.java | 88 +++--- java/src/in3/eth1/LogFilter.java | 76 ++--- java/src/in3/eth1/SimpleWallet.java | 60 ++-- java/src/in3/eth1/Transaction.java | 100 +++--- java/src/in3/eth1/TransactionReceipt.java | 102 +++--- java/src/in3/eth1/TransactionRequest.java | 74 +++-- java/src/in3/utils/Account.java | 8 +- java/src/in3/utils/Converter.java | 48 +-- java/src/in3/utils/Crypto.java | 24 +- java/src/in3/utils/JSON.java | 181 ++++++----- java/src/in3/utils/Signer.java | 52 +-- java/src/in3/utils/StorageProvider.java | 66 ++-- java/src/in3/utils/TempStorageProvider.java | 38 +-- java/src/in3/utils/TransportException.java | 16 +- java/src/in3/zksync/API.java | 40 +-- java/src/in3/zksync/AccountState.java | 4 +- java/src/in3_jni.c | 64 ++-- java/src/in3_jni.h | 38 +-- java/test/in3/eth1/APITest.java | 2 +- scripts/format_all.sh | 2 +- 217 files changed, 4296 insertions(+), 4165 deletions(-) mode change 100755 => 100644 c/src/signer/ledger-nano/firmware/src/globals.h diff --git a/c/ci-analyse.yml b/c/ci-analyse.yml index 9ce174630..8ebe41ff4 100644 --- a/c/ci-analyse.yml +++ b/c/ci-analyse.yml @@ -113,11 +113,11 @@ code_quality: format: stage: analysis needs: [] - image: docker.slock.it/build-images/cmake:clang11 + image: docker.slock.it/build-images/cmake:clang13 tags: - short-jobs script: - - find c/src/core/ c/src/cmd/ c/src/api/ c/src/verifier/ c/src/transport/ java \( -name "*.c" -o -name "*.h" -o -name "*.java" \) | xargs clang-format-11 -i + - find c/src/core/ c/src/cmd/ c/src/api/ c/src/verifier/ c/src/transport/ java \( -name "*.c" -o -name "*.h" -o -name "*.java" \) | xargs clang-format-13 -i - git diff --patch --exit-code cpd: diff --git a/c/include/in3/api_utils.h b/c/include/in3/api_utils.h index 20e43d316..38af560ee 100644 --- a/c/include/in3/api_utils.h +++ b/c/include/in3/api_utils.h @@ -50,7 +50,7 @@ extern "C" { * a 32 byte long integer used to store ethereum-numbers. * * use the as_long() or as_double() to convert this to a useable number. -*/ + */ typedef struct { uint8_t data[32]; } uint256_t; @@ -84,4 +84,4 @@ char* api_last_error(); } #endif -#endif //IN3_API_UTILS_H +#endif // IN3_API_UTILS_H diff --git a/c/include/in3/btc_api.h b/c/include/in3/btc_api.h index 1d2aced67..d0dad9ffd 100644 --- a/c/include/in3/btc_api.h +++ b/c/include/in3/btc_api.h @@ -120,7 +120,7 @@ typedef struct btc_block_txids { bytes32_t* tx; /**< array of transaction ids */ } btc_block_txids_t; -/** +/** * gets the transaction as raw bytes or null if it does not exist. * You must free the result with b_free() after use! */ @@ -128,7 +128,7 @@ bytes_t* btc_get_transaction_bytes(in3_t* in3, /**< the in3-instance*/ bytes32_t txid /**< the txid */ ); -/** +/** * gets the transaction as struct or null if it does not exist. * You must free the result with free() after use! */ @@ -136,7 +136,7 @@ btc_transaction_t* btc_get_transaction(in3_t* in3, /**< the in3-instance*/ bytes32_t txid /**< the txid */ ); -/** +/** * gets the blockheader as struct or null if it does not exist. * You must free the result with free() after use! */ @@ -144,7 +144,7 @@ btc_blockheader_t* btc_get_blockheader(in3_t* in3, /**< the in3-instance bytes32_t blockhash /**< the block hash */ ); -/** +/** * gets the blockheader as raw serialized data (80 bytes) or null if it does not exist. * You must free the result with b_free() after use! */ @@ -152,7 +152,7 @@ bytes_t* btc_get_blockheader_bytes(in3_t* in3, /**< the in3-instance*/ bytes32_t blockhash /**< the block hash */ ); -/** +/** * gets the block as struct including all transaction data or null if it does not exist. * You must free the result with free() after use! */ @@ -160,7 +160,7 @@ btc_block_txdata_t* btc_get_block_txdata(in3_t* in3, /**< the in3-instan bytes32_t blockhash /**< the block hash */ ); -/** +/** * gets the block as struct including all transaction ids or null if it does not exist. * You must free the result with free() after use! */ @@ -168,7 +168,7 @@ btc_block_txids_t* btc_get_block_txids(in3_t* in3, /**< the in3-instance bytes32_t blockhash /**< the block hash */ ); -/** +/** * gets the block as raw serialized block bytes including all transactions or null if it does not exist. * You must free the result with b_free() after use! */ @@ -188,4 +188,4 @@ btc_block_txdata_t* btc_d_to_block_txdata(d_token_t* t); /** Deserializes a `btc } #endif -#endif //IN3_BTC_API_H +#endif // IN3_BTC_API_H diff --git a/c/include/in3/bytes.h b/c/include/in3/bytes.h index 0aa9fe3a1..df7f48712 100644 --- a/c/include/in3/bytes.h +++ b/c/include/in3/bytes.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -81,38 +81,38 @@ typedef struct { bytes_t b; /**< the bytes struct */ } bytes_builder_t; -RETURNS_NONULL bytes_t* b_new(const uint8_t* data, uint32_t len); /**< allocates a new byte array with 0 filled */ -NONULL uint8_t* b_get_data(const bytes_t* b); /**< gets the data field from an input byte array */ -NONULL uint32_t b_get_len(const bytes_t* b); /**< gets the len field from an input byte array */ -NONULL void b_print(const bytes_t* a); /**< prints a the bytes as hex to stdout */ -NONULL void ba_print(const uint8_t* a, size_t l); /**< prints a the bytes as hex to stdout */ -NONULL int b_cmp(const bytes_t* a, const bytes_t* b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/ -int bytes_cmp(const bytes_t a, const bytes_t b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/ -void b_free(bytes_t* a); /**< frees the data */ -bytes_t b_concat(int cnt, ...); /**< duplicates the content of bytes*/ -NONULL bytes_t* b_dup(const bytes_t* a); /**< clones a byte array*/ -NONULL bytes_t bytes_dup(const bytes_t a); /**< clones a byte array*/ -NONULL uint8_t b_read_byte(bytes_t* b, size_t* pos); /**< reads a byte on the current position and updates the pos afterwards. */ -NONULL uint32_t b_read_int(bytes_t* b, size_t* pos); /**< reads a integer on the current position and updates the pos afterwards. */ -NONULL uint64_t b_read_long(bytes_t* b, size_t* pos); /**< reads a long on the current position and updates the pos afterwards. */ -NONULL char* b_new_chars(bytes_t* b, size_t* pos); /**< creates a new string (needs to be freed) on the current position and updates the pos afterwards. */ -NONULL bytes_t* b_new_fixed_bytes(bytes_t* b, size_t* pos, int len); /**< reads bytes with a fixed length on the current position and updates the pos afterwards. */ -bytes_builder_t* bb_newl(size_t l); /**< creates a new bytes_builder */ -NONULL void bb_free(bytes_builder_t* bb); /**< frees a bytebuilder and its content. */ -NONULL int bb_check_size(bytes_builder_t* bb, size_t len); /**< internal helper to increase the buffer if needed */ -NONULL void bb_write_chars(bytes_builder_t* bb, char* c, int len); /**< writes a string to the builder. */ -NONULL void bb_write_dyn_bytes(bytes_builder_t* bb, const bytes_t* src); /**< writes bytes to the builder with a prefixed length. */ -NONULL void bb_write_fixed_bytes(bytes_builder_t* bb, const bytes_t* src); /**< writes fixed bytes to the builder. */ -NONULL void bb_write_int(bytes_builder_t* bb, uint32_t val); /**< writes a ineteger to the builder. */ -NONULL void bb_write_long(bytes_builder_t* bb, uint64_t val); /**< writes s long to the builder. */ -NONULL void bb_write_long_be(bytes_builder_t* bb, uint64_t val, int len); /**< writes any integer value with the given length of bytes */ -NONULL void bb_write_byte(bytes_builder_t* bb, uint8_t val); /**< writes a single byte to the builder. */ -NONULL void bb_write_raw_bytes(bytes_builder_t* bb, void* ptr, size_t len); /**< writes the bytes to the builder. */ -NONULL void bb_clear(bytes_builder_t* bb); /**< resets the content of the builder. */ -NONULL void bb_replace(bytes_builder_t* bb, int offset, int delete_len, uint8_t* data, int data_len); /**< replaces or deletes a part of the content. */ -RETURNS_NONULL NONULL bytes_t* bb_move_to_bytes(bytes_builder_t* bb); /**< frees the builder and moves the content in a newly created bytes struct (which needs to be freed later). */ -NONULL uint64_t bb_read_long(bytes_builder_t* bb, size_t* i); /**< reads a long from the builder */ -NONULL uint32_t bb_read_int(bytes_builder_t* bb, size_t* i); /**< reads a int from the builder */ +RETURNS_NONULL bytes_t* b_new(const uint8_t* data, uint32_t len); /**< allocates a new byte array with 0 filled */ +NONULL uint8_t* b_get_data(const bytes_t* b); /**< gets the data field from an input byte array */ +NONULL uint32_t b_get_len(const bytes_t* b); /**< gets the len field from an input byte array */ +NONULL void b_print(const bytes_t* a); /**< prints a the bytes as hex to stdout */ +NONULL void ba_print(const uint8_t* a, size_t l); /**< prints a the bytes as hex to stdout */ +NONULL int b_cmp(const bytes_t* a, const bytes_t* b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/ +int bytes_cmp(const bytes_t a, const bytes_t b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/ +void b_free(bytes_t* a); /**< frees the data */ +bytes_t b_concat(int cnt, ...); /**< duplicates the content of bytes*/ +NONULL bytes_t* b_dup(const bytes_t* a); /**< clones a byte array*/ +NONULL bytes_t bytes_dup(const bytes_t a); /**< clones a byte array*/ +NONULL uint8_t b_read_byte(bytes_t* b, size_t* pos); /**< reads a byte on the current position and updates the pos afterwards. */ +NONULL uint32_t b_read_int(bytes_t* b, size_t* pos); /**< reads a integer on the current position and updates the pos afterwards. */ +NONULL uint64_t b_read_long(bytes_t* b, size_t* pos); /**< reads a long on the current position and updates the pos afterwards. */ +NONULL char* b_new_chars(bytes_t* b, size_t* pos); /**< creates a new string (needs to be freed) on the current position and updates the pos afterwards. */ +NONULL bytes_t* b_new_fixed_bytes(bytes_t* b, size_t* pos, int len); /**< reads bytes with a fixed length on the current position and updates the pos afterwards. */ +bytes_builder_t* bb_newl(size_t l); /**< creates a new bytes_builder */ +NONULL void bb_free(bytes_builder_t* bb); /**< frees a bytebuilder and its content. */ +NONULL int bb_check_size(bytes_builder_t* bb, size_t len); /**< internal helper to increase the buffer if needed */ +NONULL void bb_write_chars(bytes_builder_t* bb, char* c, int len); /**< writes a string to the builder. */ +NONULL void bb_write_dyn_bytes(bytes_builder_t* bb, const bytes_t* src); /**< writes bytes to the builder with a prefixed length. */ +NONULL void bb_write_fixed_bytes(bytes_builder_t* bb, const bytes_t* src); /**< writes fixed bytes to the builder. */ +NONULL void bb_write_int(bytes_builder_t* bb, uint32_t val); /**< writes a ineteger to the builder. */ +NONULL void bb_write_long(bytes_builder_t* bb, uint64_t val); /**< writes s long to the builder. */ +NONULL void bb_write_long_be(bytes_builder_t* bb, uint64_t val, int len); /**< writes any integer value with the given length of bytes */ +NONULL void bb_write_byte(bytes_builder_t* bb, uint8_t val); /**< writes a single byte to the builder. */ +NONULL void bb_write_raw_bytes(bytes_builder_t* bb, void* ptr, size_t len); /**< writes the bytes to the builder. */ +NONULL void bb_clear(bytes_builder_t* bb); /**< resets the content of the builder. */ +NONULL void bb_replace(bytes_builder_t* bb, int offset, int delete_len, uint8_t* data, int data_len); /**< replaces or deletes a part of the content. */ +RETURNS_NONULL NONULL bytes_t* bb_move_to_bytes(bytes_builder_t* bb); /**< frees the builder and moves the content in a newly created bytes struct (which needs to be freed later). */ +NONULL uint64_t bb_read_long(bytes_builder_t* bb, size_t* i); /**< reads a long from the builder */ +NONULL uint32_t bb_read_int(bytes_builder_t* bb, size_t* i); /**< reads a int from the builder */ static inline bytes_t bytes(uint8_t* a, uint32_t len) { return (bytes_t){.data = a, .len = len}; } /**< converts the given bytes to a bytes struct */ bytes_t cloned_bytes(bytes_t data); /**< cloned the passed data*/ diff --git a/c/include/in3/client.h b/c/include/in3/client.h index 655063944..0845f9c83 100644 --- a/c/include/in3/client.h +++ b/c/include/in3/client.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * this file defines the incubed configuration struct and it registration. - * - * + * + * * */ #ifndef CLIENT_H @@ -57,21 +57,21 @@ extern "C" { #define IN3_PROTO_VER "2.1.0" /**< the protocol version used when sending requests from the this client */ -#define CHAIN_ID_MAINNET 0x01 /**< chain_id for mainnet */ -#define CHAIN_ID_GOERLI 0x5 /**< chain_id for goerlii */ -#define CHAIN_ID_EWC 0xf6 /**< chain_id for ewc */ +#define CHAIN_ID_MAINNET 0x01 /**< chain_id for mainnet */ +#define CHAIN_ID_GOERLI 0x5 /**< chain_id for goerlii */ +#define CHAIN_ID_EWC 0xf6 /**< chain_id for ewc */ #define CHAIN_ID_IPFS 0x7d0 /**< chain_id for ipfs */ -#define CHAIN_ID_BTC 0x99 /**< chain_id for btc */ -#define CHAIN_ID_LOCAL 0x11 /**< chain_id for local chain */ -#define DEF_REPL_LATEST_BLK 6 /**< default replace_latest_block */ +#define CHAIN_ID_BTC 0x99 /**< chain_id for btc */ +#define CHAIN_ID_LOCAL 0x11 /**< chain_id for local chain */ +#define DEF_REPL_LATEST_BLK 6 /**< default replace_latest_block */ /** * type for a chain_id. */ typedef uint32_t chain_id_t; -/** the type of the chain. - * +/** the type of the chain. + * * for incubed a chain can be any distributed network or database with incubed support. * Depending on this chain-type the previously registered verifier will be chosen and used. */ @@ -86,9 +86,9 @@ typedef enum { } in3_chain_type_t; /** the type of proof. - * + * * Depending on the proof-type different levels of proof will be requested from the node. -*/ + */ typedef enum { PROOF_NONE = 0, /**< No Verification */ PROOF_STANDARD = 1, /**< Standard Verification of the important properties */ @@ -124,7 +124,7 @@ typedef struct in3_verified_hash { /** * Chain definition inside incubed. - * + * * for incubed a chain can be any distributed network or database with incubed support. */ typedef struct in3_chain { @@ -198,9 +198,9 @@ struct in3_plugin { }; /** Incubed Configuration. - * + * * This struct holds the configuration and also point to internal resources such as filters or chain configs. - * + * */ typedef struct in3_t_ { uint8_t signature_count; /**< the number of signatures used to proof the blockhash. */ @@ -221,27 +221,27 @@ typedef struct in3_t_ { } in3_t; /** creates a new Incubed configuration for a specified chain and returns the pointer. - * when creating the client only the one chain will be configured. (saves memory). - * but if you pass `CHAIN_ID_MULTICHAIN` as argument all known chains will be configured allowing you to switch between chains within the same client or configuring your own chain. - * + * when creating the client only the one chain will be configured. (saves memory). + * but if you pass `CHAIN_ID_MULTICHAIN` as argument all known chains will be configured allowing you to switch between chains within the same client or configuring your own chain. + * * you need to free this instance with `in3_free` after use! - * + * * Before using the client you still need to set the transport and optional the storage handlers: - * + * * * example of initialization: * ```c * // register verifiers * in3_register_eth_full(); - * + * * // create new client * in3_t* client = in3_for_chain(CHAIN_ID_MAINNET); - * + * * // configure transport * client->transport = send_curl; * * // configure storage * in3_set_storage_handler(c, storage_get_item, storage_set_item, storage_clear, NULL); - * + * * // ready to use ... * ``` * @@ -268,9 +268,9 @@ NONULL in3_ret_t in3_client_rpc_raw( char** result, /**< [in] pointer to string which will be set if the request was successful. This will hold the result as json-rpc-string. (make sure you free this after use!) */ char** error /**< [in] pointer to a string containing the error-message. (make sure you free it after use!) */); -/** executes a request and returns result as string. in case of an error, the error-property of the result will be set. +/** executes a request and returns result as string. in case of an error, the error-property of the result will be set. * This function also supports sending bulk-requests, but you can not mix internal and external calls, since bulk means all requests will be send to picked nodes. - * The resulting string must be free by the the caller of this function! + * The resulting string must be free by the the caller of this function! */ NONULL char* in3_client_exec_req( in3_t* c, /**< [in] the pointer to the incubed client config. */ @@ -291,7 +291,7 @@ NONULL void in3_free(in3_t* a /**< [in] the pointer to the incubed client config /** * configures the client based on a json-config. - * + * * For details about the structure of the config see https://in3.readthedocs.io/en/develop/api-ts.html#type-in3config * Returns NULL on success, and error string on failure (to be freed by caller) - in which case the client state is undefined */ @@ -302,7 +302,7 @@ NONULL char* in3_configure( /** * gets the current config as json. - * + * * For details about the structure of the config see https://in3.readthedocs.io/en/develop/api-ts.html#type-in3config */ NONULL char* in3_get_config( diff --git a/c/include/in3/colors.h b/c/include/in3/colors.h index 73354fb55..5a4805711 100644 --- a/c/include/in3/colors.h +++ b/c/include/in3/colors.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -110,8 +110,8 @@ #define COLORT_WHITE "" #endif -/* Control sequences, based on ANSI. -Can be used to control color, and +/* Control sequences, based on ANSI. +Can be used to control color, and clear the screen */ diff --git a/c/include/in3/core_api.h b/c/include/in3/core_api.h index 90a084ac0..43d1f4409 100644 --- a/c/include/in3/core_api.h +++ b/c/include/in3/core_api.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * Ethereum API. - * - * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. + * + * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. * */ #ifndef CORE_API_H diff --git a/c/include/in3/data.h b/c/include/in3/data.h index 1f9126a4e..d54cdad3a 100644 --- a/c/include/in3/data.h +++ b/c/include/in3/data.h @@ -1,48 +1,48 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * json-parser. - * + * * The parser can read from : * - json * - bin - * + * * When reading from json all '0x'... values will be stored as bytes_t. If the value is lower than 0xFFFFFFF, it is converted as integer. - * - * + * + * * */ #ifndef __DATA_H__ @@ -76,8 +76,8 @@ typedef enum { T_NULL = 6 /**< a NULL-value */ } d_type_t; -/** a token holding any kind of value. - * +/** a token holding any kind of value. + * * use d_type, d_len or the cast-function to get the value. */ typedef struct item { @@ -104,11 +104,11 @@ typedef struct json_parser { } json_ctx_t; /** - * - * returns the byte-representation of token. - * - * In case of a number it is returned as bigendian. - * booleans as 0x01 or 0x00 + * + * returns the byte-representation of token. + * + * In case of a number it is returned as bigendian. + * booleans as 0x01 or 0x00 * and NULL as 0x. * Objects or arrays will return 0x. */ @@ -136,16 +136,16 @@ d_token_t* d_get_or(d_token_t* item, const uint16_t key1, const uint16_t key2); d_token_t* d_get_at(d_token_t* item, const uint32_t index); /**< returns the token of an array with the given index */ d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */ -NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ -NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ -NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ -char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ +NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ +NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ +NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ +char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ -json_ctx_t* json_create(); +json_ctx_t* json_create(); NONULL d_token_t* json_create_null(json_ctx_t* jp); NONULL d_token_t* json_create_bool(json_ctx_t* jp, bool value); NONULL d_token_t* json_create_int(json_ctx_t* jp, uint64_t value); @@ -182,7 +182,7 @@ d_token_t* d_getl(d_token_t* item, uint16_t k, uint32_t minl); /** * iterator over elements of a array opf object. - * + * * usage: * ```c * for (d_iterator_t iter = d_iter( parent ); iter.left ; d_iter_next(&iter)) { diff --git a/c/include/in3/error.h b/c/include/in3/error.h index 78d678346..0d8c19ddd 100644 --- a/c/include/in3/error.h +++ b/c/include/in3/error.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -50,11 +50,11 @@ extern "C" { #define JSON_RPC_ERR_FINALITY (-16001) /** Block is not final so node refused to sign */ /** ERROR types used as return values. - * + * * All values (except IN3_OK) indicate an error. - * IN3_WAITING may be treated like an error, since we have stop executing until the response has arrived, but it is a valid return value. - * -*/ + * IN3_WAITING may be treated like an error, since we have stop executing until the response has arrived, but it is a valid return value. + * + */ typedef enum { /* On success positive values (impl. defined) upto INT_MAX maybe returned */ IN3_OK = 0, /**< Success */ @@ -106,7 +106,7 @@ typedef enum { */ #define OPTIONAL_T(t) opt_##t -/** +/** * Optional types must be defined prior to usage (e.g. DEFINE_OPTIONAL_T(int)) * Use OPTIONAL_T_UNDEFINED(t) & OPTIONAL_T_VALUE(t, v) for easy initialization (rvalues) */ @@ -116,12 +116,12 @@ typedef enum { bool defined; \ } OPTIONAL_T(t) -/** +/** * marks a used value as undefined. */ #define OPTIONAL_T_UNDEFINED(t) ((OPTIONAL_T(t)){.defined = false}) -/** +/** * sets the value of an optional type. */ #define OPTIONAL_T_VALUE(t, v) ((OPTIONAL_T(t)){.value = v, .defined = true}) @@ -135,4 +135,4 @@ char* in3_errmsg(in3_ret_t err /**< the error code */); } #endif -#endif //IN3_ERROR_H +#endif // IN3_ERROR_H diff --git a/c/include/in3/eth_api.h b/c/include/in3/eth_api.h index aa07000ab..9a4552f19 100644 --- a/c/include/in3/eth_api.h +++ b/c/include/in3/eth_api.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * Ethereum API. - * - * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. + * + * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. * */ #ifndef ETH_API_H diff --git a/c/include/in3/eth_basic.h b/c/include/in3/eth_basic.h index 1cfb76949..d5855714c 100644 --- a/c/include/in3/eth_basic.h +++ b/c/include/in3/eth_basic.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER @@ -112,7 +112,7 @@ in3_ret_t in3_register_eth_basic(in3_t* c); in3_ret_t eth_verify_eth_getLog(in3_vctx_t* vc, int l_logs); /** - * prepares a transaction and writes the data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. + * prepares a transaction and writes the data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. */ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, /**< a json-token desribing the transaction */ in3_req_t* req, /**< the current context */ @@ -120,7 +120,7 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, /**< a json-token desribing th ); /** - * signs a unsigned raw transaction and writes the raw data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. + * signs a unsigned raw transaction and writes the raw data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. */ in3_ret_t eth_sign_raw_tx(bytes_t raw_tx, /**< the unsigned raw transaction to sign */ in3_req_t* req, /**< the current context */ diff --git a/c/include/in3/eth_full.h b/c/include/in3/eth_full.h index 4c075107f..9bb84d1d7 100644 --- a/c/include/in3/eth_full.h +++ b/c/include/in3/eth_full.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER diff --git a/c/include/in3/eth_nano.h b/c/include/in3/eth_nano.h index a777f60e4..67956b134 100644 --- a/c/include/in3/eth_nano.h +++ b/c/include/in3/eth_nano.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER @@ -48,12 +48,12 @@ NONULL in3_ret_t in3_verify_eth_nano(void* p_data, in3_plugin_act_t action, void NONULL_FOR((1, 2)) in3_ret_t eth_verify_blockheader(in3_vctx_t* vc, bytes_t* header, bytes_t* expected_blockhash); -/** +/** * verifies a single signature blockheader. - * - * This function will return a positive integer with a bitmask holding the bit set according to the address that signed it. + * + * This function will return a positive integer with a bitmask holding the bit set according to the address that signed it. * This is based on the signatiures in the request-config. - * + * */ NONULL unsigned int eth_verify_signature(in3_vctx_t* vc, bytes_t* msg_hash, d_token_t* sig); @@ -74,7 +74,7 @@ NONULL in3_ret_t in3_register_eth_nano(in3_t* c); /** * helper function to rlp-encode the transaction_index. - * + * * The result must be freed after use! */ bytes_t* create_tx_path(uint32_t index); diff --git a/c/include/in3/ethereum_apdu_client.h b/c/include/in3/ethereum_apdu_client.h index 3b8eec3b0..5170bde8a 100644 --- a/c/include/in3/ethereum_apdu_client.h +++ b/c/include/in3/ethereum_apdu_client.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * this file defines the incubed configuration struct and it registration. - * - * + * + * * */ #ifndef in3_ledger_signer_eth_h__ @@ -50,15 +50,15 @@ extern "C" { /** * attaches ledger nano hardware wallet signer with incubed . - * + * * bip32 path to be given to point the specific public/private key in HD tree for Ethereum! */ in3_ret_t eth_ledger_set_signer_txn(in3_t* in3, uint8_t* bip_path); /** * returns public key at the bip_path . - * - * returns IN3_ENODEVICE error if ledger nano device is not connected + * + * returns IN3_ENODEVICE error if ledger nano device is not connected */ in3_ret_t eth_ledger_get_public_addr(uint8_t* i_bip_path, uint8_t* o_public_key); diff --git a/c/include/in3/in3_curl.h b/c/include/in3/in3_curl.h index 40a09f504..8c3424406 100644 --- a/c/include/in3/in3_curl.h +++ b/c/include/in3/in3_curl.h @@ -1,39 +1,39 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER -/** @file +/** @file * transport-handler using libcurl. */ @@ -48,7 +48,7 @@ extern "C" { /** * a transport function using curl. - * + * */ in3_ret_t send_curl(void* plugin_data, in3_plugin_act_t action, void* plugin_ctx); diff --git a/c/include/in3/in3_http.h b/c/include/in3/in3_http.h index 4c91017fe..8285f0401 100644 --- a/c/include/in3/in3_http.h +++ b/c/include/in3/in3_http.h @@ -1,39 +1,39 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER -/** @file +/** @file * transport-handler using simple http. */ @@ -49,9 +49,9 @@ extern "C" { /** * a very simple transport function, which allows to send http-requests without a dependency to curl. * Here each request will be transformed to http instead of https. - * + * * You can use it by setting the transport-function-pointer in the in3_t->transport to this function: - * + * * ```c * #include * ... diff --git a/c/include/in3/in3_init.h b/c/include/in3/in3_init.h index 56ea48c31..7d32fafa6 100644 --- a/c/include/in3/in3_init.h +++ b/c/include/in3/in3_init.h @@ -71,4 +71,4 @@ in3_t* in3_for_chain_auto_init(chain_id_t chain_id); } #endif -#endif //IN3_IN3_INIT_H +#endif // IN3_IN3_INIT_H diff --git a/c/include/in3/in3_winhttp.h b/c/include/in3/in3_winhttp.h index 43d0f502f..5e1244bfb 100644 --- a/c/include/in3/in3_winhttp.h +++ b/c/include/in3/in3_winhttp.h @@ -1,39 +1,39 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER -/** @file +/** @file * transport-handler using simple http. */ diff --git a/c/include/in3/ipfs_api.h b/c/include/in3/ipfs_api.h index 6c5c776cc..de56934ee 100644 --- a/c/include/in3/ipfs_api.h +++ b/c/include/in3/ipfs_api.h @@ -54,4 +54,4 @@ bytes_t* ipfs_get(in3_t* in3, const char* multihash); /**< Returns the content } #endif -#endif //IN3_IPFS_API_H +#endif // IN3_IPFS_API_H diff --git a/c/include/in3/ledger_signer.h b/c/include/in3/ledger_signer.h index bd65c0d76..6ec88cd36 100644 --- a/c/include/in3/ledger_signer.h +++ b/c/include/in3/ledger_signer.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * this file defines the incubed configuration struct and it registration. - * - * + * + * * */ #ifndef in3_ledger_signer_h__ @@ -50,15 +50,15 @@ extern "C" { /** * attaches ledger nano hardware wallet signer with incubed . - * + * * bip32 path to be given to point the specific public/private key in HD tree for Ethereum! */ in3_ret_t eth_ledger_set_signer(in3_t* in3, uint8_t* bip_path); /** * returns public key at the bip_path . - * - * returns IN3_ENODEVICE error if ledger nano device is not connected + * + * returns IN3_ENODEVICE error if ledger nano device is not connected */ in3_ret_t eth_ledger_get_public_key(uint8_t* bip_path, uint8_t* public_key); diff --git a/c/include/in3/log.h b/c/include/in3/log.h index 7457638fb..c6d12a845 100644 --- a/c/include/in3/log.h +++ b/c/include/in3/log.h @@ -75,8 +75,8 @@ typedef enum { LOG_TRACE, #endif /** - * in3_log_set_*() functions are not thread-safe. - * It is expected that these initialization functions will be called from the main thread before + * in3_log_set_*() functions are not thread-safe. + * It is expected that these initialization functions will be called from the main thread before * spawning more threads. */ void in3_log_set_udata_(void* udata); diff --git a/c/include/in3/mem.h b/c/include/in3/mem.h index 9ab43e032..38f344f2f 100644 --- a/c/include/in3/mem.h +++ b/c/include/in3/mem.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/include/in3/nodelist.h b/c/include/in3/nodelist.h index 1db00b740..67191f6cf 100644 --- a/c/include/in3/nodelist.h +++ b/c/include/in3/nodelist.h @@ -1,40 +1,40 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ /** * handles nodelists. - * + * * */ #include "client.h" @@ -78,8 +78,8 @@ typedef enum { ATTR_BOOT_NODE = 2, /**< used to avoid filtering manually added nodes before first nodeList update */ } in3_node_attr_type_t; -/** incubed node-configuration. - * +/** incubed node-configuration. + * * These information are read from the Registry contract and stored in this struct representing a server or node. */ typedef struct in3_node { @@ -95,7 +95,7 @@ typedef struct in3_node { /** * Weight or reputation of a node. - * + * * Based on the past performance of the node a weight is calculated given faster nodes a higher weight * and chance when selecting the next node from the nodelist. * These weights will also be stored in the cache (if available) @@ -197,7 +197,7 @@ NONULL void in3_client_run_chain_whitelisting(in3_nodeselect_def_t* data); #endif /** check if the nodelist is up to date. - * + * * if not it will fetch a new version first (if the needs_update-flag is set). */ NONULL in3_ret_t in3_node_list_get(in3_req_t* req, in3_nodeselect_def_t* data, bool update, in3_node_t** nodelist, unsigned int* nodelist_length, in3_node_weight_t** weights); diff --git a/c/include/in3/nodeselect_def.h b/c/include/in3/nodeselect_def.h index 5b1214e59..218c1c889 100644 --- a/c/include/in3/nodeselect_def.h +++ b/c/include/in3/nodeselect_def.h @@ -1,5 +1,5 @@ /** - * + * */ // @PUBLIC_HEADER #ifndef IN3_NODE_SELECT_DEF_H @@ -29,6 +29,6 @@ static inline in3_nodeselect_def_t* in3_nodeselect_def_data(in3_t* c) { */ in3_ret_t in3_register_nodeselect_def(in3_t* c); -#endif //NODESELECT_DEF +#endif // NODESELECT_DEF -#endif //IN3_NODE_SELECT_DEF_H +#endif // IN3_NODE_SELECT_DEF_H diff --git a/c/include/in3/plugin.h b/c/include/in3/plugin.h index 43dceb092..c9be20019 100644 --- a/c/include/in3/plugin.h +++ b/c/include/in3/plugin.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * this file defines the plugin-contexts - * - * + * + * * */ #ifndef PLUGIN_H @@ -105,8 +105,8 @@ typedef struct { } in3_rpc_handle_ctx_t; /** -* creates a response and returns a stringbuilder to add the result-data. -*/ + * creates a response and returns a stringbuilder to add the result-data. + */ NONULL sb_t* in3_rpc_handle_start(in3_rpc_handle_ctx_t* hctx); /** @@ -139,8 +139,8 @@ typedef struct in3_req_header { struct in3_req_header* next; /**< pointer to next header */ } in3_req_header_t; -/** request-object. - * +/** request-object. + * * represents a RPC-request */ typedef struct in3_http_request { @@ -279,13 +279,13 @@ typedef struct sign_prepare_ctx { /** type of the requested signature */ typedef enum { - SIGN_EC_RAW = 0, /**< sign the data directly */ - SIGN_EC_HASH = 1, /**< hash and sign the data */ + SIGN_EC_RAW = 0, /**< sign the data directly */ + SIGN_EC_HASH = 1, /**< hash and sign the data */ SIGN_EC_PREFIX = 2, /**< add Ethereum Signed Message-Proefix, hash and sign the data */ } d_signature_type_t; /** - * signing context. This Context is passed to the signer-function. + * signing context. This Context is passed to the signer-function. */ typedef struct sign_ctx { bytes_t signature; /**< the resulting signature */ @@ -347,7 +347,7 @@ typedef struct in3_get_config_ctx { } in3_get_config_ctx_t; // -------- CACHE --------- -/** +/** * storage handler function for reading from cache. * @returns the found result. if the key is found this function should return the values as bytes otherwise `NULL`. **/ @@ -356,7 +356,7 @@ typedef bytes_t* (*in3_storage_get_item)( const char* key /**< the key to search in the cache */ ); -/** +/** * storage handler function for writing to the cache. **/ typedef void (*in3_storage_set_item)( @@ -424,7 +424,7 @@ NONULL #endif /* - * creates an error attaching it to the context and returns -1. + * creates an error attaching it to the context and returns -1. */ in3_ret_t vc_set_error( in3_vctx_t* vc, /**< the verification context. */ @@ -525,7 +525,29 @@ typedef struct { void* data; /**< output param set by plugin code - pointer to data requested. */ void (*cleanup)(void*); /**< output param set by plugin code - if not NULL use it to cleanup the data. */ } in3_get_data_ctx_t; + +/** + * raises a error during config by setting the error-message and returning a error-code. + */ +#define CNF_ERROR(msg) \ + { \ + ctx->error_msg = _strdupn(msg, -1); \ + return IN3_EINVAL; \ + } + +/** + * sets the bytes as taken from the given property to the target and raises an error if the len does not fit. + */ +#define CNF_SET_BYTES(dst, token, property, l) \ + { \ + const bytes_t tmp = d_to_bytes(d_get(token, key(property))); \ + if (tmp.data) { \ + if (tmp.len != l) CNF_ERROR(property " must be " #l " bytes") \ + memcpy(dst, tmp.data, l); \ + } \ + } + #ifdef __cplusplus } #endif -#endif //PLUGIN_H +#endif // PLUGIN_H diff --git a/c/include/in3/request.h b/c/include/in3/request.h index 6242f5661..1a367890d 100644 --- a/c/include/in3/request.h +++ b/c/include/in3/request.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -61,8 +61,8 @@ typedef enum ctx_type { } req_type_t; /** - * the weight of a certain node as linked list. - * + * the weight of a certain node as linked list. + * * This will be used when picking the nodes to send the request to. A linked list of these structs desribe the result. */ typedef struct weight { @@ -74,8 +74,8 @@ typedef struct weight { struct weight* next; /**< next in the linked-list or NULL if this is the last element*/ } node_match_t; -/** response-object. - * +/** response-object. + * * if the error has a length>0 the response will be rejected */ typedef struct in3_response { @@ -86,7 +86,7 @@ typedef struct in3_response { /** * The Request config. - * + * * This is generated for each request and represents the current state. it holds the state until the request is finished and must be freed afterwards. * */ typedef struct in3_req { @@ -111,7 +111,7 @@ typedef struct in3_req { /** * The current state of the context. - * + * * you can check this state after each execute-call. */ typedef enum state { @@ -121,24 +121,24 @@ typedef enum state { REQ_ERROR = -1, /**< the request has a error */ } in3_req_state_t; -/** +/** * creates a new request. - * + * * the request data will be parsed and represented in the context. * calling this function will only parse the request data, but not send anything yet. - * + * * *Important*: the req_data will not be cloned but used during the execution. The caller of the this function is also responsible for freeing this string afterwards. */ NONULL in3_req_t* req_new( in3_t* client, /**< [in] the client-config. */ const char* req_data /**< [in] the rpc-request as json string. */ ); -/** +/** * creates a new request but clones the request-data. - * + * * the request data will be parsed and represented in the context. * calling this function will only parse the request data, but not send anything yet. - * + * */ NONULL in3_req_t* req_new_clone( in3_t* client, /**< [in] the client-config. */ @@ -146,7 +146,7 @@ NONULL in3_req_t* req_new_clone( ); /** * sends a previously created request to nodes and verifies it. - * + * * The execution happens within the same thread, thich mean it will be blocked until the response ha beedn received and verified. * In order to handle calls asynchronously, you need to call the `in3_req_execute` function and provide the data as needed. */ @@ -169,49 +169,49 @@ NONULL in3_req_state_t in3_req_exec_state( ); /** * execute the context, but stops whenever data are required. - * - * This function should be used in order to call data in a asyncronous way, - * since this function will not use the transport-function to actually send it. - * + * + * This function should be used in order to call data in a asyncronous way, + * since this function will not use the transport-function to actually send it. + * * The caller is responsible for delivering the required responses. * After calling you need to check the return-value: * - IN3_WAITING : provide the required data and then call in3_req_execute again. * - IN3_OK : success, we have a result. * - any other status = error - * + * * ```rust,ignore * digraph G { node[fontname="Helvetica", shape=Box, color=lightblue, style=filled ] edge[fontname="Helvetica", style=solid, fontsize=8 , color=grey] rankdir = LR; - + RPC[label="RPC-Request"] CTX[label="in3_req_t"] - + sign[label="sign data",color=lightgrey, style=""] request[label="fetch data",color=lightgrey, style=""] - + exec[ label="in3_req_execute()",color=lightgrey, style="", shape=circle ] free[label="req_free()",color=lightgrey, style=""] RPC -> CTX [label="req_new()"] CTX -> exec - - + + exec -> error [label="IN3_..."] exec -> response[label="IN3_OK"] exec -> waiting[label="IN3_WAITING"] - + waiting -> sign[label=RT_SIGN] - waiting -> request[label=RT_RPC] - + waiting -> request[label=RT_RPC] + sign -> exec [label="in3_ctx_add_response()"] request -> exec[label="in3_ctx_add_response()"] - + response -> free error->free - + { rank = same; exec, sign, request } @@ -219,11 +219,11 @@ NONULL in3_req_state_t in3_req_exec_state( } * ``` - * + * * Here is a example how to use this function: - * + * * ```c - * + * in3_ret_t in3_send_req(in3_req_t* req) { in3_ret_t ret; // execute the context and store the return value. @@ -277,7 +277,7 @@ NONULL in3_req_state_t in3_req_exec_state( sb_init(&ctx->raw_response[0].error); sb_init(&ctx->raw_response[0].result); - // data for the signature + // data for the signature uint8_t sig[65]; // use the signer to create the signature ret = ctx->client->signer->sign(ctx, SIGN_EC_HASH, data, from, sig); @@ -293,10 +293,10 @@ NONULL in3_req_state_t in3_req_exec_state( return ret; } * ``` - * - * - * - * + * + * + * + * */ NONULL in3_ret_t in3_req_execute( in3_req_t* req /**< [in] the request context. */ @@ -337,7 +337,7 @@ NONULL req_type_t req_get_type( /** * frees all resources allocated during the request. - * + * * But this will not free the request string passed when creating the context! */ NONULL void req_free( @@ -345,13 +345,13 @@ NONULL void req_free( ); /** * adds a new context as a requirment. - * + * * Whenever a verifier needs more data and wants to send a request, we should create the request and add it as dependency and stop. - * + * * If the function is called again, we need to search and see if the required status is now useable. - * + * * Here is an example of how to use it: - * + * * ```c in3_ret_t get_from_nodes(in3_req_t* parent, char* method, char* params, bytes_t* dst) { // check if the method is already existing @@ -399,7 +399,7 @@ NONULL in3_ret_t req_add_required( ); /** * searches within the required request contextes for one with the given method. - * + * * This method is used internaly to find a previously added context. */ NONULL_FOR((1, 2)) @@ -433,11 +433,11 @@ NONULL in3_ret_t req_get_error( int id /**< [in] the index of the request to check (if this is a batch-request, otherwise 0). */ ); -/** - * sends a request and returns a context used to access the result or errors. - * +/** + * sends a request and returns a context used to access the result or errors. + * * This context *MUST* be freed with req_free(ctx) after usage to release the resources. -*/ + */ NONULL in3_req_t* in3_client_rpc_ctx_raw( in3_t* c, /**< [in] the client config. */ const char* request /**< [in] rpc request. */ @@ -447,7 +447,7 @@ NONULL in3_req_t* in3_client_rpc_ctx_raw( * sends a request and returns a context used to access the result or errors. * * This context *MUST* be freed with req_free(ctx) after usage to release the resources. -*/ + */ NONULL in3_req_t* in3_client_rpc_ctx( in3_t* c, /**< [in] the clientt config. */ const char* method, /**< [in] rpc method. */ diff --git a/c/include/in3/rpc.h b/c/include/in3/rpc.h index dae197c7f..97b4d7e97 100644 --- a/c/include/in3/rpc.h +++ b/c/include/in3/rpc.h @@ -1,39 +1,39 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER -/** +/** * Ethereum data structure verification. * */ diff --git a/c/include/in3/scache.h b/c/include/in3/scache.h index 6df98fa4b..ce8de3a4e 100644 --- a/c/include/in3/scache.h +++ b/c/include/in3/scache.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/include/in3/signer.h b/c/include/in3/signer.h index 1b9ad9d56..b7e5d4935 100644 --- a/c/include/in3/signer.h +++ b/c/include/in3/signer.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -65,7 +65,7 @@ typedef enum { /** * simply signer with one private key. - * + * * since the pk pointting to the 32 byte private key is not cloned, please make sure, you manage memory allocation correctly! */ in3_ret_t eth_set_pk_signer(in3_t* in3, bytes32_t pk); diff --git a/c/include/in3/stringbuilder.h b/c/include/in3/stringbuilder.h index ad75dd236..14880e864 100644 --- a/c/include/in3/stringbuilder.h +++ b/c/include/in3/stringbuilder.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -57,7 +57,7 @@ typedef unsigned long long uintmax_t; #endif /** - * string build struct, which is able to hold and modify a growing string. + * string build struct, which is able to hold and modify a growing string. */ typedef struct sb { char* data; /**< the current string (null terminated)*/ @@ -65,25 +65,25 @@ typedef struct sb { size_t len; /**< the current length of the string */ } sb_t; /** - * creates a stringbuilder which is allocating any new memory, but uses an existing string and is used directly on the stack. + * creates a stringbuilder which is allocating any new memory, but uses an existing string and is used directly on the stack. * Since it will not grow the memory you need to pass a char* which allocated enough memory. */ NONULL static inline sb_t sb_stack(char* p) { return (sb_t){.allocted = 0xffffff, .len = 0, .data = p}; } -sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ -NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ -NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ +sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ +NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ +NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ NONULL sb_t* sb_add_char(sb_t* sb, char c); /**< add a single character */ NONULL sb_t* sb_add_chars(sb_t* sb, const char* chars); /**< adds a string */ NONULL sb_t* sb_add_range(sb_t* sb, const char* chars, int start, int len); /**< add a string range */ NONULL sb_t* sb_add_key_value(sb_t* sb, const char* key, const char* value, int value_len, bool as_string); /**< adds a value with an optional key. if as_string is true the value will be quoted. */ NONULL_FOR((1, 3)) -sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ -NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ -NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ -NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ -NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ +sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ +NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ +NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ +NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ +NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ NONULL_FOR((1)) sb_t* sb_add_rawbytes(sb_t* sb, char* prefix, bytes_t b, int fix_size); sb_t* sb_print(sb_t* sb, const char* fmt, ...); diff --git a/c/include/in3/usn_api.h b/c/include/in3/usn_api.h index 4c7a3136e..eed57b56b 100644 --- a/c/include/in3/usn_api.h +++ b/c/include/in3/usn_api.h @@ -1,41 +1,41 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * USN API. - * + * * This header-file defines easy to use function, which are verifying USN-Messages. * */ diff --git a/c/include/in3/utils.h b/c/include/in3/utils.h index 328134038..73ef193d9 100644 --- a/c/include/in3/utils.h +++ b/c/include/in3/utils.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -120,7 +120,7 @@ const char* u64_to_str(uint64_t value, char* pBuf, int szBuf); /** * convert a c hex string to a byte array storing it into an existing buffer. - * + * * @param hexdata: the hex string * @param hexlen: the len of the string to read. -1 will use strlen to determine the length. * @param out: the byte buffer @@ -153,14 +153,14 @@ int min_bytes_len(uint64_t val); /** * sets a variable value to 32byte word. * @param src The src data - * @param src_len the number of bytes + * @param src_len the number of bytes * @param dst target pointer */ void uint256_set(const uint8_t* src, wlen_t src_len, bytes32_t dst); /** * replaces a string and returns a copy. - * @retval + * @retval */ char* str_replace(char* orig, const char* rep, const char* with); @@ -170,8 +170,8 @@ char* str_replace(char* orig, const char* rep, const char* with); char* str_replace_pos(char* orig, size_t pos, size_t len, const char* rep); /** - * lightweight strstr() replacements - */ + * lightweight strstr() replacements + */ char* str_find(char* haystack, const char* needle); /** @@ -180,7 +180,7 @@ char* str_find(char* haystack, const char* needle); char* str_remove_html(char* data); /** - * current timestamp in ms. + * current timestamp in ms. */ uint64_t current_ms(); @@ -192,8 +192,8 @@ uint64_t current_ms(); } /** - * executes the expression and expects the return value to be a int indicating the error. - * if the return value is negative it will stop and return this value otherwise continue. + * executes the expression and expects the return value to be a int indicating the error. + * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY(exp) \ { \ @@ -202,8 +202,8 @@ uint64_t current_ms(); } /** - * executes the expression and expects the return value to be a int indicating the error. - * if the return value is negative it will stop and return this value otherwise continue. + * executes the expression and expects the return value to be a int indicating the error. + * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY_FINAL(exp, final) \ { \ @@ -213,7 +213,7 @@ uint64_t current_ms(); } /** - * executes the expression and expects the return value to be a int indicating the error. + * executes the expression and expects the return value to be a int indicating the error. * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY_CATCH(exp, catch) \ @@ -231,16 +231,16 @@ uint64_t current_ms(); #define CONFIG_KEY(name) key(name) /** - * executes the expression and expects value to equal val. + * executes the expression and expects value to equal val. * if not it will return IN3_EINVAL */ #define EXPECT_EQ(exp, val) \ if ((exp) != val) return IN3_EINVAL; /** - * executes the expression and expects the return value to be a int indicating the error. + * executes the expression and expects the return value to be a int indicating the error. * the return value will be set to a existing variable (var). - * if the return value is negative it will stop and return this value otherwise continue. + * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY_SET(var, exp) \ { \ @@ -249,7 +249,7 @@ uint64_t current_ms(); } /** - * executes the expression and expects the return value to be a int indicating the error. + * executes the expression and expects the return value to be a int indicating the error. * if the return value is negative it will stop and jump (goto) to a marked position "clean". * it also expects a previously declared variable "in3_ret_t res". */ diff --git a/c/include/in3/zksync.h b/c/include/in3/zksync.h index 660b1a342..7d4855642 100644 --- a/c/include/in3/zksync.h +++ b/c/include/in3/zksync.h @@ -1,41 +1,41 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2019 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * ZKSync API. - * + * * This header-file registers zksync api functions. * */ @@ -106,6 +106,7 @@ struct pay_criteria; /** internal configuration-object */ typedef struct zksync_config { char* provider_url; /**< url of the zksync-server */ + char* rest_api; /**< url of the zksync-rest-api */ uint8_t* account; /**< address of the account */ uint8_t* main_contract; /**< address of the main zksync contract*/ uint8_t* gov_contract; /**< address of the government contract */ @@ -182,6 +183,8 @@ in3_ret_t zksync_check_payment(zksync_config_t* conf, in3_pay_followup in3_ret_t zksync_add_payload(in3_pay_payload_ctx_t* ctx); in3_ret_t update_nodelist_from_cache(in3_req_t* req, unsigned int nodelen); in3_ret_t handle_zksync(void* conf, in3_plugin_act_t action, void* arg); +in3_ret_t zksync_tx_data(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx); +in3_ret_t zksync_account_history(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx); #ifdef __cplusplus } #endif diff --git a/c/src/api/btc/btc_api.c b/c/src/api/btc/btc_api.c index 45ad75050..3b8f808d0 100644 --- a/c/src/api/btc/btc_api.c +++ b/c/src/api/btc/btc_api.c @@ -40,8 +40,8 @@ #include "../utils/api_utils_priv.h" /** - * executes the expression and expects the return value to be a int indicating the error. - * if the return value is negative it will stop and return this value otherwise continue. + * executes the expression and expects the return value to be a int indicating the error. + * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY_OR_NULL(exp, msg) \ { \ diff --git a/c/src/api/btc/btc_api.h b/c/src/api/btc/btc_api.h index 6bcc825f3..3baeb366a 100644 --- a/c/src/api/btc/btc_api.h +++ b/c/src/api/btc/btc_api.h @@ -120,7 +120,7 @@ typedef struct btc_block_txids { bytes32_t* tx; /**< array of transaction ids */ } btc_block_txids_t; -/** +/** * gets the transaction as raw bytes or null if it does not exist. * You must free the result with b_free() after use! */ @@ -128,7 +128,7 @@ bytes_t* btc_get_transaction_bytes(in3_t* in3, /**< the in3-instance*/ bytes32_t txid /**< the txid */ ); -/** +/** * gets the transaction as struct or null if it does not exist. * You must free the result with free() after use! */ @@ -136,7 +136,7 @@ btc_transaction_t* btc_get_transaction(in3_t* in3, /**< the in3-instance*/ bytes32_t txid /**< the txid */ ); -/** +/** * gets the blockheader as struct or null if it does not exist. * You must free the result with free() after use! */ @@ -144,7 +144,7 @@ btc_blockheader_t* btc_get_blockheader(in3_t* in3, /**< the in3-instance bytes32_t blockhash /**< the block hash */ ); -/** +/** * gets the blockheader as raw serialized data (80 bytes) or null if it does not exist. * You must free the result with b_free() after use! */ @@ -152,7 +152,7 @@ bytes_t* btc_get_blockheader_bytes(in3_t* in3, /**< the in3-instance*/ bytes32_t blockhash /**< the block hash */ ); -/** +/** * gets the block as struct including all transaction data or null if it does not exist. * You must free the result with free() after use! */ @@ -160,7 +160,7 @@ btc_block_txdata_t* btc_get_block_txdata(in3_t* in3, /**< the in3-instan bytes32_t blockhash /**< the block hash */ ); -/** +/** * gets the block as struct including all transaction ids or null if it does not exist. * You must free the result with free() after use! */ @@ -168,7 +168,7 @@ btc_block_txids_t* btc_get_block_txids(in3_t* in3, /**< the in3-instance bytes32_t blockhash /**< the block hash */ ); -/** +/** * gets the block as raw serialized block bytes including all transactions or null if it does not exist. * You must free the result with b_free() after use! */ @@ -188,4 +188,4 @@ btc_block_txdata_t* btc_d_to_block_txdata(d_token_t* t); /** Deserializes a `btc } #endif -#endif //IN3_BTC_API_H +#endif // IN3_BTC_API_H diff --git a/c/src/api/core/core_api.c b/c/src/api/core/core_api.c index 55111d0a7..8fa3546fd 100644 --- a/c/src/api/core/core_api.c +++ b/c/src/api/core/core_api.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/api/core/core_api.h b/c/src/api/core/core_api.h index a281b4598..b422c5cb1 100644 --- a/c/src/api/core/core_api.h +++ b/c/src/api/core/core_api.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * Ethereum API. - * - * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. + * + * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. * */ #ifndef CORE_API_H diff --git a/c/src/api/eth1/abi.h b/c/src/api/eth1/abi.h index 114be8ad4..702ae70ef 100644 --- a/c/src/api/eth1/abi.h +++ b/c/src/api/eth1/abi.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -51,7 +51,7 @@ typedef enum { ABI_ARRAY = 9 /**< a dynamic or fixed size array of elements */ } abi_coder_type_t; -/** +/** * a coder configuration for a specific type. * Depending on the type the config is stored in the union-structs. */ @@ -101,9 +101,9 @@ void abi_sig_free( /** * parses a ABI signature string and creates the a pointer to the struct, which can be used to encode and decode date - * + * * The signature string may contain either just a comma separated list of valid solidity types: - * + * * ```c * "address" // single type * "address,uint,bool" // tuple @@ -112,19 +112,19 @@ void abi_sig_free( * "uint[4]" // fixed array * "(uint,bool)[]" // dynamic array of a tuple * ``` - * + * * Optionaly a function name can be prefixed, which will be used when creating the functionhash: * ```c * "execTransaction(bytes,uint,uint)" * ``` - * + * * Optionally a return type can be added which is used when decoding the value: - * + * * ```c * "isValidSAignature(bytes,bytes):(bytes4)" // return the single type as array with one value * "isValidSAignature(bytes,bytes):bytes4" // return the single type as single value * ``` - * + * */ abi_sig_t* abi_sig_create( char* signature, /**< the abi signature */ @@ -140,7 +140,7 @@ bool abi_is_dynamic( /** * encodes JSON-data to bytes. - * The resulting bytes data-field MUST be freed if not NULL! + * The resulting bytes data-field MUST be freed if not NULL! */ bytes_t abi_encode( abi_sig_t* s, /**< the signature to use */ @@ -149,9 +149,9 @@ bytes_t abi_encode( ); /** - * decodes bytes to a JSON-structure. - * The resulting json_ctx MUST be freed using `json_free` if not NULL. - */ + * decodes bytes to a JSON-structure. + * The resulting json_ctx MUST be freed using `json_free` if not NULL. + */ json_ctx_t* abi_decode( abi_sig_t* s, /**< the signature to use */ bytes_t data, /**< the data to decode */ @@ -160,9 +160,9 @@ json_ctx_t* abi_decode( ); /** - * decodes bytes to a JSON-structure. - * The resulting json_ctx MUST be freed using `json_free` if not NULL. - */ + * decodes bytes to a JSON-structure. + * The resulting json_ctx MUST be freed using `json_free` if not NULL. + */ json_ctx_t* abi_decode_event( abi_sig_t* s, /**< the signature to use */ bytes_t topics, /**< the topics to decode */ diff --git a/c/src/api/eth1/abi_decode.c b/c/src/api/eth1/abi_decode.c index b40edeb08..bd6064cdf 100644 --- a/c/src/api/eth1/abi_decode.c +++ b/c/src/api/eth1/abi_decode.c @@ -69,7 +69,7 @@ static in3_ret_t decode_value(abi_coder_t* c, bytes_t data, json_ctx_t* res, int memset(word, 0xff, 32 - b); // fill all bytes with ff so we can use uint64_t int64_t val = (int64_t) bytes_to_long(word + 24, 8); // take the value and convert to a signed char tmp[24]; // - json_create_string(res, tmp, sprintf(tmp, "%" PRId64, val)); //format the signed as string + json_create_string(res, tmp, sprintf(tmp, "%" PRId64, val)); // format the signed as string } else json_create_int(res, bytes_to_long(word + 24, 8)); diff --git a/c/src/api/eth1/ens.c b/c/src/api/eth1/ens.c index 7ddd05278..4ca0cfec0 100644 --- a/c/src/api/eth1/ens.c +++ b/c/src/api/eth1/ens.c @@ -81,7 +81,7 @@ in3_ret_t ens_resolve(in3_req_t* parent, char* name, const address_t registry, i char* cachekey = NULL; bytes_t dst_bytes = bytes(dst, *res_len); - //check cache + // check cache if (in3_plugin_is_registered(parent->client, PLGN_ACT_CACHE)) { cachekey = alloca(strlen(name) + 5); sprintf(cachekey, "ens:%s:%i:%d", name, type, (int) parent->client->chain.chain_id); diff --git a/c/src/api/eth1/ens.h b/c/src/api/eth1/ens.h index 4b631fc1b..4c386f143 100644 --- a/c/src/api/eth1/ens.h +++ b/c/src/api/eth1/ens.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/api/eth1/eth_api.c b/c/src/api/eth1/eth_api.c index 576458e4c..13ebc196d 100644 --- a/c/src/api/eth1/eth_api.c +++ b/c/src/api/eth1/eth_api.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -134,12 +134,12 @@ static uint32_t write_tx(d_token_t* t, eth_tx_t* tx) { /** calculate the tx size as struct+data */ static uint32_t get_tx_size(d_token_t* tx) { return align(d_to_bytes(d_get(tx, K_INPUT)).len) + sizeof(eth_tx_t); } -/** +/** * allocates memory for the block and all required lists like the transactions and copies the data. - * + * * this allocates more memory than just the block-struct, but does it with one malloc! * so the structure looksm like this: - * + * * struct { * eth_block_t block; * uint8_t[] extra_data; diff --git a/c/src/api/eth1/eth_api.h b/c/src/api/eth1/eth_api.h index 56855fbea..6ea44fe75 100644 --- a/c/src/api/eth1/eth_api.h +++ b/c/src/api/eth1/eth_api.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * Ethereum API. - * - * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. + * + * This header-file defines easy to use function, which are preparing the JSON-RPC-Request, which is then executed and verified by the incubed-client. * */ #ifndef ETH_API_H diff --git a/c/src/api/eth1/key.c b/c/src/api/eth1/key.c index c86cbd720..eb07779f0 100644 --- a/c/src/api/eth1/key.c +++ b/c/src/api/eth1/key.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/api/eth1/rpc_api.c b/c/src/api/eth1/rpc_api.c index 7ca45855f..a71844e27 100644 --- a/c/src/api/eth1/rpc_api.c +++ b/c/src/api/eth1/rpc_api.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/api/ipfs/ipfs_api.h b/c/src/api/ipfs/ipfs_api.h index dd89b9a89..44530683d 100644 --- a/c/src/api/ipfs/ipfs_api.h +++ b/c/src/api/ipfs/ipfs_api.h @@ -54,4 +54,4 @@ bytes_t* ipfs_get(in3_t* in3, const char* multihash); /**< Returns the content } #endif -#endif //IN3_IPFS_API_H +#endif // IN3_IPFS_API_H diff --git a/c/src/api/usn/usn_api.c b/c/src/api/usn/usn_api.c index 6e16d4218..57be4dc89 100644 --- a/c/src/api/usn/usn_api.c +++ b/c/src/api/usn/usn_api.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #include "usn_api.h" diff --git a/c/src/api/usn/usn_api.h b/c/src/api/usn/usn_api.h index 1f3907b1b..3efe078a4 100644 --- a/c/src/api/usn/usn_api.h +++ b/c/src/api/usn/usn_api.h @@ -1,41 +1,41 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * USN API. - * + * * This header-file defines easy to use function, which are verifying USN-Messages. * */ diff --git a/c/src/api/utils/api_utils.h b/c/src/api/utils/api_utils.h index 39fafd159..aef92bf64 100644 --- a/c/src/api/utils/api_utils.h +++ b/c/src/api/utils/api_utils.h @@ -50,7 +50,7 @@ extern "C" { * a 32 byte long integer used to store ethereum-numbers. * * use the as_long() or as_double() to convert this to a useable number. -*/ + */ typedef struct { uint8_t data[32]; } uint256_t; @@ -84,4 +84,4 @@ char* api_last_error(); } #endif -#endif //IN3_API_UTILS_H +#endif // IN3_API_UTILS_H diff --git a/c/src/api/utils/api_utils_priv.h b/c/src/api/utils/api_utils_priv.h index e2c81df8d..886f973d9 100644 --- a/c/src/api/utils/api_utils_priv.h +++ b/c/src/api/utils/api_utils_priv.h @@ -91,4 +91,4 @@ void api_set_error(int err, const char* msg); /** returns the result from a previously executed ctx */ d_token_t* get_result(in3_req_t* req); -#endif //IN3_API_UTILS_PRIV_H +#endif // IN3_API_UTILS_PRIV_H diff --git a/c/src/cmd/http-server/http_server.c b/c/src/cmd/http-server/http_server.c index 671393550..16e00e7bc 100644 --- a/c/src/cmd/http-server/http_server.c +++ b/c/src/cmd/http-server/http_server.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -150,7 +150,7 @@ static void error_response(char* message, int error_code) { printf("HTTP/1.1 200\r\nContent-Type: application/json; charset=utf-8\r\nContent-Length: %lu\r\n\r\n%s\r\n", strlen(payload), payload); } -//client connection +// client connection void* respond(void* arg) { req_t* r = arg; char* buf = malloc(65535); @@ -190,7 +190,7 @@ void* respond(void* arg) { memcpy(params, range.data + 1, range.len - 2); params[range.len - 2] = 0; } - fprintf(stderr, "RPC %s %s\n", d_get_string(req->requests[0], K_METHOD), params); //conceal typing and save position + fprintf(stderr, "RPC %s %s\n", d_get_string(req->requests[0], K_METHOD), params); // conceal typing and save position if (in3_send_req(req) == IN3_OK) { // the request was succesfull, so we delete interim errors (which can happen in case in3 had to retry) if (req->error) _free(req->error); @@ -228,8 +228,8 @@ void* respond(void* arg) { close(STDOUT_FILENO); } - //Closing SOCKET - shutdown(r->con, SHUT_RDWR); //All further send and recieve operations are DISABLED... + // Closing SOCKET + shutdown(r->con, SHUT_RDWR); // All further send and recieve operations are DISABLED... close(r->con); #ifdef THREADSAFE _free(r); @@ -311,7 +311,7 @@ void http_run_server(const char* port, in3_t* in3, char* allowed_methods) { } #else - clients[s] = accept(listenfd, (struct sockaddr*) &clientaddr, &addrlen); + clients[s] = accept(listenfd, (struct sockaddr*) &clientaddr, &addrlen); if (clients[s] < 0) { perror("accept() error"); diff --git a/c/src/cmd/http-server/http_server.h b/c/src/cmd/http-server/http_server.h index 906ea9a0b..59fa1943f 100644 --- a/c/src/cmd/http-server/http_server.h +++ b/c/src/cmd/http-server/http_server.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/cmd/in3/helper.c b/c/src/cmd/in3/helper.c index 7128dc6f0..bdc879dd0 100644 --- a/c/src/cmd/in3/helper.c +++ b/c/src/cmd/in3/helper.c @@ -1,38 +1,38 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * simple commandline-util sending in3-requests. * */ #include "helper.h" @@ -70,17 +70,17 @@ const char* get_help_args() { // helper to read the password from tty void read_pass(char* pw, int pwsize) { int i = 0, ch = 0; - recorder_print(1, COLORT_HIDDEN); //conceal typing and save position + recorder_print(1, COLORT_HIDDEN); // conceal typing and save position while (true) { ch = getchar(); - if (ch == '\r' || ch == '\n' || ch == EOF) break; //get characters until CR or NL - if (i < pwsize - 1) { //do not save pw longer than space in pw - pw[i] = ch; //longer pw can be entered but excess is ignored + if (ch == '\r' || ch == '\n' || ch == EOF) break; // get characters until CR or NL + if (i < pwsize - 1) { // do not save pw longer than space in pw + pw[i] = ch; // longer pw can be entered but excess is ignored pw[i + 1] = 0; } i++; } - recorder_print(1, COLORT_RESETHIDDEN); //reveal typing + recorder_print(1, COLORT_RESETHIDDEN); // reveal typing } static bool is_number(char* val) { @@ -103,7 +103,7 @@ void configure_opt(in3_t* c, char* name, char* value, int argc, char** argv) { while (p) { char* next = strtok(NULL, "."); if (!next) { - if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0 || is_number(value) || *value=='{' || *value=='[') + if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0 || is_number(value) || *value == '{' || *value == '[') sb_print(&sb, "\"%s\":%s", p, value); else sb_print(&sb, "\"%s\":\"%s\"", p, value); diff --git a/c/src/cmd/in3/in3_storage.c b/c/src/cmd/in3/in3_storage.c index d1edb2393..7fdb263e0 100644 --- a/c/src/cmd/in3/in3_storage.c +++ b/c/src/cmd/in3/in3_storage.c @@ -2,34 +2,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/cmd/in3/in3_storage.h b/c/src/cmd/in3/in3_storage.h index 04b4e256f..5b6542c9a 100644 --- a/c/src/cmd/in3/in3_storage.h +++ b/c/src/cmd/in3/in3_storage.h @@ -1,38 +1,38 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** +/** * storage handler storing cache in the home-dir/.in3 */ diff --git a/c/src/cmd/in3/tx.c b/c/src/cmd/in3/tx.c index 4220264f0..504310189 100644 --- a/c/src/cmd/in3/tx.c +++ b/c/src/cmd/in3/tx.c @@ -14,7 +14,7 @@ static abi_sig_t* prepare_tx(char* fn_sig, char* to, sb_t* args, char* block_num if (error) die(error); // parse-error we stop here. if (req) { // if type is a tuple, it means we have areuments we need to parse. json_ctx_t* in_data = parse_json(args->data); // the args are passed as a "[]"- json-array string. - rdata = abi_encode(req, in_data->result, &error); //encode data + rdata = abi_encode(req, in_data->result, &error); // encode data if (error) die(error); // we then set the data, which appends the arguments to the functionhash. json_free(in_data); // of course we clean up ;-) } // diff --git a/c/src/cmd/tools/data.c b/c/src/cmd/tools/data.c index 768c9d9fa..9af9cb8f7 100644 --- a/c/src/cmd/tools/data.c +++ b/c/src/cmd/tools/data.c @@ -1,38 +1,38 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * simple commandline-util parsing json and creating bin * */ diff --git a/c/src/cmd/tools/rlp.c b/c/src/cmd/tools/rlp.c index d4519ec81..f90606efc 100644 --- a/c/src/cmd/tools/rlp.c +++ b/c/src/cmd/tools/rlp.c @@ -1,38 +1,38 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * simple commandline-util parsing json and creating bin * */ diff --git a/c/src/core/client/client.c b/c/src/core/client/client.c index 73c00f0e0..ff217be7c 100644 --- a/c/src/core/client/client.c +++ b/c/src/core/client/client.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -333,7 +333,7 @@ uint32_t in3_get_request_timeout( return request->req->client->timeout; } -/** +/** * storage handler to handle cache. **/ typedef struct in3_storage_handler { diff --git a/c/src/core/client/client.h b/c/src/core/client/client.h index 9bd06d68c..3264cddc9 100644 --- a/c/src/core/client/client.h +++ b/c/src/core/client/client.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * this file defines the incubed configuration struct and it registration. - * - * + * + * * */ #ifndef CLIENT_H @@ -57,21 +57,21 @@ extern "C" { #define IN3_PROTO_VER "2.1.0" /**< the protocol version used when sending requests from the this client */ -#define CHAIN_ID_MAINNET 0x01 /**< chain_id for mainnet */ -#define CHAIN_ID_GOERLI 0x5 /**< chain_id for goerlii */ -#define CHAIN_ID_EWC 0xf6 /**< chain_id for ewc */ +#define CHAIN_ID_MAINNET 0x01 /**< chain_id for mainnet */ +#define CHAIN_ID_GOERLI 0x5 /**< chain_id for goerlii */ +#define CHAIN_ID_EWC 0xf6 /**< chain_id for ewc */ #define CHAIN_ID_IPFS 0x7d0 /**< chain_id for ipfs */ -#define CHAIN_ID_BTC 0x99 /**< chain_id for btc */ -#define CHAIN_ID_LOCAL 0x11 /**< chain_id for local chain */ -#define DEF_REPL_LATEST_BLK 6 /**< default replace_latest_block */ +#define CHAIN_ID_BTC 0x99 /**< chain_id for btc */ +#define CHAIN_ID_LOCAL 0x11 /**< chain_id for local chain */ +#define DEF_REPL_LATEST_BLK 6 /**< default replace_latest_block */ /** * type for a chain_id. */ typedef uint32_t chain_id_t; -/** the type of the chain. - * +/** the type of the chain. + * * for incubed a chain can be any distributed network or database with incubed support. * Depending on this chain-type the previously registered verifier will be chosen and used. */ @@ -86,9 +86,9 @@ typedef enum { } in3_chain_type_t; /** the type of proof. - * + * * Depending on the proof-type different levels of proof will be requested from the node. -*/ + */ typedef enum { PROOF_NONE = 0, /**< No Verification */ PROOF_STANDARD = 1, /**< Standard Verification of the important properties */ @@ -124,7 +124,7 @@ typedef struct in3_verified_hash { /** * Chain definition inside incubed. - * + * * for incubed a chain can be any distributed network or database with incubed support. */ typedef struct in3_chain { @@ -198,9 +198,9 @@ struct in3_plugin { }; /** Incubed Configuration. - * + * * This struct holds the configuration and also point to internal resources such as filters or chain configs. - * + * */ typedef struct in3_t_ { uint8_t signature_count; /**< the number of signatures used to proof the blockhash. */ @@ -221,27 +221,27 @@ typedef struct in3_t_ { } in3_t; /** creates a new Incubed configuration for a specified chain and returns the pointer. - * when creating the client only the one chain will be configured. (saves memory). - * but if you pass `CHAIN_ID_MULTICHAIN` as argument all known chains will be configured allowing you to switch between chains within the same client or configuring your own chain. - * + * when creating the client only the one chain will be configured. (saves memory). + * but if you pass `CHAIN_ID_MULTICHAIN` as argument all known chains will be configured allowing you to switch between chains within the same client or configuring your own chain. + * * you need to free this instance with `in3_free` after use! - * + * * Before using the client you still need to set the transport and optional the storage handlers: - * + * * * example of initialization: * ```c * // register verifiers * in3_register_eth_full(); - * + * * // create new client * in3_t* client = in3_for_chain(CHAIN_ID_MAINNET); - * + * * // configure transport * client->transport = send_curl; * * // configure storage * in3_set_storage_handler(c, storage_get_item, storage_set_item, storage_clear, NULL); - * + * * // ready to use ... * ``` * @@ -268,9 +268,9 @@ NONULL in3_ret_t in3_client_rpc_raw( char** result, /**< [in] pointer to string which will be set if the request was successful. This will hold the result as json-rpc-string. (make sure you free this after use!) */ char** error /**< [in] pointer to a string containing the error-message. (make sure you free it after use!) */); -/** executes a request and returns result as string. in case of an error, the error-property of the result will be set. +/** executes a request and returns result as string. in case of an error, the error-property of the result will be set. * This function also supports sending bulk-requests, but you can not mix internal and external calls, since bulk means all requests will be send to picked nodes. - * The resulting string must be free by the the caller of this function! + * The resulting string must be free by the the caller of this function! */ NONULL char* in3_client_exec_req( in3_t* c, /**< [in] the pointer to the incubed client config. */ @@ -291,7 +291,7 @@ NONULL void in3_free(in3_t* a /**< [in] the pointer to the incubed client config /** * configures the client based on a json-config. - * + * * For details about the structure of the config see https://in3.readthedocs.io/en/develop/api-ts.html#type-in3config * Returns NULL on success, and error string on failure (to be freed by caller) - in which case the client state is undefined */ @@ -302,7 +302,7 @@ NONULL char* in3_configure( /** * gets the current config as json. - * + * * For details about the structure of the config see https://in3.readthedocs.io/en/develop/api-ts.html#type-in3config */ NONULL char* in3_get_config( diff --git a/c/src/core/client/client_init.c b/c/src/core/client/client_init.c index 2fdfb7bea..9f8df7aa4 100644 --- a/c/src/core/client/client_init.c +++ b/c/src/core/client/client_init.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/client/execute.c b/c/src/core/client/execute.c index 39eac1b6f..ad945ac0d 100644 --- a/c/src/core/client/execute.c +++ b/c/src/core/client/execute.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/client/keys.h b/c/src/core/client/keys.h index 56e88ed58..1e7ecdb7a 100644 --- a/c/src/core/client/keys.h +++ b/c/src/core/client/keys.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/client/plugin.h b/c/src/core/client/plugin.h index 4474b88a0..c9be20019 100644 --- a/c/src/core/client/plugin.h +++ b/c/src/core/client/plugin.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * this file defines the plugin-contexts - * - * + * + * * */ #ifndef PLUGIN_H @@ -105,8 +105,8 @@ typedef struct { } in3_rpc_handle_ctx_t; /** -* creates a response and returns a stringbuilder to add the result-data. -*/ + * creates a response and returns a stringbuilder to add the result-data. + */ NONULL sb_t* in3_rpc_handle_start(in3_rpc_handle_ctx_t* hctx); /** @@ -139,8 +139,8 @@ typedef struct in3_req_header { struct in3_req_header* next; /**< pointer to next header */ } in3_req_header_t; -/** request-object. - * +/** request-object. + * * represents a RPC-request */ typedef struct in3_http_request { @@ -285,7 +285,7 @@ typedef enum { } d_signature_type_t; /** - * signing context. This Context is passed to the signer-function. + * signing context. This Context is passed to the signer-function. */ typedef struct sign_ctx { bytes_t signature; /**< the resulting signature */ @@ -347,7 +347,7 @@ typedef struct in3_get_config_ctx { } in3_get_config_ctx_t; // -------- CACHE --------- -/** +/** * storage handler function for reading from cache. * @returns the found result. if the key is found this function should return the values as bytes otherwise `NULL`. **/ @@ -356,7 +356,7 @@ typedef bytes_t* (*in3_storage_get_item)( const char* key /**< the key to search in the cache */ ); -/** +/** * storage handler function for writing to the cache. **/ typedef void (*in3_storage_set_item)( @@ -424,7 +424,7 @@ NONULL #endif /* - * creates an error attaching it to the context and returns -1. + * creates an error attaching it to the context and returns -1. */ in3_ret_t vc_set_error( in3_vctx_t* vc, /**< the verification context. */ @@ -526,8 +526,6 @@ typedef struct { void (*cleanup)(void*); /**< output param set by plugin code - if not NULL use it to cleanup the data. */ } in3_get_data_ctx_t; - - /** * raises a error during config by setting the error-message and returning a error-code. */ @@ -549,10 +547,7 @@ typedef struct { } \ } - - - #ifdef __cplusplus } #endif -#endif //PLUGIN_H +#endif // PLUGIN_H diff --git a/c/src/core/client/request.c b/c/src/core/client/request.c index 5b3398fa8..00c4bff92 100644 --- a/c/src/core/client/request.c +++ b/c/src/core/client/request.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/client/request.h b/c/src/core/client/request.h index 4436b4c06..5d1fec423 100644 --- a/c/src/core/client/request.h +++ b/c/src/core/client/request.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -61,8 +61,8 @@ typedef enum ctx_type { } req_type_t; /** - * the weight of a certain node as linked list. - * + * the weight of a certain node as linked list. + * * This will be used when picking the nodes to send the request to. A linked list of these structs desribe the result. */ typedef struct weight { @@ -74,8 +74,8 @@ typedef struct weight { struct weight* next; /**< next in the linked-list or NULL if this is the last element*/ } node_match_t; -/** response-object. - * +/** response-object. + * * if the error has a length>0 the response will be rejected */ typedef struct in3_response { @@ -86,7 +86,7 @@ typedef struct in3_response { /** * The Request config. - * + * * This is generated for each request and represents the current state. it holds the state until the request is finished and must be freed afterwards. * */ typedef struct in3_req { @@ -111,7 +111,7 @@ typedef struct in3_req { /** * The current state of the context. - * + * * you can check this state after each execute-call. */ typedef enum state { @@ -121,24 +121,24 @@ typedef enum state { REQ_ERROR = -1, /**< the request has a error */ } in3_req_state_t; -/** +/** * creates a new request. - * + * * the request data will be parsed and represented in the context. * calling this function will only parse the request data, but not send anything yet. - * + * * *Important*: the req_data will not be cloned but used during the execution. The caller of the this function is also responsible for freeing this string afterwards. */ NONULL in3_req_t* req_new( in3_t* client, /**< [in] the client-config. */ const char* req_data /**< [in] the rpc-request as json string. */ ); -/** +/** * creates a new request but clones the request-data. - * + * * the request data will be parsed and represented in the context. * calling this function will only parse the request data, but not send anything yet. - * + * */ NONULL in3_req_t* req_new_clone( in3_t* client, /**< [in] the client-config. */ @@ -146,7 +146,7 @@ NONULL in3_req_t* req_new_clone( ); /** * sends a previously created request to nodes and verifies it. - * + * * The execution happens within the same thread, thich mean it will be blocked until the response ha beedn received and verified. * In order to handle calls asynchronously, you need to call the `in3_req_execute` function and provide the data as needed. */ @@ -169,49 +169,49 @@ NONULL in3_req_state_t in3_req_exec_state( ); /** * execute the context, but stops whenever data are required. - * - * This function should be used in order to call data in a asyncronous way, - * since this function will not use the transport-function to actually send it. - * + * + * This function should be used in order to call data in a asyncronous way, + * since this function will not use the transport-function to actually send it. + * * The caller is responsible for delivering the required responses. * After calling you need to check the return-value: * - IN3_WAITING : provide the required data and then call in3_req_execute again. * - IN3_OK : success, we have a result. * - any other status = error - * + * * ```rust,ignore * digraph G { node[fontname="Helvetica", shape=Box, color=lightblue, style=filled ] edge[fontname="Helvetica", style=solid, fontsize=8 , color=grey] rankdir = LR; - + RPC[label="RPC-Request"] CTX[label="in3_req_t"] - + sign[label="sign data",color=lightgrey, style=""] request[label="fetch data",color=lightgrey, style=""] - + exec[ label="in3_req_execute()",color=lightgrey, style="", shape=circle ] free[label="req_free()",color=lightgrey, style=""] RPC -> CTX [label="req_new()"] CTX -> exec - - + + exec -> error [label="IN3_..."] exec -> response[label="IN3_OK"] exec -> waiting[label="IN3_WAITING"] - + waiting -> sign[label=RT_SIGN] - waiting -> request[label=RT_RPC] - + waiting -> request[label=RT_RPC] + sign -> exec [label="in3_ctx_add_response()"] request -> exec[label="in3_ctx_add_response()"] - + response -> free error->free - + { rank = same; exec, sign, request } @@ -219,11 +219,11 @@ NONULL in3_req_state_t in3_req_exec_state( } * ``` - * + * * Here is a example how to use this function: - * + * * ```c - * + * in3_ret_t in3_send_req(in3_req_t* req) { in3_ret_t ret; // execute the context and store the return value. @@ -277,7 +277,7 @@ NONULL in3_req_state_t in3_req_exec_state( sb_init(&ctx->raw_response[0].error); sb_init(&ctx->raw_response[0].result); - // data for the signature + // data for the signature uint8_t sig[65]; // use the signer to create the signature ret = ctx->client->signer->sign(ctx, SIGN_EC_HASH, data, from, sig); @@ -293,10 +293,10 @@ NONULL in3_req_state_t in3_req_exec_state( return ret; } * ``` - * - * - * - * + * + * + * + * */ NONULL in3_ret_t in3_req_execute( in3_req_t* req /**< [in] the request context. */ @@ -337,7 +337,7 @@ NONULL req_type_t req_get_type( /** * frees all resources allocated during the request. - * + * * But this will not free the request string passed when creating the context! */ NONULL void req_free( @@ -345,13 +345,13 @@ NONULL void req_free( ); /** * adds a new context as a requirment. - * + * * Whenever a verifier needs more data and wants to send a request, we should create the request and add it as dependency and stop. - * + * * If the function is called again, we need to search and see if the required status is now useable. - * + * * Here is an example of how to use it: - * + * * ```c in3_ret_t get_from_nodes(in3_req_t* parent, char* method, char* params, bytes_t* dst) { // check if the method is already existing @@ -399,7 +399,7 @@ NONULL in3_ret_t req_add_required( ); /** * searches within the required request contextes for one with the given method. - * + * * This method is used internaly to find a previously added context. */ NONULL_FOR((1, 2)) @@ -433,11 +433,11 @@ NONULL in3_ret_t req_get_error( int id /**< [in] the index of the request to check (if this is a batch-request, otherwise 0). */ ); -/** - * sends a request and returns a context used to access the result or errors. - * +/** + * sends a request and returns a context used to access the result or errors. + * * This context *MUST* be freed with req_free(ctx) after usage to release the resources. -*/ + */ NONULL in3_req_t* in3_client_rpc_ctx_raw( in3_t* c, /**< [in] the client config. */ const char* request /**< [in] rpc request. */ @@ -447,7 +447,7 @@ NONULL in3_req_t* in3_client_rpc_ctx_raw( * sends a request and returns a context used to access the result or errors. * * This context *MUST* be freed with req_free(ctx) after usage to release the resources. -*/ + */ NONULL in3_req_t* in3_client_rpc_ctx( in3_t* c, /**< [in] the clientt config. */ const char* method, /**< [in] rpc method. */ diff --git a/c/src/core/client/request_internal.h b/c/src/core/client/request_internal.h index 80d0f552f..c0036187c 100644 --- a/c/src/core/client/request_internal.h +++ b/c/src/core/client/request_internal.h @@ -87,7 +87,7 @@ in3_ret_t req_set_error_intern( * handles a failable context * * This context *MUST* be freed with req_free(ctx) after usage to release the resources. -*/ + */ in3_ret_t req_handle_failable( in3_req_t* req /**< [in] the current request context. */ ); diff --git a/c/src/core/client/version.h b/c/src/core/client/version.h index d6ce6f2b2..206841200 100644 --- a/c/src/core/client/version.h +++ b/c/src/core/client/version.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -50,4 +50,4 @@ #define IN3_VERSION "local" #endif -#endif //IN3_VERSION_H +#endif // IN3_VERSION_H diff --git a/c/src/core/util/bitset.c b/c/src/core/util/bitset.c index c8db53a04..ab46930bd 100644 --- a/c/src/core/util/bitset.c +++ b/c/src/core/util/bitset.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/util/bitset.h b/c/src/core/util/bitset.h index 96214d37c..1ebd6d7be 100644 --- a/c/src/core/util/bitset.h +++ b/c/src/core/util/bitset.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -94,4 +94,4 @@ bool bs_isempty(bitset_t* bs); bitset_t* bs_clone(bitset_t* bs); bitset_t* bs_from_ull(unsigned long long u, size_t l); -#endif //IN3_BITSET_H +#endif // IN3_BITSET_H diff --git a/c/src/core/util/bytes.c b/c/src/core/util/bytes.c index ddb807557..49320a86d 100644 --- a/c/src/core/util/bytes.c +++ b/c/src/core/util/bytes.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/util/bytes.h b/c/src/core/util/bytes.h index 0aa9fe3a1..df7f48712 100644 --- a/c/src/core/util/bytes.h +++ b/c/src/core/util/bytes.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -81,38 +81,38 @@ typedef struct { bytes_t b; /**< the bytes struct */ } bytes_builder_t; -RETURNS_NONULL bytes_t* b_new(const uint8_t* data, uint32_t len); /**< allocates a new byte array with 0 filled */ -NONULL uint8_t* b_get_data(const bytes_t* b); /**< gets the data field from an input byte array */ -NONULL uint32_t b_get_len(const bytes_t* b); /**< gets the len field from an input byte array */ -NONULL void b_print(const bytes_t* a); /**< prints a the bytes as hex to stdout */ -NONULL void ba_print(const uint8_t* a, size_t l); /**< prints a the bytes as hex to stdout */ -NONULL int b_cmp(const bytes_t* a, const bytes_t* b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/ -int bytes_cmp(const bytes_t a, const bytes_t b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/ -void b_free(bytes_t* a); /**< frees the data */ -bytes_t b_concat(int cnt, ...); /**< duplicates the content of bytes*/ -NONULL bytes_t* b_dup(const bytes_t* a); /**< clones a byte array*/ -NONULL bytes_t bytes_dup(const bytes_t a); /**< clones a byte array*/ -NONULL uint8_t b_read_byte(bytes_t* b, size_t* pos); /**< reads a byte on the current position and updates the pos afterwards. */ -NONULL uint32_t b_read_int(bytes_t* b, size_t* pos); /**< reads a integer on the current position and updates the pos afterwards. */ -NONULL uint64_t b_read_long(bytes_t* b, size_t* pos); /**< reads a long on the current position and updates the pos afterwards. */ -NONULL char* b_new_chars(bytes_t* b, size_t* pos); /**< creates a new string (needs to be freed) on the current position and updates the pos afterwards. */ -NONULL bytes_t* b_new_fixed_bytes(bytes_t* b, size_t* pos, int len); /**< reads bytes with a fixed length on the current position and updates the pos afterwards. */ -bytes_builder_t* bb_newl(size_t l); /**< creates a new bytes_builder */ -NONULL void bb_free(bytes_builder_t* bb); /**< frees a bytebuilder and its content. */ -NONULL int bb_check_size(bytes_builder_t* bb, size_t len); /**< internal helper to increase the buffer if needed */ -NONULL void bb_write_chars(bytes_builder_t* bb, char* c, int len); /**< writes a string to the builder. */ -NONULL void bb_write_dyn_bytes(bytes_builder_t* bb, const bytes_t* src); /**< writes bytes to the builder with a prefixed length. */ -NONULL void bb_write_fixed_bytes(bytes_builder_t* bb, const bytes_t* src); /**< writes fixed bytes to the builder. */ -NONULL void bb_write_int(bytes_builder_t* bb, uint32_t val); /**< writes a ineteger to the builder. */ -NONULL void bb_write_long(bytes_builder_t* bb, uint64_t val); /**< writes s long to the builder. */ -NONULL void bb_write_long_be(bytes_builder_t* bb, uint64_t val, int len); /**< writes any integer value with the given length of bytes */ -NONULL void bb_write_byte(bytes_builder_t* bb, uint8_t val); /**< writes a single byte to the builder. */ -NONULL void bb_write_raw_bytes(bytes_builder_t* bb, void* ptr, size_t len); /**< writes the bytes to the builder. */ -NONULL void bb_clear(bytes_builder_t* bb); /**< resets the content of the builder. */ -NONULL void bb_replace(bytes_builder_t* bb, int offset, int delete_len, uint8_t* data, int data_len); /**< replaces or deletes a part of the content. */ -RETURNS_NONULL NONULL bytes_t* bb_move_to_bytes(bytes_builder_t* bb); /**< frees the builder and moves the content in a newly created bytes struct (which needs to be freed later). */ -NONULL uint64_t bb_read_long(bytes_builder_t* bb, size_t* i); /**< reads a long from the builder */ -NONULL uint32_t bb_read_int(bytes_builder_t* bb, size_t* i); /**< reads a int from the builder */ +RETURNS_NONULL bytes_t* b_new(const uint8_t* data, uint32_t len); /**< allocates a new byte array with 0 filled */ +NONULL uint8_t* b_get_data(const bytes_t* b); /**< gets the data field from an input byte array */ +NONULL uint32_t b_get_len(const bytes_t* b); /**< gets the len field from an input byte array */ +NONULL void b_print(const bytes_t* a); /**< prints a the bytes as hex to stdout */ +NONULL void ba_print(const uint8_t* a, size_t l); /**< prints a the bytes as hex to stdout */ +NONULL int b_cmp(const bytes_t* a, const bytes_t* b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/ +int bytes_cmp(const bytes_t a, const bytes_t b); /**< compares 2 byte arrays and returns 1 for equal and 0 for not equal*/ +void b_free(bytes_t* a); /**< frees the data */ +bytes_t b_concat(int cnt, ...); /**< duplicates the content of bytes*/ +NONULL bytes_t* b_dup(const bytes_t* a); /**< clones a byte array*/ +NONULL bytes_t bytes_dup(const bytes_t a); /**< clones a byte array*/ +NONULL uint8_t b_read_byte(bytes_t* b, size_t* pos); /**< reads a byte on the current position and updates the pos afterwards. */ +NONULL uint32_t b_read_int(bytes_t* b, size_t* pos); /**< reads a integer on the current position and updates the pos afterwards. */ +NONULL uint64_t b_read_long(bytes_t* b, size_t* pos); /**< reads a long on the current position and updates the pos afterwards. */ +NONULL char* b_new_chars(bytes_t* b, size_t* pos); /**< creates a new string (needs to be freed) on the current position and updates the pos afterwards. */ +NONULL bytes_t* b_new_fixed_bytes(bytes_t* b, size_t* pos, int len); /**< reads bytes with a fixed length on the current position and updates the pos afterwards. */ +bytes_builder_t* bb_newl(size_t l); /**< creates a new bytes_builder */ +NONULL void bb_free(bytes_builder_t* bb); /**< frees a bytebuilder and its content. */ +NONULL int bb_check_size(bytes_builder_t* bb, size_t len); /**< internal helper to increase the buffer if needed */ +NONULL void bb_write_chars(bytes_builder_t* bb, char* c, int len); /**< writes a string to the builder. */ +NONULL void bb_write_dyn_bytes(bytes_builder_t* bb, const bytes_t* src); /**< writes bytes to the builder with a prefixed length. */ +NONULL void bb_write_fixed_bytes(bytes_builder_t* bb, const bytes_t* src); /**< writes fixed bytes to the builder. */ +NONULL void bb_write_int(bytes_builder_t* bb, uint32_t val); /**< writes a ineteger to the builder. */ +NONULL void bb_write_long(bytes_builder_t* bb, uint64_t val); /**< writes s long to the builder. */ +NONULL void bb_write_long_be(bytes_builder_t* bb, uint64_t val, int len); /**< writes any integer value with the given length of bytes */ +NONULL void bb_write_byte(bytes_builder_t* bb, uint8_t val); /**< writes a single byte to the builder. */ +NONULL void bb_write_raw_bytes(bytes_builder_t* bb, void* ptr, size_t len); /**< writes the bytes to the builder. */ +NONULL void bb_clear(bytes_builder_t* bb); /**< resets the content of the builder. */ +NONULL void bb_replace(bytes_builder_t* bb, int offset, int delete_len, uint8_t* data, int data_len); /**< replaces or deletes a part of the content. */ +RETURNS_NONULL NONULL bytes_t* bb_move_to_bytes(bytes_builder_t* bb); /**< frees the builder and moves the content in a newly created bytes struct (which needs to be freed later). */ +NONULL uint64_t bb_read_long(bytes_builder_t* bb, size_t* i); /**< reads a long from the builder */ +NONULL uint32_t bb_read_int(bytes_builder_t* bb, size_t* i); /**< reads a int from the builder */ static inline bytes_t bytes(uint8_t* a, uint32_t len) { return (bytes_t){.data = a, .len = len}; } /**< converts the given bytes to a bytes struct */ bytes_t cloned_bytes(bytes_t data); /**< cloned the passed data*/ diff --git a/c/src/core/util/colors.h b/c/src/core/util/colors.h index 73354fb55..5a4805711 100644 --- a/c/src/core/util/colors.h +++ b/c/src/core/util/colors.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -110,8 +110,8 @@ #define COLORT_WHITE "" #endif -/* Control sequences, based on ANSI. -Can be used to control color, and +/* Control sequences, based on ANSI. +Can be used to control color, and clear the screen */ diff --git a/c/src/core/util/data.c b/c/src/core/util/data.c index 2bb60a447..0b0d06051 100644 --- a/c/src/core/util/data.c +++ b/c/src/core/util/data.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -165,7 +165,7 @@ int d_bytes_to(d_token_t* item, uint8_t* dst, const int max_size) { if (max > l) { memset(dst, 0, max - l); memcpy(dst + max - l, item->data, l); - d_bytesl(item, max); //TODO we should not need this! + d_bytesl(item, max); // TODO we should not need this! l = max; } else diff --git a/c/src/core/util/data.h b/c/src/core/util/data.h index 1f9126a4e..d54cdad3a 100644 --- a/c/src/core/util/data.h +++ b/c/src/core/util/data.h @@ -1,48 +1,48 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * json-parser. - * + * * The parser can read from : * - json * - bin - * + * * When reading from json all '0x'... values will be stored as bytes_t. If the value is lower than 0xFFFFFFF, it is converted as integer. - * - * + * + * * */ #ifndef __DATA_H__ @@ -76,8 +76,8 @@ typedef enum { T_NULL = 6 /**< a NULL-value */ } d_type_t; -/** a token holding any kind of value. - * +/** a token holding any kind of value. + * * use d_type, d_len or the cast-function to get the value. */ typedef struct item { @@ -104,11 +104,11 @@ typedef struct json_parser { } json_ctx_t; /** - * - * returns the byte-representation of token. - * - * In case of a number it is returned as bigendian. - * booleans as 0x01 or 0x00 + * + * returns the byte-representation of token. + * + * In case of a number it is returned as bigendian. + * booleans as 0x01 or 0x00 * and NULL as 0x. * Objects or arrays will return 0x. */ @@ -136,16 +136,16 @@ d_token_t* d_get_or(d_token_t* item, const uint16_t key1, const uint16_t key2); d_token_t* d_get_at(d_token_t* item, const uint32_t index); /**< returns the token of an array with the given index */ d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */ -NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ -NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ -NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ -char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ +NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ +NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ +NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ +char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ -json_ctx_t* json_create(); +json_ctx_t* json_create(); NONULL d_token_t* json_create_null(json_ctx_t* jp); NONULL d_token_t* json_create_bool(json_ctx_t* jp, bool value); NONULL d_token_t* json_create_int(json_ctx_t* jp, uint64_t value); @@ -182,7 +182,7 @@ d_token_t* d_getl(d_token_t* item, uint16_t k, uint32_t minl); /** * iterator over elements of a array opf object. - * + * * usage: * ```c * for (d_iterator_t iter = d_iter( parent ); iter.left ; d_iter_next(&iter)) { diff --git a/c/src/core/util/debug.c b/c/src/core/util/debug.c index 7cf66c6b7..52bced814 100644 --- a/c/src/core/util/debug.c +++ b/c/src/core/util/debug.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/util/debug.h b/c/src/core/util/debug.h index 6009055e1..04abd97aa 100644 --- a/c/src/core/util/debug.h +++ b/c/src/core/util/debug.h @@ -2,38 +2,38 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * logs debug data only if the DEBUG-flag is set. * */ @@ -60,7 +60,7 @@ void __dbg_log(int raw, char* file, const char* func, int line, char* fmt, ...); { printk("ENTER %s::%s\n", __FILE__, __func__); } #define DBG_FNCTRACE_LEAVE \ { printk("LEAVE %s::%s\n", __FILE__, __func__); } -#endif //DBG_FNCTRACE +#endif // DBG_FNCTRACE /** dumps the given data as hex coded bytes to stdout */ extern void msg_dump(const char* s, const unsigned char* data, unsigned len); diff --git a/c/src/core/util/error.h b/c/src/core/util/error.h index 78d678346..0d8c19ddd 100644 --- a/c/src/core/util/error.h +++ b/c/src/core/util/error.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -50,11 +50,11 @@ extern "C" { #define JSON_RPC_ERR_FINALITY (-16001) /** Block is not final so node refused to sign */ /** ERROR types used as return values. - * + * * All values (except IN3_OK) indicate an error. - * IN3_WAITING may be treated like an error, since we have stop executing until the response has arrived, but it is a valid return value. - * -*/ + * IN3_WAITING may be treated like an error, since we have stop executing until the response has arrived, but it is a valid return value. + * + */ typedef enum { /* On success positive values (impl. defined) upto INT_MAX maybe returned */ IN3_OK = 0, /**< Success */ @@ -106,7 +106,7 @@ typedef enum { */ #define OPTIONAL_T(t) opt_##t -/** +/** * Optional types must be defined prior to usage (e.g. DEFINE_OPTIONAL_T(int)) * Use OPTIONAL_T_UNDEFINED(t) & OPTIONAL_T_VALUE(t, v) for easy initialization (rvalues) */ @@ -116,12 +116,12 @@ typedef enum { bool defined; \ } OPTIONAL_T(t) -/** +/** * marks a used value as undefined. */ #define OPTIONAL_T_UNDEFINED(t) ((OPTIONAL_T(t)){.defined = false}) -/** +/** * sets the value of an optional type. */ #define OPTIONAL_T_VALUE(t, v) ((OPTIONAL_T(t)){.value = v, .defined = true}) @@ -135,4 +135,4 @@ char* in3_errmsg(in3_ret_t err /**< the error code */); } #endif -#endif //IN3_ERROR_H +#endif // IN3_ERROR_H diff --git a/c/src/core/util/log.c b/c/src/core/util/log.c index 652617073..34e2d8e99 100644 --- a/c/src/core/util/log.c +++ b/c/src/core/util/log.c @@ -169,7 +169,7 @@ void in3_log_(in3_log_level_t level, const char* filename, const char* function, va_end(args); fflush(stderr); #endif - //fflush(stderr); + // fflush(stderr); } /* Log to file */ diff --git a/c/src/core/util/log.h b/c/src/core/util/log.h index 7457638fb..c6d12a845 100644 --- a/c/src/core/util/log.h +++ b/c/src/core/util/log.h @@ -75,8 +75,8 @@ typedef enum { LOG_TRACE, #endif /** - * in3_log_set_*() functions are not thread-safe. - * It is expected that these initialization functions will be called from the main thread before + * in3_log_set_*() functions are not thread-safe. + * It is expected that these initialization functions will be called from the main thread before * spawning more threads. */ void in3_log_set_udata_(void* udata); diff --git a/c/src/core/util/mem.c b/c/src/core/util/mem.c index 0f96e0346..c1dc895af 100644 --- a/c/src/core/util/mem.c +++ b/c/src/core/util/mem.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/util/mem.h b/c/src/core/util/mem.h index 9ab43e032..38f344f2f 100644 --- a/c/src/core/util/mem.h +++ b/c/src/core/util/mem.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/util/scache.c b/c/src/core/util/scache.c index 54bbed85c..d28f1bede 100644 --- a/c/src/core/util/scache.c +++ b/c/src/core/util/scache.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/util/scache.h b/c/src/core/util/scache.h index 6df98fa4b..ce8de3a4e 100644 --- a/c/src/core/util/scache.h +++ b/c/src/core/util/scache.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/util/stringbuilder.c b/c/src/core/util/stringbuilder.c index 62c0be58d..9e821d513 100644 --- a/c/src/core/util/stringbuilder.c +++ b/c/src/core/util/stringbuilder.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/core/util/stringbuilder.h b/c/src/core/util/stringbuilder.h index ad75dd236..14880e864 100644 --- a/c/src/core/util/stringbuilder.h +++ b/c/src/core/util/stringbuilder.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -57,7 +57,7 @@ typedef unsigned long long uintmax_t; #endif /** - * string build struct, which is able to hold and modify a growing string. + * string build struct, which is able to hold and modify a growing string. */ typedef struct sb { char* data; /**< the current string (null terminated)*/ @@ -65,25 +65,25 @@ typedef struct sb { size_t len; /**< the current length of the string */ } sb_t; /** - * creates a stringbuilder which is allocating any new memory, but uses an existing string and is used directly on the stack. + * creates a stringbuilder which is allocating any new memory, but uses an existing string and is used directly on the stack. * Since it will not grow the memory you need to pass a char* which allocated enough memory. */ NONULL static inline sb_t sb_stack(char* p) { return (sb_t){.allocted = 0xffffff, .len = 0, .data = p}; } -sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ -NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ -NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ +sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ +NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ +NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ NONULL sb_t* sb_add_char(sb_t* sb, char c); /**< add a single character */ NONULL sb_t* sb_add_chars(sb_t* sb, const char* chars); /**< adds a string */ NONULL sb_t* sb_add_range(sb_t* sb, const char* chars, int start, int len); /**< add a string range */ NONULL sb_t* sb_add_key_value(sb_t* sb, const char* key, const char* value, int value_len, bool as_string); /**< adds a value with an optional key. if as_string is true the value will be quoted. */ NONULL_FOR((1, 3)) -sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ -NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ -NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ -NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ -NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ +sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ +NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ +NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ +NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ +NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ NONULL_FOR((1)) sb_t* sb_add_rawbytes(sb_t* sb, char* prefix, bytes_t b, int fix_size); sb_t* sb_print(sb_t* sb, const char* fmt, ...); diff --git a/c/src/core/util/utils.c b/c/src/core/util/utils.c index 54d4ee67b..a42ba658c 100644 --- a/c/src/core/util/utils.c +++ b/c/src/core/util/utils.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #define _POSIX_C_SOURCE 199309L @@ -378,7 +378,7 @@ int64_t parse_float_val(const char* data, int32_t expo) { } if (exp_found) - expo += (int32_t)(neg ? (0 - val) : val); + expo += (int32_t) (neg ? (0 - val) : val); neg = false; val = 0; expo += major; diff --git a/c/src/core/util/utils.h b/c/src/core/util/utils.h index 328134038..73ef193d9 100644 --- a/c/src/core/util/utils.h +++ b/c/src/core/util/utils.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -120,7 +120,7 @@ const char* u64_to_str(uint64_t value, char* pBuf, int szBuf); /** * convert a c hex string to a byte array storing it into an existing buffer. - * + * * @param hexdata: the hex string * @param hexlen: the len of the string to read. -1 will use strlen to determine the length. * @param out: the byte buffer @@ -153,14 +153,14 @@ int min_bytes_len(uint64_t val); /** * sets a variable value to 32byte word. * @param src The src data - * @param src_len the number of bytes + * @param src_len the number of bytes * @param dst target pointer */ void uint256_set(const uint8_t* src, wlen_t src_len, bytes32_t dst); /** * replaces a string and returns a copy. - * @retval + * @retval */ char* str_replace(char* orig, const char* rep, const char* with); @@ -170,8 +170,8 @@ char* str_replace(char* orig, const char* rep, const char* with); char* str_replace_pos(char* orig, size_t pos, size_t len, const char* rep); /** - * lightweight strstr() replacements - */ + * lightweight strstr() replacements + */ char* str_find(char* haystack, const char* needle); /** @@ -180,7 +180,7 @@ char* str_find(char* haystack, const char* needle); char* str_remove_html(char* data); /** - * current timestamp in ms. + * current timestamp in ms. */ uint64_t current_ms(); @@ -192,8 +192,8 @@ uint64_t current_ms(); } /** - * executes the expression and expects the return value to be a int indicating the error. - * if the return value is negative it will stop and return this value otherwise continue. + * executes the expression and expects the return value to be a int indicating the error. + * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY(exp) \ { \ @@ -202,8 +202,8 @@ uint64_t current_ms(); } /** - * executes the expression and expects the return value to be a int indicating the error. - * if the return value is negative it will stop and return this value otherwise continue. + * executes the expression and expects the return value to be a int indicating the error. + * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY_FINAL(exp, final) \ { \ @@ -213,7 +213,7 @@ uint64_t current_ms(); } /** - * executes the expression and expects the return value to be a int indicating the error. + * executes the expression and expects the return value to be a int indicating the error. * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY_CATCH(exp, catch) \ @@ -231,16 +231,16 @@ uint64_t current_ms(); #define CONFIG_KEY(name) key(name) /** - * executes the expression and expects value to equal val. + * executes the expression and expects value to equal val. * if not it will return IN3_EINVAL */ #define EXPECT_EQ(exp, val) \ if ((exp) != val) return IN3_EINVAL; /** - * executes the expression and expects the return value to be a int indicating the error. + * executes the expression and expects the return value to be a int indicating the error. * the return value will be set to a existing variable (var). - * if the return value is negative it will stop and return this value otherwise continue. + * if the return value is negative it will stop and return this value otherwise continue. */ #define TRY_SET(var, exp) \ { \ @@ -249,7 +249,7 @@ uint64_t current_ms(); } /** - * executes the expression and expects the return value to be a int indicating the error. + * executes the expression and expects the return value to be a int indicating the error. * if the return value is negative it will stop and jump (goto) to a marked position "clean". * it also expects a previously declared variable "in3_ret_t res". */ diff --git a/c/src/init/in3_init.h b/c/src/init/in3_init.h index 3811897d5..29b0f9462 100644 --- a/c/src/init/in3_init.h +++ b/c/src/init/in3_init.h @@ -71,4 +71,4 @@ in3_t* in3_for_chain_auto_init(chain_id_t chain_id); } #endif -#endif //IN3_IN3_INIT_H +#endif // IN3_IN3_INIT_H diff --git a/c/src/nodeselect/full/cache.c b/c/src/nodeselect/full/cache.c index 16a88f60a..2471186b8 100644 --- a/c/src/nodeselect/full/cache.c +++ b/c/src/nodeselect/full/cache.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/nodeselect/full/cache.h b/c/src/nodeselect/full/cache.h index ac37f1883..63d1ade5b 100644 --- a/c/src/nodeselect/full/cache.h +++ b/c/src/nodeselect/full/cache.h @@ -1,40 +1,40 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ /** * handles caching and storage. - * + * * storing nodelists and other caches with the storage handler as specified in the client. * If no storage handler is specified nothing will be cached. * */ @@ -48,9 +48,9 @@ #define CACHE_H /** - * reads the nodelist from cache. - * - * This function is usually called internally to fill the weights + * reads the nodelist from cache. + * + * This function is usually called internally to fill the weights * and nodelist from the the cache. * If you call `in3_set_storage_handler` there is no need to call this explicitly. */ @@ -60,10 +60,10 @@ in3_ret_t in3_cache_update_nodelist( ); /** - * stores the nodelist to thes cache. - * + * stores the nodelist to thes cache. + * * It will be automatically called if the nodelist has changed and read from the nodes or the weight of a node changed. - * + * */ in3_ret_t in3_cache_store_nodelist( in3_t* c, /**< the client */ diff --git a/c/src/nodeselect/full/nodelist.c b/c/src/nodeselect/full/nodelist.c index a7bcec6cd..52862769a 100644 --- a/c/src/nodeselect/full/nodelist.c +++ b/c/src/nodeselect/full/nodelist.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/nodeselect/full/nodelist.h b/c/src/nodeselect/full/nodelist.h index 9ce7389b1..41aa9c6e3 100644 --- a/c/src/nodeselect/full/nodelist.h +++ b/c/src/nodeselect/full/nodelist.h @@ -1,40 +1,40 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ /** * handles nodelists. - * + * * */ #include "../../core/client/client.h" @@ -78,8 +78,8 @@ typedef enum { ATTR_BOOT_NODE = 2, /**< used to avoid filtering manually added nodes before first nodeList update */ } in3_node_attr_type_t; -/** incubed node-configuration. - * +/** incubed node-configuration. + * * These information are read from the Registry contract and stored in this struct representing a server or node. */ typedef struct in3_node { @@ -95,7 +95,7 @@ typedef struct in3_node { /** * Weight or reputation of a node. - * + * * Based on the past performance of the node a weight is calculated given faster nodes a higher weight * and chance when selecting the next node from the nodelist. * These weights will also be stored in the cache (if available) @@ -197,7 +197,7 @@ NONULL void in3_client_run_chain_whitelisting(in3_nodeselect_def_t* data); #endif /** check if the nodelist is up to date. - * + * * if not it will fetch a new version first (if the needs_update-flag is set). */ NONULL in3_ret_t in3_node_list_get(in3_req_t* req, in3_nodeselect_def_t* data, bool update, in3_node_t** nodelist, unsigned int* nodelist_length, in3_node_weight_t** weights); diff --git a/c/src/nodeselect/full/nodeselect_def.c b/c/src/nodeselect/full/nodeselect_def.c index 31e3c4a46..75b6aca32 100644 --- a/c/src/nodeselect/full/nodeselect_def.c +++ b/c/src/nodeselect/full/nodeselect_def.c @@ -594,9 +594,9 @@ static void check_autoupdate(const in3_req_t* ctx, in3_nodeselect_def_t* data, d memcpy(data->nodelist_upd8_params->node, n->address, 20); data->nodelist_upd8_params->exp_last_block = d_get_long(response_in3, K_LAST_NODE_LIST); data->nodelist_upd8_params->timestamp = in3_time(NULL) + update_waittime(d_get_long(response_in3, K_LAST_NODE_LIST), - d_get_long(response_in3, K_CURRENT_BLOCK), - ctx->client->replace_latest_block, - data->avg_block_time); + d_get_long(response_in3, K_CURRENT_BLOCK), + ctx->client->replace_latest_block, + data->avg_block_time); } } diff --git a/c/src/nodeselect/full/nodeselect_def.h b/c/src/nodeselect/full/nodeselect_def.h index 390f7455f..4a6993441 100644 --- a/c/src/nodeselect/full/nodeselect_def.h +++ b/c/src/nodeselect/full/nodeselect_def.h @@ -1,5 +1,5 @@ /** - * + * */ // @PUBLIC_HEADER #ifndef IN3_NODE_SELECT_DEF_H @@ -29,6 +29,6 @@ static inline in3_nodeselect_def_t* in3_nodeselect_def_data(in3_t* c) { */ in3_ret_t in3_register_nodeselect_def(in3_t* c); -#endif //NODESELECT_DEF +#endif // NODESELECT_DEF -#endif //IN3_NODE_SELECT_DEF_H +#endif // IN3_NODE_SELECT_DEF_H diff --git a/c/src/nodeselect/full/nodeselect_def_cfg.h b/c/src/nodeselect/full/nodeselect_def_cfg.h index 349a03107..a1a62bece 100644 --- a/c/src/nodeselect/full/nodeselect_def_cfg.h +++ b/c/src/nodeselect/full/nodeselect_def_cfg.h @@ -358,4 +358,4 @@ static inline json_ctx_t* nodeselect_def_cfg(chain_id_t chain_id) { return bincfg.data ? parse_binary(&bincfg) : NULL; } -#endif //IN3_NODE_SELECT_DEF_CFG_H +#endif // IN3_NODE_SELECT_DEF_CFG_H diff --git a/c/src/nodeselect/full/nodeselect_def_cfg_template.h b/c/src/nodeselect/full/nodeselect_def_cfg_template.h index 3d45da25a..800a4592e 100644 --- a/c/src/nodeselect/full/nodeselect_def_cfg_template.h +++ b/c/src/nodeselect/full/nodeselect_def_cfg_template.h @@ -206,4 +206,4 @@ static inline json_ctx_t* nodeselect_def_cfg(chain_id_t chain_id) { return bincfg.data ? parse_binary(&bincfg) : NULL; } -#endif //IN3_NODE_SELECT_DEF_CFG_H +#endif // IN3_NODE_SELECT_DEF_CFG_H diff --git a/c/src/nodeselect/full/registry.c b/c/src/nodeselect/full/registry.c index b869aa81b..b1a4f1ab1 100644 --- a/c/src/nodeselect/full/registry.c +++ b/c/src/nodeselect/full/registry.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/nodeselect/full/registry.h b/c/src/nodeselect/full/registry.h index 06477b2c2..9cc739357 100644 --- a/c/src/nodeselect/full/registry.h +++ b/c/src/nodeselect/full/registry.h @@ -13,4 +13,4 @@ in3_ret_t eth_verify_in3_nodelist(in3_nodeselect_def_t* data, in3_vctx_t* vc, ui NONULL in3_ret_t eth_verify_in3_whitelist(in3_nodeselect_def_t* data, in3_vctx_t* vc); #endif -#endif //IN3_NODE_SELECT_REGISTRY_H +#endif // IN3_NODE_SELECT_REGISTRY_H diff --git a/c/src/pay/eth/pay_eth.c b/c/src/pay/eth/pay_eth.c index 25a091e38..dbf149292 100644 --- a/c/src/pay/eth/pay_eth.c +++ b/c/src/pay/eth/pay_eth.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2019 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #include "pay_eth.h" diff --git a/c/src/pay/eth/pay_eth.h b/c/src/pay/eth/pay_eth.h index 68db6ec54..6e105bf30 100644 --- a/c/src/pay/eth/pay_eth.h +++ b/c/src/pay/eth/pay_eth.h @@ -1,40 +1,40 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2019 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ /** @file * USN API. - * + * * This header-file defines easy to use function, which are verifying USN-Messages. * */ diff --git a/c/src/pay/zksync/zk_helper.c b/c/src/pay/zksync/zk_helper.c index 4bf69df49..89f1ee98e 100644 --- a/c/src/pay/zksync/zk_helper.c +++ b/c/src/pay/zksync/zk_helper.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2019 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/pay/zksync/zk_helper.h b/c/src/pay/zksync/zk_helper.h index 8af5e54b7..7bde6529b 100644 --- a/c/src/pay/zksync/zk_helper.h +++ b/c/src/pay/zksync/zk_helper.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2019 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/pay/zksync/zk_incentive.c b/c/src/pay/zksync/zk_incentive.c index 563e62f45..e0ec3cd2c 100644 --- a/c/src/pay/zksync/zk_incentive.c +++ b/c/src/pay/zksync/zk_incentive.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2019 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #include "../../core/client/keys.h" @@ -70,8 +70,8 @@ static in3_ret_t ensure_payment_data(in3_req_t* req, zksync_config_t* conf) { uint8_t pub[65]; bytes_t pubkey_bytes = {.len = 64, .data = ((uint8_t*) &pub) + 1}; char* message = "\x19" - "Ethereum Signed Message:\n68" - "Access zkSync account.\n\nOnly sign this message for a trusted client!"; + "Ethereum Signed Message:\n68" + "Access zkSync account.\n\nOnly sign this message for a trusted client!"; in3_pay_sign_req_ctx_t sctx = {.req = req, .request = NULL, .signature = {0}}; bytes_t sig_bytes = bytes(sctx.signature, 65); diff --git a/c/src/pay/zksync/zk_message.c b/c/src/pay/zksync/zk_message.c index eb2163823..6e7624a5e 100644 --- a/c/src/pay/zksync/zk_message.c +++ b/c/src/pay/zksync/zk_message.c @@ -176,7 +176,7 @@ in3_ret_t zksync_sign_transfer(sb_t* sb, zksync_tx_data_t* data, in3_req_t* ctx, in3_log_debug("zksync_sign_transfer human readable :\n%s\n", msg_data); if (signature.len == 65 && signature.data[64] < 27) - signature.data[64] += 27; //because EIP155 chainID = 0 + signature.data[64] += 27; // because EIP155 chainID = 0 } // now create the packed sync transfer @@ -283,7 +283,7 @@ in3_ret_t zksync_sign_change_pub_key(sb_t* sb, in3_req_t* ctx, uint8_t* sync_pub if (conf->sign_type != ZK_SIGN_CREATE2) { TRY(req_require_signature(ctx, SIGN_EC_PREFIX, &signature, bytes((uint8_t*) ethmsg, 60), bytes(conf->account, 20))) if (signature.len == 65 && signature.data[64] < 27) - signature.data[64] += 27; //because EIP155 chainID = 0 + signature.data[64] += 27; // because EIP155 chainID = 0 } sb_add_chars(sb, "{\"type\":\"ChangePubKey\",\"accountId\":"); diff --git a/c/src/pay/zksync/zk_transfer.c b/c/src/pay/zksync/zk_transfer.c index 79b4ac6e6..06e104441 100644 --- a/c/src/pay/zksync/zk_transfer.c +++ b/c/src/pay/zksync/zk_transfer.c @@ -74,7 +74,7 @@ in3_ret_t zksync_transfer(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, zk_m if (ret == IN3_OK && cached && cached->value.data) { uint8_t* start_sig = (void*) strstr((void*) cached->value.data, ",\"signature\":"); sb_t* sb = in3_rpc_handle_start(ctx); - sb_add_range(sb, (void*) cached->value.data, 0, start_sig ? ((size_t)(start_sig - cached->value.data)) : (strlen((void*) cached->value.data) - 177)); + sb_add_range(sb, (void*) cached->value.data, 0, start_sig ? ((size_t) (start_sig - cached->value.data)) : (strlen((void*) cached->value.data) - 177)); sb_add_chars(sb, ",\"txHash\":\""); sb_add_chars(sb, d_string(result)); sb_add_chars(sb, "\"}"); diff --git a/c/src/pay/zksync/zksync.c b/c/src/pay/zksync/zksync.c index 300086e0d..7ae2eb3ea 100644 --- a/c/src/pay/zksync/zksync.c +++ b/c/src/pay/zksync/zksync.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2019 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #include "zksync.h" diff --git a/c/src/pay/zksync/zksync.h b/c/src/pay/zksync/zksync.h index b93ec3616..4af9e3aa8 100644 --- a/c/src/pay/zksync/zksync.h +++ b/c/src/pay/zksync/zksync.h @@ -1,41 +1,41 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2019 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * ZKSync API. - * + * * This header-file registers zksync api functions. * */ diff --git a/c/src/signer/ledger-nano/firmware/src/globals.h b/c/src/signer/ledger-nano/firmware/src/globals.h old mode 100755 new mode 100644 index 29a7054e0..e75d3f30d --- a/c/src/signer/ledger-nano/firmware/src/globals.h +++ b/c/src/signer/ledger-nano/firmware/src/globals.h @@ -22,7 +22,7 @@ extern cx_sha256_t hash; extern unsigned char msg_hash[HASH_LEN]; extern cx_ecfp_private_key_t private_key; -//bip32 path stored after apdu request parsing +// bip32 path stored after apdu request parsing extern unsigned int path[BIP32_PATH_LEN_MAX]; extern int path_len_bip; diff --git a/c/src/signer/ledger-nano/firmware/src/menu.c b/c/src/signer/ledger-nano/firmware/src/menu.c index 96f884ff7..f6714f444 100644 --- a/c/src/signer/ledger-nano/firmware/src/menu.c +++ b/c/src/signer/ledger-nano/firmware/src/menu.c @@ -96,7 +96,7 @@ unsigned char io_event(unsigned char channel) { (os_seph_features() & SEPROXYHAL_TAG_SESSION_START_EVENT_FEATURE_SCREEN_BIG)) { if (!display_text_part()) { - //PRINTF ("io_event:display_text_part"); + // PRINTF ("io_event:display_text_part"); ui_approval(); } else { diff --git a/c/src/signer/ledger-nano/firmware/src/operations.c b/c/src/signer/ledger-nano/firmware/src/operations.c index 9a05399fa..a31063492 100644 --- a/c/src/signer/ledger-nano/firmware/src/operations.c +++ b/c/src/signer/ledger-nano/firmware/src/operations.c @@ -9,9 +9,9 @@ int path_len_bip; unsigned char msg_hash[HASH_LEN]; cx_ecfp_private_key_t private_key; -//static const unsigned int path__[5]= {44|0x80000000, 60|0x80000000, 0|0x80000000, 0, 0}; +// static const unsigned int path__[5]= {44|0x80000000, 60|0x80000000, 0|0x80000000, 0, 0}; -//function to get public key at the given path +// function to get public key at the given path cx_ecfp_public_key_t public_key_at_given_path(cx_curve_t curve_id, unsigned char* loc, int path_len) { PRINTF("public_key_at_given_path:enter"); cx_ecfp_public_key_t public_key; @@ -29,7 +29,7 @@ cx_ecfp_public_key_t public_key_at_given_path(cx_curve_t curve_id, unsigned char return public_key; } -//function to get private key at the given path +// function to get private key at the given path cx_ecfp_private_key_t private_key_at_given_path(cx_curve_t curve_id, unsigned char* loc, int path_len) { cx_ecfp_public_key_t public_key; unsigned char private_key_data[32]; @@ -149,13 +149,13 @@ uint32_t read_bip32_path(uint32_t bytes, const uint8_t* buf, uint32_t* bip32_pat PRINTF(" bytes %d path_length %d ", bytes, path_length); for (size_t i = 0; i < path_length; i++) { - //PRINTF("\n buf %d bip32_path %d path__ %d i %d",buf[i],bip32_path[i],path__[i], i); + // PRINTF("\n buf %d bip32_path %d path__ %d i %d",buf[i],bip32_path[i],path__[i], i); if (i < 3) bip32_path[i] = buf[i] | (0x80000000); else bip32_path[i] = buf[i] | (0x00000000); - //PRINTF("\n buf %d bip32_path %d path__ %d i %d \n",buf[i],bip32_path[i],path__[i], i); + // PRINTF("\n buf %d bip32_path %d path__ %d i %d \n",buf[i],bip32_path[i],path__[i], i); } return path_length; diff --git a/c/src/signer/ledger-nano/signer/device_apdu_commands.c b/c/src/signer/ledger-nano/signer/device_apdu_commands.c index 69717a1e0..e169393c4 100644 --- a/c/src/signer/ledger-nano/signer/device_apdu_commands.c +++ b/c/src/signer/ledger-nano/signer/device_apdu_commands.c @@ -81,8 +81,8 @@ void wrap_apdu(uint8_t* i_apdu, int len, uint16_t seq, bytes_t* o_wrapped_hid_cm int len_to_bytes(uint16_t x, uint8_t* buf) { - buf[1] = (uint8_t)(x & 0xFF); - buf[0] = (uint8_t)((x >> 8) & 0xFF); + buf[1] = (uint8_t) (x & 0xFF); + buf[0] = (uint8_t) ((x >> 8) & 0xFF); return 2; } @@ -107,13 +107,13 @@ void read_hid_response(hid_device* handle, bytes_t* response) { bytes_read = hid_read(handle, read_chunk, sizeof(read_chunk)); - if (memcmp(bug_header, read_chunk, sizeof(bug_header)) == 0) { //random bug header received, signing will have to be reattempted + if (memcmp(bug_header, read_chunk, sizeof(bug_header)) == 0) { // random bug header received, signing will have to be reattempted total_bytes_available = 0; index_counter = 0; break; } if (bytes_read > 0) { - if (index_counter == 0) //first chunk read + if (index_counter == 0) // first chunk read { total_bytes_available = read_chunk[6]; if (total_bytes_available == 0) { diff --git a/c/src/signer/ledger-nano/signer/device_apdu_commands.h b/c/src/signer/ledger-nano/signer/device_apdu_commands.h index bdb36f9eb..f2b6d71ba 100644 --- a/c/src/signer/ledger-nano/signer/device_apdu_commands.h +++ b/c/src/signer/ledger-nano/signer/device_apdu_commands.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/signer/ledger-nano/signer/ethereum_apdu_client.c b/c/src/signer/ledger-nano/signer/ethereum_apdu_client.c index 7ae73e74e..329c733b6 100644 --- a/c/src/signer/ledger-nano/signer/ethereum_apdu_client.c +++ b/c/src/signer/ledger-nano/signer/ethereum_apdu_client.c @@ -39,7 +39,7 @@ in3_ret_t eth_ledger_sign_txn(void* p_data, in3_plugin_act_t action, void* p_ctx memcpy(bip_data, bip_path_bytes, sizeof(bip_data)); set_command_params_eth(); - //parse and convert bip into hardened form + // parse and convert bip into hardened form read_bip32_path(5, bip_data, bip32); int recid = 0; @@ -177,7 +177,7 @@ in3_ret_t eth_ledger_get_public_addr(uint8_t* i_bip_path, uint8_t* o_public_key) return IN3_OK; } - //parse and convert bip into hardened form + // parse and convert bip into hardened form read_bip32_path(5, i_bip_path, bip32); apdu[index_counter++] = 0xe0; diff --git a/c/src/signer/ledger-nano/signer/ethereum_apdu_client.h b/c/src/signer/ledger-nano/signer/ethereum_apdu_client.h index 2101ca90f..57820b532 100644 --- a/c/src/signer/ledger-nano/signer/ethereum_apdu_client.h +++ b/c/src/signer/ledger-nano/signer/ethereum_apdu_client.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * this file defines the incubed configuration struct and it registration. - * - * + * + * * */ #ifndef in3_ledger_signer_eth_h__ @@ -50,15 +50,15 @@ extern "C" { /** * attaches ledger nano hardware wallet signer with incubed . - * + * * bip32 path to be given to point the specific public/private key in HD tree for Ethereum! */ in3_ret_t eth_ledger_set_signer_txn(in3_t* in3, uint8_t* bip_path); /** * returns public key at the bip_path . - * - * returns IN3_ENODEVICE error if ledger nano device is not connected + * + * returns IN3_ENODEVICE error if ledger nano device is not connected */ in3_ret_t eth_ledger_get_public_addr(uint8_t* i_bip_path, uint8_t* o_public_key); diff --git a/c/src/signer/ledger-nano/signer/ethereum_apdu_client_priv.h b/c/src/signer/ledger-nano/signer/ethereum_apdu_client_priv.h index 01efe46c0..4c9650363 100644 --- a/c/src/signer/ledger-nano/signer/ethereum_apdu_client_priv.h +++ b/c/src/signer/ledger-nano/signer/ethereum_apdu_client_priv.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #ifndef in3_ethereum_apdu_client_priv_h__ diff --git a/c/src/signer/ledger-nano/signer/ledger_signer.c b/c/src/signer/ledger-nano/signer/ledger_signer.c index 6ba77bebc..eb7fc467d 100644 --- a/c/src/signer/ledger-nano/signer/ledger_signer.c +++ b/c/src/signer/ledger-nano/signer/ledger_signer.c @@ -95,12 +95,12 @@ in3_ret_t eth_ledger_sign(void* p_data, in3_plugin_act_t action, void* p_ctx) { apdu[index_counter++] = P1_FINAL; apdu[index_counter++] = IDM_SECP256K1; - apdu[index_counter++] = 0x01; //1st arg tag + apdu[index_counter++] = 0x01; // 1st arg tag apdu[index_counter++] = sizeof(bip_data); memcpy(apdu + index_counter, &bip_data, sizeof(bip_data)); index_counter += sizeof(bip_data); - apdu[index_counter++] = 0x02; //2nd arg tag + apdu[index_counter++] = 0x02; // 2nd arg tag apdu[index_counter++] = msg_len; memcpy(apdu + index_counter, hash, msg_len); index_counter += msg_len; diff --git a/c/src/signer/ledger-nano/signer/ledger_signer.h b/c/src/signer/ledger-nano/signer/ledger_signer.h index 3f3cc522b..6e1d9bd73 100644 --- a/c/src/signer/ledger-nano/signer/ledger_signer.h +++ b/c/src/signer/ledger-nano/signer/ledger_signer.h @@ -1,42 +1,42 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER /** @file * this file defines the incubed configuration struct and it registration. - * - * + * + * * */ #ifndef in3_ledger_signer_h__ @@ -50,15 +50,15 @@ extern "C" { /** * attaches ledger nano hardware wallet signer with incubed . - * + * * bip32 path to be given to point the specific public/private key in HD tree for Ethereum! */ in3_ret_t eth_ledger_set_signer(in3_t* in3, uint8_t* bip_path); /** * returns public key at the bip_path . - * - * returns IN3_ENODEVICE error if ledger nano device is not connected + * + * returns IN3_ENODEVICE error if ledger nano device is not connected */ in3_ret_t eth_ledger_get_public_key(uint8_t* bip_path, uint8_t* public_key); diff --git a/c/src/signer/ledger-nano/signer/ledger_signer_priv.h b/c/src/signer/ledger-nano/signer/ledger_signer_priv.h index a9c3a8aa5..51ba334b8 100644 --- a/c/src/signer/ledger-nano/signer/ledger_signer_priv.h +++ b/c/src/signer/ledger-nano/signer/ledger_signer_priv.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #ifndef in3_ledger_signer_priv_h__ diff --git a/c/src/signer/ledger-nano/signer/types.h b/c/src/signer/ledger-nano/signer/types.h index 5345268f1..1b25d8abd 100644 --- a/c/src/signer/ledger-nano/signer/types.h +++ b/c/src/signer/ledger-nano/signer/types.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #ifndef in3_types_h__ @@ -52,7 +52,7 @@ typedef struct TXN_ { bytes_t to; bytes_t value; bytes_t data; - bytes_t v; //chain id + bytes_t v; // chain id bytes_t r; bytes_t s; } TXN; diff --git a/c/src/signer/ledger-nano/signer/utility.c b/c/src/signer/ledger-nano/signer/utility.c index a5e68b268..297e0764a 100644 --- a/c/src/signer/ledger-nano/signer/utility.c +++ b/c/src/signer/ledger-nano/signer/utility.c @@ -4,7 +4,7 @@ void extract_signture(bytes_t i_raw_sig, uint8_t* o_sig) { - //ECDSA signature encoded as TLV: 30 L 02 Lr r 02 Ls s + // ECDSA signature encoded as TLV: 30 L 02 Lr r 02 Ls s int lr = i_raw_sig.data[3]; int ls = i_raw_sig.data[lr + 5]; int offset = 0; diff --git a/c/src/signer/ledger-nano/signer/utility.h b/c/src/signer/ledger-nano/signer/utility.h index 455ece3f4..214794f3c 100644 --- a/c/src/signer/ledger-nano/signer/utility.h +++ b/c/src/signer/ledger-nano/signer/utility.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #ifndef in3_ledger_utility_h__ diff --git a/c/src/signer/multisig/multisig.c b/c/src/signer/multisig/multisig.c index d9af76aab..5f6225161 100644 --- a/c/src/signer/multisig/multisig.c +++ b/c/src/signer/multisig/multisig.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -155,7 +155,7 @@ in3_ret_t get_tx_hash(in3_req_t* ctx, multisig_t* ms, tx_data_t* tx_data, bytes3 ' uint256 gasPrice,'+ ' address gasToken,'+ ' address refundReceiver,'+ - ' uint256 _nonce'+ * + ' uint256 _nonce'+ * */ int offset_data = 4 + 10 * 32; int size = offset_data + ((tx_data->data.len + 31) / 32 + 1) * 32; @@ -447,7 +447,7 @@ in3_ret_t gs_create_contract_signature(multisig_t* ms, in3_sign_ctx_t* ctx) { break; case SIGN_EC_PREFIX: case SIGN_EC_HASH: { - //do we know the domain_seperator? + // do we know the domain_seperator? if (memiszero(ms->domain_sep, 32)) { // TODO get it from cache bytes_t* result = NULL; diff --git a/c/src/signer/multisig/multisig.h b/c/src/signer/multisig/multisig.h index 87d18f7e9..c1edf87bb 100644 --- a/c/src/signer/multisig/multisig.h +++ b/c/src/signer/multisig/multisig.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #include "../../core/client/client.h" diff --git a/c/src/signer/pk-signer/signer.c b/c/src/signer/pk-signer/signer.c index 074772887..84ef932f7 100644 --- a/c/src/signer/pk-signer/signer.c +++ b/c/src/signer/pk-signer/signer.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/signer/pk-signer/signer.h b/c/src/signer/pk-signer/signer.h index ca93d9283..5e5a02dc4 100644 --- a/c/src/signer/pk-signer/signer.h +++ b/c/src/signer/pk-signer/signer.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -65,7 +65,7 @@ typedef enum { /** * simply signer with one private key. - * + * * since the pk pointting to the 32 byte private key is not cloned, please make sure, you manage memory allocation correctly! */ in3_ret_t eth_set_pk_signer(in3_t* in3, bytes32_t pk); diff --git a/c/src/tools/clientdata/client_data.h b/c/src/tools/clientdata/client_data.h index eb2da0b52..d650013cc 100644 --- a/c/src/tools/clientdata/client_data.h +++ b/c/src/tools/clientdata/client_data.h @@ -42,4 +42,4 @@ void* in3_plugin_get_client_data(in3_t* c); in3_ret_t in3_register_client_data(in3_t* c, void* data); -#endif //IN3_CLIENT_DATA_H +#endif // IN3_CLIENT_DATA_H diff --git a/c/src/tools/swift/swift.h b/c/src/tools/swift/swift.h index 92a525b11..0243b1e66 100644 --- a/c/src/tools/swift/swift.h +++ b/c/src/tools/swift/swift.h @@ -48,4 +48,4 @@ typedef struct in3_swift_cb { in3_ret_t in3_register_swift(in3_t* _NONULL c, swift_cb_t* _NONULL cbs); -#endif //IN3_SWIFT_H +#endif // IN3_SWIFT_H diff --git a/c/src/transport/curl/in3_curl.c b/c/src/transport/curl/in3_curl.c index 1ae201fe0..b40862cd7 100644 --- a/c/src/transport/curl/in3_curl.c +++ b/c/src/transport/curl/in3_curl.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -257,7 +257,7 @@ in3_ret_t send_curl(void* plugin_data, in3_plugin_act_t action, void* plugin_ctx in3_ret_t res; uint64_t start = current_ms(); res = send_curl_blocking((const char**) req->urls, req->urls_len, req->payload, req->req->raw_response, req->req->client->timeout, req); - uint32_t t = (uint32_t)(current_ms() - start); + uint32_t t = (uint32_t) (current_ms() - start); for (int i = 0; i < req->urls_len; i++) req->req->raw_response[i].time = t; return res; #else diff --git a/c/src/transport/curl/in3_curl.h b/c/src/transport/curl/in3_curl.h index 3de4fc023..ed4453312 100644 --- a/c/src/transport/curl/in3_curl.h +++ b/c/src/transport/curl/in3_curl.h @@ -1,39 +1,39 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER -/** @file +/** @file * transport-handler using libcurl. */ @@ -48,7 +48,7 @@ extern "C" { /** * a transport function using curl. - * + * */ in3_ret_t send_curl(void* plugin_data, in3_plugin_act_t action, void* plugin_ctx); diff --git a/c/src/transport/http/in3_http.c b/c/src/transport/http/in3_http.c index f12d629d5..944dbb4d5 100644 --- a/c/src/transport/http/in3_http.c +++ b/c/src/transport/http/in3_http.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -106,7 +106,7 @@ in3_ret_t send_http(void* plugin_data, in3_plugin_act_t action, void* plugin_ctx continue; } - //Create a socket + // Create a socket if ((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { in3_ctx_add_response(req->req, n, true, "could not create the socket", -1, 0); continue; @@ -120,7 +120,7 @@ in3_ret_t send_http(void* plugin_data, in3_plugin_act_t action, void* plugin_ctx serv_addr.sin_family = AF_INET; serv_addr.sin_port = htons(portno); memcpy(&serv_addr.sin_addr.s_addr, server->h_addr, server->h_length); - //Connect to remote server + // Connect to remote server if (connect(s, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0) { in3_ctx_add_response(req->req, n, true, "Connection failed", -1, 0); continue; @@ -131,13 +131,13 @@ in3_ret_t send_http(void* plugin_data, in3_plugin_act_t action, void* plugin_ctx continue; } - //Receive a reply from the server + // Receive a reply from the server if ((received = recv(s, response, 2000, 0)) == SOCKET_ERROR) { in3_ctx_add_response(req->req, n, true, "Receive failed", -1, 0); continue; } - //Add a NULL terminating character to make it a proper string before printing + // Add a NULL terminating character to make it a proper string before printing response[received] = '\0'; in3_ctx_add_response(req->req, n, false, response, -1, 0); @@ -205,7 +205,7 @@ in3_ret_t send_http(void* plugin_data, in3_plugin_act_t action, void* plugin_ctx #endif - req->req->raw_response[n].time = (uint32_t)(current_ms() - start); + req->req->raw_response[n].time = (uint32_t) (current_ms() - start); // now evaluate the response diff --git a/c/src/transport/http/in3_http.h b/c/src/transport/http/in3_http.h index dc07b91f9..264a01120 100644 --- a/c/src/transport/http/in3_http.h +++ b/c/src/transport/http/in3_http.h @@ -1,39 +1,39 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER -/** @file +/** @file * transport-handler using simple http. */ @@ -49,9 +49,9 @@ extern "C" { /** * a very simple transport function, which allows to send http-requests without a dependency to curl. * Here each request will be transformed to http instead of https. - * + * * You can use it by setting the transport-function-pointer in the in3_t->transport to this function: - * + * * ```c * #include * ... diff --git a/c/src/transport/winhttp/in3_winhttp.c b/c/src/transport/winhttp/in3_winhttp.c index 0c4fa4731..c26e7445c 100644 --- a/c/src/transport/winhttp/in3_winhttp.c +++ b/c/src/transport/winhttp/in3_winhttp.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/transport/winhttp/in3_winhttp.h b/c/src/transport/winhttp/in3_winhttp.h index 7e71f8072..c834d6d1b 100644 --- a/c/src/transport/winhttp/in3_winhttp.h +++ b/c/src/transport/winhttp/in3_winhttp.h @@ -1,39 +1,39 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER -/** @file +/** @file * transport-handler using simple http. */ diff --git a/c/src/verifier/btc/btc.c b/c/src/verifier/btc/btc.c index c6fb1ab8d..e53425fd5 100644 --- a/c/src/verifier/btc/btc.c +++ b/c/src/verifier/btc/btc.c @@ -319,7 +319,7 @@ in3_ret_t btc_verify_tx(btc_target_conf_t* conf, in3_vctx_t* vc, uint8_t* tx_id, in3_ret_t btc_verify_blockcount(btc_target_conf_t* conf, in3_vctx_t* vc) { UNUSED_VAR(conf); // verify the blockheader - //TODO verify the proof + // TODO verify the proof return vc->proof ? IN3_OK : vc_err(vc, "missing the proof"); } diff --git a/c/src/verifier/btc/btc_merkle.h b/c/src/verifier/btc/btc_merkle.h index 09ae5764c..074133cc8 100644 --- a/c/src/verifier/btc/btc_merkle.h +++ b/c/src/verifier/btc/btc_merkle.h @@ -5,7 +5,7 @@ #include "../../core/util/error.h" #include -/** +/** * creates the merkle root based on the given hashes */ in3_ret_t btc_merkle_create_root( diff --git a/c/src/verifier/btc/btc_target.h b/c/src/verifier/btc/btc_target.h index 13b57477d..75cebefaa 100644 --- a/c/src/verifier/btc/btc_target.h +++ b/c/src/verifier/btc/btc_target.h @@ -30,11 +30,11 @@ typedef struct btc_target_conf { /** * @brief checks if the target is within a range - * @note - * @param vc: - * @param old_target: - * @param new_target: - * @retval + * @note + * @param vc: + * @param old_target: + * @param new_target: + * @retval */ in3_ret_t btc_new_target_check(in3_vctx_t* vc, bytes32_t old_target, bytes32_t new_target); diff --git a/c/src/verifier/btc/btc_types.c b/c/src/verifier/btc/btc_types.c index ce424556b..d75c6e551 100644 --- a/c/src/verifier/btc/btc_types.c +++ b/c/src/verifier/btc/btc_types.c @@ -74,7 +74,7 @@ in3_ret_t btc_tx_id(btc_tx_t* tx, bytes32_t dst) { data.data = data.len > 1000 ? _malloc(data.len) : alloca(data.len); memcpy(data.data, tx->all.data, 4); // nVersion memcpy(data.data + 4, start, data.len - 8); // txins/txouts - memcpy(data.data + data.len - 4, tx->all.data + tx->all.len - 4, 4); //lockTime + memcpy(data.data + data.len - 4, tx->all.data + tx->all.len - 4, 4); // lockTime btc_hash(data, dst); if (data.len > 1000) _free(data.data); diff --git a/c/src/verifier/eth1/basic/eth_account.c b/c/src/verifier/eth1/basic/eth_account.c index e621b5d49..ca40df883 100644 --- a/c/src/verifier/eth1/basic/eth_account.c +++ b/c/src/verifier/eth1/basic/eth_account.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -165,7 +165,7 @@ in3_ret_t eth_verify_account_proof(in3_vctx_t* vc) { if (strcmp(vc->method, "eth_call") == 0) contract = d_getl(d_get_at(d_get(vc->request, K_PARAMS), 0), K_TO, 20); - //now check the results + // now check the results if (!(accounts = d_get(vc->proof, K_ACCOUNTS))) return vc_err(vc, "no accounts"); for (i = 0, t = accounts + 1; i < d_len(accounts); i++, t = d_next(t)) { if (verify_proof(vc, header, t)) diff --git a/c/src/verifier/eth1/basic/eth_basic.c b/c/src/verifier/eth1/basic/eth_basic.c index 9e6f6cf95..19f080621 100644 --- a/c/src/verifier/eth1/basic/eth_basic.c +++ b/c/src/verifier/eth1/basic/eth_basic.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/basic/eth_basic.h b/c/src/verifier/eth1/basic/eth_basic.h index 1f3ba3cb9..f9d01e7d6 100644 --- a/c/src/verifier/eth1/basic/eth_basic.h +++ b/c/src/verifier/eth1/basic/eth_basic.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER @@ -112,7 +112,7 @@ in3_ret_t in3_register_eth_basic(in3_t* c); in3_ret_t eth_verify_eth_getLog(in3_vctx_t* vc, int l_logs); /** - * prepares a transaction and writes the data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. + * prepares a transaction and writes the data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. */ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, /**< a json-token desribing the transaction */ in3_req_t* req, /**< the current context */ @@ -120,7 +120,7 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, /**< a json-token desribing th ); /** - * signs a unsigned raw transaction and writes the raw data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. + * signs a unsigned raw transaction and writes the raw data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. */ in3_ret_t eth_sign_raw_tx(bytes_t raw_tx, /**< the unsigned raw transaction to sign */ in3_req_t* req, /**< the current context */ diff --git a/c/src/verifier/eth1/basic/eth_getBlock.c b/c/src/verifier/eth1/basic/eth_getBlock.c index a3cbee71d..c0ed479b2 100644 --- a/c/src/verifier/eth1/basic/eth_getBlock.c +++ b/c/src/verifier/eth1/basic/eth_getBlock.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -76,7 +76,7 @@ in3_ret_t eth_verify_eth_getBlockTransactionCount(in3_vctx_t* vc, bytes_t* block if (d_type(vc->result) != T_INTEGER) return vc_err(vc, "Invalid transaction count"); - //transactions count + // transactions count int32_t count = d_int(vc->result); // this means result: null, which is ok, since we can not verify a transaction that does not exists diff --git a/c/src/verifier/eth1/basic/eth_getLog.c b/c/src/verifier/eth1/basic/eth_getLog.c index cbda3415d..c9d9f3479 100644 --- a/c/src/verifier/eth1/basic/eth_getLog.c +++ b/c/src/verifier/eth1/basic/eth_getLog.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/basic/eth_getTransaction.c b/c/src/verifier/eth1/basic/eth_getTransaction.c index 1aa7ca39b..db19e3909 100644 --- a/c/src/verifier/eth1/basic/eth_getTransaction.c +++ b/c/src/verifier/eth1/basic/eth_getTransaction.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/basic/filter.c b/c/src/verifier/eth1/basic/filter.c index 12ef044c6..7bc128912 100644 --- a/c/src/verifier/eth1/basic/filter.c +++ b/c/src/verifier/eth1/basic/filter.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/basic/filter.h b/c/src/verifier/eth1/basic/filter.h index 2cdeb1cc5..4202fb007 100644 --- a/c/src/verifier/eth1/basic/filter.h +++ b/c/src/verifier/eth1/basic/filter.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -45,4 +45,4 @@ in3_ret_t filter_get_changes(in3_filter_handler_t* filters, in3_req_t* req, size bool filter_opt_valid(d_token_t* tx_params); char* filter_opt_set_fromBlock(char* fopt, uint64_t toBlock, bool should_overwrite); -#endif //FILTER_H +#endif // FILTER_H diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index 413cb8d3f..891d0aaef 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -151,7 +151,7 @@ static inline uint64_t get_v(chain_id_t chain) { } /** - * prepares a transaction and writes the data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. + * prepares a transaction and writes the data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. */ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst) { address_t from; @@ -204,7 +204,7 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst) { } /** - * signs a unsigned raw transaction and writes the raw data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. + * signs a unsigned raw transaction and writes the raw data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. */ in3_ret_t eth_sign_raw_tx(bytes_t raw_tx, in3_req_t* ctx, address_t from, bytes_t* dst) { bytes_t signature; diff --git a/c/src/verifier/eth1/basic/trie.c b/c/src/verifier/eth1/basic/trie.c index fc8eda8dd..41e8acdc7 100644 --- a/c/src/verifier/eth1/basic/trie.c +++ b/c/src/verifier/eth1/basic/trie.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/basic/trie.h b/c/src/verifier/eth1/basic/trie.h index bd9d8d963..facc5735f 100644 --- a/c/src/verifier/eth1/basic/trie.h +++ b/c/src/verifier/eth1/basic/trie.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/accounts.c b/c/src/verifier/eth1/evm/accounts.c index 818ff7f1d..d6697e4d1 100644 --- a/c/src/verifier/eth1/evm/accounts.c +++ b/c/src/verifier/eth1/evm/accounts.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/accounts.h b/c/src/verifier/eth1/evm/accounts.h index cf47cd084..68f0c606e 100644 --- a/c/src/verifier/eth1/evm/accounts.h +++ b/c/src/verifier/eth1/evm/accounts.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/big.c b/c/src/verifier/eth1/evm/big.c index f6bfd54a1..f759705e3 100644 --- a/c/src/verifier/eth1/evm/big.c +++ b/c/src/verifier/eth1/evm/big.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -76,7 +76,7 @@ int big_sign(uint8_t* val, wlen_t len, uint8_t* dst) { } /** * returns 0 if the value is positive or 1 if negavtive. in this case the absolute value is copied to dst. -*/ + */ int big_signed(uint8_t* val, wlen_t len, uint8_t* dst) { if ((*val & 128) == 0) return 0; if (len > 32) return -1; @@ -153,7 +153,7 @@ int big_sub(uint8_t* a, wlen_t len_a, uint8_t* b, wlen_t len_b, uint8_t* out) { uint_fast16_t carry = 0; if (l > 32) l = 32; for (int_fast8_t i = l - 1;; i--) { - carry = (uint_fast16_t)(len_a ? a[--len_a] : 0) - (uint_fast16_t)(len_b ? b[--len_b] : 0) - (uint_fast16_t) borrow; + carry = (uint_fast16_t) (len_a ? a[--len_a] : 0) - (uint_fast16_t) (len_b ? b[--len_b] : 0) - (uint_fast16_t) borrow; out[i] = carry & 0xFF; borrow = (carry >> 8) & 1; if (i == 0) break; diff --git a/c/src/verifier/eth1/evm/big.h b/c/src/verifier/eth1/evm/big.h index 40c2da1b8..c8ba1859d 100644 --- a/c/src/verifier/eth1/evm/big.h +++ b/c/src/verifier/eth1/evm/big.h @@ -1,38 +1,38 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * Ethereum Nanon verification. * */ diff --git a/c/src/verifier/eth1/evm/code.c b/c/src/verifier/eth1/evm/code.c index 1f4bd520d..f63460a37 100644 --- a/c/src/verifier/eth1/evm/code.c +++ b/c/src/verifier/eth1/evm/code.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/code.h b/c/src/verifier/eth1/evm/code.h index 6e87e3221..50b69bb37 100644 --- a/c/src/verifier/eth1/evm/code.h +++ b/c/src/verifier/eth1/evm/code.h @@ -1,38 +1,38 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * code cache. * */ diff --git a/c/src/verifier/eth1/evm/env.c b/c/src/verifier/eth1/evm/env.c index 07f5ae40e..9739427a9 100644 --- a/c/src/verifier/eth1/evm/env.c +++ b/c/src/verifier/eth1/evm/env.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/evm.c b/c/src/verifier/eth1/evm/evm.c index 32e16fd15..cf73a444e 100644 --- a/c/src/verifier/eth1/evm/evm.c +++ b/c/src/verifier/eth1/evm/evm.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/evm.h b/c/src/verifier/eth1/evm/evm.h index 050a79d1b..82a1a12e2 100644 --- a/c/src/verifier/eth1/evm/evm.h +++ b/c/src/verifier/eth1/evm/evm.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -85,7 +85,7 @@ typedef enum evm_state { #define EVM_PROP_ISTANBUL 32 #define EVM_PROP_NO_FINALIZE 32768 #define EVM_PROP_STATIC 256 -#define EVM_PROP_TXCREATE 512 /**< executing a creation transaction > */ +#define EVM_PROP_TXCREATE 512 /**< executing a creation transaction > */ #define EVM_PROP_CALL_DEPEND_ON_REFUND 1024 /**< executing code that depends on subcall gas refund to succeed > */ #define EVM_ENV_BALANCE 1 @@ -201,16 +201,16 @@ typedef enum evm_state { /** * This function provides data from the enviroment. - * - * depending on the key the function will set the out_data-pointer to the result. + * + * depending on the key the function will set the out_data-pointer to the result. * This means the enviroment is responsible for memory management and also to clean up resources afterwards. - * + * * @param evm passes the current evm-pointer * @param evm_key the requested value * @param in_data the pointer to the argument like the address - * @param - * - * + * @param + * + * */ typedef int (*evm_get_env)(void* evm, uint16_t evm_key, uint8_t* in_data, int in_len, uint8_t** out_data, int offset, int len); diff --git a/c/src/verifier/eth1/evm/evm_mem.h b/c/src/verifier/eth1/evm/evm_mem.h index b08125d4b..c4e362786 100644 --- a/c/src/verifier/eth1/evm/evm_mem.h +++ b/c/src/verifier/eth1/evm/evm_mem.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/gas.c b/c/src/verifier/eth1/evm/gas.c index 51dbf1e3c..df9c54e4f 100644 --- a/c/src/verifier/eth1/evm/gas.c +++ b/c/src/verifier/eth1/evm/gas.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/gas.h b/c/src/verifier/eth1/evm/gas.h index e80675061..cb34f0fc3 100644 --- a/c/src/verifier/eth1/evm/gas.h +++ b/c/src/verifier/eth1/evm/gas.h @@ -1,38 +1,38 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * evm gas defines. * */ diff --git a/c/src/verifier/eth1/evm/opcodes.c b/c/src/verifier/eth1/evm/opcodes.c index 550eaba67..43c8f39a7 100644 --- a/c/src/verifier/eth1/evm/opcodes.c +++ b/c/src/verifier/eth1/evm/opcodes.c @@ -243,7 +243,7 @@ int op_shift(evm_t* evm, uint8_t left) { if (l == EVM_ERROR_EMPTY_STACK) return l; if (l < 0) { // the number is out of range if ((l = evm_stack_pop_ref(evm, &b)) < 0) return EVM_ERROR_EMPTY_STACK; - if (left == 2 && l == 32 && (*b & 128)) { //signed number return max NUMBER as fault + if (left == 2 && l == 32 && (*b & 128)) { // signed number return max NUMBER as fault memset(res, 0xFF, 32); return evm_stack_push(evm, res, 32); } diff --git a/c/src/verifier/eth1/evm/opcodes.h b/c/src/verifier/eth1/evm/opcodes.h index 8523fbf1b..2c44121a8 100644 --- a/c/src/verifier/eth1/evm/opcodes.h +++ b/c/src/verifier/eth1/evm/opcodes.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/pre_blake2.c b/c/src/verifier/eth1/evm/pre_blake2.c index e7dad25a8..1f468a632 100644 --- a/c/src/verifier/eth1/evm/pre_blake2.c +++ b/c/src/verifier/eth1/evm/pre_blake2.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/pre_ec.c b/c/src/verifier/eth1/evm/pre_ec.c index 0dab559ce..d1f472518 100644 --- a/c/src/verifier/eth1/evm/pre_ec.c +++ b/c/src/verifier/eth1/evm/pre_ec.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/precompiled.c b/c/src/verifier/eth1/evm/precompiled.c index 894ac38c3..88d3d43ef 100644 --- a/c/src/verifier/eth1/evm/precompiled.c +++ b/c/src/verifier/eth1/evm/precompiled.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/evm/precompiled.h b/c/src/verifier/eth1/evm/precompiled.h index 6f828dbcf..72469383a 100644 --- a/c/src/verifier/eth1/evm/precompiled.h +++ b/c/src/verifier/eth1/evm/precompiled.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/full/eth_full.c b/c/src/verifier/eth1/full/eth_full.c index 2bfbbecfd..bfebfebf6 100644 --- a/c/src/verifier/eth1/full/eth_full.c +++ b/c/src/verifier/eth1/full/eth_full.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/full/eth_full.h b/c/src/verifier/eth1/full/eth_full.h index d768cbd29..850456728 100644 --- a/c/src/verifier/eth1/full/eth_full.h +++ b/c/src/verifier/eth1/full/eth_full.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER diff --git a/c/src/verifier/eth1/nano/blockheader.c b/c/src/verifier/eth1/nano/blockheader.c index 2d059863d..9adcf61b9 100644 --- a/c/src/verifier/eth1/nano/blockheader.c +++ b/c/src/verifier/eth1/nano/blockheader.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/nano/chains.h b/c/src/verifier/eth1/nano/chains.h index b8f8f36d7..8109681b0 100644 --- a/c/src/verifier/eth1/nano/chains.h +++ b/c/src/verifier/eth1/nano/chains.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/nano/chainspec.c b/c/src/verifier/eth1/nano/chainspec.c index f71a5178a..99004a504 100644 --- a/c/src/verifier/eth1/nano/chainspec.c +++ b/c/src/verifier/eth1/nano/chainspec.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/nano/chainspec.h b/c/src/verifier/eth1/nano/chainspec.h index 3e5245285..919c4bc58 100644 --- a/c/src/verifier/eth1/nano/chainspec.h +++ b/c/src/verifier/eth1/nano/chainspec.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -48,7 +48,7 @@ /** * defines the flags for the current activated EIPs. * Since it does not make sense to support a evm defined before Homestead, homestead EIP is always turned on! - * + * */ typedef struct __attribute__((__packed__)) eip_ { @@ -71,8 +71,8 @@ typedef struct __attribute__((__packed__)) eip_ { } eip_t; /** the consensus type. - * -*/ + * + */ typedef enum { ETH_POW = 0, /**< Pro of Work (Ethash) */ ETH_POA_AURA = 1, /**< Proof of Authority using Aura */ diff --git a/c/src/verifier/eth1/nano/eth_nano.c b/c/src/verifier/eth1/nano/eth_nano.c index b1d297009..4ecf14564 100644 --- a/c/src/verifier/eth1/nano/eth_nano.c +++ b/c/src/verifier/eth1/nano/eth_nano.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/nano/eth_nano.h b/c/src/verifier/eth1/nano/eth_nano.h index cf242364e..fe2980952 100644 --- a/c/src/verifier/eth1/nano/eth_nano.h +++ b/c/src/verifier/eth1/nano/eth_nano.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER @@ -48,12 +48,12 @@ NONULL in3_ret_t in3_verify_eth_nano(void* p_data, in3_plugin_act_t action, void NONULL_FOR((1, 2)) in3_ret_t eth_verify_blockheader(in3_vctx_t* vc, bytes_t* header, bytes_t* expected_blockhash); -/** +/** * verifies a single signature blockheader. - * - * This function will return a positive integer with a bitmask holding the bit set according to the address that signed it. + * + * This function will return a positive integer with a bitmask holding the bit set according to the address that signed it. * This is based on the signatiures in the request-config. - * + * */ NONULL unsigned int eth_verify_signature(in3_vctx_t* vc, bytes_t* msg_hash, d_token_t* sig); @@ -74,7 +74,7 @@ NONULL in3_ret_t in3_register_eth_nano(in3_t* c); /** * helper function to rlp-encode the transaction_index. - * + * * The result must be freed after use! */ bytes_t* create_tx_path(uint32_t index); diff --git a/c/src/verifier/eth1/nano/merkle.c b/c/src/verifier/eth1/nano/merkle.c index 168566de7..bbbc4bfb0 100644 --- a/c/src/verifier/eth1/nano/merkle.c +++ b/c/src/verifier/eth1/nano/merkle.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/nano/merkle.h b/c/src/verifier/eth1/nano/merkle.h index 0b5c99589..db43cce89 100644 --- a/c/src/verifier/eth1/nano/merkle.h +++ b/c/src/verifier/eth1/nano/merkle.h @@ -1,40 +1,40 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * Merkle Proof Verification. - * + * * */ #include "../../../core/util/bytes.h" @@ -48,30 +48,30 @@ /** * verifies a merkle proof. - * + * * * expectedValue == NULL : value must not exist * expectedValue.data ==NULL : please copy the data I want to evaluate it afterwards. * expectedValue.data !=NULL : the value must match the data. - * + * * \param rootHash the expected root hash of the trie. * \param path the path the the value * \param proof a array of bytes of rlp encoded nodes. This array must be terminatzed with a NULL-Pointer. - * \param expectedValue a byte-object with the raw value. If the data-pointer is NULL, it will be set to the last leaf and can be checked afterwards. + * \param expectedValue a byte-object with the raw value. If the data-pointer is NULL, it will be set to the last leaf and can be checked afterwards. */ NONULL_FOR((1, 2, 3)) int trie_verify_proof(bytes_t* rootHash, bytes_t* path, bytes_t** proof, bytes_t* expectedValue); /** * helper function split a path into 4-bit nibbles. - * + * * The result must be freed after use! - * + * * \param path the path of bytes. * \param use_prefix if true (or 1) the first byte of the path is interpreded as the leaf or extension marker. - * - * \return the resulting bytes represent a 4bit-number each and are terminated with a 0xFF. - * + * + * \return the resulting bytes represent a 4bit-number each and are terminated with a 0xFF. + * */ NONULL uint8_t* trie_path_to_nibbles(bytes_t path, int use_prefix); diff --git a/c/src/verifier/eth1/nano/rlp.c b/c/src/verifier/eth1/nano/rlp.c index f28359adc..3246ce8da 100644 --- a/c/src/verifier/eth1/nano/rlp.c +++ b/c/src/verifier/eth1/nano/rlp.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -74,7 +74,7 @@ int rlp_decode(bytes_t* b, int index, bytes_t* dst) { i += c - 0x80; } else if (c < 0xc0) { // very long item - for (l = 0, n = 0; n < (uint8_t)(c - 0xB7); n++) l |= (*(b->data + i + 1 + n)) << (8 * ((c - 0xb7) - n - 1)); + for (l = 0, n = 0; n < (uint8_t) (c - 0xB7); n++) l |= (*(b->data + i + 1 + n)) << (8 * ((c - 0xb7) - n - 1)); if ((int) p == index) return ref(dst, b, l, b->data + i + c - 0xb7 + 1, 1); i += l + c - 0xb7; } @@ -84,7 +84,7 @@ int rlp_decode(bytes_t* b, int index, bytes_t* dst) { i += l; // + 1; } else { // very long list - for (l = 0, n = 0; n < (uint8_t)(c - 0xF7); n++) l |= (*(b->data + i + 1 + n)) << (8 * ((c - 0xf7) - n - 1)); + for (l = 0, n = 0; n < (uint8_t) (c - 0xF7); n++) l |= (*(b->data + i + 1 + n)) << (8 * ((c - 0xf7) - n - 1)); if ((int) p == index) return ref(dst, b, l, b->data + i + c - 0xf7 + 1, 2); i += l + c - 0xf7; } diff --git a/c/src/verifier/eth1/nano/rlp.h b/c/src/verifier/eth1/nano/rlp.h index a277b663b..69e2ee719 100644 --- a/c/src/verifier/eth1/nano/rlp.h +++ b/c/src/verifier/eth1/nano/rlp.h @@ -1,40 +1,40 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * RLP-En/Decoding as described in the [Ethereum RLP-Spec](https://github.com/ethereum/wiki/wiki/RLP). - * + * * This decoding works without allocating new memory. * */ @@ -45,37 +45,37 @@ /** * this function decodes the given bytes and returns the element with the given index by updating the reference of dst. - * + * * the bytes will only hold references and do **not** need to be freed! * * ```c * bytes_t* tx_raw = serialize_tx(tx); - * + * * bytes_t item; - * + * * // decodes the tx_raw by letting the item point to range of the first element, which should be the body of a list. * if (rlp_decode(tx_raw, 0, &item) !=2) return -1 ; - * + * * // now decode the 4th element (which is the value) and let item point to that range. * if (rlp_decode(&item, 4, &item) !=1) return -1 ; - * + * * ``` * \param b the ptr to the incoming bytes to decode. * \param index the element to decode (if the index<0 the function returns the number of elements found.) * \param dst the bytes to store the range found. (only the data and len-property will be modified to point to the correct range.) - * + * * \return * - 0 : means item out of range * - 1 : item found - * - 2 : list found ( you can then decode the same bytes again) + * - 2 : list found ( you can then decode the same bytes again) */ int rlp_decode(bytes_t* b, int index, bytes_t* dst); /** * this function expects a list item (like the blockheader as first item and will then find the item within this list). - * - * It is a shortcut for - * + * + * It is a shortcut for + * * ```c * // decode the list * if (rlp_decode(b,0,dst)!=2) return 0; @@ -85,61 +85,61 @@ int rlp_decode(bytes_t* b, int index, bytes_t* dst); * \param b the ptr to the incoming bytes to decode. * \param index the element to decode (if the index<0 the function returns the number of elements found.) * \param dst the bytes to store the range found. (only the data and len-property will be modified to point to the correct range.) - * + * * \return * - 0 : means item out of range * - 1 : item found - * - 2 : list found ( you can then decode the same bytes again) + * - 2 : list found ( you can then decode the same bytes again) * */ int rlp_decode_in_list(bytes_t* b, int index, bytes_t* dst); /** * returns the number of elements found in the data. - * + * * \param b the ptr to the incoming bytes to decode. */ int rlp_decode_len(bytes_t* b); /** * encode a item as single string and add it to the bytes_builder. - * + * * \param bb a builder a dst * \param val the bytes to be added. - * + * */ void rlp_encode_item(bytes_builder_t* bb, bytes_t* val); /** * encode a the value as list of already encoded items. - * + * * \param bb a builder a dst * \param val the list to be added. - * + * */ void rlp_encode_list(bytes_builder_t* bb, bytes_t* val); /** * converts the data in the builder to a list. - * - * This function is optimized to not increase the memory more than needed and is fastet than - * creating a second builder to encode the data. - * + * + * This function is optimized to not increase the memory more than needed and is fastet than + * creating a second builder to encode the data. + * * \param bb the builder containing the data. - * + * * \return the same builder. */ bytes_builder_t* rlp_encode_to_list(bytes_builder_t* bb); /** * converts the data in the builder to a rlp-encoded item. - * - * This function is optimized to not increase the memory more than needed and is faster than - * creating a second builder to encode the data. - * + * + * This function is optimized to not increase the memory more than needed and is faster than + * creating a second builder to encode the data. + * * \param bb the builder containing the data. - * + * * \return the same builder. */ bytes_builder_t* rlp_encode_to_item(bytes_builder_t* bb); diff --git a/c/src/verifier/eth1/nano/serialize.c b/c/src/verifier/eth1/nano/serialize.c index dc05b95b4..e2ef6fc97 100644 --- a/c/src/verifier/eth1/nano/serialize.c +++ b/c/src/verifier/eth1/nano/serialize.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/nano/serialize.h b/c/src/verifier/eth1/nano/serialize.h index a8052ad1b..ecc5eef57 100644 --- a/c/src/verifier/eth1/nano/serialize.h +++ b/c/src/verifier/eth1/nano/serialize.h @@ -1,89 +1,89 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ -/** @file +/** @file * serialization of ETH-Objects. - * + * * This incoming tokens will represent their values as properties based on [JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC). - * + * * */ #include "../../../core/util/data.h" /** * creates rlp-encoded raw bytes for a receipt. - * + * * The bytes must be freed with b_free after use! - * + * * \param receipt the json-onject as descibed in [eth_getTransactionReceipt](https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionreceipt) */ bytes_t* serialize_tx_receipt(d_token_t* receipt); /** * creates rlp-encoded raw bytes for a transaction. - * + * * The bytes must be freed with b_free after use! - * + * * \param receipt the json-onject as descibed in [eth_getTransactionByHash](https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_gettransactionbyhash) - * + * */ bytes_t* serialize_tx(d_token_t* tx); /** * creates rlp-encoded raw bytes for a transaction from direct values. - * + * * The bytes must be freed with b_free after use! - * - * + * + * */ bytes_t* serialize_tx_raw(bytes_t nonce, bytes_t gas_price, bytes_t gas_limit, bytes_t to, bytes_t value, bytes_t data, uint64_t v, bytes_t r, bytes_t s); /** * creates rlp-encoded raw bytes for a account. - * + * * The bytes must be freed with b_free after use! - * - * + * + * */ bytes_t* serialize_account(d_token_t* a); /** * creates rlp-encoded raw bytes for a blockheader. - * + * * The bytes must be freed with b_free after use! - * + * * \param receipt the json-onject as descibed in [eth_getBlockByHash](https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbyhash) */ bytes_t* serialize_block_header(d_token_t* block); @@ -93,7 +93,7 @@ bytes_t* serialize_block_header(d_token_t* block); * \param ml the minimum number of bytes. if the length is 0, a one byte-string with 0x00 will be written as 0x. * \param rlp the builder to add to. * \param t the token representing the value. must be a integer, bytes or NULL. - * + * * \return 0 if added -1 if the value could not be handled. */ int rlp_add(bytes_builder_t* rlp, d_token_t* t, int ml); diff --git a/c/src/verifier/eth1/nano/signature.c b/c/src/verifier/eth1/nano/signature.c index f84afc227..fbf7b5f7d 100644 --- a/c/src/verifier/eth1/nano/signature.c +++ b/c/src/verifier/eth1/nano/signature.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/nano/txreceipt.c b/c/src/verifier/eth1/nano/txreceipt.c index 6b865ba92..7a301eb88 100644 --- a/c/src/verifier/eth1/nano/txreceipt.c +++ b/c/src/verifier/eth1/nano/txreceipt.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/c/src/verifier/eth1/nano/vhist.c b/c/src/verifier/eth1/nano/vhist.c index c11b20683..9b7498f78 100644 --- a/c/src/verifier/eth1/nano/vhist.c +++ b/c/src/verifier/eth1/nano/vhist.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ #ifdef POA diff --git a/c/src/verifier/eth1/nano/vhist.h b/c/src/verifier/eth1/nano/vhist.h index 3c12be640..28adac113 100644 --- a/c/src/verifier/eth1/nano/vhist.h +++ b/c/src/verifier/eth1/nano/vhist.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -62,4 +62,4 @@ void vh_add_state(vhist_t* vh, d_token_t* state, bool is_spec); void vh_cache_save(vhist_t* vh, in3_t* c); vhist_t* vh_cache_retrieve(in3_t* c); -#endif //IN3_VHIST_H +#endif // IN3_VHIST_H diff --git a/c/src/verifier/eth1/rpc/rpc.h b/c/src/verifier/eth1/rpc/rpc.h index 40a218b90..89b8038bb 100644 --- a/c/src/verifier/eth1/rpc/rpc.h +++ b/c/src/verifier/eth1/rpc/rpc.h @@ -1,39 +1,39 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ // @PUBLIC_HEADER -/** +/** * Ethereum data structure verification. * */ diff --git a/c/src/verifier/ipfs/ipfs.h b/c/src/verifier/ipfs/ipfs.h index 16539ae7c..087791ee5 100644 --- a/c/src/verifier/ipfs/ipfs.h +++ b/c/src/verifier/ipfs/ipfs.h @@ -48,4 +48,4 @@ in3_ret_t ipfs_verify_hash(const char* content, const char* encoding, const char */ in3_ret_t in3_register_ipfs(in3_t* c); -#endif //IN3_IPFS_H +#endif // IN3_IPFS_H diff --git a/c/src/verifier/ipfs/ipfs.pb.h b/c/src/verifier/ipfs/ipfs.pb.h index d4d13c425..c1bd93316 100644 --- a/c/src/verifier/ipfs/ipfs.pb.h +++ b/c/src/verifier/ipfs/ipfs.pb.h @@ -51,7 +51,7 @@ typedef struct _PBLink { /* Helper constants for enums */ #define _Data_DataType_MIN Data_DataType_Raw #define _Data_DataType_MAX Data_DataType_HAMTShard -#define _Data_DataType_ARRAYSIZE ((Data_DataType)(Data_DataType_HAMTShard + 1)) +#define _Data_DataType_ARRAYSIZE ((Data_DataType) (Data_DataType_HAMTShard + 1)) /* Initializer values for message structs */ #define Data_init_default \ diff --git a/java/src/in3/IN3.java b/java/src/in3/IN3.java index 8f94a6ae2..3bf0e9b43 100644 --- a/java/src/in3/IN3.java +++ b/java/src/in3/IN3.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -93,7 +93,9 @@ protected void finalize() { free(); } - /** sets config object in the client */ + /** + * sets config object in the client + */ private native void setConfig(String val); protected void setConfig(ClientConfiguration config) { @@ -171,7 +173,9 @@ public void setStorageProvider(StorageProvider val) { initcache(); } - /** provides the ability to cache content */ + /** + * provides the ability to cache content + */ public StorageProvider getStorageProvider() { return provider; } @@ -191,10 +195,14 @@ public IN3Transport getTransport() { return IN3.transport; } - /** servers to filter for the given chain. The chain-id based on EIP-155. */ + /** + * servers to filter for the given chain. The chain-id based on EIP-155. + */ public native long getChainId(); - /** sets the chain to be used. The chain-id based on EIP-155. */ + /** + * sets the chain to be used. The chain-id based on EIP-155. + */ public native void setChainId(long val); /** @@ -297,7 +305,9 @@ public Object sendRPCasObject(String method, Object[] params) { return sendRPCasObject(method, params, true); } - /** internal function to handle the internal requests */ + /** + * internal function to handle the internal requests + */ static byte[][] sendRequest(String method, String[] urls, byte[] payload, String[] headers) throws TransportException { return IN3.transport.handle(method, urls, payload, headers); } diff --git a/java/src/in3/Loader.java b/java/src/in3/Loader.java index a685e7362..4cdb0de95 100644 --- a/java/src/in3/Loader.java +++ b/java/src/in3/Loader.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/java/src/in3/NodeList.java b/java/src/in3/NodeList.java index 02547ae65..60621969e 100644 --- a/java/src/in3/NodeList.java +++ b/java/src/in3/NodeList.java @@ -31,7 +31,9 @@ protected static NodeList asNodeList(Object o) { return new NodeList((JSON) o); } - /** returns an array of IN3Node */ + /** + * returns an array of IN3Node + */ public IN3Node[] getNodes() { Object obj = data.get("nodes"); if (obj != null) { diff --git a/java/src/in3/Proof.java b/java/src/in3/Proof.java index 684c90a07..b5dc817e1 100644 --- a/java/src/in3/Proof.java +++ b/java/src/in3/Proof.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -39,10 +39,16 @@ */ public enum Proof { - /** No Verification */ + /** + No Verification + */ none, - /** Standard Verification of the important properties */ + /** + Standard Verification of the important properties + */ standard, - /** Full Verification including even uncles wich leads to higher payload */ + /** + Full Verification including even uncles wich leads to higher payload + */ full } diff --git a/java/src/in3/config/ClientConfiguration.java b/java/src/in3/config/ClientConfiguration.java index 4f7308e74..d71f5bd5e 100644 --- a/java/src/in3/config/ClientConfiguration.java +++ b/java/src/in3/config/ClientConfiguration.java @@ -26,7 +26,9 @@ public Integer getRequestCount() { return data.getInteger("requestCount"); } - /** sets the number of requests send when getting a first answer */ + /** + * sets the number of requests send when getting a first answer + */ public void setRequestCount(Integer requestCount) { setDirty(requestCount != getRequestCount()); data.put("requestCount", requestCount); @@ -50,7 +52,9 @@ public Proof getProof() { return proof != null ? Proof.valueOf(proof) : null; } - /** sets the type of proof used */ + /** + * sets the type of proof used + */ public void setProof(Proof proof) { setDirty(!isObjectEqual(getProof(), proof)); data.put("proof", proof.toString()); @@ -60,7 +64,9 @@ public Integer getMaxAttempts() { return data.getInteger("maxAttempts"); } - /** sets the max number of attempts before giving up */ + /** + * sets the max number of attempts before giving up + */ public void setMaxAttempts(int maxAttempts) { setDirty(maxAttempts != getMaxAttempts()); data.put("maxAttempts", maxAttempts); @@ -70,7 +76,9 @@ public Integer getSignatureCount() { return data.getInteger("signatureCount"); } - /** sets the number of signatures used to proof the blockhash. */ + /** + * sets the number of signatures used to proof the blockhash. + */ public void setSignatureCount(int signatureCount) { setDirty(signatureCount != getSignatureCount()); data.put("signatureCount", signatureCount); @@ -80,7 +88,9 @@ public Integer getFinality() { return data.getInteger("finality"); } - /** sets the number of signatures in percent required for the request */ + /** + * sets the number of signatures in percent required for the request + */ public void setFinality(int finality) { setDirty(finality != getFinality()); data.put("finality", finality); @@ -179,7 +189,9 @@ public Long getNodeLimit() { return data.getLong("nodeLimit"); } - /** sets the limit of nodes to store in the client. */ + /** + * sets the limit of nodes to store in the client. + */ public void setNodeLimit(long nodeLimit) { setDirty(nodeLimit != getNodeLimit()); data.put("nodeLimit", nodeLimit); @@ -193,7 +205,9 @@ public Integer getReplaceLatestBlock() { return data.getInteger("replaceLatestBlock"); } - /** replaces the *latest* with blockNumber- specified value */ + /** + * replaces the *latest* with blockNumber- specified value + */ public void setReplaceLatestBlock(int replaceLatestBlock) { setDirty(replaceLatestBlock != getReplaceLatestBlock()); data.put("replaceLatestBlock", replaceLatestBlock); diff --git a/java/src/in3/config/Configuration.java b/java/src/in3/config/Configuration.java index b12ecf3ae..9399daa11 100644 --- a/java/src/in3/config/Configuration.java +++ b/java/src/in3/config/Configuration.java @@ -5,8 +5,8 @@ */ public interface Configuration { /** - * generates a json-string based on the internal data. - */ + * generates a json-string based on the internal data. + */ public String toJSON(); public void markAsSynced(); public boolean isSynced(); diff --git a/java/src/in3/config/NodeRegistryConfiguration.java b/java/src/in3/config/NodeRegistryConfiguration.java index 0f47ce0ac..56c8f1880 100644 --- a/java/src/in3/config/NodeRegistryConfiguration.java +++ b/java/src/in3/config/NodeRegistryConfiguration.java @@ -85,7 +85,7 @@ public void markAsSynced() { /* * returns a COPY of the nodes array with the applied configuration - * + * * assert nodeConfiguration.getNodesConfiguration() != nodeConfiguration.getNodesConfiguration(); * assert Arrays.equals(nodeConfiguration.getNodesConfiguration(), nodeConfiguration.getNodesConfiguration()); */ diff --git a/java/src/in3/eth1/API.java b/java/src/in3/eth1/API.java index 2edcbcb78..17d8eba79 100644 --- a/java/src/in3/eth1/API.java +++ b/java/src/in3/eth1/API.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -83,273 +83,285 @@ public class API { private IN3 in3; /** - * creates an eth1.API using the given incubed instance. - */ + * creates an eth1.API using the given incubed instance. + */ public API(IN3 in3) { this.in3 = in3; } /** - * finds the Block as specified by the number. use `Block.LATEST` for getting - * the lastest block. - */ - public Block getBlockByNumber(long block, /** < the Blocknumber */ + * finds the Block as specified by the number. use `Block.LATEST` for getting + * the lastest block. + */ + public Block getBlockByNumber(long block, /** + < the Blocknumber + */ boolean includeTransactions /** - * < if true all Transactions will be includes, if not only the - * transactionhashes - */ + * < if true all Transactions will be includes, if not only the + * transactionhashes + */ ) { return Block.asBlock(in3.sendRPCasObject(GET_BLOCK_BY_NUMBER, new Object[] {getBlockString(block), includeTransactions})); } /** - * Returns information about a block by hash. - */ - public Block getBlockByHash(String blockHash, /** < the Blocknumber */ + * Returns information about a block by hash. + */ + public Block getBlockByHash(String blockHash, /** + < the Blocknumber + */ boolean includeTransactions /** - * < if true all Transactions will be includes, if not only the - * transactionhashes - */ + * < if true all Transactions will be includes, if not only the + * transactionhashes + */ ) { return Block .asBlock(in3.sendRPCasObject(BLOCK_BY_HASH, new Object[] {blockHash, includeTransactions})); } /** - * the current BlockNumber. - */ + * the current BlockNumber. + */ public long getBlockNumber() { return JSON.asLong(in3.sendRPCasObject(BLOCK_NUMBER, new Object[] {})); } /** - * the current Gas Price. - */ + * the current Gas Price. + */ public long getGasPrice() { return JSON.asLong(in3.sendRPCasObject(GAS_PRICE, new Object[] {})); } /** - * Returns the EIP155 chain ID used for transaction signing at the current best - * block. Null is returned if not available. - */ + * Returns the EIP155 chain ID used for transaction signing at the current best + * block. Null is returned if not available. + */ public String getChainId() { return JSON.asString(in3.sendRPCasObject(CHAIN_ID, new Object[] {})); } /** - * calls a function of a smart contract and returns the result. - * - * @return the decoded result. if only one return value is expected the Object - * will be returned, if not an array of objects will be the result. - */ - public Object call(TransactionRequest request, /** < the transaction to call. */ - long block /** < the Block used to for the state. */ + * calls a function of a smart contract and returns the result. + * + * @return the decoded result. if only one return value is expected the Object + * will be returned, if not an array of objects will be the result. + */ + public Object call(TransactionRequest request, /** + < the transaction to call. + */ + long block /** + < the Block used to for the state. + */ ) { return request.getResult((String) in3.sendRPCasObject(CALL, new Object[] {request.getTransactionJson(), getBlockString(block)})); } /** - * Makes a call or transaction, which won't be added to the blockchain and - * returns the used gas, which can be used for estimating the used gas. - * - * @return the gas required to call the function. - */ - public long estimateGas(TransactionRequest request, /** < the transaction to call. */ - long block /** < the Block used to for the state. */ + * Makes a call or transaction, which won't be added to the blockchain and + * returns the used gas, which can be used for estimating the used gas. + * + * @return the gas required to call the function. + */ + public long estimateGas(TransactionRequest request, /** + < the transaction to call. + */ + long block /** + < the Block used to for the state. + */ ) { return JSON.asLong(in3.sendRPCasObject(ESTIMATE_GAS, new Object[] {request.getTransactionJson(), getBlockString(block)})); } /** - * Returns the balance of the account of given address in wei. - */ + * Returns the balance of the account of given address in wei. + */ public BigInteger getBalance(String address, long block) { return JSON .asBigInteger(in3.sendRPCasObject(GET_BALANCE, new Object[] {address, getBlockString(block)})); } /** - * Returns code at a given address. - */ + * Returns code at a given address. + */ public String getCode(String address, long block) { return JSON.asString(in3.sendRPCasObject(GET_CODE, new Object[] {address, getBlockString(block)})); } /** - * Returns the value from a storage position at a given address. - */ + * Returns the value from a storage position at a given address. + */ public String getStorageAt(String address, BigInteger position, long block) { return JSON.asString(in3.sendRPCasObject(GET_STORAGE_AT, new Object[] {address, JSON.asString(position), getBlockString(block)})); } /** - * Returns the number of transactions in a block from a block matching the given - * block hash. - */ + * Returns the number of transactions in a block from a block matching the given + * block hash. + */ public long getBlockTransactionCountByHash(String blockHash) { return JSON.asLong(in3.sendRPCasObject(GET_BLOCK_TRANSACTION_COUNT_BY_HASH, new Object[] {blockHash})); } /** - * Returns the number of transactions in a block from a block matching the given - * block number. - */ + * Returns the number of transactions in a block from a block matching the given + * block number. + */ public long getBlockTransactionCountByNumber(long block) { return JSON.asLong( in3.sendRPCasObject(GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER, new Object[] {getBlockString(block)})); } /** - * Polling method for a filter, which returns an array of logs which occurred - * since last poll. - */ + * Polling method for a filter, which returns an array of logs which occurred + * since last poll. + */ public Log[] getFilterChangesFromLogs(long id) { return Log.asLogs(in3.sendRPCasObject(GET_FILTER_CHANGES, new Object[] {JSON.asString(id)})); } /** - * Polling method for a filter, which returns an array of logs which occurred - * since last poll. - */ + * Polling method for a filter, which returns an array of logs which occurred + * since last poll. + */ public String[] getFilterChangesFromBlocks(long id) { return JSON.asStringArray(in3.sendRPCasObject(GET_FILTER_CHANGES, new Object[] {JSON.asString(id)})); } /** - * Polling method for a filter, which returns an array of logs which occurred - * since last poll. - */ + * Polling method for a filter, which returns an array of logs which occurred + * since last poll. + */ public Log[] getFilterLogs(long id) { return Log.asLogs(in3.sendRPCasObject(GET_FILTER_LOGS, new Object[] {JSON.asString(id)})); } /** - * Polling method for a filter, which returns an array of logs which occurred - * since last poll. - */ + * Polling method for a filter, which returns an array of logs which occurred + * since last poll. + */ public Log[] getLogs(LogFilter filter) { return Log.asLogs(in3.sendRPCasObject(GET_LOGS, new Object[] {filter.toString()})); } /** - * Returns information about a transaction by block hash and transaction index - * position. - */ + * Returns information about a transaction by block hash and transaction index + * position. + */ public Transaction getTransactionByBlockHashAndIndex(String blockHash, int index) { return Transaction.asTransaction(in3.sendRPCasObject(GET_TRANSACTION_BY_BLOCK_HASH_AND_INDEX, new Object[] {blockHash, JSON.asString(index)})); } /** - * Returns information about a transaction by block number and transaction index - * position. - */ + * Returns information about a transaction by block number and transaction index + * position. + */ public Transaction getTransactionByBlockNumberAndIndex(long block, int index) { return Transaction.asTransaction(in3.sendRPCasObject(GET_TRANSACTION_BY_BLOCK_NUMBER_AND_INDEX, new Object[] {JSON.asString(block), JSON.asString(index)})); } /** - * Returns the information about a transaction requested by transaction hash. - */ + * Returns the information about a transaction requested by transaction hash. + */ public Transaction getTransactionByHash(String transactionHash) { return Transaction .asTransaction(in3.sendRPCasObject(GET_TRANSACTION_BY_HASH, new Object[] {transactionHash})); } /** - * Returns the number of transactions sent from an address. - */ + * Returns the number of transactions sent from an address. + */ public BigInteger getTransactionCount(String address, long block) { return JSON.asBigInteger( in3.sendRPCasObject(GET_TRANSACTION_COUNT, new Object[] {address, getBlockString(block)})); } /** - * Returns the number of transactions sent from an address. - */ + * Returns the number of transactions sent from an address. + */ public TransactionReceipt getTransactionReceipt(String transactionHash) { return TransactionReceipt.asTransactionReceipt( in3.sendRPCasObject(GET_TRANSACTION_RECEIPT, new Object[] {transactionHash})); } /** - * Returns information about a uncle of a block number and uncle index position. - * Note: An uncle doesn't contain individual transactions. - */ + * Returns information about a uncle of a block number and uncle index position. + * Note: An uncle doesn't contain individual transactions. + */ public Block getUncleByBlockNumberAndIndex(long block, int pos) { return Block.asBlock(in3.sendRPCasObject(GET_UNCLE_BY_BLOCK_NUMBER_AND_INDEX, new Object[] {getBlockString(block), JSON.asString(pos)})); } /** - * Returns the number of uncles in a block from a block matching the given block - * hash. - */ + * Returns the number of uncles in a block from a block matching the given block + * hash. + */ public long getUncleCountByBlockHash(String block) { return JSON.asLong(in3.sendRPCasObject(GET_UNCLE_COUNT_BY_BLOCK_HASH, new Object[] {block})); } /** - * Returns the number of uncles in a block from a block matching the given block - * hash. - */ + * Returns the number of uncles in a block from a block matching the given block + * hash. + */ public long getUncleCountByBlockNumber(long block) { return JSON .asLong(in3.sendRPCasObject(GET_UNCLE_COUNT_BY_BLOCK_NUMBER, new Object[] {getBlockString(block)})); } /** - * Creates a filter in the node, to notify when a new block arrives. To check if - * the state has changed, call eth_getFilterChanges. - */ + * Creates a filter in the node, to notify when a new block arrives. To check if + * the state has changed, call eth_getFilterChanges. + */ public long newBlockFilter() { return JSON.asLong(in3.sendRPCasObject(NEW_BLOCK_FILTER, new Object[] {})); } /** - * Creates a filter object, based on filter options, to notify when the state - * changes (logs). To check if the state has changed, call eth_getFilterChanges. - * - * A note on specifying topic filters: Topics are order-dependent. A transaction - * with a log with topics [A, B] will be matched by the following topic filters: - * - * [] "anything" [A] "A in first position (and anything after)" [null, B] - * "anything in first position AND B in second position (and anything after)" - * [A, B] "A in first position AND B in second position (and anything after)" - * [[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position - * (and anything after)" - * - */ + * Creates a filter object, based on filter options, to notify when the state + * changes (logs). To check if the state has changed, call eth_getFilterChanges. + * + * A note on specifying topic filters: Topics are order-dependent. A transaction + * with a log with topics [A, B] will be matched by the following topic filters: + * + * [] "anything" [A] "A in first position (and anything after)" [null, B] + * "anything in first position AND B in second position (and anything after)" + * [A, B] "A in first position AND B in second position (and anything after)" + * [[A, B], [A, B]] "(A OR B) in first position AND (A OR B) in second position + * (and anything after)" + * + */ public long newLogFilter(LogFilter filter) { return JSON.asLong(in3.sendRPCasObject(NEW_FILTER, new Object[] {filter.toString()})); } /** - * uninstall filter. - */ + * uninstall filter. + */ public boolean uninstallFilter(long filter) { return (boolean) in3.sendRPCasObject(UNINSTALL_FILTER, new Object[] {JSON.asString(filter)}); } /** - * Creates new message call transaction or a contract creation for signed - * transactions. - * - * @return transactionHash - */ + * Creates new message call transaction or a contract creation for signed + * transactions. + * + * @return transactionHash + */ public String sendRawTransaction(String data) { return JSON.asString(in3.sendRPCasObject(SEND_RAW_TRANSACTION, new Object[] {data})); } /** - * encodes the arguments as described in the method signature using ABI-Encoding. - */ + * encodes the arguments as described in the method signature using ABI-Encoding. + */ public String abiEncode(String signature, String[] params) { Object rawResult = in3.sendRPCasObject(ABI_ENCODE, new Object[] { signature, @@ -358,45 +370,45 @@ public String abiEncode(String signature, String[] params) { } /** - * decodes the data based on the signature. - */ + * decodes the data based on the signature. + */ public String[] abiDecode(String signature, String encoded) { Object rawResult = in3.sendRPCasObject(ABI_DECODE, new Object[] {signature, encoded}); return JSON.asStringArray(rawResult); } /** - * converts the given address to a checksum address. - */ + * converts the given address to a checksum address. + */ public String checksumAddress(String address) { return checksumAddress(address, null); } /** - * converts the given address to a checksum address. Second parameter includes the chainId. - */ + * converts the given address to a checksum address. Second parameter includes the chainId. + */ public String checksumAddress(String address, Boolean useChainId) { return JSON.asString(in3.sendRPCasObject(CHECKSUM_ADDRESS, new Object[] {address, useChainId})); } /** - * resolve ens-name. - */ + * resolve ens-name. + */ public String ens(String name) { return ens(name, null); } /** - * resolve ens-name. Second parameter especifies if it is an address, owner, resolver or hash. - */ + * resolve ens-name. Second parameter especifies if it is an address, owner, resolver or hash. + */ public String ens(String name, ENSMethod type) { return JSON.asString(in3.sendRPCasObject(ENS, new Object[] {name, type}, false)); } /** - * sends a Transaction as described by the TransactionRequest. This will require - * a signer to be set in order to sign the transaction. - */ + * sends a Transaction as described by the TransactionRequest. This will require + * a signer to be set in order to sign the transaction. + */ public String sendTransaction(TransactionRequest tx) { Signer signer = in3.getSigner(); if (signer == null) @@ -411,11 +423,11 @@ public String sendTransaction(TransactionRequest tx) { } /** - * the current Gas Price. - * - * @return the decoded result. if only one return value is expected the Object - * will be returned, if not an array of objects will be the result. - */ + * the current Gas Price. + * + * @return the decoded result. if only one return value is expected the Object + * will be returned, if not an array of objects will be the result. + */ public Object call(String to, String function, Object... params) { TransactionRequest req = new TransactionRequest(); req.setTo(to); diff --git a/java/src/in3/eth1/Block.java b/java/src/in3/eth1/Block.java index 878e445c8..217a9d890 100644 --- a/java/src/in3/eth1/Block.java +++ b/java/src/in3/eth1/Block.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -39,7 +39,7 @@ /** * represents a Block in ethereum. - * + * */ public class Block { diff --git a/java/src/in3/eth1/Log.java b/java/src/in3/eth1/Log.java index 1e597e9d9..214615e7b 100644 --- a/java/src/in3/eth1/Log.java +++ b/java/src/in3/eth1/Log.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -39,7 +39,7 @@ /** * a log entry of a transaction receipt. - * + * */ public class Log { @@ -70,65 +70,65 @@ protected static Log asLog(Object o) { } /** - * true when the log was removed, due to a chain reorganization. false if its a - * valid log. - */ + * true when the log was removed, due to a chain reorganization. false if its a + * valid log. + */ public boolean isRemoved() { return (Boolean) data.get("removed"); } /** - * integer of the log index position in the block. null when its pending log. - */ + * integer of the log index position in the block. null when its pending log. + */ public int getLogIndex() { return JSON.asInt(data.get("logIndex")); } /** - * integer of the transactions index position log was created from. null when - * its pending log. - */ + * integer of the transactions index position log was created from. null when + * its pending log. + */ public int gettTansactionIndex() { return JSON.asInt(data.get("transactionIndex")); } /** - * Hash, 32 Bytes - hash of the transactions this log was created from. null - * when its pending log. - */ + * Hash, 32 Bytes - hash of the transactions this log was created from. null + * when its pending log. + */ public String getTransactionHash() { return data.getString("transactionHash"); } /** - * Hash, 32 Bytes - hash of the block where this log was in. null when its - * pending. null when its pending log. - */ + * Hash, 32 Bytes - hash of the block where this log was in. null when its + * pending. null when its pending log. + */ public String getBlockHash() { return data.getString("blockHash"); } /** - * the block number where this log was in. null when its pending. null when its - * pending log. - */ + * the block number where this log was in. null when its pending. null when its + * pending log. + */ public long getBlockNumber() { return data.getLong("blockNumber"); } /** - * 20 Bytes - address from which this log originated. - */ + * 20 Bytes - address from which this log originated. + */ public String getAddress() { return data.getString("address"); } /** - * Array of 0 to 4 32 Bytes DATA of indexed log arguments. (In solidity: The - * first topic is the hash of the signature of the event (e.g. - * Deposit(address,bytes32,uint256)), except you declared the event with the - * anonymous specifier.) - */ + * Array of 0 to 4 32 Bytes DATA of indexed log arguments. (In solidity: The + * first topic is the hash of the signature of the event (e.g. + * Deposit(address,bytes32,uint256)), except you declared the event with the + * anonymous specifier.) + */ public String[] getTopics() { return data.getStringArray("topics"); } diff --git a/java/src/in3/eth1/LogFilter.java b/java/src/in3/eth1/LogFilter.java index 7902ad07f..0d9af01f1 100644 --- a/java/src/in3/eth1/LogFilter.java +++ b/java/src/in3/eth1/LogFilter.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -42,30 +42,32 @@ public class LogFilter { /** - * Quantity or Tag - (optional) (default: latest) Integer block number, or - * 'latest' for the last mined block or 'pending', 'earliest' for not yet mined - * transactions. - */ + * Quantity or Tag - (optional) (default: latest) Integer block number, or + * 'latest' for the last mined block or 'pending', 'earliest' for not yet mined + * transactions. + */ private long fromBlock = Block.LATEST; /** - * Quantity or Tag - (optional) (default: latest) Integer block number, or - * 'latest' for the last mined block or 'pending', 'earliest' for not yet mined - * transactions. - */ + * Quantity or Tag - (optional) (default: latest) Integer block number, or + * 'latest' for the last mined block or 'pending', 'earliest' for not yet mined + * transactions. + */ private long toBlock = Block.LATEST; /** - * (optional) 20 Bytes - Contract address or a list of addresses from which logs - * should originate. - */ + * (optional) 20 Bytes - Contract address or a list of addresses from which logs + * should originate. + */ private String address; /** - * (optional) Array of 32 Bytes Data topics. Topics are order-dependent. It's - * possible to pass in null to match any topic, or a subarray of multiple topics - * of which one should be matching. - */ + * (optional) Array of 32 Bytes Data topics. Topics are order-dependent. It's + * possible to pass in null to match any topic, or a subarray of multiple topics + * of which one should be matching. + */ private Object[] topics; - /** a(optional) The maximum number of entries to retrieve (latest first). */ + /** + * a(optional) The maximum number of entries to retrieve (latest first). + */ private int limit; public long getFromBlock() { @@ -109,8 +111,8 @@ public void setLimit(int limit) { } /** - * creates a JSON-String. - */ + * creates a JSON-String. + */ public String toString() { StringBuilder sb = new StringBuilder("{"); if (fromBlock >= 0) diff --git a/java/src/in3/eth1/SimpleWallet.java b/java/src/in3/eth1/SimpleWallet.java index 86acb6f7d..650b25bb7 100644 --- a/java/src/in3/eth1/SimpleWallet.java +++ b/java/src/in3/eth1/SimpleWallet.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -53,8 +53,8 @@ public class SimpleWallet implements Signer { Map privateKeys = new HashMap(); /** - * adds a key to the wallet and returns its public address. - */ + * adds a key to the wallet and returns its public address. + */ public String addRawKey(String data) { String address = getAddressFromKey(data); // create address @@ -63,8 +63,8 @@ public String addRawKey(String data) { } /** - * adds a key to the wallet and returns its public address. - */ + * adds a key to the wallet and returns its public address. + */ public String addKeyStore(String jsonData, String passphrase) { String data = decodeKeystore(jsonData, passphrase); if (data == null) @@ -74,21 +74,25 @@ public String addKeyStore(String jsonData, String passphrase) { } /** - * optiional method which allows to change the transaction-data before sending - * it. This can be used for redirecting it through a multisig. - */ + * optiional method which allows to change the transaction-data before sending + * it. This can be used for redirecting it through a multisig. + */ public TransactionRequest prepareTransaction(IN3 in3, TransactionRequest tx) { // TODO here you could transform the data in order to support multisigs. // for now we don't manipulate the data. return tx; } - /** returns true if the account is supported (or unlocked) */ + /** + * returns true if the account is supported (or unlocked) + */ public boolean canSign(String address) { return privateKeys.containsKey(address.toLowerCase()); } - /** signing of the raw data. */ + /** + * signing of the raw data. + */ public String sign(String data, String address) { String key = privateKeys.get(address.toLowerCase()); return signData(key, data); diff --git a/java/src/in3/eth1/Transaction.java b/java/src/in3/eth1/Transaction.java index 939f4373f..69ae1598d 100644 --- a/java/src/in3/eth1/Transaction.java +++ b/java/src/in3/eth1/Transaction.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -40,7 +40,7 @@ /** * represents a Transaction in ethereum. - * + * */ public class Transaction { @@ -56,106 +56,106 @@ public static Transaction asTransaction(Object o) { } /** - * the blockhash of the block containing this transaction. - */ + * the blockhash of the block containing this transaction. + */ public String getBlockHash() { return data.getString("blockHash"); } /** - * the block number of the block containing this transaction. - */ + * the block number of the block containing this transaction. + */ public long getBlockNumber() { return data.getLong("blockNumber"); } /** - * the chainId of this transaction. - */ + * the chainId of this transaction. + */ public String getChainId() { return data.getString("chainId"); } /** - * the address of the deployed contract (if successfull) - */ + * the address of the deployed contract (if successfull) + */ public String getCreatedContractAddress() { return data.getString("creates"); } /** - * the address of the sender. - */ + * the address of the sender. + */ public String getFrom() { return data.getString("from"); } /** - * the Transaction hash. - */ + * the Transaction hash. + */ public String getHash() { return data.getString("hash"); } /** - * the Transaction data or input data. - */ + * the Transaction data or input data. + */ public String getData() { return data.getString("input"); } /** - * the nonce used in the transaction. - */ + * the nonce used in the transaction. + */ public long getNonce() { return data.getLong("nonce"); } /** - * the public key of the sender. - */ + * the public key of the sender. + */ public String getPublicKey() { return data.getString("publicKey"); } /** - * the value send in wei. - */ + * the value send in wei. + */ public BigInteger getValue() { return data.getBigInteger("value"); } /** - * the raw transaction as rlp encoded data. - */ + * the raw transaction as rlp encoded data. + */ public String getRaw() { return data.getString("raw"); } /** - * the address of the receipient or contract. - */ + * the address of the receipient or contract. + */ public String getTo() { return data.getString("to"); } /** - * the signature of the sender - a array of the [ r, s, v] - */ + * the signature of the sender - a array of the [ r, s, v] + */ public String[] getSignature() { return new String[] {data.getString("r"), data.getString("s"), data.getString("v")}; } /** - * the gas price provided by the sender. - */ + * the gas price provided by the sender. + */ public long getGasPrice() { return data.getLong("gasPrice"); } /** - * the gas provided by the sender. - */ + * the gas provided by the sender. + */ public long getGas() { return data.getLong("gas"); } diff --git a/java/src/in3/eth1/TransactionReceipt.java b/java/src/in3/eth1/TransactionReceipt.java index 4f237ece3..ac0b66cdc 100644 --- a/java/src/in3/eth1/TransactionReceipt.java +++ b/java/src/in3/eth1/TransactionReceipt.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -39,7 +39,7 @@ /** * represents a Transaction receipt in ethereum. - * + * */ public class TransactionReceipt { @@ -55,92 +55,92 @@ protected static TransactionReceipt asTransactionReceipt(Object o) { } /** - * the blockhash of the block containing this transaction. - */ + * the blockhash of the block containing this transaction. + */ public String getBlockHash() { return data.getString("blockHash"); } /** - * the block number of the block containing this transaction. - */ + * the block number of the block containing this transaction. + */ public long getBlockNumber() { return data.getLong("blockNumber"); } /** - * the address of the deployed contract (if successfull) - */ + * the address of the deployed contract (if successfull) + */ public String getCreatedContractAddress() { return data.getString("contractAddress"); } /** - * the address of the sender. - */ + * the address of the sender. + */ public String getFrom() { return data.getString("from"); } /** - * the Transaction hash. - */ + * the Transaction hash. + */ public String getTransactionHash() { return data.getString("transactionHash"); } /** - * the Transaction index. - */ + * the Transaction index. + */ public int getTransactionIndex() { return JSON.asInt(data.get("transactionIndex")); } /** - * 20 Bytes - The address of the receiver. null when it's a contract creation - * transaction. - */ + * 20 Bytes - The address of the receiver. null when it's a contract creation + * transaction. + */ public String getTo() { return data.getString("to"); } /** - * The amount of gas used by this specific transaction alone. - */ + * The amount of gas used by this specific transaction alone. + */ public long getGasUsed() { return data.getLong("gasUsed"); } /** - * Array of log objects, which this transaction generated. - */ + * Array of log objects, which this transaction generated. + */ public Log[] getLogs() { return Log.asLogs(data.get("logs")); } /** - * 256 Bytes - A bloom filter of logs/events generated by contracts during - * transaction execution. Used to efficiently rule out transactions without - * expected logs - */ + * 256 Bytes - A bloom filter of logs/events generated by contracts during + * transaction execution. Used to efficiently rule out transactions without + * expected logs + */ public String getLogsBloom() { return data.getString("logsBloom"); } /** - * 32 Bytes - Merkle root of the state trie after the transaction has been - * executed (optional after Byzantium hard fork EIP609). - */ + * 32 Bytes - Merkle root of the state trie after the transaction has been + * executed (optional after Byzantium hard fork EIP609). + */ public String getRoot() { return data.getString("root"); } /** - * success of a Transaction. - * - * true indicates transaction failure , false indicates transaction success. Set - * for blocks mined after Byzantium hard fork EIP609, null before. - */ + * success of a Transaction. + * + * true indicates transaction failure , false indicates transaction success. Set + * for blocks mined after Byzantium hard fork EIP609, null before. + */ public boolean getStatus() { return data.getLong("status") == 1; } diff --git a/java/src/in3/eth1/TransactionRequest.java b/java/src/in3/eth1/TransactionRequest.java index 8dee22b70..ef811946d 100644 --- a/java/src/in3/eth1/TransactionRequest.java +++ b/java/src/in3/eth1/TransactionRequest.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -43,31 +43,49 @@ */ public class TransactionRequest { - /** the from address */ + /** + * the from address + */ private String from; - /** the recipients address */ + /** + * the recipients address + */ private String to; - /** the data */ + /** + * the data + */ private String data; - /** the value of the transaction */ + /** + * the value of the transaction + */ private BigInteger value; - /** the nonce (transactionCount of the sender) */ + /** + * the nonce (transactionCount of the sender) + */ private long nonce = -1; - /** the gas to use */ + /** + * the gas to use + */ private long gas; - /** the gas price to use */ + /** + * the gas price to use + */ private long gasPrice; - /** the signature for the function to call */ + /** + * the signature for the function to call + */ private String function; - /** the params to use for encoding in the data */ + /** + * the params to use for encoding in the data + */ private Object[] params; public String getFrom() { diff --git a/java/src/in3/utils/Account.java b/java/src/in3/utils/Account.java index 6db7a3fb3..9939d57ef 100644 --- a/java/src/in3/utils/Account.java +++ b/java/src/in3/utils/Account.java @@ -17,15 +17,15 @@ protected static Account asAccount(Object o) { } /** - * address from ecrecover operation. - */ + * address from ecrecover operation. + */ public String getAddress() { return data.getString("address"); } /** - * public key from ecrecover operation. - */ + * public key from ecrecover operation. + */ public String getPublicKey() { return data.getString("publicKey"); } diff --git a/java/src/in3/utils/Converter.java b/java/src/in3/utils/Converter.java index 229e57aa0..ac713c372 100644 --- a/java/src/in3/utils/Converter.java +++ b/java/src/in3/utils/Converter.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -39,10 +39,10 @@ */ public interface Converter { /** - * Applies this function to the given argument. - * - * @param t the function argument - * @return the function result - */ + * Applies this function to the given argument. + * + * @param t the function argument + * @return the function result + */ R apply(T t); } diff --git a/java/src/in3/utils/Crypto.java b/java/src/in3/utils/Crypto.java index a126f041c..215fd3199 100644 --- a/java/src/in3/utils/Crypto.java +++ b/java/src/in3/utils/Crypto.java @@ -26,8 +26,8 @@ public Crypto(IN3 in3) { } /** - * returns a signature given a message and a key. - */ + * returns a signature given a message and a key. + */ public Signature signData(String msg, String key, SignatureType sigType) { return Signature.asSignature(in3.sendRPCasObject(SIGN_DATA, new Object[] {msg, key, JSON.asString(sigType)})); } @@ -37,36 +37,36 @@ public String decryptKey(String key, String passphrase) { } /** - * extracts the public address from a private key. - */ + * extracts the public address from a private key. + */ public String pk2address(String key) { return JSON.asString(in3.sendRPCasObject(PK2ADDRESS, new Object[] {key})); } /** - * extracts the public key from a private key. - */ + * extracts the public key from a private key. + */ public String pk2public(String key) { return JSON.asString(in3.sendRPCasObject(PK2PUBLIC, new Object[] {key})); } /** - * extracts the address and public key from a signature. - */ + * extracts the address and public key from a signature. + */ public Account ecrecover(String msg, String sig) { return ecrecover(msg, sig, null); } /** - * extracts the address and public key from a signature. - */ + * extracts the address and public key from a signature. + */ public Account ecrecover(String msg, String sig, SignatureType sigType) { return Account.asAccount(in3.sendRPCasObject(ECRECOVER, new Object[] {msg, sig, JSON.asString(sigType)})); } /** - * returns a signature given a message and a key. - */ + * returns a signature given a message and a key. + */ public Signature signData(String msg, String key) { return Signature.asSignature(signData(msg, key, null)); } diff --git a/java/src/in3/utils/JSON.java b/java/src/in3/utils/JSON.java index cfc050c29..1345a04ef 100644 --- a/java/src/in3/utils/JSON.java +++ b/java/src/in3/utils/JSON.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -40,7 +40,7 @@ /** * internal helper tool to represent a JSON-Object. - * + * * Since the internal representation of JSON in incubed uses hashes instead of * name, the getter will creates these hashes. */ @@ -56,122 +56,148 @@ public class JSON { public JSON() {} /** - * gets the property - * - * @return the raw object. - */ - public Object get(String prop /** the name of the property. */ + * gets the property + * + * @return the raw object. + */ + public Object get(String prop /** + the name of the property. + */ ) { return map.get(key(prop)); } /** - * adds values. This function will be called from the JNI-Iterface. - * - * Internal use only! - */ - public void put(String key /** the key */ + * adds values. This function will be called from the JNI-Iterface. + * + * Internal use only! + */ + public void put(String key /** + the key + */ , - Object val /** the value object */ + Object val /** + the value object + */ ) { map.put(key(key), val); } /** - * adds values. This function will be called from the JNI-Iterface. - * - * Internal use only! - */ - public void put(int key /** the hash of the key */ + * adds values. This function will be called from the JNI-Iterface. + * + * Internal use only! + */ + public void put(int key /** + the hash of the key + */ , - Object val /** the value object */ + Object val /** + the value object + */ ) { map.put(key, val); } /** - * returns the property as boolean - * - * @return the boolean value - */ - public boolean getBoolean(String key /** the propertyName */ + * returns the property as boolean + * + * @return the boolean value + */ + public boolean getBoolean(String key /** + the propertyName + */ ) { return asBoolean(get(key)); } /** - * returns the property as long - * - * @return the long value - */ - public long getLong(String key /** the propertyName */ + * returns the property as long + * + * @return the long value + */ + public long getLong(String key /** + the propertyName + */ ) { return asLong(get(key)); } /** - * returns the property as double - * - * @return the long value - */ - public double getDouble(String key /** the propertyName */ + * returns the property as double + * + * @return the long value + */ + public double getDouble(String key /** + the propertyName + */ ) { return asDouble(get(key)); } /** * returns the property as BigInteger - * + * * @return the BigInteger value */ - public Object getObject(String key /** the propertyName */ + public Object getObject(String key /** + the propertyName + */ ) { return get(key); } /** - * returns the property as BigInteger - * - * @return the BigInteger value - */ - public Integer getInteger(String key /** the propertyName */ + * returns the property as BigInteger + * + * @return the BigInteger value + */ + public Integer getInteger(String key /** + the propertyName + */ ) { return asInt(get(key)); } /** - * returns the property as BigInteger - * - * @return the BigInteger value - */ - public BigInteger getBigInteger(String key /** the propertyName */ + * returns the property as BigInteger + * + * @return the BigInteger value + */ + public BigInteger getBigInteger(String key /** + the propertyName + */ ) { return asBigInteger(get(key)); } /** - * returns the property as StringArray - * - * @return the array or null - */ - public String[] getStringArray(String key /** the propertyName */ + * returns the property as StringArray + * + * @return the array or null + */ + public String[] getStringArray(String key /** + the propertyName + */ ) { return asStringArray(get(key)); } /** - * returns the property as String or in case of a number as hexstring. - * - * @return the hexstring - */ - public String getString(String key /** the propertyName */ + * returns the property as String or in case of a number as hexstring. + * + * @return the hexstring + */ + public String getString(String key /** + the propertyName + */ ) { return asString(get(key)); } /** - * casts the object to a String[] - */ + * casts the object to a String[] + */ public static String[] asStringArray(Object o) { if (o == null) return null; @@ -349,7 +375,8 @@ public T put(String key, T value) { }; } - /** parses a String to a json-object. If the json represents + /** + * parses a String to a json-object. If the json represents * - a object : JSON is returned * - a Array : a Array is returned * - other types the wrapped primative typed (Boolean, Integer, Long or String) will be returned. diff --git a/java/src/in3/utils/Signer.java b/java/src/in3/utils/Signer.java index d6ea6882b..fd206cd57 100644 --- a/java/src/in3/utils/Signer.java +++ b/java/src/in3/utils/Signer.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -42,14 +42,18 @@ */ public interface Signer { /** - * optiional method which allows to change the transaction-data before sending - * it. This can be used for redirecting it through a multisig. - */ + * optiional method which allows to change the transaction-data before sending + * it. This can be used for redirecting it through a multisig. + */ TransactionRequest prepareTransaction(IN3 in3, TransactionRequest tx); - /** returns true if the account is supported (or unlocked) */ + /** + * returns true if the account is supported (or unlocked) + */ boolean canSign(String address); - /** signing of the raw data. */ + /** + * signing of the raw data. + */ String sign(String data, String address); } diff --git a/java/src/in3/utils/StorageProvider.java b/java/src/in3/utils/StorageProvider.java index b6c23459a..993441de3 100644 --- a/java/src/in3/utils/StorageProvider.java +++ b/java/src/in3/utils/StorageProvider.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -40,18 +40,28 @@ */ public interface StorageProvider { /** - * returns a item from cache () - * @return the bytes or null if not found. - */ - byte[] getItem(String key /** the key for the item */); + * returns a item from cache () + * @return the bytes or null if not found. + */ + byte[] getItem(String key /** + the key for the item + */ + ); /** - * stores a item in the cache. - */ - void setItem(String key /** the key for the item */, byte[] content /** the value to store */); + * stores a item in the cache. + */ + void setItem(String key /** + the key for the item + */ + , + byte[] content /** + the value to store + */ + ); /** - * clear the cache. - */ + * clear the cache. + */ boolean clear(); } diff --git a/java/src/in3/utils/TempStorageProvider.java b/java/src/in3/utils/TempStorageProvider.java index 104566bc3..acd611ad2 100644 --- a/java/src/in3/utils/TempStorageProvider.java +++ b/java/src/in3/utils/TempStorageProvider.java @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/java/src/in3/utils/TransportException.java b/java/src/in3/utils/TransportException.java index 2318cea95..2b234c80e 100644 --- a/java/src/in3/utils/TransportException.java +++ b/java/src/in3/utils/TransportException.java @@ -1,17 +1,17 @@ package in3.utils; /** * Exception to be thrown in case of failed request. - * + * */ public class TransportException extends Exception { private int status; private int index; /** - * constrcutor - * @param message - * @param status - */ + * constrcutor + * @param message + * @param status + */ public TransportException(String message, int status, int index) { super(message); this.status = status; @@ -23,9 +23,9 @@ public int getIndex() { } /** - * the http-status - * @return - */ + * the http-status + * @return + */ public int getStatus() { return status; } diff --git a/java/src/in3/zksync/API.java b/java/src/in3/zksync/API.java index f63cae74d..957794494 100644 --- a/java/src/in3/zksync/API.java +++ b/java/src/in3/zksync/API.java @@ -17,105 +17,105 @@ public API(IN3 in3) { } /** - * the address of the zksync contract. + * the address of the zksync contract. */ public String getContractAddress() { return (String) in3.sendRPCasObject("zksync_contract_address", new Object[] {}); } /** - * the available tokens. + * the available tokens. */ public Token[] getTokens() { return Token.asTokens(in3.sendRPCasObject("zksync_tokens", new Object[] {})); } /** - * returns the current balance, nonce and key for the given account. if address is null, the current configured Account will be used. - */ + * returns the current balance, nonce and key for the given account. if address is null, the current configured Account will be used. + */ public Account getAccountInfo(String address) { return Account.asAccount(in3.sendRPCasObject("zksync_account_info", address == null ? new Object[] {} : new Object[] {address})); } /** - * the Transaction State. + * the Transaction State. */ public Tx getTransactionInfo(String txid) { return Tx.asTx(in3.sendRPCasObject("zksync_tx_info", new Object[] {txid})); } /** - * the EthOp State. (State of a deposit or emergencyWithdraw - Transaction ) + * the EthOp State. (State of a deposit or emergencyWithdraw - Transaction ) */ public EthOp getEthOpInfo(String txid) { return EthOp.asEthOp(in3.sendRPCasObject("zksync_ethop_info", new Object[] {txid})); } /** - * sets the sync keys and returns the confirmed pubkeyhash + * sets the sync keys and returns the confirmed pubkeyhash */ public String setKey(String token) { return (String) in3.sendRPCasObject("zksync_set_key", new Object[] {token}); } /** - * returns the pubkeyhash based on the current config. + * returns the pubkeyhash based on the current config. */ public String getPubKeyHash() { return (String) in3.sendRPCasObject("zksync_pubkeyhash", new Object[] {}); } /** - * returns the public key based on the current config. + * returns the public key based on the current config. */ public String getPubKey() { return (String) in3.sendRPCasObject("zksync_pubkey", new Object[] {}); } /** - * returns the private key based on the current config. + * returns the private key based on the current config. */ public String getSyncKey() { return (String) in3.sendRPCasObject("zksync_sync_key", new Object[] {}); } /** - * returns the address of the account based on the current config. + * returns the address of the account based on the current config. */ public String getAccountAddress() { return (String) in3.sendRPCasObject("zksync_account_address", new Object[] {}); } /** - * signs the data and returns a musig schnorr signature. + * signs the data and returns a musig schnorr signature. */ public String sign(byte[] message) { return (String) in3.sendRPCasObject("zksync_sign", new Object[] {message}); } /** - * signs the data and returns a musig schnorr signature. + * signs the data and returns a musig schnorr signature. */ public boolean verify(byte[] message, String signature) { return (Boolean) in3.sendRPCasObject("zksync_verify", new Object[] {message, signature}); } /** - * calculates the current tx fees for the specified + * calculates the current tx fees for the specified */ public TxFee getTxFee(String txType, String toAddress, String token) { return TxFee.asTxFee(in3.sendRPCasObject("zksync_get_tx_fee", new Object[] {txType, toAddress, token})); } /** - * sends the specified amount of tokens to the zksync contract as deposit for the specified amount (or null if this the same as send) - * returns the ethopId + * sends the specified amount of tokens to the zksync contract as deposit for the specified amount (or null if this the same as send) + * returns the ethopId */ public String deposit(BigInteger amount, String token, boolean approveDepositAmountForERC20, String account) { return (String) in3.sendRPCasObject("zksync_deposit", new Object[] {amount, token, approveDepositAmountForERC20, account}); } /** - * transfers the specified amount of tokens in L2 + * transfers the specified amount of tokens in L2 * returns the txid */ public String transfer(String toAddress, BigInteger amount, String token, String fromAccount) { @@ -123,7 +123,7 @@ public String transfer(String toAddress, BigInteger amount, String token, String } /** - * withdraw the specified amount of tokens to L1 + * withdraw the specified amount of tokens to L1 * returns the txid */ public String withdraw(String toAddress, BigInteger amount, String token, String fromAccount) { @@ -131,7 +131,7 @@ public String withdraw(String toAddress, BigInteger amount, String token, String } /** - * withdraw all tokens from L2 to L1. + * withdraw all tokens from L2 to L1. * returns the txId */ public String emergencyWithdraw(String token) { @@ -139,7 +139,7 @@ public String emergencyWithdraw(String token) { } /** - * aggregate the pubKey to one pubKeys for signing together as musig Schnorr signatures. + * aggregate the pubKey to one pubKeys for signing together as musig Schnorr signatures. */ public String aggregatePubkey(String[] pubKeys) { StringBuilder s = new StringBuilder(pubKeys[0]); diff --git a/java/src/in3/zksync/AccountState.java b/java/src/in3/zksync/AccountState.java index 96f5ae3d4..6b2786884 100644 --- a/java/src/in3/zksync/AccountState.java +++ b/java/src/in3/zksync/AccountState.java @@ -34,7 +34,9 @@ public String getPubKeyHash() { return data.getString("pubKeyHash"); } - /** the balance of the specified token (or null) */ + /** + * the balance of the specified token (or null) + */ public BigInteger getBalance(String token) { return data.getBigInteger(token); } diff --git a/java/src/in3_jni.c b/java/src/in3_jni.c index 495f96e0b..87a0d9ea0 100644 --- a/java/src/in3_jni.c +++ b/java/src/in3_jni.c @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ @@ -130,9 +130,9 @@ bytes_t* storage_get_item(void* cptr, const char* key) { if (!handler) return NULL; jstring js = (*jni)->NewStringUTF(jni, key); - jbyteArray result = (jbyteArray)(*jni)->CallObjectMethod(jni, handler, - (*jni)->GetMethodID(jni, (*jni)->GetObjectClass(jni, handler), "getItem", "(Ljava/lang/String;)[B"), - js); + jbyteArray result = (jbyteArray) (*jni)->CallObjectMethod(jni, handler, + (*jni)->GetMethodID(jni, (*jni)->GetObjectClass(jni, handler), "getItem", "(Ljava/lang/String;)[B"), + js); if (result == NULL) return NULL; bytes_t* res = _malloc(sizeof(bytes_t)); @@ -210,8 +210,8 @@ JNIEXPORT jstring JNICALL Java_in3_IN3_sendinternal(JNIEnv* env, jobject ob, jst else strcpy(error, ctx->error); - //need to release this string when done with it in order to - //avoid memory leak + // need to release this string when done with it in order to + // avoid memory leak (*env)->ReleaseStringUTFChars(env, jreq, str); req_free(ctx); @@ -318,8 +318,8 @@ JNIEXPORT jobject JNICALL Java_in3_IN3_sendobjectinternal(JNIEnv* env, jobject o else strcpy(error, ctx->error); - //need to release this string when done with it in order to - //avoid memory leak + // need to release this string when done with it in order to + // avoid memory leak (*env)->ReleaseStringUTFChars(env, jreq, str); req_free(ctx); @@ -354,9 +354,9 @@ in3_ret_t Java_in3_IN3_transport(void* plugin_data, in3_plugin_act_t action, voi in3_http_request_t* req = plugin_ctx; uint64_t start = current_ms(); - //char** urls, int urls_len, char* payload, in3_response_t* res + // char** urls, int urls_len, char* payload, in3_response_t* res in3_ret_t success = IN3_OK; - //payload + // payload jbyteArray jpayload = (*jni)->NewByteArray(jni, req->payload_len); (*jni)->SetByteArrayRegion(jni, jpayload, 0, req->payload_len, (jbyte*) req->payload); @@ -388,7 +388,7 @@ in3_ret_t Java_in3_IN3_transport(void* plugin_data, in3_plugin_act_t action, voi mid = (*jni)->GetMethodID(jni, cls, "getMessage", "()Ljava/lang/String;"); jstring jmsg = (*jni)->CallObjectMethod(jni, transport_exception, mid); const char* msg = (*jni)->GetStringUTFChars(jni, jmsg, 0); - in3_req_add_response(req, index, 0 - status, msg, -1, (uint32_t)(end - start)); + in3_req_add_response(req, index, 0 - status, msg, -1, (uint32_t) (end - start)); (*jni)->ReleaseStringUTFChars(jni, jmsg, msg); (*jni)->ExceptionClear(jni); } @@ -411,7 +411,7 @@ in3_ret_t Java_in3_IN3_transport(void* plugin_data, in3_plugin_act_t action, voi } } - for (unsigned int i = 0; i < req->urls_len; i++) req->req->raw_response[i].time = (uint32_t)(end - start); + for (unsigned int i = 0; i < req->urls_len; i++) req->req->raw_response[i].time = (uint32_t) (end - start); return success; } @@ -549,7 +549,7 @@ JNIEXPORT jstring JNICALL Java_in3_eth1_SimpleWallet_decodeKeystore(JNIEnv* env, return NULL; } -//in3_ret_t jsign(void* pk, d_signature_type_t type, bytes_t message, bytes_t account, uint8_t* dst) { +// in3_ret_t jsign(void* pk, d_signature_type_t type, bytes_t message, bytes_t account, uint8_t* dst) { in3_ret_t jsign(in3_sign_ctx_t* sc) { in3_req_t* ctx = (in3_req_t*) sc->req; if (ctx == NULL) return IN3_EIGNORE; @@ -654,7 +654,7 @@ JNIEXPORT jlong JNICALL Java_in3_IN3_init(JNIEnv* env, jobject ob, jlong jchain) jni = env; // turn to debug - return (jlong)(size_t) in3; + return (jlong) (size_t) in3; } JNIEXPORT jstring JNICALL Java_in3_IN3_getVersion(JNIEnv* env, jclass c) { diff --git a/java/src/in3_jni.h b/java/src/in3_jni.h index e7f84561d..b01695ef5 100644 --- a/java/src/in3_jni.h +++ b/java/src/in3_jni.h @@ -1,34 +1,34 @@ /******************************************************************************* * This file is part of the Incubed project. * Sources: https://github.com/blockchainsllc/in3 - * + * * Copyright (C) 2018-2020 slock.it GmbH, Blockchains LLC - * - * + * + * * COMMERCIAL LICENSE USAGE - * - * Licensees holding a valid commercial license may use this file in accordance - * with the commercial license agreement provided with the Software or, alternatively, - * in accordance with the terms contained in a written agreement between you and - * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further + * + * Licensees holding a valid commercial license may use this file in accordance + * with the commercial license agreement provided with the Software or, alternatively, + * in accordance with the terms contained in a written agreement between you and + * slock.it GmbH/Blockchains LLC. For licensing terms and conditions or further * information please contact slock.it at in3@slock.it. - * + * * Alternatively, this file may be used under the AGPL license as follows: - * + * * AGPL LICENSE USAGE - * + * * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Affero General Public License as published by the Free Software + * terms of the GNU Affero General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - * [Permissions of this strong copyleft license are conditioned on making available - * complete source code of licensed works and modifications, which include larger - * works using a licensed work, under the same license. Copyright and license notices + * [Permissions of this strong copyleft license are conditioned on making available + * complete source code of licensed works and modifications, which include larger + * works using a licensed work, under the same license. Copyright and license notices * must be preserved. Contributors provide an express grant of patent rights.] - * You should have received a copy of the GNU Affero General Public License along + * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . *******************************************************************************/ diff --git a/java/test/in3/eth1/APITest.java b/java/test/in3/eth1/APITest.java index c5bcfc07d..9a482c976 100644 --- a/java/test/in3/eth1/APITest.java +++ b/java/test/in3/eth1/APITest.java @@ -235,7 +235,7 @@ public void getTransactionByBlockHashAndIndex() { IN3 in3 = builder.constructClient(mockedResponses); Transaction tx = in3.getEth1API().getTransactionByBlockHashAndIndex( - "0xd03f4a0ce830ce568be08aa37bc0a72374e92da5b388e839b35f24a144a5085d", 1); + "0xd03f4a0ce830ce568be08aa37bc0a72374e92da5b388e839b35f24a144a5085d", 1); Assertions.assertEquals(tx.getValue(), new BigInteger("48958690000000000")); } diff --git a/scripts/format_all.sh b/scripts/format_all.sh index 0152bd4df..45d3b97e7 100755 --- a/scripts/format_all.sh +++ b/scripts/format_all.sh @@ -1,6 +1,6 @@ #!/bin/sh cd .. -docker run --rm -v $(pwd):$(pwd) docker.slock.it/build-images/cmake:clang11 /bin/bash -c \ +docker run --rm -v $(pwd):$(pwd) docker.slock.it/build-images/cmake:clang13 /bin/bash -c \ "cd $PWD; find c/src java -not -path \"c/src/third-party/*\" \\( -name \"*.c\" -o -name \"*.h\" -o -name \"*.java\" \\) | xargs clang-format -i" cd scripts From 7f2eb31a442ade70328e861ff3ee6b4ee5fbcf2a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 15 Jun 2021 19:19:01 +0200 Subject: [PATCH 004/110] use clang13 --- c/ci-analyse.yml | 2 +- c/ci.yml | 4 ++-- scripts/analyse.sh | 2 +- scripts/build.sh | 6 +++--- wasm/ci.yml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/c/ci-analyse.yml b/c/ci-analyse.yml index 8ebe41ff4..d5863481c 100644 --- a/c/ci-analyse.yml +++ b/c/ci-analyse.yml @@ -28,7 +28,7 @@ coverage: clangcheck: stage: analysis - image: docker.slock.it/build-images/cmake:clang11 + image: docker.slock.it/build-images/cmake:clang13 needs: [] extends: .only_full allow_failure: false diff --git a/c/ci.yml b/c/ci.yml index d1aed7e0a..eabc285d2 100644 --- a/c/ci.yml +++ b/c/ci.yml @@ -124,8 +124,8 @@ clang50: - .conanbuild - .only_full -clang11: - image: docker.slock.it/build-images/cmake:clang11 +clang13: + image: docker.slock.it/build-images/cmake:clang13 extends: - .conanbuild - .only_full diff --git a/scripts/analyse.sh b/scripts/analyse.sh index c5c87e8a3..40cce07e5 100755 --- a/scripts/analyse.sh +++ b/scripts/analyse.sh @@ -10,6 +10,6 @@ cd .. docker run \ --rm \ -v $(pwd):$(pwd) \ - docker.slock.it/build-images/cmake:clang11 \ + docker.slock.it/build-images/cmake:clang13 \ /bin/bash -c "cd $(pwd); rm -rf build; mkdir build; cd build; scan-build-11 $OPTS cmake -DEVM_GAS=true -DCMAKE_BUILD_TYPE=DEBUG -DIN3_SERVER=true .. && scan-build-11 $OPTS --exclude ../c/src/third-party --force-analyze-debug-code -o report make -j8" cd scripts diff --git a/scripts/build.sh b/scripts/build.sh index faa5bb2b0..3cc7b7685 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -54,7 +54,7 @@ if [ "$CONTAINER" = "--help" ]; then echo " - android-clang8-armv8" echo " - centos" echo " - android" - echo " - clang11" + echo " - clang13" echo " - clang10" echo " - clang9" echo " - clang50" @@ -118,7 +118,7 @@ elif [ "$CONTAINER" = "wasm_local" ]; then emcmake cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=true -DWASM=true -DASMJS=false -DWASM_EMMALLOC=true -DIPFS=false -DZKSYNC=true -DWASM_EMBED=false -DCMAKE_BUILD_TYPE=$BUILDTYPE .. make -j8 in3_wasm elif [ "$CONTAINER" = "wasm" ]; then - CONTAINER=docker.slock.it/build-images/cmake:clang11 + CONTAINER=docker.slock.it/build-images/cmake:clang13 echo $CONTAINER > build/container.txt docker run --rm -v $RD:$RD $CONTAINER /bin/bash -c "cd $RD/build; emcmake cmake -DWASM=true -DASMJS=false -DBTC_PRE_BPI34=false -DWASM_EMMALLOC=true -DZKSYNC=true -DWASM_EMBED=false -DCMAKE_BUILD_TYPE=$BUILDTYPE .. && make -j8" elif [ "$CONTAINER" = "asmjs_local" ]; then @@ -127,7 +127,7 @@ elif [ "$CONTAINER" = "asmjs_local" ]; then emcmake cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=true -DWASM=true -DASMJS=true -DZKSYNC=false -DBTC=true -DBTC_PRE_BPI34=false -DIPFS=true -DWASM_EMMALLOC=true -DCMAKE_BUILD_TYPE=$BUILDTYPE .. make -j8 in3_wasm elif [ "$CONTAINER" = "asmjs" ]; then - CONTAINER=docker.slock.it/build-images/cmake:clang11 + CONTAINER=docker.slock.it/build-images/cmake:clang13 echo $CONTAINER > build/container.txt docker run --rm -v $RD:$RD $CONTAINER /bin/bash -c "cd $RD/build; emcmake cmake -DWASM=true -DASMJS=true -DWASM_EMMALLOC=true -DCMAKE_BUILD_TYPE=$BUILDTYPE .. && make -j8" else diff --git a/wasm/ci.yml b/wasm/ci.yml index 74cd5f941..f94e06515 100644 --- a/wasm/ci.yml +++ b/wasm/ci.yml @@ -34,7 +34,7 @@ test_asmjs: wasm: - image: docker.slock.it/build-images/cmake:clang11 + image: docker.slock.it/build-images/cmake:clang13 needs: [] stage: bindings tags: From b577118b82cd9cf3358cd298d9f3afcf72588106 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 15 Jun 2021 19:27:02 +0200 Subject: [PATCH 005/110] fix scan-build --- c/ci-analyse.yml | 4 ++-- scripts/analyse.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/c/ci-analyse.yml b/c/ci-analyse.yml index d5863481c..d8f4cd88c 100644 --- a/c/ci-analyse.yml +++ b/c/ci-analyse.yml @@ -37,8 +37,8 @@ clangcheck: script: - mkdir _build - cd _build - - scan-build-11 cmake -DTAG_VERSION=$CI_COMMIT_TAG -DCMAKE_BUILD_TYPE=DEBUG -DIN3_SERVER=true .. - - scan-build-11 --status-bugs --exclude ../c/src/third-party --force-analyze-debug-code -o ../report make + - scan-build-13 cmake -DTAG_VERSION=$CI_COMMIT_TAG -DCMAKE_BUILD_TYPE=DEBUG -DIN3_SERVER=true .. + - scan-build-13 --status-bugs --exclude ../c/src/third-party --force-analyze-debug-code -o ../report make artifacts: paths: - report diff --git a/scripts/analyse.sh b/scripts/analyse.sh index 40cce07e5..f14d8060b 100755 --- a/scripts/analyse.sh +++ b/scripts/analyse.sh @@ -11,5 +11,5 @@ docker run \ --rm \ -v $(pwd):$(pwd) \ docker.slock.it/build-images/cmake:clang13 \ - /bin/bash -c "cd $(pwd); rm -rf build; mkdir build; cd build; scan-build-11 $OPTS cmake -DEVM_GAS=true -DCMAKE_BUILD_TYPE=DEBUG -DIN3_SERVER=true .. && scan-build-11 $OPTS --exclude ../c/src/third-party --force-analyze-debug-code -o report make -j8" + /bin/bash -c "cd $(pwd); rm -rf build; mkdir build; cd build; scan-build-13 $OPTS cmake -DEVM_GAS=true -DCMAKE_BUILD_TYPE=DEBUG -DIN3_SERVER=true .. && scan-build-13 $OPTS --exclude ../c/src/third-party --force-analyze-debug-code -o report make -j8" cd scripts From 17fd82a6baf9b82329b292f3c869679867b8b4b5 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 15 Jun 2021 19:34:30 +0200 Subject: [PATCH 006/110] fix emscripten warning --- wasm/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasm/src/CMakeLists.txt b/wasm/src/CMakeLists.txt index b849dca0b..1235b48cc 100644 --- a/wasm/src/CMakeLists.txt +++ b/wasm/src/CMakeLists.txt @@ -32,7 +32,7 @@ # with this program. If not, see . ############################################################################### -set(EMC_PROPS "-s ALLOW_MEMORY_GROWTH=1 -s NODEJS_CATCH_REJECTION=0 -s EXPORT_NAME=in3w -s FILESYSTEM=0 -s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"ccall\", \"cwrap\"]'") +set(EMC_PROPS "-s ALLOW_MEMORY_GROWTH=1 -s NODEJS_CATCH_REJECTION=0 -s EXPORT_NAME=in3w -s FILESYSTEM=0 -s 'EXPORTED_RUNTIME_METHODS=[\"ccall\", \"cwrap\"]'") IF (ASMJS) set(WASM_EMBED true) From 7c8b1b8c2ee79a798b216da4538024379bda7b7f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 17 Jun 2021 08:09:13 +0200 Subject: [PATCH 007/110] fix handling IN3_EIGNORE --- c/src/verifier/eth1/basic/sign_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index 891d0aaef..bce236f5d 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -183,7 +183,7 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst) { if (in3_plugin_is_registered(ctx->client, PLGN_ACT_SIGN_PREPARE)) { in3_sign_prepare_ctx_t pctx = {.req = ctx, .old_tx = *dst, .new_tx = {0}}; memcpy(pctx.account, from, 20); - in3_ret_t prep_res = in3_plugin_execute_first(ctx, PLGN_ACT_SIGN_PREPARE, &pctx); + in3_ret_t prep_res = in3_plugin_execute_first_or_none(ctx, PLGN_ACT_SIGN_PREPARE, &pctx); if (prep_res) { if (dst->data) _free(dst->data); From 76aaa2a994b456674894a32c9b31d9e020355d08 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 17 Jun 2021 15:52:15 +0200 Subject: [PATCH 008/110] add wallet in prepare_signature --- c/include/in3/plugin.h | 1 + c/src/core/client/plugin.h | 1 + c/src/verifier/eth1/basic/rpc.yml | 4 ++++ c/src/verifier/eth1/basic/sign_tx.c | 7 +++++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/c/include/in3/plugin.h b/c/include/in3/plugin.h index c9be20019..9bd0e500a 100644 --- a/c/include/in3/plugin.h +++ b/c/include/in3/plugin.h @@ -270,6 +270,7 @@ typedef struct sign_account_ctx { typedef struct sign_prepare_ctx { struct in3_req* req; /**< the context of the request in order report errors */ address_t account; /**< the account to use for the signature */ + address_t wallet; /**< if set to a non zero-value it will specify the wallet to use */ bytes_t old_tx; bytes_t new_tx; diff --git a/c/src/core/client/plugin.h b/c/src/core/client/plugin.h index c9be20019..9bd0e500a 100644 --- a/c/src/core/client/plugin.h +++ b/c/src/core/client/plugin.h @@ -270,6 +270,7 @@ typedef struct sign_account_ctx { typedef struct sign_prepare_ctx { struct in3_req* req; /**< the context of the request in order report errors */ address_t account; /**< the account to use for the signature */ + address_t wallet; /**< if set to a non zero-value it will specify the wallet to use */ bytes_t old_tx; bytes_t new_tx; diff --git a/c/src/verifier/eth1/basic/rpc.yml b/c/src/verifier/eth1/basic/rpc.yml index 0e7efd251..f96086d42 100644 --- a/c/src/verifier/eth1/basic/rpc.yml +++ b/c/src/verifier/eth1/basic/rpc.yml @@ -9,6 +9,10 @@ types: descr: sender of the address (if not sepcified, the first signer will be the sender) type: address optional: true + wallet: + descr: if specified, the transaction will be send through the specified wallet. + type: address + optional: true value: descr: value in wei to send type: uint256 diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index bce236f5d..32b8db50b 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -113,9 +113,10 @@ static in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res) // if it is not specified, we rely on the from-address of the signer. if (!in3_plugin_is_registered(ctx->client, PLGN_ACT_SIGN_ACCOUNT)) return req_set_error(ctx, "missing from address in tx", IN3_EINVAL); + // find the first account which is able to sign in3_sign_account_ctx_t actx = {.req = ctx, .accounts = NULL, .accounts_len = 0}; TRY(in3_plugin_execute_first(ctx, PLGN_ACT_SIGN_ACCOUNT, &actx)) - if (!actx.accounts) return req_set_error(ctx, "no from address found", IN3_EINVAL); + if (!actx.accounts || !actx.accounts_len) return req_set_error(ctx, "no from address found", IN3_EINVAL); memcpy(res, actx.accounts, 20); _free(actx.accounts); return IN3_OK; @@ -181,7 +182,9 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst) { // do we need to change it? if (in3_plugin_is_registered(ctx->client, PLGN_ACT_SIGN_PREPARE)) { - in3_sign_prepare_ctx_t pctx = {.req = ctx, .old_tx = *dst, .new_tx = {0}}; + in3_sign_prepare_ctx_t pctx = {.req = ctx, .old_tx = *dst, .new_tx = {0}}; + bytes_t wallet = d_to_bytes(d_get(tx, key("wallet"))); + if (wallet.len == 20) memcpy(pctx.wallet, wallet.data, 20); memcpy(pctx.account, from, 20); in3_ret_t prep_res = in3_plugin_execute_first_or_none(ctx, PLGN_ACT_SIGN_PREPARE, &pctx); From c05ef8ed538dc5fd52994dd721be8332c6d14c0d Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 18 Jun 2021 14:33:17 +0200 Subject: [PATCH 009/110] add writer and tx to prepare ctx --- c/src/api/eth1/rpc_api.c | 19 ++++++++++++++----- c/src/core/client/plugin.h | 8 ++++---- c/src/core/util/data.c | 6 ++++++ c/src/core/util/data.h | 24 +++++++++++++----------- c/src/core/util/scache.c | 7 +++++++ c/src/core/util/scache.h | 8 ++++++++ c/src/verifier/eth1/basic/eth_basic.h | 3 ++- c/src/verifier/eth1/basic/rpc.yml | 4 ++++ c/src/verifier/eth1/basic/sign_tx.c | 26 +++++++++++++++++++++----- 9 files changed, 79 insertions(+), 26 deletions(-) diff --git a/c/src/api/eth1/rpc_api.c b/c/src/api/eth1/rpc_api.c index a71844e27..5803a4ac4 100644 --- a/c/src/api/eth1/rpc_api.c +++ b/c/src/api/eth1/rpc_api.c @@ -520,15 +520,24 @@ static in3_ret_t in3_decryptKey(in3_rpc_handle_ctx_t* ctx) { static in3_ret_t in3_prepareTx(in3_rpc_handle_ctx_t* ctx) { CHECK_PARAMS_LEN(ctx->req, ctx->params, 1); CHECK_PARAM_TYPE(ctx->req, ctx->params, 0, T_OBJECT); - d_token_t* tx = d_get_at(ctx->params, 0); - bytes_t dst = {0}; + d_token_t* tx = d_get_at(ctx->params, 0); + bytes_t dst = {0}; + sb_t sb = {0}; + bool write_debug = (d_len(ctx->params) == 2 && d_get_int_at(ctx->params, 1)); #if defined(ETH_BASIC) || defined(ETH_FULL) - TRY(eth_prepare_unsigned_tx(tx, ctx->req, &dst)) + if (write_debug) sb_add_char(&sb, '{'); + TRY_CATCH(eth_prepare_unsigned_tx(tx, ctx->req, &dst, write_debug ? &sb : NULL), _free(sb.data)) #else if (ctx->params || tx || ctx) return req_set_error(ctx->req, "eth_basic is needed in order to use eth_prepareTx", IN3_EINVAL); #endif - in3_rpc_handle_with_bytes(ctx, dst); + if (sb.data) { + sb_add_chars(&sb, ",\"state\":\"unsigned\"}"); + in3_rpc_handle_with_string(ctx, sb.data); + } + else + in3_rpc_handle_with_bytes(ctx, dst); _free(dst.data); + _free(sb.data); return IN3_OK; } @@ -540,7 +549,7 @@ static in3_ret_t in3_signTx(in3_rpc_handle_ctx_t* ctx) { bytes_t* data = NULL; if (strcmp(ctx->method, "eth_signTransaction") == 0 || d_type(tx_data) == T_OBJECT) { #if defined(ETH_BASIC) || defined(ETH_FULL) - TRY(eth_prepare_unsigned_tx(tx_data, ctx->req, &tx_raw)) + TRY(eth_prepare_unsigned_tx(tx_data, ctx->req, &tx_raw, NULL)) from_b = d_get_bytes(tx_data, K_FROM); data = &tx_raw; #else diff --git a/c/src/core/client/plugin.h b/c/src/core/client/plugin.h index 9bd0e500a..1f9033a83 100644 --- a/c/src/core/client/plugin.h +++ b/c/src/core/client/plugin.h @@ -270,10 +270,10 @@ typedef struct sign_account_ctx { typedef struct sign_prepare_ctx { struct in3_req* req; /**< the context of the request in order report errors */ address_t account; /**< the account to use for the signature */ - address_t wallet; /**< if set to a non zero-value it will specify the wallet to use */ - bytes_t old_tx; - bytes_t new_tx; - + d_token_t* tx; /**< the tx-definition, which may contain additional properties */ + bytes_t old_tx; /**< the source-transaction */ + bytes_t new_tx; /**< the new-transaction, if the transaction should not changed, the data-ptr must be NULL otherwise a new allocated memory is expected, which will be cleaned by the caller. */ + sb_t* output; /**< if this is not NULL, the transaction will not be send, but returns only the state */ } in3_sign_prepare_ctx_t; // -------------- SIGN ----------------------- diff --git a/c/src/core/util/data.c b/c/src/core/util/data.c index 0b0d06051..d8f39e824 100644 --- a/c/src/core/util/data.c +++ b/c/src/core/util/data.c @@ -903,6 +903,12 @@ d_token_t* json_create_bytes(json_ctx_t* jp, bytes_t value) { return r; } +d_token_t* json_create_ref_item(json_ctx_t* jp, d_type_t type, void* data, int len) { + d_token_t* r = next_item(jp, type, len); + r->data = data; + return r; +} + int json_create_object(json_ctx_t* jp) { next_item(jp, T_OBJECT, 0); return jp->len - 1; diff --git a/c/src/core/util/data.h b/c/src/core/util/data.h index d54cdad3a..167442a00 100644 --- a/c/src/core/util/data.h +++ b/c/src/core/util/data.h @@ -136,16 +136,16 @@ d_token_t* d_get_or(d_token_t* item, const uint16_t key1, const uint16_t key2); d_token_t* d_get_at(d_token_t* item, const uint32_t index); /**< returns the token of an array with the given index */ d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */ -NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ -NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ -NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ -char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ - -json_ctx_t* json_create(); +NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ +NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ +NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ +char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ + +json_ctx_t* json_create(); NONULL d_token_t* json_create_null(json_ctx_t* jp); NONULL d_token_t* json_create_bool(json_ctx_t* jp, bool value); NONULL d_token_t* json_create_int(json_ctx_t* jp, uint64_t value); @@ -154,7 +154,9 @@ NONULL d_token_t* json_create_bytes(json_ctx_t* jp, bytes_t value); NONULL int json_create_object(json_ctx_t* jp); NONULL int json_create_array(json_ctx_t* jp); NONULL void json_object_add_prop(json_ctx_t* jp, int ob_index, d_key_t key, d_token_t* value); -NONULL void json_array_add_value(json_ctx_t* jp, int parent_index, d_token_t* value); +NONULL d_token_t* json_create_ref_item(json_ctx_t* jp, d_type_t type, void* data, int len); + +NONULL void json_array_add_value(json_ctx_t* jp, int parent_index, d_token_t* value); // Helper function to map string to 2byte keys (only for tests or debugging) char* d_get_keystr(json_ctx_t* json, d_key_t k); /**< returns the string for a key. This only works for index keys or known keys! */ diff --git a/c/src/core/util/scache.c b/c/src/core/util/scache.c index d28f1bede..c1efe8527 100644 --- a/c/src/core/util/scache.c +++ b/c/src/core/util/scache.c @@ -68,3 +68,10 @@ cache_entry_t* in3_cache_add_entry(cache_entry_t** cache, bytes_t key, bytes_t v if (cache) *cache = entry; return entry; } + +cache_entry_t* in3_cache_get_entry_by_prop(cache_entry_t* cache, cache_props_t prop) { + for (; cache; cache = cache->next) { + if (cache->props == prop) return cache; + } + return NULL; +} \ No newline at end of file diff --git a/c/src/core/util/scache.h b/c/src/core/util/scache.h index ce8de3a4e..b6d2afcc4 100644 --- a/c/src/core/util/scache.h +++ b/c/src/core/util/scache.h @@ -76,6 +76,14 @@ bytes_t* in3_cache_get_entry( bytes_t* key /**< the key to compare with */ ); +/** + * get the entry for a given property. + */ +cache_entry_t* in3_cache_get_entry_by_prop( + cache_entry_t* cache, /**< the root entry of the linked list. */ + cache_props_t prop /**< the prop, which must match exactly */ +); + /** * adds an entry to the linked list. */ diff --git a/c/src/verifier/eth1/basic/eth_basic.h b/c/src/verifier/eth1/basic/eth_basic.h index f9d01e7d6..76cdf6a00 100644 --- a/c/src/verifier/eth1/basic/eth_basic.h +++ b/c/src/verifier/eth1/basic/eth_basic.h @@ -116,7 +116,8 @@ in3_ret_t eth_verify_eth_getLog(in3_vctx_t* vc, int l_logs); */ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, /**< a json-token desribing the transaction */ in3_req_t* req, /**< the current context */ - bytes_t* dst /**< the bytes to write the result to. */ + bytes_t* dst, /**< the bytes to write the result to. */ + sb_t* meta /**< a stringbuilder in order write the wallet_state and metadata depending on the tx. */ ); /** diff --git a/c/src/verifier/eth1/basic/rpc.yml b/c/src/verifier/eth1/basic/rpc.yml index f96086d42..ec6857634 100644 --- a/c/src/verifier/eth1/basic/rpc.yml +++ b/c/src/verifier/eth1/basic/rpc.yml @@ -34,6 +34,10 @@ types: descr: the data-section of the transaction type: bytes optional: true + signatures: + descr: additional signatures which should be used when sending through a multisig + type: bytes + optional: true blockheader: diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index 32b8db50b..1d088845c 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -154,7 +154,7 @@ static inline uint64_t get_v(chain_id_t chain) { /** * prepares a transaction and writes the data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. */ -in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst) { +in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst, sb_t* meta) { address_t from; // read the values @@ -180,11 +180,22 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst) { *dst = *raw; _free(raw); + // write state? + if (meta) { + sb_add_rawbytes(meta, "\"input\":{\"to\":\"0x", to, 0); + sb_add_rawbytes(meta, "\",\"sender\":\"0x", bytes(from, 20), 0); + sb_add_rawbytes(meta, "\",\"value\":\"0x", value, 0); + sb_add_rawbytes(meta, "\",\"data\":\"0x", data, 0); + sb_add_rawbytes(meta, "\",\"gas\":\"0x", gas_limit, 0); + sb_add_rawbytes(meta, "\",\"gasPrice\":\"0x", gas_price, 0); + sb_add_rawbytes(meta, "\",\"nonce\":\"0x", nonce, 0); + sb_add_rawbytes(meta, "\",\"pre_unsigned\":\"0x", *dst, 0); + sb_add_chars(meta, "\"}"); + } + // do we need to change it? if (in3_plugin_is_registered(ctx->client, PLGN_ACT_SIGN_PREPARE)) { - in3_sign_prepare_ctx_t pctx = {.req = ctx, .old_tx = *dst, .new_tx = {0}}; - bytes_t wallet = d_to_bytes(d_get(tx, key("wallet"))); - if (wallet.len == 20) memcpy(pctx.wallet, wallet.data, 20); + in3_sign_prepare_ctx_t pctx = {.req = ctx, .old_tx = *dst, .new_tx = {0}, .output = meta, .tx = tx}; memcpy(pctx.account, from, 20); in3_ret_t prep_res = in3_plugin_execute_first_or_none(ctx, PLGN_ACT_SIGN_PREPARE, &pctx); @@ -199,6 +210,11 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst) { } } + if (meta) { + sb_add_rawbytes(meta, ",\"unsigned\":\"0x", *dst, 0); + sb_add_chars(meta, "\""); + } + // cleanup subcontexts TRY(req_remove_required(ctx, req_find_required(ctx, "eth_getTransactionCount", NULL), false)) TRY(req_remove_required(ctx, req_find_required(ctx, "eth_gasPrice", NULL), false)) @@ -278,7 +294,7 @@ in3_ret_t handle_eth_sendTransaction(in3_req_t* ctx, d_token_t* req) { memcpy(unsigned_tx.data, raw.data, raw.len); } else - TRY(eth_prepare_unsigned_tx(tx_params + 1, ctx, &unsigned_tx)); + TRY(eth_prepare_unsigned_tx(tx_params + 1, ctx, &unsigned_tx, NULL)); TRY_FINAL(eth_sign_raw_tx(unsigned_tx, ctx, from, &signed_tx), if (unsigned_tx.data) _free(unsigned_tx.data);) From b28078d89e344210dde2f21471b805c06e47f7e1 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 18 Jun 2021 17:10:31 +0200 Subject: [PATCH 010/110] handle sign with a wallet differently --- c/src/cmd/in3/rpc_handler.c | 12 ++++++++++++ c/src/verifier/eth1/basic/eth_basic.h | 5 +++++ c/src/verifier/eth1/basic/sign_tx.c | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/c/src/cmd/in3/rpc_handler.c b/c/src/cmd/in3/rpc_handler.c index 7308c7a48..87aea69b7 100644 --- a/c/src/cmd/in3/rpc_handler.c +++ b/c/src/cmd/in3/rpc_handler.c @@ -20,12 +20,24 @@ static bool _call(in3_t* c, char** method, sb_t* params) { *method = "eth_call"; return false; } + +#ifdef MOD_WALLET +void* wallet_get_default(void* conf, uint_fast8_t type_mask); +void* wallet_get_config(in3_t* c); +#endif + static bool _send(in3_t* c, char** method, sb_t* params) { encode_abi(c, params, false); if (is_onlyshow_rawtx() && (c->plugin_acts & (PLGN_ACT_SIGN | PLGN_ACT_SIGN_ACCOUNT)) == 0) *method = "in3_prepareTx"; else *method = get_txdata()->wait ? "eth_sendTransactionAndWait" : "eth_sendTransaction"; + +#ifdef MOD_WALLET + void* conf = wallet_get_config(c); + if (conf && wallet_get_default(conf, 0)) + *method = "l1_wallet_exec"; +#endif return false; } diff --git a/c/src/verifier/eth1/basic/eth_basic.h b/c/src/verifier/eth1/basic/eth_basic.h index 76cdf6a00..4d24efc44 100644 --- a/c/src/verifier/eth1/basic/eth_basic.h +++ b/c/src/verifier/eth1/basic/eth_basic.h @@ -146,4 +146,9 @@ const uint8_t* empty_hash(); */ RETURNS_NONULL NONULL char* eth_wallet_sign(const char* key, const char* data); +/** + * determines the from-address in case no from-address has been specified. + */ +NONULL in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res); + #endif // in3_eth_basic_h__ \ No newline at end of file diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index 1d088845c..afd65cfba 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -101,7 +101,7 @@ static in3_ret_t get_from_nodes(in3_req_t* parent, char* method, char* params, b } /** gets the from-fied from the tx or ask the signer */ -static in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res) { +in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res) { d_token_t* t = d_get(tx, K_FROM); if (t) { // we only accept valid from addresses which need to be 20 bytes From 719cff1058e656a4b3a9d6e9cd3d90680468464e Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 19 Jun 2021 00:34:47 +0200 Subject: [PATCH 011/110] allow in3_conf.json as initial config --- c/src/cmd/in3/option_handler.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/c/src/cmd/in3/option_handler.c b/c/src/cmd/in3/option_handler.c index ab09e2234..7fd5ef4f4 100644 --- a/c/src/cmd/in3/option_handler.c +++ b/c/src/cmd/in3/option_handler.c @@ -254,6 +254,24 @@ void init_env(in3_t* c, int argc, char* argv[]) { } } + // is there a config-file we can load? + char* home = get_storage_dir(); + char* cnf = alloca(strlen(home) + 20); + strcpy(cnf, home); + strcpy(cnf + strlen(cnf) - 1, "_conf.json"); + + FILE* cnf_file = fopen(cnf, "r"); + if (cnf_file) { + char* error = in3_configure(c, (char*) readFile(cnf_file).data); + if (error) { + char* msg = _malloc(strlen(error) + 200); + sprintf(msg, "Error reading the in3_conf.json : %s", error); + die(msg); + } + else + fclose(cnf_file); + } + // handle chainId if (getenv("IN3_CHAIN")) configure(c, "chainId", getenv("IN3_CHAIN")); From c5372e39e2f70ea27ede97eef48d8d924779fcac Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 19 Jun 2021 00:35:01 +0200 Subject: [PATCH 012/110] detect home-dir --- c/src/cmd/in3/in3_storage.c | 2 +- c/src/cmd/in3/in3_storage.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/c/src/cmd/in3/in3_storage.c b/c/src/cmd/in3/in3_storage.c index 7fdb263e0..6b49a7aea 100644 --- a/c/src/cmd/in3/in3_storage.c +++ b/c/src/cmd/in3/in3_storage.c @@ -51,7 +51,7 @@ #endif static char* _HOME_DIR = NULL; -static char* get_storage_dir() { +char* get_storage_dir() { if (_HOME_DIR == NULL) { #if defined(_WIN32) char* home = getenv("USERPROFILE"); diff --git a/c/src/cmd/in3/in3_storage.h b/c/src/cmd/in3/in3_storage.h index 5b6542c9a..99c272770 100644 --- a/c/src/cmd/in3/in3_storage.h +++ b/c/src/cmd/in3/in3_storage.h @@ -42,6 +42,6 @@ bytes_t* storage_get_item(void* cptr, const char* key); void storage_set_item(void* cptr, const char* key, bytes_t* content); -void storage_clear(void* cptr); - +void storage_clear(void* cptr); +char* get_storage_dir(); in3_ret_t in3_register_file_storage(in3_t* c); \ No newline at end of file From 84c1a064ce9418e401a59357233ed0d2ec5ca57f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 19 Jun 2021 00:35:15 +0200 Subject: [PATCH 013/110] allow - as placeholder for stdin --- c/src/cmd/in3/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/c/src/cmd/in3/main.c b/c/src/cmd/in3/main.c index d10a7cb89..f1996f2a0 100644 --- a/c/src/cmd/in3/main.c +++ b/c/src/cmd/in3/main.c @@ -62,7 +62,11 @@ int main(int argc, char* argv[]) { else { // otherwise we add it to the params if (args->len > 1) sb_add_char(args, ','); - if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC) + if (*argv[i] == '-' && *(argv[i] + 1) == 0) { + bytes_t b = readFile(stdin); + sb_add_range(args, (char*) b.data, 0, b.len); + } + else if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC) sb_print(args, "\"%s\"", get_wei(argv[i])); else sb_print(args, From c8f08605c8fcb9bb1932cee72c2ecb31035143c2 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 19 Jun 2021 15:20:40 +0200 Subject: [PATCH 014/110] add prepare_only option for zksync --- c/src/pay/zksync/zk_message.c | 47 ++++++++++++++++++++++------------- c/src/pay/zksync/zksync.h | 26 +++++++++++-------- 2 files changed, 46 insertions(+), 27 deletions(-) diff --git a/c/src/pay/zksync/zk_message.c b/c/src/pay/zksync/zk_message.c index 6e7624a5e..bd01c1446 100644 --- a/c/src/pay/zksync/zk_message.c +++ b/c/src/pay/zksync/zk_message.c @@ -158,8 +158,11 @@ static in3_ret_t sign_sync_transfer(zksync_tx_data_t* data, in3_req_t* ctx, zksy long_to_bytes(data->valid.from, raw + (*total) - 16); long_to_bytes(data->valid.to, raw + (*total) - 8); - // sign data - return zksync_sign(conf, bytes(raw, (*total)), ctx, sig); + if (!data->prepare) // sign data + return zksync_sign(conf, bytes(raw, (*total)), ctx, sig); + + data->prepare->zk_message = bytes_dup(bytes(raw, (*total))); + return IN3_OK; } in3_ret_t zksync_sign_transfer(sb_t* sb, zksync_tx_data_t* data, in3_req_t* ctx, zksync_config_t* conf) { @@ -169,14 +172,19 @@ in3_ret_t zksync_sign_transfer(sb_t* sb, zksync_tx_data_t* data, in3_req_t* ctx, bytes_t signature = bytes(NULL, 0); if (data->conf->sign_type != ZK_SIGN_CREATE2) { - char msg_data[216]; + char msg_data[256]; sb_t msg = sb_stack(msg_data); create_human_readable_tx_info(&msg, data, data->type == ZK_WITHDRAW ? "Withdraw " : "Transfer "); - TRY(req_require_signature(ctx, SIGN_EC_PREFIX, &signature, bytes((uint8_t*) msg_data, msg.len), bytes(data->from, 20))) - in3_log_debug("zksync_sign_transfer human readable :\n%s\n", msg_data); - if (signature.len == 65 && signature.data[64] < 27) - signature.data[64] += 27; // because EIP155 chainID = 0 + if (data->prepare) + data->prepare->human_message = _strdupn(msg_data); + else { + TRY(req_require_signature(ctx, SIGN_EC_PREFIX, &signature, bytes((uint8_t*) msg_data, msg.len), bytes(data->from, 20))) + in3_log_debug("zksync_sign_transfer human readable :\n%s\n", msg_data); + + if (signature.len == 65 && signature.data[64] < 27) + signature.data[64] += 27; // because EIP155 chainID = 0 + } } // now create the packed sync transfer @@ -219,17 +227,22 @@ in3_ret_t zksync_sign_transfer(sb_t* sb, zksync_tx_data_t* data, in3_req_t* ctx, sb_add_int(sb, (int64_t) data->valid.to); sb_add_chars(sb, ",\"nonce\":"); sb_add_int(sb, data->nonce); - sb_add_rawbytes(sb, ",\"signature\":{\"pubKey\":\"", bytes(sig, 32), 0); - sb_add_rawbytes(sb, "\",\"signature\":\"", bytes(sig + 32, 64), 0); - sb_add_chars(sb, "\"}},"); - if (data->conf->sign_type == ZK_SIGN_CREATE2) - sb_add_chars(sb, "null"); - else { - sb_add_chars(sb, "{\"type\":\""); - sb_add_chars(sb, data->conf->sign_type == ZK_SIGN_CONTRACT ? "EIP1271Signature" : "EthereumSignature"); - sb_add_rawbytes(sb, "\",\"signature\":\"0x", signature, 0); - sb_add_chars(sb, "\"}"); + if (!data->prepare) { + sb_add_rawbytes(sb, ",\"signature\":{\"pubKey\":\"", bytes(sig, 32), 0); + sb_add_rawbytes(sb, "\",\"signature\":\"", bytes(sig + 32, 64), 0); + sb_add_chars(sb, "\"}},"); + if (data->conf->sign_type == ZK_SIGN_CREATE2) + sb_add_chars(sb, "null"); + else { + sb_add_chars(sb, "{\"type\":\""); + sb_add_chars(sb, data->conf->sign_type == ZK_SIGN_CONTRACT ? "EIP1271Signature" : "EthereumSignature"); + sb_add_rawbytes(sb, "\",\"signature\":\"0x", signature, 0); + sb_add_chars(sb, "\"}"); + } } + else + sb_add_chars(sb, "}"); + return IN3_OK; } diff --git a/c/src/pay/zksync/zksync.h b/c/src/pay/zksync/zksync.h index 4af9e3aa8..39228045b 100644 --- a/c/src/pay/zksync/zksync.h +++ b/c/src/pay/zksync/zksync.h @@ -142,17 +142,23 @@ typedef struct pay_criteria { } pay_criteria_t; /** a transaction */ + +typedef struct { + bytes_t zk_message; + char* human_message; +} zk_prepare_ctx_t; typedef struct { - zksync_config_t* conf; /**< the configuration of the zksync-account */ - uint32_t account_id; /**< the id of the account */ - address_t from; /**< the from-address */ - address_t to; /**< the address of the receipient */ - zksync_token_t* token; /**< the token to use */ - uint32_t nonce; /**< current nonce */ - zk_msg_type_t type; /**< message type */ - zk_fee_t amount; /**< amount to send */ - zk_fee_t fee; /**< ransaction fees */ - zksync_valid_t valid; /**< validity */ + zksync_config_t* conf; /**< the configuration of the zksync-account */ + uint32_t account_id; /**< the id of the account */ + address_t from; /**< the from-address */ + address_t to; /**< the address of the receipient */ + zksync_token_t* token; /**< the token to use */ + uint32_t nonce; /**< current nonce */ + zk_msg_type_t type; /**< message type */ + zk_fee_t amount; /**< amount to send */ + zk_fee_t fee; /**< ransaction fees */ + zksync_valid_t valid; /**< validity */ + zk_prepare_ctx_t* prepare; /**< if a prepare ctx is set the data will not be signed, but only the messages are created and stored.*/ } zksync_tx_data_t; /** registers the zksync-plugin in the client */ From b9b20f70fbdf5d153de06960a0375e9fa94cd2c1 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 19 Jun 2021 22:50:12 +0200 Subject: [PATCH 015/110] redirect to wallet_exec --- c/src/cmd/in3/rpc_handler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/cmd/in3/rpc_handler.c b/c/src/cmd/in3/rpc_handler.c index 87aea69b7..915db1caa 100644 --- a/c/src/cmd/in3/rpc_handler.c +++ b/c/src/cmd/in3/rpc_handler.c @@ -36,7 +36,7 @@ static bool _send(in3_t* c, char** method, sb_t* params) { #ifdef MOD_WALLET void* conf = wallet_get_config(c); if (conf && wallet_get_default(conf, 0)) - *method = "l1_wallet_exec"; + *method = "wallet_exec"; #endif return false; } From c3b413a0758150da06ecef74fa906293d04d7e5b Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 19 Jun 2021 22:50:25 +0200 Subject: [PATCH 016/110] support retry in plugins --- c/src/core/client/client_init.c | 8 ++++++++ c/src/core/util/debug.c | 1 + c/src/core/util/error.h | 1 + 3 files changed, 10 insertions(+) diff --git a/c/src/core/client/client_init.c b/c/src/core/client/client_init.c index 9f8df7aa4..bf608e531 100644 --- a/c/src/core/client/client_init.c +++ b/c/src/core/client/client_init.c @@ -507,10 +507,18 @@ in3_ret_t in3_plugin_execute_first_or_none(in3_req_t* ctx, in3_plugin_act_t acti assert(ctx); if (!in3_plugin_is_registered(ctx->client, action)) return IN3_OK; + int retry = 0; + +_retry: for (in3_plugin_t* p = ctx->client->plugins; p; p = p->next) { if (p->acts & action) { in3_ret_t ret = p->action_fn(p->data, action, plugin_ctx); + if (ret == IN3_ERETRY) { + retry++; + if (retry > 3) return req_set_error(ctx, "Max retries when executing plugins exceeded!", IN3_EUNKNOWN); + goto _retry; + } if (ret != IN3_EIGNORE) return ret; } } diff --git a/c/src/core/util/debug.c b/c/src/core/util/debug.c index 52bced814..7fd7c0399 100644 --- a/c/src/core/util/debug.c +++ b/c/src/core/util/debug.c @@ -101,6 +101,7 @@ char* in3_errmsg(in3_ret_t err /**< the error code */) { case IN3_ENODEVICE: return "no hardware wallet connected"; case IN3_EAPDU: return "error in usb communication protocol"; case IN3_EPLGN_NONE: return "no plugin could handle specified action"; + case IN3_ERETRY: return "request to retry all plugins"; case IN3_HTTP_BAD_REQUEST: return "400 - Bad Request"; case IN3_HTTP_UNAUTHORIZED: return "401 - Unauthorized"; case IN3_HTTP_PAYMENT_REQUIRED: return "402 - Payment required"; diff --git a/c/src/core/util/error.h b/c/src/core/util/error.h index 0d8c19ddd..f2e87eb1e 100644 --- a/c/src/core/util/error.h +++ b/c/src/core/util/error.h @@ -79,6 +79,7 @@ typedef enum { IN3_ENODEVICE = -19, /**< harware wallet device not connected */ IN3_EAPDU = -20, /**< error in hardware wallet communication */ IN3_EPLGN_NONE = -21, /**< no plugin could handle specified action */ + IN3_ERETRY = -22, /**< request to retry all plugins again */ IN3_HTTP_BAD_REQUEST = -400, /**< Bad Request */ IN3_HTTP_UNAUTHORIZED = -401, /**< Unauthorized */ From dd4777eb89ad171b301126a76cda264e95d1280d Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 19 Jun 2021 22:50:49 +0200 Subject: [PATCH 017/110] create2 as struct instead of pointer --- c/src/pay/zksync/zk_helper.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/c/src/pay/zksync/zk_helper.c b/c/src/pay/zksync/zk_helper.c index 89f1ee98e..510119f2e 100644 --- a/c/src/pay/zksync/zk_helper.c +++ b/c/src/pay/zksync/zk_helper.c @@ -98,15 +98,14 @@ void zksync_calculate_account(address_t creator, bytes32_t codehash, bytes32_t s in3_ret_t zksync_check_create2(zksync_config_t* conf, in3_req_t* ctx) { if (conf->sign_type != ZK_SIGN_CREATE2) return IN3_OK; if (conf->account) return IN3_OK; - if (!conf->create2) return req_set_error(ctx, "missing create2 section in zksync-config", IN3_ECONFIG); - if (memiszero(conf->create2->creator, 20)) return req_set_error(ctx, "no creator in create2-config", IN3_ECONFIG); - if (memiszero(conf->create2->codehash, 32)) return req_set_error(ctx, "no codehash in create2-config", IN3_ECONFIG); - if (memiszero(conf->create2->salt_arg, 32)) return req_set_error(ctx, "no saltarg in create2-config", IN3_ECONFIG); + if (memiszero(conf->create2.creator, 20)) return req_set_error(ctx, "no creator in create2-config", IN3_ECONFIG); + if (memiszero(conf->create2.codehash, 32)) return req_set_error(ctx, "no codehash in create2-config", IN3_ECONFIG); + if (memiszero(conf->create2.salt_arg, 32)) return req_set_error(ctx, "no saltarg in create2-config", IN3_ECONFIG); if (!conf->account) { address_t pub_key_hash; TRY(zksync_get_pubkey_hash(conf, ctx, pub_key_hash)) conf->account = _malloc(20); - zksync_calculate_account(conf->create2->creator, conf->create2->codehash, conf->create2->salt_arg, pub_key_hash, conf->account); + zksync_calculate_account(conf->create2.creator, conf->create2.codehash, conf->create2.salt_arg, pub_key_hash, conf->account); } return IN3_OK; } From f9ecc2caf95d20fb12d9c05a08b67aed4c2f0eed Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 19 Jun 2021 22:51:32 +0200 Subject: [PATCH 018/110] support prepare instead of signing --- c/src/pay/zksync/zk_message.c | 13 +++++++------ c/src/pay/zksync/zksync.c | 17 +++++++++++------ c/src/pay/zksync/zksync.h | 5 ++++- c/src/signer/multisig/multisig.c | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/c/src/pay/zksync/zk_message.c b/c/src/pay/zksync/zk_message.c index bd01c1446..2991d08f3 100644 --- a/c/src/pay/zksync/zk_message.c +++ b/c/src/pay/zksync/zk_message.c @@ -160,8 +160,9 @@ static in3_ret_t sign_sync_transfer(zksync_tx_data_t* data, in3_req_t* ctx, zksy if (!data->prepare) // sign data return zksync_sign(conf, bytes(raw, (*total)), ctx, sig); + else - data->prepare->zk_message = bytes_dup(bytes(raw, (*total))); + data->prepare->zk_message = bytes_dup(bytes(raw, (*total))); return IN3_OK; } @@ -177,7 +178,7 @@ in3_ret_t zksync_sign_transfer(sb_t* sb, zksync_tx_data_t* data, in3_req_t* ctx, create_human_readable_tx_info(&msg, data, data->type == ZK_WITHDRAW ? "Withdraw " : "Transfer "); if (data->prepare) - data->prepare->human_message = _strdupn(msg_data); + data->prepare->human_message = _strdupn(msg_data, -1); else { TRY(req_require_signature(ctx, SIGN_EC_PREFIX, &signature, bytes((uint8_t*) msg_data, msg.len), bytes(data->from, 20))) in3_log_debug("zksync_sign_transfer human readable :\n%s\n", msg_data); @@ -326,10 +327,10 @@ in3_ret_t zksync_sign_change_pub_key(sb_t* sb, in3_req_t* ctx, uint8_t* sync_pub sb_add_rawbytes(sb, "\"type\":\"ECDSA\",\"ethSignature\":\"0x", signature, 0); else if (conf->sign_type == ZK_SIGN_CONTRACT) sb_add_rawbytes(sb, "\"type\":\"Onchain", signature, 0); - else if (conf->sign_type == ZK_SIGN_CREATE2 && conf->create2) { - sb_add_rawbytes(sb, "\"type\":\"CREATE2\",\"creatorAddress\":\"0x", bytes(conf->create2->creator, 20), 0); - sb_add_rawbytes(sb, "\",\"saltArg\":\"0x", bytes(conf->create2->salt_arg, 32), 0); - sb_add_rawbytes(sb, "\",\"codeHash\":\"0x", bytes(conf->create2->codehash, 32), 0); + else if (conf->sign_type == ZK_SIGN_CREATE2) { + sb_add_rawbytes(sb, "\"type\":\"CREATE2\",\"creatorAddress\":\"0x", bytes(conf->create2.creator, 20), 0); + sb_add_rawbytes(sb, "\",\"saltArg\":\"0x", bytes(conf->create2.salt_arg, 32), 0); + sb_add_rawbytes(sb, "\",\"codeHash\":\"0x", bytes(conf->create2.codehash, 32), 0); } sb_add_chars(sb, "\"}"); } diff --git a/c/src/pay/zksync/zksync.c b/c/src/pay/zksync/zksync.c index 7ae2eb3ea..b548d2329 100644 --- a/c/src/pay/zksync/zksync.c +++ b/c/src/pay/zksync/zksync.c @@ -208,7 +208,6 @@ static in3_ret_t config_free(zksync_config_t* conf, bool free_conf) { if (conf->main_contract) _free(conf->main_contract); if (conf->account) _free(conf->account); if (conf->tokens) _free(conf->tokens); - if (conf->create2) _free(conf->create2); if (conf->proof_verify_method) _free(conf->proof_verify_method); if (conf->musig_pub_keys.data) _free(conf->musig_pub_keys.data); if (conf->incentive && conf->incentive->token) _free(conf->incentive->token); @@ -311,13 +310,12 @@ static in3_ret_t config_set(zksync_config_t* conf, in3_configure_ctx_t* ctx) { d_token_t* create2 = d_get(ctx->token, CONFIG_KEY("create2")); if (create2) { conf->sign_type = ZK_SIGN_CREATE2; - if (!conf->create2) conf->create2 = _calloc(1, sizeof(zk_create2_t)); - bytes_t* t = d_get_bytes(create2, CONFIG_KEY("creator")); - if (t && t->len == 20) memcpy(conf->create2->creator, t->data, 20); + bytes_t* t = d_get_bytes(create2, CONFIG_KEY("creator")); + if (t && t->len == 20) memcpy(conf->create2.creator, t->data, 20); t = d_get_bytes(create2, CONFIG_KEY("saltarg")); - if (t && t->len == 32) memcpy(conf->create2->salt_arg, t->data, 32); + if (t && t->len == 32) memcpy(conf->create2.salt_arg, t->data, 32); t = d_get_bytes(create2, CONFIG_KEY("codehash")); - if (t && t->len == 32) memcpy(conf->create2->codehash, t->data, 32); + if (t && t->len == 32) memcpy(conf->create2.codehash, t->data, 32); } d_token_t* incentive = d_get(ctx->token, CONFIG_KEY("incentive")); @@ -370,6 +368,13 @@ in3_ret_t handle_zksync(void* conf, in3_plugin_act_t action, void* arg) { return IN3_EIGNORE; } +zksync_config_t* zksync_get_conf(in3_req_t* req) { + for (in3_plugin_t* p = req->client->plugins; p; p = p->next) { + if (p->action_fn == handle_zksync) return p->data; + } + return NULL; +} + in3_ret_t in3_register_zksync(in3_t* c) { zksync_config_t* conf = _calloc(sizeof(zksync_config_t), 1); conf->version = 1; diff --git a/c/src/pay/zksync/zksync.h b/c/src/pay/zksync/zksync.h index 39228045b..c9b8672bb 100644 --- a/c/src/pay/zksync/zksync.h +++ b/c/src/pay/zksync/zksync.h @@ -120,7 +120,7 @@ typedef struct zksync_config { zksync_token_t* tokens; /**< the token-list */ zk_sign_type_t sign_type; /**< the signature-type to use*/ uint32_t version; /**< zksync version */ - zk_create2_t* create2; /**< create2 args */ + zk_create2_t create2; /**< create2 args */ bytes_t musig_pub_keys; /**< the public keys of all participants of a schnorr musig signature */ zk_musig_session_t* musig_sessions; /**< linked list of open musig sessions */ char** musig_urls; /**< urls to get signatureshares, the order must be in the same order as the pub_keys */ @@ -191,6 +191,9 @@ in3_ret_t update_nodelist_from_cache(in3_req_t* req, unsigned int node in3_ret_t handle_zksync(void* conf, in3_plugin_act_t action, void* arg); in3_ret_t zksync_tx_data(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx); in3_ret_t zksync_account_history(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx); + +NONULL zksync_config_t* zksync_get_conf(in3_req_t* req); + #ifdef __cplusplus } #endif diff --git a/c/src/signer/multisig/multisig.c b/c/src/signer/multisig/multisig.c index 5f6225161..302a1330d 100644 --- a/c/src/signer/multisig/multisig.c +++ b/c/src/signer/multisig/multisig.c @@ -45,7 +45,7 @@ #include "../../verifier/eth1/nano/rlp.h" #include "../../verifier/eth1/nano/serialize.h" -bool ecrecover_sig(bytes32_t hash, uint8_t* sig, address_t result) { +static bool ecrecover_sig(bytes32_t hash, uint8_t* sig, address_t result) { // check messagehash uint8_t pubkey[65], tmp[32]; From a7c60fcd1d6788d6e926a9578ac0cd6248465395 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 23 Jun 2021 08:30:36 +0200 Subject: [PATCH 019/110] allow inherited cache-entries --- c/src/core/client/request.c | 6 ++++++ c/src/core/util/scache.h | 11 ++++++----- c/src/pay/zksync/zk_musig.c | 6 ++++++ c/src/pay/zksync/zk_transfer.c | 4 ++-- c/src/pay/zksync/zksync.c | 4 ++++ c/src/pay/zksync/zksync.h | 9 +++++++++ 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/c/src/core/client/request.c b/c/src/core/client/request.c index 00c4bff92..e7bb1758c 100644 --- a/c/src/core/client/request.c +++ b/c/src/core/client/request.c @@ -390,6 +390,12 @@ in3_ret_t req_send_sub_request(in3_req_t* parent, char* method, char* params, ch ctx = req_new(parent->client, req); if (!ctx) return req_set_error(parent, "Invalid request!", IN3_ERPC); if (child) *child = ctx; + + // inherit cache-entries + for (cache_entry_t* ce = parent->cache; ce; ce = ce->next) { + if (ce->props & CACHE_PROP_INHERIT) in3_cache_add_entry(&ctx->cache, ce->key, ce->value)->props = ce->props & (~CACHE_PROP_MUST_FREE); + } + if (use_cache) in3_cache_add_ptr(&ctx->cache, req)->props = CACHE_PROP_SRC_REQ; in3_ret_t ret = req_add_required(parent, ctx); diff --git a/c/src/core/util/scache.h b/c/src/core/util/scache.h index b6d2afcc4..03f9711ba 100644 --- a/c/src/core/util/scache.h +++ b/c/src/core/util/scache.h @@ -50,11 +50,12 @@ extern "C" { #include typedef enum cache_props { - CACHE_PROP_MUST_FREE = 0x1, /**< indicates the content must be freed*/ - CACHE_PROP_SRC_REQ = 0x2, /**< the value holds the src-request */ - CACHE_PROP_ONLY_EXTERNAL = 0x4, /**< should only be freed if the context is external */ - CACHE_PROP_JSON = 0x8, /**< indicates the content is a json_ctxt and must be freed as such*/ - CACHE_PROP_PAYMENT = 0x80 /**< This cache-entry is a payment.data */ + CACHE_PROP_MUST_FREE = 0x1, /**< indicates the content must be freed*/ + CACHE_PROP_SRC_REQ = 0x2, /**< the value holds the src-request */ + CACHE_PROP_ONLY_EXTERNAL = 0x4, /**< should only be freed if the context is external */ + CACHE_PROP_JSON = 0x8, /**< indicates the content is a json_ctxt and must be freed as such*/ + CACHE_PROP_INHERIT = 0x10, /**< indicates the content will be inherited when creating sub_request*/ + CACHE_PROP_PAYMENT = 0x80 /**< This cache-entry is a payment.data */ } cache_props_t; /** * represents a single cache entry in a linked list. diff --git a/c/src/pay/zksync/zk_musig.c b/c/src/pay/zksync/zk_musig.c index d871bca47..9f0cd5e5e 100644 --- a/c/src/pay/zksync/zk_musig.c +++ b/c/src/pay/zksync/zk_musig.c @@ -180,6 +180,12 @@ static in3_ret_t verify_proof(zksync_config_t* conf, in3_req_t* ctx, bytes_t* ac } static in3_ret_t create_proof(zksync_config_t* conf, in3_req_t* ctx, bytes_t* msg, char** proof_data) { + cache_entry_t* cached = in3_cache_get_entry_by_prop(ctx->cache, ZKSYNC_CACHED_PROOF); + if (cached) { + *proof_data = (void*) cached->value.data; + return IN3_OK; + } + if (!conf->proof_create_method) return req_set_error(ctx, "No proof_method configured to verify the proof", IN3_ECONFIG); // prepare the arguments to create the proof diff --git a/c/src/pay/zksync/zk_transfer.c b/c/src/pay/zksync/zk_transfer.c index 06e104441..83bae35d9 100644 --- a/c/src/pay/zksync/zk_transfer.c +++ b/c/src/pay/zksync/zk_transfer.c @@ -56,7 +56,7 @@ in3_ret_t zksync_transfer(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, zk_m // create payload cache_entry_t* cached = ctx->req->cache; while (cached) { - if (cached->props & 0x10) break; + if (cached->props & 0xF100) break; cached = cached->next; } if (!cached) { @@ -66,7 +66,7 @@ in3_ret_t zksync_transfer(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, zk_m TRY(ret) if (!sb.data) return IN3_EUNKNOWN; cached = in3_cache_add_entry(&ctx->req->cache, bytes(NULL, 0), bytes((void*) sb.data, strlen(sb.data))); - cached->props = CACHE_PROP_MUST_FREE | 0x10; + cached->props = CACHE_PROP_MUST_FREE | 0xF100; } d_token_t* result = NULL; diff --git a/c/src/pay/zksync/zksync.c b/c/src/pay/zksync/zksync.c index b548d2329..d67a67ccb 100644 --- a/c/src/pay/zksync/zksync.c +++ b/c/src/pay/zksync/zksync.c @@ -145,6 +145,10 @@ static in3_ret_t zksync_rpc(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { // mark zksync as experimental REQUIRE_EXPERIMENTAL(ctx->req, "zksync") + // use custom conf if set + const cache_entry_t* cached = in3_cache_get_entry_by_prop(ctx->req->cache, ZKSYNC_CACHED_CONFIG); + if (cached) conf = (void*) cached->value.data; + // handle rpc -functions TRY_RPC("deposit", zksync_deposit(conf, ctx)) TRY_RPC("transfer", zksync_transfer(conf, ctx, ZK_TRANSFER)) diff --git a/c/src/pay/zksync/zksync.h b/c/src/pay/zksync/zksync.h index c9b8672bb..3d7b5a3a9 100644 --- a/c/src/pay/zksync/zksync.h +++ b/c/src/pay/zksync/zksync.h @@ -58,6 +58,15 @@ typedef uint64_t zk_fee_t; typedef uint64_t zk_fee_p_t; #endif +/** + * cache-key for specifying the a different config. The value.data needs to point to a zksync_config_t-struct. + */ +static const cache_props_t ZKSYNC_CACHED_CONFIG = 0xFE00 | CACHE_PROP_INHERIT; +/** + * cache-key for specifying the the proof. The value.data needs to point to a char* containing the proof, that must be used when signing with musig. + */ +static const cache_props_t ZKSYNC_CACHED_PROOF = 0xFF00 | CACHE_PROP_INHERIT; + /** represents a token supported in zksync. */ typedef struct { uint16_t id; /**< the id used in messaged */ From 4094136b6981fafda4f7f020a173fd8dfda0ffd2 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 23 Jun 2021 13:49:24 +0200 Subject: [PATCH 020/110] fixed meory issues --- c/src/pay/zksync/zk_musig.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/c/src/pay/zksync/zk_musig.c b/c/src/pay/zksync/zk_musig.c index 9f0cd5e5e..8eb349ca9 100644 --- a/c/src/pay/zksync/zk_musig.c +++ b/c/src/pay/zksync/zk_musig.c @@ -182,7 +182,7 @@ static in3_ret_t verify_proof(zksync_config_t* conf, in3_req_t* ctx, bytes_t* ac static in3_ret_t create_proof(zksync_config_t* conf, in3_req_t* ctx, bytes_t* msg, char** proof_data) { cache_entry_t* cached = in3_cache_get_entry_by_prop(ctx->cache, ZKSYNC_CACHED_PROOF); if (cached) { - *proof_data = (void*) cached->value.data; + *proof_data = _strdupn((char*) cached->value.data, -1); return IN3_OK; } @@ -261,6 +261,12 @@ in3_ret_t zksync_musig_sign(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { in3_log_debug("create new session with pub_key pos %d\n", pos); TRY(pos) + // check if we have all musig_urls + for (unsigned int n = 0; n < pub_keys.len; n += 32) { + if (n / 32 == pos) continue; + if (conf->musig_urls == NULL || !conf->musig_urls[n / 32]) return req_set_error(ctx->req, "Missing musig_url!", IN3_ECONFIG); + } + // if a method is specified we create the proof here if (conf->proof_create_method && proof == NULL) TRY(create_proof(conf, ctx->req, &message, &proof_data)) From 0c32dbb2a75809acf3afc87d36b5dcb1b60b3f6b Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 09:05:34 +0200 Subject: [PATCH 021/110] support files as argument --- c/src/cmd/in3/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/c/src/cmd/in3/main.c b/c/src/cmd/in3/main.c index f1996f2a0..129a8517c 100644 --- a/c/src/cmd/in3/main.c +++ b/c/src/cmd/in3/main.c @@ -65,8 +65,19 @@ int main(int argc, char* argv[]) { if (*argv[i] == '-' && *(argv[i] + 1) == 0) { bytes_t b = readFile(stdin); sb_add_range(args, (char*) b.data, 0, b.len); + continue; } - else if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC) + if ((*argv[i] == '.' && *(argv[i] + 1) == '/') || *argv[i] == '/') { + // looks like a file + FILE* f = fopen(argv[i], "r"); + if (f) { + bytes_t b = readFile(f); + fclose(f); + sb_add_range(args, (char*) b.data, 0, b.len); + continue; + } + } + if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC) sb_print(args, "\"%s\"", get_wei(argv[i])); else sb_print(args, From 51e6c9733466395020e2961ad526a510d4f20973 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 09:05:52 +0200 Subject: [PATCH 022/110] add check if the existing is a real value --- c/src/pay/zksync/zk_helper.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/c/src/pay/zksync/zk_helper.c b/c/src/pay/zksync/zk_helper.c index 510119f2e..77e405951 100644 --- a/c/src/pay/zksync/zk_helper.c +++ b/c/src/pay/zksync/zk_helper.c @@ -292,13 +292,15 @@ in3_ret_t zksync_get_nonce(zksync_config_t* conf, in3_req_t* ctx, d_token_t* non in3_ret_t zksync_get_fee(zksync_config_t* conf, in3_req_t* ctx, d_token_t* fee_in, bytes_t to, d_token_t* token, char* type, zk_fee_p_t* fee) { if (fee_in && (d_type(fee_in) == T_INTEGER || d_type(fee_in) == T_BYTES)) { -#ifdef ZKSYNC_256 bytes_t b = d_to_bytes(fee_in); - memcpy(fee + 32 - b.len, b.data, b.len); + if (b.data && b.len) { +#ifdef ZKSYNC_256 + memcpy(fee + 32 - b.len, b.data, b.len); #else - *fee = d_long(fee_in); + *fee = d_long(fee_in); #endif - return IN3_OK; + return IN3_OK; + } } d_token_t* result; bool is_object_type = *type == '{'; From 63409ca3d4d5cb4ac171d207dccfa7177eaf8095 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 09:06:15 +0200 Subject: [PATCH 023/110] we only check if the musig urls are set on the client side --- c/src/pay/zksync/zk_musig.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/c/src/pay/zksync/zk_musig.c b/c/src/pay/zksync/zk_musig.c index 8eb349ca9..af374c5f2 100644 --- a/c/src/pay/zksync/zk_musig.c +++ b/c/src/pay/zksync/zk_musig.c @@ -261,11 +261,12 @@ in3_ret_t zksync_musig_sign(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { in3_log_debug("create new session with pub_key pos %d\n", pos); TRY(pos) - // check if we have all musig_urls - for (unsigned int n = 0; n < pub_keys.len; n += 32) { - if (n / 32 == pos) continue; - if (conf->musig_urls == NULL || !conf->musig_urls[n / 32]) return req_set_error(ctx->req, "Missing musig_url!", IN3_ECONFIG); - } + // check if we have all musig_urls (but only if we are in client mode) + if (d_type(ctx->params + 1) != T_OBJECT) + for (unsigned int n = 0; n < pub_keys.len; n += 32) { + if (n / 32 == pos) continue; + if (conf->musig_urls == NULL || !conf->musig_urls[n / 32]) return req_set_error(ctx->req, "Missing musig_url!", IN3_ECONFIG); + } // if a method is specified we create the proof here if (conf->proof_create_method && proof == NULL) From 691d04898bde41d6690f6992e6d46de81b8dca1a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 09:06:55 +0200 Subject: [PATCH 024/110] add a only_update option where we set the key without a response --- c/src/pay/zksync/zk_setkey.c | 22 ++++++++++++++++++---- c/src/pay/zksync/zksync.c | 2 +- c/src/pay/zksync/zksync.h | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/c/src/pay/zksync/zk_setkey.c b/c/src/pay/zksync/zk_setkey.c index 7b6055ffa..132a929d2 100644 --- a/c/src/pay/zksync/zk_setkey.c +++ b/c/src/pay/zksync/zk_setkey.c @@ -57,16 +57,21 @@ static in3_ret_t auth_pub_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, return IN3_OK; } -in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { +in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, bool only_update) { address_t pub_hash; + d_token_t tmp; zksync_valid_t valid; uint32_t nonce; - int plen = d_len(ctx->params); + int plen = only_update ? 0 : d_len(ctx->params); d_token_t* token = plen == 1 ? ctx->params + 1 : NULL; bytes_t* new_key = d_get_bytes_at(ctx->params, 1); valid.from = plen > 2 ? d_get_long_at(ctx->params, 2) : 0; valid.to = plen > 3 ? d_get_long_at(ctx->params, 3) : 0; if (!valid.to) valid.to = 0xffffffffl; + if (!token) { + token = &tmp; + tmp = (d_token_t){.data = (void*) "ETH", .len = T_STRING << 28 | 3, .key = 0}; + } zksync_token_t* token_data = NULL; if (!token) return req_set_error(ctx->req, "Missing fee token as first token", IN3_EINVAL); @@ -92,9 +97,10 @@ in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { )) // create payload for change key tx + cache_props_t ckey = CACHE_PROP_MUST_FREE | 0xC100; cache_entry_t* cached = ctx->req->cache; while (cached) { - if (cached->props & 0x10) break; + if (cached->props == ckey) break; cached = cached->next; } if (!cached) { @@ -104,12 +110,20 @@ in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { TRY(ret) if (!sb.data) return IN3_EUNKNOWN; cached = in3_cache_add_entry(&ctx->req->cache, bytes(NULL, 0), bytes((void*) sb.data, strlen(sb.data))); - cached->props = CACHE_PROP_MUST_FREE | 0x10; + cached->props = ckey; } d_token_t* result = NULL; in3_ret_t ret = send_provider_request(ctx->req, conf, "tx_submit", (void*) cached->value.data, &result); if (ret == IN3_OK) { + if (only_update) { + if (d_type(result) == T_STRING) { + conf->nonce++; + memcpy(conf->pub_key_hash_set, pub_hash, 20); + return IN3_OK; + } + return req_set_error(ctx->req, "Invalid response qwhen setting key", IN3_ERPC); + } // return only the pubkeyhash as result sb_t* sb = in3_rpc_handle_start(ctx); sb_add_rawbytes(sb, "\"sync:", bytes(pub_hash, 20), 20); diff --git a/c/src/pay/zksync/zksync.c b/c/src/pay/zksync/zksync.c index d67a67ccb..ebe95b98d 100644 --- a/c/src/pay/zksync/zksync.c +++ b/c/src/pay/zksync/zksync.c @@ -153,7 +153,7 @@ static in3_ret_t zksync_rpc(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { TRY_RPC("deposit", zksync_deposit(conf, ctx)) TRY_RPC("transfer", zksync_transfer(conf, ctx, ZK_TRANSFER)) TRY_RPC("withdraw", zksync_transfer(conf, ctx, ZK_WITHDRAW)) - TRY_RPC("set_key", zksync_set_key(conf, ctx)) + TRY_RPC("set_key", zksync_set_key(conf, ctx, false)) TRY_RPC("emergency_withdraw", zksync_emergency_withdraw(conf, ctx)) TRY_RPC("sync_key", zksync_get_key(conf, ctx)) TRY_RPC("aggregate_pubkey", zksync_aggregate_pubkey(ctx)) diff --git a/c/src/pay/zksync/zksync.h b/c/src/pay/zksync/zksync.h index 3d7b5a3a9..9adefad46 100644 --- a/c/src/pay/zksync/zksync.h +++ b/c/src/pay/zksync/zksync.h @@ -174,7 +174,7 @@ typedef struct { NONULL in3_ret_t in3_register_zksync(in3_t* c); /** sets a PubKeyHash for the current Account */ -NONULL in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx); +NONULL in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, bool only_update); /** sends a transfer transaction in Layer 2*/ NONULL in3_ret_t zksync_transfer(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, zk_msg_type_t type); From ab97c2d1c9963103c8ffa585085ba97f712d2439 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 13:40:35 +0200 Subject: [PATCH 025/110] generate valid input args in prepare --- c/src/pay/zksync/zk_message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/src/pay/zksync/zk_message.c b/c/src/pay/zksync/zk_message.c index 2991d08f3..7f706a7fd 100644 --- a/c/src/pay/zksync/zk_message.c +++ b/c/src/pay/zksync/zk_message.c @@ -209,12 +209,12 @@ in3_ret_t zksync_sign_transfer(sb_t* sb, zksync_tx_data_t* data, in3_req_t* ctx, sb_add_int(sb, data->token->id); sb_add_chars(sb, ",\"tokenId\":"); sb_add_int(sb, data->token->id); - sb_add_chars(sb, ",\"amount\":"); + sb_add_chars(sb, data->prepare ? ",\"value\":" : ",\"amount\":"); #ifdef ZKSYNC_256 char dec[80]; to_dec(dec, data->amount); sb_add_chars(sb, dec); - sb_add_chars(sb, ",\"fee\":"); + sb_add_chars(sb, data->prepare ? ",\"gas\":" : ",\"fee\":"); to_dec(dec, data->fee); sb_add_chars(sb, dec); #else From 881abd5fe81b21f797509a8aebc234f3200fab92 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 13:56:38 +0200 Subject: [PATCH 026/110] fix format --- c/src/core/util/data.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/c/src/core/util/data.h b/c/src/core/util/data.h index 167442a00..214bda377 100644 --- a/c/src/core/util/data.h +++ b/c/src/core/util/data.h @@ -136,16 +136,16 @@ d_token_t* d_get_or(d_token_t* item, const uint16_t key1, const uint16_t key2); d_token_t* d_get_at(d_token_t* item, const uint32_t index); /**< returns the token of an array with the given index */ d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */ -NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ -NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ -NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ -char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ - -json_ctx_t* json_create(); +NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ +NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ +NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ +char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ + +json_ctx_t* json_create(); NONULL d_token_t* json_create_null(json_ctx_t* jp); NONULL d_token_t* json_create_bool(json_ctx_t* jp, bool value); NONULL d_token_t* json_create_int(json_ctx_t* jp, uint64_t value); From 9cbbe674c19b662cfca94aeb8b96ade7d8922115 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 13:57:55 +0200 Subject: [PATCH 027/110] fix warning --- c/src/pay/zksync/zk_musig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/pay/zksync/zk_musig.c b/c/src/pay/zksync/zk_musig.c index af374c5f2..c94bf10d2 100644 --- a/c/src/pay/zksync/zk_musig.c +++ b/c/src/pay/zksync/zk_musig.c @@ -264,7 +264,7 @@ in3_ret_t zksync_musig_sign(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { // check if we have all musig_urls (but only if we are in client mode) if (d_type(ctx->params + 1) != T_OBJECT) for (unsigned int n = 0; n < pub_keys.len; n += 32) { - if (n / 32 == pos) continue; + if (n / 32 == (unsigned) pos) continue; if (conf->musig_urls == NULL || !conf->musig_urls[n / 32]) return req_set_error(ctx->req, "Missing musig_url!", IN3_ECONFIG); } From eb6647166d3f8915b1cedef333d076e5148d75b5 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 14:22:19 +0200 Subject: [PATCH 028/110] add sb_add_json method --- c/src/core/util/stringbuilder.c | 26 ++++++++++++++++++++++++++ c/src/core/util/stringbuilder.h | 19 ++++++++++--------- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/c/src/core/util/stringbuilder.c b/c/src/core/util/stringbuilder.c index 9e821d513..145653aa5 100644 --- a/c/src/core/util/stringbuilder.c +++ b/c/src/core/util/stringbuilder.c @@ -283,4 +283,30 @@ sb_t* sb_print(sb_t* sb, const char* fmt, ...) { sb_vprint(sb, fmt, args); va_end(args); return sb; +} + +sb_t* sb_add_json(sb_t* sb, const char* prefix, d_token_t* token) { + if (!token) return sb; + if (prefix) sb_add_chars(sb, prefix); + switch (d_type(token)) { + case T_ARRAY: + case T_OBJECT: { + str_range_t r = d_to_json(token); + return sb_add_range(sb, r.data, 0, r.len); + } + case T_BOOLEAN: + return sb_add_chars(sb, d_int(token) ? "true" : "false"); + case T_INTEGER: + return sb_add_int(sb, d_int(token)); + case T_BYTES: + return sb_add_bytes(sb, NULL, d_bytes(token), 1, false); + case T_STRING: { + sb_add_char(sb, '\"'); + sb_add_escaped_chars(sb, d_string(token)); + return sb_add_char(sb, '\"'); + } + case T_NULL: + return sb_add_chars(sb, "null"); + } + return sb; } \ No newline at end of file diff --git a/c/src/core/util/stringbuilder.h b/c/src/core/util/stringbuilder.h index 14880e864..1aa4731ce 100644 --- a/c/src/core/util/stringbuilder.h +++ b/c/src/core/util/stringbuilder.h @@ -45,6 +45,7 @@ extern "C" { #endif #include "bytes.h" +#include "data.h" #include #include #include @@ -70,25 +71,25 @@ typedef struct sb { */ NONULL static inline sb_t sb_stack(char* p) { return (sb_t){.allocted = 0xffffff, .len = 0, .data = p}; } -sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ -NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ -NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ +sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ +NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ +NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ NONULL sb_t* sb_add_char(sb_t* sb, char c); /**< add a single character */ NONULL sb_t* sb_add_chars(sb_t* sb, const char* chars); /**< adds a string */ NONULL sb_t* sb_add_range(sb_t* sb, const char* chars, int start, int len); /**< add a string range */ NONULL sb_t* sb_add_key_value(sb_t* sb, const char* key, const char* value, int value_len, bool as_string); /**< adds a value with an optional key. if as_string is true the value will be quoted. */ NONULL_FOR((1, 3)) -sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ -NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ -NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ -NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ -NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ +sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ +NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ +NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ +NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ +NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ NONULL_FOR((1)) sb_t* sb_add_rawbytes(sb_t* sb, char* prefix, bytes_t b, int fix_size); sb_t* sb_print(sb_t* sb, const char* fmt, ...); sb_t* sb_vprint(sb_t* sb, const char* fmt, va_list args); - +sb_t* sb_add_json(sb_t* sb, const char* prefix, d_token_t* token); #ifdef __cplusplus } #endif From ab72d4b33a4dbc10e327e89facf8a411152461dc Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 14:30:02 +0200 Subject: [PATCH 029/110] fix stringbuilder-dependency issue --- c/include/in3/data.h | 26 ++++++++++---------- c/include/in3/error.h | 1 + c/include/in3/eth_basic.h | 8 ++++++- c/include/in3/plugin.h | 8 +++---- c/include/in3/scache.h | 19 +++++++++++---- c/include/in3/stringbuilder.h | 18 +++++++------- c/include/in3/zksync.h | 42 +++++++++++++++++++++++---------- c/src/core/util/data.h | 22 ++++++++--------- c/src/core/util/stringbuilder.h | 1 + 9 files changed, 92 insertions(+), 53 deletions(-) diff --git a/c/include/in3/data.h b/c/include/in3/data.h index d54cdad3a..46e1fa044 100644 --- a/c/include/in3/data.h +++ b/c/include/in3/data.h @@ -59,7 +59,6 @@ extern "C" { #include "bytes.h" #include "mem.h" -#include "stringbuilder.h" #include #include #include @@ -103,6 +102,8 @@ typedef struct json_parser { size_t keys_last; // points to the position of the last key. } json_ctx_t; +#include "stringbuilder.h" + /** * * returns the byte-representation of token. @@ -136,16 +137,16 @@ d_token_t* d_get_or(d_token_t* item, const uint16_t key1, const uint16_t key2); d_token_t* d_get_at(d_token_t* item, const uint32_t index); /**< returns the token of an array with the given index */ d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */ -NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ -NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ -NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ -char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ +NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ +NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ +NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ +char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ -json_ctx_t* json_create(); +json_ctx_t* json_create(); NONULL d_token_t* json_create_null(json_ctx_t* jp); NONULL d_token_t* json_create_bool(json_ctx_t* jp, bool value); NONULL d_token_t* json_create_int(json_ctx_t* jp, uint64_t value); @@ -154,7 +155,9 @@ NONULL d_token_t* json_create_bytes(json_ctx_t* jp, bytes_t value); NONULL int json_create_object(json_ctx_t* jp); NONULL int json_create_array(json_ctx_t* jp); NONULL void json_object_add_prop(json_ctx_t* jp, int ob_index, d_key_t key, d_token_t* value); -NONULL void json_array_add_value(json_ctx_t* jp, int parent_index, d_token_t* value); +NONULL d_token_t* json_create_ref_item(json_ctx_t* jp, d_type_t type, void* data, int len); + +NONULL void json_array_add_value(json_ctx_t* jp, int parent_index, d_token_t* value); // Helper function to map string to 2byte keys (only for tests or debugging) char* d_get_keystr(json_ctx_t* json, d_key_t k); /**< returns the string for a key. This only works for index keys or known keys! */ @@ -179,7 +182,6 @@ static inline bytes_t* d_get_bytes_at(d_token_t* r, uint32_t pos) { return d_byt static inline bool d_is_binary_ctx(json_ctx_t* ctx) { return ctx->allocated == 0; } /**< check if the parser context was created from binary data. */ bytes_t* d_get_byteskl(d_token_t* r, d_key_t k, uint32_t minl); d_token_t* d_getl(d_token_t* item, uint16_t k, uint32_t minl); - /** * iterator over elements of a array opf object. * diff --git a/c/include/in3/error.h b/c/include/in3/error.h index 0d8c19ddd..f2e87eb1e 100644 --- a/c/include/in3/error.h +++ b/c/include/in3/error.h @@ -79,6 +79,7 @@ typedef enum { IN3_ENODEVICE = -19, /**< harware wallet device not connected */ IN3_EAPDU = -20, /**< error in hardware wallet communication */ IN3_EPLGN_NONE = -21, /**< no plugin could handle specified action */ + IN3_ERETRY = -22, /**< request to retry all plugins again */ IN3_HTTP_BAD_REQUEST = -400, /**< Bad Request */ IN3_HTTP_UNAUTHORIZED = -401, /**< Unauthorized */ diff --git a/c/include/in3/eth_basic.h b/c/include/in3/eth_basic.h index d5855714c..b730dc142 100644 --- a/c/include/in3/eth_basic.h +++ b/c/include/in3/eth_basic.h @@ -116,7 +116,8 @@ in3_ret_t eth_verify_eth_getLog(in3_vctx_t* vc, int l_logs); */ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, /**< a json-token desribing the transaction */ in3_req_t* req, /**< the current context */ - bytes_t* dst /**< the bytes to write the result to. */ + bytes_t* dst, /**< the bytes to write the result to. */ + sb_t* meta /**< a stringbuilder in order write the wallet_state and metadata depending on the tx. */ ); /** @@ -145,4 +146,9 @@ const uint8_t* empty_hash(); */ RETURNS_NONULL NONULL char* eth_wallet_sign(const char* key, const char* data); +/** + * determines the from-address in case no from-address has been specified. + */ +NONULL in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res); + #endif // in3_eth_basic_h__ \ No newline at end of file diff --git a/c/include/in3/plugin.h b/c/include/in3/plugin.h index 9bd0e500a..1f9033a83 100644 --- a/c/include/in3/plugin.h +++ b/c/include/in3/plugin.h @@ -270,10 +270,10 @@ typedef struct sign_account_ctx { typedef struct sign_prepare_ctx { struct in3_req* req; /**< the context of the request in order report errors */ address_t account; /**< the account to use for the signature */ - address_t wallet; /**< if set to a non zero-value it will specify the wallet to use */ - bytes_t old_tx; - bytes_t new_tx; - + d_token_t* tx; /**< the tx-definition, which may contain additional properties */ + bytes_t old_tx; /**< the source-transaction */ + bytes_t new_tx; /**< the new-transaction, if the transaction should not changed, the data-ptr must be NULL otherwise a new allocated memory is expected, which will be cleaned by the caller. */ + sb_t* output; /**< if this is not NULL, the transaction will not be send, but returns only the state */ } in3_sign_prepare_ctx_t; // -------------- SIGN ----------------------- diff --git a/c/include/in3/scache.h b/c/include/in3/scache.h index ce8de3a4e..03f9711ba 100644 --- a/c/include/in3/scache.h +++ b/c/include/in3/scache.h @@ -50,11 +50,12 @@ extern "C" { #include typedef enum cache_props { - CACHE_PROP_MUST_FREE = 0x1, /**< indicates the content must be freed*/ - CACHE_PROP_SRC_REQ = 0x2, /**< the value holds the src-request */ - CACHE_PROP_ONLY_EXTERNAL = 0x4, /**< should only be freed if the context is external */ - CACHE_PROP_JSON = 0x8, /**< indicates the content is a json_ctxt and must be freed as such*/ - CACHE_PROP_PAYMENT = 0x80 /**< This cache-entry is a payment.data */ + CACHE_PROP_MUST_FREE = 0x1, /**< indicates the content must be freed*/ + CACHE_PROP_SRC_REQ = 0x2, /**< the value holds the src-request */ + CACHE_PROP_ONLY_EXTERNAL = 0x4, /**< should only be freed if the context is external */ + CACHE_PROP_JSON = 0x8, /**< indicates the content is a json_ctxt and must be freed as such*/ + CACHE_PROP_INHERIT = 0x10, /**< indicates the content will be inherited when creating sub_request*/ + CACHE_PROP_PAYMENT = 0x80 /**< This cache-entry is a payment.data */ } cache_props_t; /** * represents a single cache entry in a linked list. @@ -76,6 +77,14 @@ bytes_t* in3_cache_get_entry( bytes_t* key /**< the key to compare with */ ); +/** + * get the entry for a given property. + */ +cache_entry_t* in3_cache_get_entry_by_prop( + cache_entry_t* cache, /**< the root entry of the linked list. */ + cache_props_t prop /**< the prop, which must match exactly */ +); + /** * adds an entry to the linked list. */ diff --git a/c/include/in3/stringbuilder.h b/c/include/in3/stringbuilder.h index 14880e864..000ccaefe 100644 --- a/c/include/in3/stringbuilder.h +++ b/c/include/in3/stringbuilder.h @@ -45,6 +45,7 @@ extern "C" { #endif #include "bytes.h" +#include "data.h" #include #include #include @@ -70,24 +71,25 @@ typedef struct sb { */ NONULL static inline sb_t sb_stack(char* p) { return (sb_t){.allocted = 0xffffff, .len = 0, .data = p}; } -sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ -NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ -NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ +sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ +NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ +NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ NONULL sb_t* sb_add_char(sb_t* sb, char c); /**< add a single character */ NONULL sb_t* sb_add_chars(sb_t* sb, const char* chars); /**< adds a string */ NONULL sb_t* sb_add_range(sb_t* sb, const char* chars, int start, int len); /**< add a string range */ NONULL sb_t* sb_add_key_value(sb_t* sb, const char* key, const char* value, int value_len, bool as_string); /**< adds a value with an optional key. if as_string is true the value will be quoted. */ NONULL_FOR((1, 3)) -sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ -NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ -NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ -NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ -NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ +sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ +NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ +NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ +NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ +NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ NONULL_FOR((1)) sb_t* sb_add_rawbytes(sb_t* sb, char* prefix, bytes_t b, int fix_size); sb_t* sb_print(sb_t* sb, const char* fmt, ...); sb_t* sb_vprint(sb_t* sb, const char* fmt, va_list args); +sb_t* sb_add_json(sb_t* sb, const char* prefix, d_token_t* token); #ifdef __cplusplus } diff --git a/c/include/in3/zksync.h b/c/include/in3/zksync.h index 7d4855642..859c8e464 100644 --- a/c/include/in3/zksync.h +++ b/c/include/in3/zksync.h @@ -58,6 +58,15 @@ typedef uint64_t zk_fee_t; typedef uint64_t zk_fee_p_t; #endif +/** + * cache-key for specifying the a different config. The value.data needs to point to a zksync_config_t-struct. + */ +static const cache_props_t ZKSYNC_CACHED_CONFIG = 0xFE00 | CACHE_PROP_INHERIT; +/** + * cache-key for specifying the the proof. The value.data needs to point to a char* containing the proof, that must be used when signing with musig. + */ +static const cache_props_t ZKSYNC_CACHED_PROOF = 0xFF00 | CACHE_PROP_INHERIT; + /** represents a token supported in zksync. */ typedef struct { uint16_t id; /**< the id used in messaged */ @@ -120,7 +129,7 @@ typedef struct zksync_config { zksync_token_t* tokens; /**< the token-list */ zk_sign_type_t sign_type; /**< the signature-type to use*/ uint32_t version; /**< zksync version */ - zk_create2_t* create2; /**< create2 args */ + zk_create2_t create2; /**< create2 args */ bytes_t musig_pub_keys; /**< the public keys of all participants of a schnorr musig signature */ zk_musig_session_t* musig_sessions; /**< linked list of open musig sessions */ char** musig_urls; /**< urls to get signatureshares, the order must be in the same order as the pub_keys */ @@ -142,24 +151,30 @@ typedef struct pay_criteria { } pay_criteria_t; /** a transaction */ + +typedef struct { + bytes_t zk_message; + char* human_message; +} zk_prepare_ctx_t; typedef struct { - zksync_config_t* conf; /**< the configuration of the zksync-account */ - uint32_t account_id; /**< the id of the account */ - address_t from; /**< the from-address */ - address_t to; /**< the address of the receipient */ - zksync_token_t* token; /**< the token to use */ - uint32_t nonce; /**< current nonce */ - zk_msg_type_t type; /**< message type */ - zk_fee_t amount; /**< amount to send */ - zk_fee_t fee; /**< ransaction fees */ - zksync_valid_t valid; /**< validity */ + zksync_config_t* conf; /**< the configuration of the zksync-account */ + uint32_t account_id; /**< the id of the account */ + address_t from; /**< the from-address */ + address_t to; /**< the address of the receipient */ + zksync_token_t* token; /**< the token to use */ + uint32_t nonce; /**< current nonce */ + zk_msg_type_t type; /**< message type */ + zk_fee_t amount; /**< amount to send */ + zk_fee_t fee; /**< ransaction fees */ + zksync_valid_t valid; /**< validity */ + zk_prepare_ctx_t* prepare; /**< if a prepare ctx is set the data will not be signed, but only the messages are created and stored.*/ } zksync_tx_data_t; /** registers the zksync-plugin in the client */ NONULL in3_ret_t in3_register_zksync(in3_t* c); /** sets a PubKeyHash for the current Account */ -NONULL in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx); +NONULL in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, bool only_update); /** sends a transfer transaction in Layer 2*/ NONULL in3_ret_t zksync_transfer(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, zk_msg_type_t type); @@ -185,6 +200,9 @@ in3_ret_t update_nodelist_from_cache(in3_req_t* req, unsigned int node in3_ret_t handle_zksync(void* conf, in3_plugin_act_t action, void* arg); in3_ret_t zksync_tx_data(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx); in3_ret_t zksync_account_history(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx); + +NONULL zksync_config_t* zksync_get_conf(in3_req_t* req); + #ifdef __cplusplus } #endif diff --git a/c/src/core/util/data.h b/c/src/core/util/data.h index 214bda377..46e1fa044 100644 --- a/c/src/core/util/data.h +++ b/c/src/core/util/data.h @@ -59,7 +59,6 @@ extern "C" { #include "bytes.h" #include "mem.h" -#include "stringbuilder.h" #include #include #include @@ -103,6 +102,8 @@ typedef struct json_parser { size_t keys_last; // points to the position of the last key. } json_ctx_t; +#include "stringbuilder.h" + /** * * returns the byte-representation of token. @@ -136,16 +137,16 @@ d_token_t* d_get_or(d_token_t* item, const uint16_t key1, const uint16_t key2); d_token_t* d_get_at(d_token_t* item, const uint32_t index); /**< returns the token of an array with the given index */ d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */ -NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ -NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ -NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ -char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ +NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ +NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ +NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ +char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ -json_ctx_t* json_create(); +json_ctx_t* json_create(); NONULL d_token_t* json_create_null(json_ctx_t* jp); NONULL d_token_t* json_create_bool(json_ctx_t* jp, bool value); NONULL d_token_t* json_create_int(json_ctx_t* jp, uint64_t value); @@ -181,7 +182,6 @@ static inline bytes_t* d_get_bytes_at(d_token_t* r, uint32_t pos) { return d_byt static inline bool d_is_binary_ctx(json_ctx_t* ctx) { return ctx->allocated == 0; } /**< check if the parser context was created from binary data. */ bytes_t* d_get_byteskl(d_token_t* r, d_key_t k, uint32_t minl); d_token_t* d_getl(d_token_t* item, uint16_t k, uint32_t minl); - /** * iterator over elements of a array opf object. * diff --git a/c/src/core/util/stringbuilder.h b/c/src/core/util/stringbuilder.h index 1aa4731ce..000ccaefe 100644 --- a/c/src/core/util/stringbuilder.h +++ b/c/src/core/util/stringbuilder.h @@ -90,6 +90,7 @@ sb_t* sb_add_rawbytes(sb_t* sb, char* prefix, bytes_t b, int fix_size); sb_t* sb_print(sb_t* sb, const char* fmt, ...); sb_t* sb_vprint(sb_t* sb, const char* fmt, va_list args); sb_t* sb_add_json(sb_t* sb, const char* prefix, d_token_t* token); + #ifdef __cplusplus } #endif From 882bffff491d6459472a2c28e7a00d75e2d07f0d Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 16:45:38 +0200 Subject: [PATCH 030/110] fix nested lists --- scripts/generator/generate.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/generator/generate.js b/scripts/generator/generate.js index 9ae19aef2..7b39cf29c 100755 --- a/scripts/generator/generate.js +++ b/scripts/generator/generate.js @@ -82,21 +82,21 @@ function print_object(def, pad, useNum, doc, pre) { if (p.cmd) asArray(p.cmd).forEach(_ => s += '\n' + pad + 'This option can also be used in its short-form in the comandline client `-' + _ + '` .') doc.push(s) if (typeof pt === 'object') { - doc.push('The ' + prop + ' object supports the following properties :\n' + pad) + doc.push(pad + ' The ' + prop + ' object supports the following properties :\n' + pad) print_object(pt, pad + ' ', false, doc) } if (rpc_doc === doc) { - if (p.example) doc.push('\n' + pad + ' *Example* : ' + prop + ': ' + JSON.stringify(p.example)) + if (p.example) doc.push('\n' + pad + ' *Example* : ' + prop + ': ' + JSON.stringify(p.example)) } else if (config_doc === doc) asArray(p.example).forEach(ex => { key = prop - doc.push(pad+'```sh') + doc.push(pad + '```sh') if (typeof (ex) == 'object') - doc.push(pad+'> ' + cmdName + ' ' + Object.keys(ex).filter(_ => typeof (ex[_]) !== 'object').map(k => '--' + pre + key + '.' + k + '=' + ex[k]).join(' ') + ' ....\n') + doc.push(pad + '> ' + cmdName + ' ' + Object.keys(ex).filter(_ => typeof (ex[_]) !== 'object').map(k => '--' + pre + key + '.' + k + '=' + ex[k]).join(' ') + ' ....\n') else - doc.push(pad+[...asArray(p.cmd).map(_ => '-' + _), '--' + pre + key].map(_ => '> ' + cmdName + ' ' + _ + (ex === true ? '' : (_.startsWith('--') ? '=' : ' ') + ex) + ' ....').join('\n') + '\n') - doc.push(pad+'```\n') + doc.push(pad + [...asArray(p.cmd).map(_ => '-' + _), '--' + pre + key].map(_ => '> ' + cmdName + ' ' + _ + (ex === true ? '' : (_.startsWith('--') ? '=' : ' ') + ex) + ' ....').join('\n') + '\n') + doc.push(pad + '```\n') }) doc.push(pad + '\n') @@ -121,7 +121,7 @@ function handle_config(conf, pre, title, descr) { config_doc.push(s) if (typeof (c.type) === 'object') { config_doc.push('The ' + key + ' object supports the following properties :\n') - print_object(c.type, '', false, config_doc, key+".") + print_object(c.type, '', false, config_doc, key + ".") } if (c.example !== undefined) { config_doc.push('\n*Example:*\n') From dc41eff57439bf081bb9adeed6b6ad3936c43ec8 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 24 Jun 2021 23:21:09 +0200 Subject: [PATCH 031/110] add support for token when preparing transactions --- c/src/cmd/in3/in3.yml | 4 ++ c/src/cmd/in3/option_handler.c | 1 + c/src/cmd/in3/tx.c | 19 +++++--- c/src/cmd/in3/tx.h | 1 + c/src/core/util/data.c | 35 ++++++++++++++- c/src/core/util/data.h | 5 ++- c/src/pay/zksync/zk_helper.c | 8 +++- c/src/verifier/eth1/basic/sign_tx.c | 70 ++++++++++++++++++++++++++--- scripts/_in3.sh | 6 ++- 9 files changed, 132 insertions(+), 17 deletions(-) diff --git a/c/src/cmd/in3/in3.yml b/c/src/cmd/in3/in3.yml index f964e569c..3e8f42a15 100644 --- a/c/src/cmd/in3/in3.yml +++ b/c/src/cmd/in3/in3.yml @@ -49,6 +49,10 @@ config: type: uint descr: 'the gas limit to use when sending transactions. (default: 100000)' example: 100000 + token : + cmd: token + type: string + descr: 'the address of the erc20-token contract.' nonce : cmd: nonce type: uint diff --git a/c/src/cmd/in3/option_handler.c b/c/src/cmd/in3/option_handler.c index 7fd5ef4f4..b2634839c 100644 --- a/c/src/cmd/in3/option_handler.c +++ b/c/src/cmd/in3/option_handler.c @@ -193,6 +193,7 @@ bool handle_option(in3_t* c, char* key, char* value, sb_t* conf, int argc, char* CHECK_OPTION("version", show_version()) CHECK_OPTION("chainId", set_chainId(value, conf)) CHECK_OPTION("from", set_string(&get_txdata()->from, value)) + CHECK_OPTION("token", set_string(&get_txdata()->token, value)) CHECK_OPTION("to", set_string(&get_txdata()->to, value)) CHECK_OPTION("gas", set_uint64(&get_txdata()->gas, value)) CHECK_OPTION("gas_price", set_uint64(&get_txdata()->gas_price, value)) diff --git a/c/src/cmd/in3/tx.c b/c/src/cmd/in3/tx.c index 504310189..e1fc821f8 100644 --- a/c/src/cmd/in3/tx.c +++ b/c/src/cmd/in3/tx.c @@ -7,7 +7,7 @@ tx_t* get_txdata() { } // prepare a eth_call or eth_sendTransaction -static abi_sig_t* prepare_tx(char* fn_sig, char* to, sb_t* args, char* block_number, uint64_t gas, uint64_t gas_price, char* value, bytes_t* data, char* from) { +static abi_sig_t* prepare_tx(char* fn_sig, char* to, sb_t* args, char* block_number, uint64_t gas, uint64_t gas_price, char* value, bytes_t* data, char* from, char* token) { char* error = NULL; bytes_t rdata = {0}; abi_sig_t* req = fn_sig ? abi_sig_create(fn_sig, &error) : NULL; // only if we have a function signature, we will parse it and create a call_request. @@ -60,16 +60,23 @@ static abi_sig_t* prepare_tx(char* fn_sig, char* to, sb_t* args, char* block_num sb_add_chars(params, from); sb_add_chars(params, "\""); } + if (token) { + sb_add_chars(params, ", \"token\":\""); + sb_add_chars(params, token); + sb_add_chars(params, "\""); + } if (gas_price) { long_to_bytes(gas_price, gasdata); b_optimize_len(&g_bytes); sb_add_bytes(params, ", \"gasPrice\":", &g_bytes, 1, false); } - long_to_bytes(gas ? gas : 100000, gasdata); - g_bytes = bytes(gasdata, 8); - b_optimize_len(&g_bytes); - sb_add_bytes(params, ", \"gasLimit\":", &g_bytes, 1, false); + if (gas) { + long_to_bytes(gas, gasdata); + g_bytes = bytes(gasdata, 8); + b_optimize_len(&g_bytes); + sb_add_bytes(params, ", \"gasLimit\":", &g_bytes, 1, false); + } sb_add_chars(params, "}]"); } args->len = 0; @@ -79,5 +86,5 @@ static abi_sig_t* prepare_tx(char* fn_sig, char* to, sb_t* args, char* block_num } void encode_abi(in3_t* c, sb_t* args, bool with_block) { - _tx.abi_sig = prepare_tx(_tx.sig, resolve(c, _tx.to), args, _tx.block == NULL && with_block ? "latest" : _tx.block, _tx.gas, _tx.gas_price, _tx.value, _tx.data, _tx.from); + _tx.abi_sig = prepare_tx(_tx.sig, resolve(c, _tx.to), args, _tx.block == NULL && with_block ? "latest" : _tx.block, _tx.gas, _tx.gas_price, _tx.value, _tx.data, _tx.from, _tx.token); } \ No newline at end of file diff --git a/c/src/cmd/in3/tx.h b/c/src/cmd/in3/tx.h index 0c7f7d9d8..9a0e7e269 100644 --- a/c/src/cmd/in3/tx.h +++ b/c/src/cmd/in3/tx.h @@ -13,6 +13,7 @@ typedef struct tx { char* signtype; char* sig; abi_sig_t* abi_sig; + char* token; } tx_t; diff --git a/c/src/core/util/data.c b/c/src/core/util/data.c index d8f39e824..5d8a147cb 100644 --- a/c/src/core/util/data.c +++ b/c/src/core/util/data.c @@ -98,7 +98,7 @@ static d_key_t add_key(json_ctx_t* ctx, const char* name, size_t len) { return (d_key_t) k + 1; } -static size_t d_token_size(const d_token_t* item) { +size_t d_token_size(const d_token_t* item) { if (item == NULL) return 0; size_t i, c = 1; switch (d_type(item)) { @@ -1024,3 +1024,36 @@ d_token_t* d_getl(d_token_t* item, uint16_t k, uint32_t minl) { d_iterator_t d_iter(d_token_t* parent) { return (d_iterator_t){.left = d_len(parent), .token = parent + 1}; } /**< creates a iterator for a object or array */ + +d_token_t* token_from_string(char* val, d_token_t* d, bytes32_t buffer) { + if (!val) + d->len = T_NULL << 28; + else { + if (val[0] == '0' && val[1] == 'x') { + int l = hex_to_bytes(val + 2, strlen(val + 2), buffer, 32); + if (l < 5) { + d->data = NULL; + d->len = bytes_to_int(buffer, 4) | (T_INTEGER << 28); + } + else { + d->data = buffer; + d->len = l; + } + } + else { + d->data = (uint8_t*) val; + d->len = strlen(val) | (T_STRING << 28); + } + } + return d; +} + +d_token_t* token_from_bytes(bytes_t b, d_token_t* d) { + if (!b.data) + d->len = T_NULL << 28; + else { + d->data = b.data; + d->len = b.len; + } + return d; +} diff --git a/c/src/core/util/data.h b/c/src/core/util/data.h index 46e1fa044..565dd9220 100644 --- a/c/src/core/util/data.h +++ b/c/src/core/util/data.h @@ -123,6 +123,7 @@ int32_t d_intd(const d_token_t* item, const uint32_t def_val); uint64_t d_long(const d_token_t* item); /**< returns the value as long. only if type is integer or bytes, but short enough */ uint64_t d_longd(const d_token_t* item, const uint64_t def_val); /**< returns the value as long or if NULL the default. only if type is integer or bytes, but short enough */ bytes_t** d_create_bytes_vec(const d_token_t* arr); /** creates a array of bytes from JOSN-array */ +size_t d_token_size(const d_token_t* item); /** returns the size (number of tokens ) of the token */ static inline d_type_t d_type(const d_token_t* item) { return (item ? ((item->len & 0xF0000000) >> 28) : T_NULL); } /**< type of the token */ static inline int d_len(const d_token_t* item) { /**< number of elements in the token (only for object or array, other will return 0) */ if (item == NULL) return 0; @@ -156,8 +157,10 @@ NONULL int json_create_object(json_ctx_t* jp); NONULL int json_create_array(json_ctx_t* jp); NONULL void json_object_add_prop(json_ctx_t* jp, int ob_index, d_key_t key, d_token_t* value); NONULL d_token_t* json_create_ref_item(json_ctx_t* jp, d_type_t type, void* data, int len); +NONULL void json_array_add_value(json_ctx_t* jp, int parent_index, d_token_t* value); -NONULL void json_array_add_value(json_ctx_t* jp, int parent_index, d_token_t* value); +NONULL d_token_t* token_from_string(char* val, d_token_t* d, bytes32_t buffer); /**< returns a token ptr using the val without allocating memory in the heap, which can be used to pass values as token */ +NONULL d_token_t* token_from_bytes(bytes_t b, d_token_t* d); /**< returns a token ptr using the val without allocating memory in the heap, which can be used to pass values as token */ // Helper function to map string to 2byte keys (only for tests or debugging) char* d_get_keystr(json_ctx_t* json, d_key_t k); /**< returns the string for a key. This only works for index keys or known keys! */ diff --git a/c/src/pay/zksync/zk_helper.c b/c/src/pay/zksync/zk_helper.c index 77e405951..7d4895edf 100644 --- a/c/src/pay/zksync/zk_helper.c +++ b/c/src/pay/zksync/zk_helper.c @@ -382,7 +382,13 @@ in3_ret_t resolve_tokens(zksync_config_t* conf, in3_req_t* ctx, d_token_t* token if (!token_dst) return IN3_OK; for (unsigned int i = 0; i < conf->token_len; i++) { - if (d_type(token_src) == T_STRING) { + if (d_type(token_src) == T_INTEGER) { + if (d_int(token_src) == (int32_t) conf->tokens[i].id) { + *token_dst = conf->tokens + i; + return IN3_OK; + } + } + else if (d_type(token_src) == T_STRING) { if (strcmp(d_string(token_src), conf->tokens[i].symbol) == 0) { *token_dst = conf->tokens + i; return IN3_OK; diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index afd65cfba..aa281b0de 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -151,6 +151,52 @@ static inline uint64_t get_v(chain_id_t chain) { return v; } +/** creates a memory in heap which will automatilcy be freed when the context is freed. + * if called twice with the same key, the same memory is returned + */ +static bytes_t get_or_create_cached(in3_req_t* req, d_key_t k, int size) { + cache_props_t p = (((uint32_t) k) << 16) | CACHE_PROP_MUST_FREE; + cache_entry_t* cache = in3_cache_get_entry_by_prop(req->cache, p); + if (!cache) { + cache = in3_cache_add_entry(&req->cache, bytes(NULL, 0), bytes(_calloc(1, size), size)); + cache->props = p; + } + return cache->value; +} + +static in3_ret_t transform_erc20(in3_req_t* req, d_token_t* tx, bytes_t* to, bytes_t* value, bytes_t* data, bytes_t* gas_limit) { + char* token = d_get_string(tx, key("token")); + if (token && token[0] == '0' && token[1] == 'x' && strlen(token) == 42) { + if (to->len != 20) return req_set_error(req, "Invalid to address!", IN3_EINVAL); + *data = get_or_create_cached(req, key("pdata"), 68); + memcpy(data->data, "\xa9\x05\x9c\xbb", 4); // transfer (address, uint256) + memcpy(data->data + 4 + 32 - 20, to->data, 20); // recipient + memcpy(data->data + 4 + 64 - value->len, value->data, value->len); // value + + *to = get_or_create_cached(req, key("pto"), 20); + hex_to_bytes(token, -1, to->data, to->len); + + uint64_t gas = bytes_to_long(gas_limit->data, gas_limit->len) + 100000; // we add 100000 gas for using transfer + *gas_limit = get_or_create_cached(req, key("pgas"), 8); + long_to_bytes(gas, gas_limit->data); + b_optimize_len(gas_limit); + + value->len = 0; // we don't need a value anymore, since it is encoded + } + else if (token) + return req_set_error(req, "Invalid Token. Only token-addresses are supported!", IN3_EINVAL); +} + +/** based on the tx-entries the transaction is manipulated before creating the raw transaction. */ +static in3_ret_t transform_tx(in3_req_t* req, d_token_t* tx, bytes_t* to, bytes_t* value, bytes_t* data, bytes_t* gas_limit) { + // do we need to convert to the ERC20.transfer function? + TRY(transform_erc20(req, tx, to, value, data, gas_limit)) + + // TODO handle abi-encoding.... + + return IN3_OK; +} + /** * prepares a transaction and writes the data to the dst-bytes. In case of success, you MUST free only the data-pointer of the dst. */ @@ -175,11 +221,6 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst, s TRY(get_from_address(tx, ctx, from)) TRY(get_nonce_and_gasprice(&nonce, &gas_price, ctx, from)) - // create raw without signature - bytes_t* raw = serialize_tx_raw(nonce, gas_price, gas_limit, to, value, data, get_v(chain_id), bytes(NULL, 0), bytes(NULL, 0)); - *dst = *raw; - _free(raw); - // write state? if (meta) { sb_add_rawbytes(meta, "\"input\":{\"to\":\"0x", to, 0); @@ -189,7 +230,24 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst, s sb_add_rawbytes(meta, "\",\"gas\":\"0x", gas_limit, 0); sb_add_rawbytes(meta, "\",\"gasPrice\":\"0x", gas_price, 0); sb_add_rawbytes(meta, "\",\"nonce\":\"0x", nonce, 0); - sb_add_rawbytes(meta, "\",\"pre_unsigned\":\"0x", *dst, 0); + sb_add_char(meta, '\"'); + sb_add_json(meta, ",\"fn_sig\":", d_get(tx, key("fn_sig"))); + sb_add_json(meta, ",\"fn_args\":", d_get(tx, key("fn_args"))); + sb_add_json(meta, ",\"token\":", d_get(tx, key("token"))); + sb_add_json(meta, ",\"wallet\":", d_get(tx, key("wallet"))); + } + + // do we need to transform the tx before we sign it? + TRY(transform_tx(ctx, tx, &to, &value, &data, &gas_limit)); + + // create raw without signature + bytes_t* raw = serialize_tx_raw(nonce, gas_price, gas_limit, to, value, data, get_v(chain_id), bytes(NULL, 0), bytes(NULL, 0)); + *dst = *raw; + _free(raw); + + // write state? + if (meta) { + sb_add_rawbytes(meta, ",\"pre_unsigned\":\"0x", *dst, 0); sb_add_chars(meta, "\"}"); } diff --git a/scripts/_in3.sh b/scripts/_in3.sh index e41437e03..538db7eb1 100755 --- a/scripts/_in3.sh +++ b/scripts/_in3.sh @@ -30,7 +30,7 @@ subcmds=( 'getblock: Returns data of block for given block hash ' 'getblockcount: Returns the number of blocks in the longest blockchain' 'getblockheader: Returns data of block header for given block hash ' - 'getdifficulty: Returns the proof-of-work difficulty as a multiple of the minimum difficulty ' + 'getdifficulty: Returns the proof-of-work difficulty as a multiple of the minimum difficulty' 'getrawtransaction: Returns the raw transaction data ' 'in3_config: changes the configuration of a client ' 'eth_blockNumber: returns the number of the most recent block' @@ -72,7 +72,7 @@ subcmds=( 'web3_clientVersion: Returns the underlying client version' 'web3_sha3: Returns Keccak-256 (not the standardized SHA3-256) of the given data ' 'zksync_account_address: returns the address of the account used' - 'zksync_account_history: returns the history of transaction for a given account ' + 'zksync_account_history: returns the history of transaction for a given account ' 'zksync_account_info: returns account_info from the server
' 'zksync_aggregate_pubkey: calculate the public key based on multiple public keys signing together using schnorr musig signatur... ' 'zksync_contract_address: returns the contract address' @@ -184,6 +184,8 @@ args=( '-gp[the gas price to use when sending transactions]:gas_price:()' '--gas=[the gas limit to use when sending transactions]:gas:()' '-gas[the gas limit to use when sending transactions]:gas:()' +'--token=[the address of the erc20-token contract]:token:()' +'-token[the address of the erc20-token contract]:token:()' '--nonce=[the nonce]:nonce:()' '-nonce[the nonce]:nonce:()' '--test=[creates a new json-test written to stdout with the name as specified]:test:()' From e51825f2a2089a3d5630352088c091bfde922fc4 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 07:17:36 +0200 Subject: [PATCH 032/110] fix warning --- c/src/verifier/eth1/basic/sign_tx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index aa281b0de..cb9d66df1 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -185,6 +185,8 @@ static in3_ret_t transform_erc20(in3_req_t* req, d_token_t* tx, bytes_t* to, byt } else if (token) return req_set_error(req, "Invalid Token. Only token-addresses are supported!", IN3_EINVAL); + + return IN3_OK; } /** based on the tx-entries the transaction is manipulated before creating the raw transaction. */ From 49e4171f7114e90e2772a656c80c98051ea65395 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 07:19:22 +0200 Subject: [PATCH 033/110] format --- c/include/in3/data.h | 23 +++++++++++++---------- c/include/in3/stringbuilder.h | 16 ++++++++-------- c/src/core/util/data.h | 20 ++++++++++---------- c/src/core/util/stringbuilder.h | 16 ++++++++-------- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/c/include/in3/data.h b/c/include/in3/data.h index 46e1fa044..a717e9e82 100644 --- a/c/include/in3/data.h +++ b/c/include/in3/data.h @@ -123,6 +123,7 @@ int32_t d_intd(const d_token_t* item, const uint32_t def_val); uint64_t d_long(const d_token_t* item); /**< returns the value as long. only if type is integer or bytes, but short enough */ uint64_t d_longd(const d_token_t* item, const uint64_t def_val); /**< returns the value as long or if NULL the default. only if type is integer or bytes, but short enough */ bytes_t** d_create_bytes_vec(const d_token_t* arr); /** creates a array of bytes from JOSN-array */ +size_t d_token_size(const d_token_t* item); /** returns the size (number of tokens ) of the token */ static inline d_type_t d_type(const d_token_t* item) { return (item ? ((item->len & 0xF0000000) >> 28) : T_NULL); } /**< type of the token */ static inline int d_len(const d_token_t* item) { /**< number of elements in the token (only for object or array, other will return 0) */ if (item == NULL) return 0; @@ -137,16 +138,16 @@ d_token_t* d_get_or(d_token_t* item, const uint16_t key1, const uint16_t key2); d_token_t* d_get_at(d_token_t* item, const uint32_t index); /**< returns the token of an array with the given index */ d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */ -NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ -NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ -NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ -char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ +NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ +NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ +NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ +char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ -json_ctx_t* json_create(); +json_ctx_t* json_create(); NONULL d_token_t* json_create_null(json_ctx_t* jp); NONULL d_token_t* json_create_bool(json_ctx_t* jp, bool value); NONULL d_token_t* json_create_int(json_ctx_t* jp, uint64_t value); @@ -156,8 +157,10 @@ NONULL int json_create_object(json_ctx_t* jp); NONULL int json_create_array(json_ctx_t* jp); NONULL void json_object_add_prop(json_ctx_t* jp, int ob_index, d_key_t key, d_token_t* value); NONULL d_token_t* json_create_ref_item(json_ctx_t* jp, d_type_t type, void* data, int len); +NONULL void json_array_add_value(json_ctx_t* jp, int parent_index, d_token_t* value); -NONULL void json_array_add_value(json_ctx_t* jp, int parent_index, d_token_t* value); +NONULL d_token_t* token_from_string(char* val, d_token_t* d, bytes32_t buffer); /**< returns a token ptr using the val without allocating memory in the heap, which can be used to pass values as token */ +NONULL d_token_t* token_from_bytes(bytes_t b, d_token_t* d); /**< returns a token ptr using the val without allocating memory in the heap, which can be used to pass values as token */ // Helper function to map string to 2byte keys (only for tests or debugging) char* d_get_keystr(json_ctx_t* json, d_key_t k); /**< returns the string for a key. This only works for index keys or known keys! */ diff --git a/c/include/in3/stringbuilder.h b/c/include/in3/stringbuilder.h index 000ccaefe..140623d05 100644 --- a/c/include/in3/stringbuilder.h +++ b/c/include/in3/stringbuilder.h @@ -71,20 +71,20 @@ typedef struct sb { */ NONULL static inline sb_t sb_stack(char* p) { return (sb_t){.allocted = 0xffffff, .len = 0, .data = p}; } -sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ -NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ -NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ +sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ +NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ +NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ NONULL sb_t* sb_add_char(sb_t* sb, char c); /**< add a single character */ NONULL sb_t* sb_add_chars(sb_t* sb, const char* chars); /**< adds a string */ NONULL sb_t* sb_add_range(sb_t* sb, const char* chars, int start, int len); /**< add a string range */ NONULL sb_t* sb_add_key_value(sb_t* sb, const char* key, const char* value, int value_len, bool as_string); /**< adds a value with an optional key. if as_string is true the value will be quoted. */ NONULL_FOR((1, 3)) -sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ -NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ -NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ -NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ -NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ +sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ +NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ +NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ +NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ +NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ NONULL_FOR((1)) sb_t* sb_add_rawbytes(sb_t* sb, char* prefix, bytes_t b, int fix_size); sb_t* sb_print(sb_t* sb, const char* fmt, ...); diff --git a/c/src/core/util/data.h b/c/src/core/util/data.h index 565dd9220..a717e9e82 100644 --- a/c/src/core/util/data.h +++ b/c/src/core/util/data.h @@ -138,16 +138,16 @@ d_token_t* d_get_or(d_token_t* item, const uint16_t key1, const uint16_t key2); d_token_t* d_get_at(d_token_t* item, const uint32_t index); /**< returns the token of an array with the given index */ d_token_t* d_next(d_token_t* item); /**< returns the next sibling of an array or object */ -NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ -NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ -NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ -NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ -char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ - -json_ctx_t* json_create(); +NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ +NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ +NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ +NONULL str_range_t d_to_json(const d_token_t* item); /**< returns the string for a object or array. This only works for json as string. For binary it will not work! */ +char* d_create_json(json_ctx_t* ctx, d_token_t* item); /**< creates a json-string. It does not work for objects if the parsed data were binary!*/ + +json_ctx_t* json_create(); NONULL d_token_t* json_create_null(json_ctx_t* jp); NONULL d_token_t* json_create_bool(json_ctx_t* jp, bool value); NONULL d_token_t* json_create_int(json_ctx_t* jp, uint64_t value); diff --git a/c/src/core/util/stringbuilder.h b/c/src/core/util/stringbuilder.h index 000ccaefe..140623d05 100644 --- a/c/src/core/util/stringbuilder.h +++ b/c/src/core/util/stringbuilder.h @@ -71,20 +71,20 @@ typedef struct sb { */ NONULL static inline sb_t sb_stack(char* p) { return (sb_t){.allocted = 0xffffff, .len = 0, .data = p}; } -sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ -NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ -NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ +sb_t* sb_new(const char* chars); /**< creates a new stringbuilder and copies the inital characters into it.*/ +NONULL sb_t* sb_init(sb_t* sb); /**< initializes a stringbuilder by allocating memory. */ +NONULL void sb_free(sb_t* sb); /**< frees all resources of the stringbuilder */ NONULL sb_t* sb_add_char(sb_t* sb, char c); /**< add a single character */ NONULL sb_t* sb_add_chars(sb_t* sb, const char* chars); /**< adds a string */ NONULL sb_t* sb_add_range(sb_t* sb, const char* chars, int start, int len); /**< add a string range */ NONULL sb_t* sb_add_key_value(sb_t* sb, const char* key, const char* value, int value_len, bool as_string); /**< adds a value with an optional key. if as_string is true the value will be quoted. */ NONULL_FOR((1, 3)) -sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ -NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ -NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ -NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ -NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ +sb_t* sb_add_bytes(sb_t* sb, const char* prefix, const bytes_t* bytes, int len, bool as_array); /**< add bytes as 0x-prefixed hexcoded string (including an optional prefix), if len>1 is passed bytes maybe an array ( if as_array==true) */ +NONULL sb_t* sb_add_hexuint_l(sb_t* sb, uintmax_t uint, size_t l); /**< add a integer value as hexcoded, 0x-prefixed string*/ +NONULL sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars); /**< add chars but escapes all quotes */ +NONULL sb_t* sb_add_int(sb_t* sb, int64_t val); /**< adds a numeric value to the stringbuilder */ +NONULL char* format_json(const char* json); /**< format a json string and returns a new string, which needs to be freed */ NONULL_FOR((1)) sb_t* sb_add_rawbytes(sb_t* sb, char* prefix, bytes_t b, int fix_size); sb_t* sb_print(sb_t* sb, const char* fmt, ...); From a1c26af925f33ac57a2c3090ddb324d4ab58cb12 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 09:12:45 +0200 Subject: [PATCH 034/110] changed type --- c/src/cmd/in3/rpc_handler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/cmd/in3/rpc_handler.c b/c/src/cmd/in3/rpc_handler.c index 915db1caa..6eafad143 100644 --- a/c/src/cmd/in3/rpc_handler.c +++ b/c/src/cmd/in3/rpc_handler.c @@ -22,7 +22,7 @@ static bool _call(in3_t* c, char** method, sb_t* params) { } #ifdef MOD_WALLET -void* wallet_get_default(void* conf, uint_fast8_t type_mask); +void* wallet_get_default(void* conf, int type_mask); void* wallet_get_config(in3_t* c); #endif From 12593bf0d1b8330954644e9ca3b0bd36c00f615e Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 09:15:58 +0200 Subject: [PATCH 035/110] fixed unused --- c/src/api/eth1/rpc_api.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c/src/api/eth1/rpc_api.c b/c/src/api/eth1/rpc_api.c index 5803a4ac4..90ad9ac6b 100644 --- a/c/src/api/eth1/rpc_api.c +++ b/c/src/api/eth1/rpc_api.c @@ -520,11 +520,11 @@ static in3_ret_t in3_decryptKey(in3_rpc_handle_ctx_t* ctx) { static in3_ret_t in3_prepareTx(in3_rpc_handle_ctx_t* ctx) { CHECK_PARAMS_LEN(ctx->req, ctx->params, 1); CHECK_PARAM_TYPE(ctx->req, ctx->params, 0, T_OBJECT); - d_token_t* tx = d_get_at(ctx->params, 0); - bytes_t dst = {0}; - sb_t sb = {0}; - bool write_debug = (d_len(ctx->params) == 2 && d_get_int_at(ctx->params, 1)); + d_token_t* tx = d_get_at(ctx->params, 0); + bytes_t dst = {0}; + sb_t sb = {0}; #if defined(ETH_BASIC) || defined(ETH_FULL) + bool write_debug = (d_len(ctx->params) == 2 && d_get_int_at(ctx->params, 1)); if (write_debug) sb_add_char(&sb, '{'); TRY_CATCH(eth_prepare_unsigned_tx(tx, ctx->req, &dst, write_debug ? &sb : NULL), _free(sb.data)) #else From 302f4263077f1d1ef4ee69ca0f4dd34e2aa37757 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 11:40:54 +0200 Subject: [PATCH 036/110] fix escaping newlines --- c/src/core/util/stringbuilder.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/c/src/core/util/stringbuilder.c b/c/src/core/util/stringbuilder.c index 145653aa5..503e8aa79 100644 --- a/c/src/core/util/stringbuilder.c +++ b/c/src/core/util/stringbuilder.c @@ -92,7 +92,7 @@ sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars) { int escapes = 0; if (l == 0 || chars == NULL) return sb; for (int i = 0; i < l; i++) { - if (chars[i] == '"') escapes++; + if (chars[i] == '"' || chars[i] == '\n') escapes++; } check_size(sb, l + escapes); memcpy(sb->data + sb->len, chars, l); @@ -104,6 +104,12 @@ sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars) { memcpy(sb->data + sb->len + i + escapes + 1, chars + i, l - i); escapes++; } + if (chars[i] == '\n') { + memcpy(sb->data + sb->len + i + escapes + 1, chars + i, l - i); + sb->data[sb->len + i + escapes] = '\\'; + sb->data[sb->len + i + escapes + 1] = 'n'; + escapes++; + } } } sb->len += l + escapes; From 8f447e780b71f40e580e880a7676e0fcfb3961fd Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 11:41:13 +0200 Subject: [PATCH 037/110] check if the signing key is set before siging --- c/src/pay/zksync/zk_message.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/c/src/pay/zksync/zk_message.c b/c/src/pay/zksync/zk_message.c index 7f706a7fd..765a05176 100644 --- a/c/src/pay/zksync/zk_message.c +++ b/c/src/pay/zksync/zk_message.c @@ -248,8 +248,7 @@ in3_ret_t zksync_sign_transfer(sb_t* sb, zksync_tx_data_t* data, in3_req_t* ctx, } in3_ret_t zksync_sign(zksync_config_t* conf, bytes_t msg, in3_req_t* ctx, uint8_t* sig) { - in3_log_debug("signing zksync data: \n"); - b_print(&msg); + TRY(zksync_get_sync_key(conf, ctx, NULL)) if (memiszero(conf->sync_key, 32)) return req_set_error(ctx, "no signing key set", IN3_ECONFIG); if (!conf->musig_pub_keys.data) return zkcrypto_sign_musig(conf->sync_key, msg, sig); char* p = alloca(msg.len * 2 + 5); From a99713d1db45d5baf7b4e6edb942324498b87fb8 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 13:22:03 +0200 Subject: [PATCH 038/110] stringbuilder dependency is not needed. --- c/include/in3/data.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/c/include/in3/data.h b/c/include/in3/data.h index a717e9e82..7665dc70b 100644 --- a/c/include/in3/data.h +++ b/c/include/in3/data.h @@ -102,8 +102,6 @@ typedef struct json_parser { size_t keys_last; // points to the position of the last key. } json_ctx_t; -#include "stringbuilder.h" - /** * * returns the byte-representation of token. From f2f41de53aa9d621e84dd22798a8eca1f2fca35a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 13:22:16 +0200 Subject: [PATCH 039/110] remove sb dep --- c/src/core/util/data.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/c/src/core/util/data.h b/c/src/core/util/data.h index a717e9e82..7665dc70b 100644 --- a/c/src/core/util/data.h +++ b/c/src/core/util/data.h @@ -102,8 +102,6 @@ typedef struct json_parser { size_t keys_last; // points to the position of the last key. } json_ctx_t; -#include "stringbuilder.h" - /** * * returns the byte-representation of token. From 5e1c27f73eec7fcf89c5be23d5167815b3274dc9 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 13:22:45 +0200 Subject: [PATCH 040/110] fix dep --- c/src/api/eth1/abi_parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/c/src/api/eth1/abi_parse.c b/c/src/api/eth1/abi_parse.c index d2822f683..1b60db182 100644 --- a/c/src/api/eth1/abi_parse.c +++ b/c/src/api/eth1/abi_parse.c @@ -3,6 +3,7 @@ #include "../../core/util/bytes.h" #include "../../core/util/data.h" #include "../../core/util/mem.h" +#include "../../core/util/stringbuilder.h" #include "../../core/util/utils.h" #include "abi.h" #include From 95c39336ce518101eeedd08a66b5c0554886573d Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 13:22:59 +0200 Subject: [PATCH 041/110] fix NPE --- c/src/core/util/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/core/util/data.c b/c/src/core/util/data.c index 5d8a147cb..196657a5a 100644 --- a/c/src/core/util/data.c +++ b/c/src/core/util/data.c @@ -730,7 +730,7 @@ char* d_create_json(json_ctx_t* ctx, d_token_t* item) { str_range_t d_to_json(const d_token_t* item) { str_range_t s; - if (item) { + if (item && item->data) { s.data = (char*) item->data; s.len = find_end(s.data); } From 85a52cf14592e1899161f0526d079d962b2941d9 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 13:23:16 +0200 Subject: [PATCH 042/110] adding arrays to sb --- c/src/core/util/stringbuilder.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/c/src/core/util/stringbuilder.c b/c/src/core/util/stringbuilder.c index 503e8aa79..05cfca364 100644 --- a/c/src/core/util/stringbuilder.c +++ b/c/src/core/util/stringbuilder.c @@ -297,8 +297,13 @@ sb_t* sb_add_json(sb_t* sb, const char* prefix, d_token_t* token) { switch (d_type(token)) { case T_ARRAY: case T_OBJECT: { - str_range_t r = d_to_json(token); - return sb_add_range(sb, r.data, 0, r.len); + const char* brackets = d_type(token) == T_ARRAY ? "[]" : "{}"; + str_range_t r = d_to_json(token); + if (r.data) return sb_add_range(sb, r.data, 0, r.len); + sb_add_char(sb, brackets[0]); + for (d_iterator_t iter = d_iter(token); iter.left; d_iter_next(&iter)) + sb_add_json(sb, iter.token != token + 1 ? "," : "", iter.token); + sb_add_char(sb, brackets[1]); } case T_BOOLEAN: return sb_add_chars(sb, d_int(token) ? "true" : "false"); From 53442eb283f76c5ccb8cf59bb56ee5b2bdf77816 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 13:23:36 +0200 Subject: [PATCH 043/110] support abiencoding --- c/src/verifier/eth1/basic/sign_tx.c | 37 ++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index cb9d66df1..aca0db8e2 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -189,13 +189,44 @@ static in3_ret_t transform_erc20(in3_req_t* req, d_token_t* tx, bytes_t* to, byt return IN3_OK; } +static in3_ret_t transform_abi(in3_req_t* req, d_token_t* tx, bytes_t* data) { + char* fn = d_get_string(tx, key("fn_sig")); + + if (fn) { + d_token_t* args = d_get(tx, key("fn_args")); + if (args && d_type(args) != T_ARRAY) return req_set_error(req, "Invalid argument type for tx", IN3_EINVAL); + + sb_t params = {0}; + sb_add_char(¶ms, '\"'); + sb_add_chars(¶ms, fn); + + if (args) + sb_add_json(¶ms, "\",", args); + else + sb_add_chars(¶ms, "\",[]"); + + d_token_t* res; + TRY_FINAL(req_send_sub_request(req, "in3_abiEncode", params.data, NULL, &res, NULL), _free(params.data)) + + if (d_type(res) != T_BYTES || d_len(res) < 4) return req_set_error(req, "abi encoded data", IN3_EINVAL); + if (data->data) { + // if this is a deployment transaction we concate it with the arguments without the functionhash + bytes_t new_data = get_or_create_cached(req, key("deploy_data"), data->len + d_len(res) - 4); + memcpy(new_data.data, data->data, data->len); + memcpy(new_data.data + data->len, d_bytes(res)->data + 4, d_len(res) - 4); + *data = new_data; + } + else + *data = d_to_bytes(res); + } + + return IN3_OK; +} /** based on the tx-entries the transaction is manipulated before creating the raw transaction. */ static in3_ret_t transform_tx(in3_req_t* req, d_token_t* tx, bytes_t* to, bytes_t* value, bytes_t* data, bytes_t* gas_limit) { // do we need to convert to the ERC20.transfer function? TRY(transform_erc20(req, tx, to, value, data, gas_limit)) - - // TODO handle abi-encoding.... - + TRY(transform_abi(req, tx, data)) return IN3_OK; } From 8b93d0fb16fafd459230d208e95087f0f8619c64 Mon Sep 17 00:00:00 2001 From: jbentke Date: Fri, 25 Jun 2021 13:37:18 +0200 Subject: [PATCH 044/110] added check for zksync deposit for empty depositTo param --- c/src/pay/zksync/zk_deposit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/pay/zksync/zk_deposit.c b/c/src/pay/zksync/zk_deposit.c index 5c2c92894..f5c29857c 100644 --- a/c/src/pay/zksync/zk_deposit.c +++ b/c/src/pay/zksync/zk_deposit.c @@ -30,7 +30,7 @@ in3_ret_t zksync_deposit(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { // make sure we have an account uint8_t* account = conf->account; - if ((tmp = params_get(ctx->params, key("depositTo"), 3))) { + if ((tmp = params_get(ctx->params, key("depositTo"), 3)) && d_type(tmp) == T_BYTES) { if (tmp->len != 20) return req_set_error(ctx->req, "invalid depositTo", IN3_ERPC); account = tmp->data; } From 7b87f45333eb8e8739c455818fc49a213bd6bc20 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 25 Jun 2021 15:32:19 +0200 Subject: [PATCH 045/110] fixed warning --- c/src/core/util/stringbuilder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/core/util/stringbuilder.c b/c/src/core/util/stringbuilder.c index 05cfca364..8739599d2 100644 --- a/c/src/core/util/stringbuilder.c +++ b/c/src/core/util/stringbuilder.c @@ -303,7 +303,7 @@ sb_t* sb_add_json(sb_t* sb, const char* prefix, d_token_t* token) { sb_add_char(sb, brackets[0]); for (d_iterator_t iter = d_iter(token); iter.left; d_iter_next(&iter)) sb_add_json(sb, iter.token != token + 1 ? "," : "", iter.token); - sb_add_char(sb, brackets[1]); + return sb_add_char(sb, brackets[1]); } case T_BOOLEAN: return sb_add_chars(sb, d_int(token) ? "true" : "false"); From 518305c49271b6c224bd178ab1918d1396b4d14c Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 28 Jun 2021 21:43:34 +0200 Subject: [PATCH 046/110] add bytes_to_hex_string as util --- c/src/core/util/utils.c | 17 +++++++++++++++++ c/src/core/util/utils.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/c/src/core/util/utils.c b/c/src/core/util/utils.c index a42ba658c..992ee72eb 100644 --- a/c/src/core/util/utils.c +++ b/c/src/core/util/utils.c @@ -188,6 +188,23 @@ int bytes_to_hex(const uint8_t* buffer, int len, char* out) { return len * 2; } +char* bytes_to_hex_string(char* out, const char* prefix, const bytes_t b, const char* postfix) { + char* res = out; + if (prefix) { + int l = strlen(prefix); + memcpy(out, prefix, l); + out += l; + } + out += bytes_to_hex(b.data, b.len, out); + if (postfix) { + int l = strlen(postfix); + memcpy(out, postfix, l); + out += l; + } + *out = 0; + return res; +} + /** writes 32 bytes to the pointer. */ int keccak(bytes_t data, void* dst) { struct SHA3_CTX ctx; diff --git a/c/src/core/util/utils.h b/c/src/core/util/utils.h index 73ef193d9..0020e3095 100644 --- a/c/src/core/util/utils.h +++ b/c/src/core/util/utils.h @@ -329,6 +329,10 @@ int64_t parse_float_val(const char* data, /**< the data string*/ */ void b256_add(bytes32_t a, uint8_t* b, wlen_t len_b); +/** + * prints a bytes into a string + */ +char* bytes_to_hex_string(char* out, const char* prefix, const bytes_t b, const char* postfix); #ifdef THREADSAFE #define _NAME(x, y) x##y #if defined(_MSC_VER) || defined(__MINGW32__) From 45e4f73a9e6d70a86e0c97589bc1a8c6c40b4a02 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 29 Jun 2021 08:27:25 +0200 Subject: [PATCH 047/110] handle fields --- scripts/generator/generate.js | 12 ++++++++++-- scripts/generator/util.js | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/generator/generate.js b/scripts/generator/generate.js index 7b39cf29c..83bdb30e1 100755 --- a/scripts/generator/generate.js +++ b/scripts/generator/generate.js @@ -54,10 +54,18 @@ function scan(dir) { types = { ...types, ...ob.types } delete ob.types } + let lastAPI = null for (const k of Object.keys(ob)) { if (ob[k].config) config = { ...config, ...ob[k].config } delete ob[k].config - docs[k] = { ...docs[k], ...ob[k] } + if (!generators.length && ob[k].fields && lastAPI) { + delete ob[k].fields + for (const n of Object.keys(ob[k]).filter(_ => !docs[lastAPI][_])) delete ob[k][n] + docs[lastAPI] = { ...docs[lastAPI], ...ob[k] } + } + else + docs[k] = { ...docs[k], ...ob[k] } + lastAPI = k } } else if (f.isDirectory()) scan(dir + '/' + f.name) @@ -169,7 +177,7 @@ for (const s of Object.keys(docs).sort()) { if (rdescr) rpc_doc.push(rdescr + '\n') delete rpcs.descr - for (const rpc of Object.keys(rpcs).sort()) { + for (const rpc of Object.keys(rpcs).filter(_ => _ != 'fields').sort()) { const def = rpcs[rpc] def.returns = def.returns || def.result def.result = def.returns || def.result diff --git a/scripts/generator/util.js b/scripts/generator/util.js index 4d5d7a7c1..39849c5eb 100644 --- a/scripts/generator/util.js +++ b/scripts/generator/util.js @@ -31,4 +31,7 @@ exports.short_descr = function (d) { if (zd.indexOf('[') >= 0) zd = zd.substr(0, zd.indexOf('[')) if (zd.length > 100) zd = zd.substr(0, 100) + '...' return zd -} \ No newline at end of file +} +exports.addAll = function addAll(array, elements) { + exports.asArray(elements).forEach(_ => array.push(_)) +} From e77d650a2a1bc21930e055c82cbbcf4b3175386f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Tue, 29 Jun 2021 09:18:12 +0200 Subject: [PATCH 048/110] zksync-pk fix --- c/src/pay/zksync/zksync.c | 1 + 1 file changed, 1 insertion(+) diff --git a/c/src/pay/zksync/zksync.c b/c/src/pay/zksync/zksync.c index ebe95b98d..09b30de3e 100644 --- a/c/src/pay/zksync/zksync.c +++ b/c/src/pay/zksync/zksync.c @@ -382,6 +382,7 @@ zksync_config_t* zksync_get_conf(in3_req_t* req) { in3_ret_t in3_register_zksync(in3_t* c) { zksync_config_t* conf = _calloc(sizeof(zksync_config_t), 1); conf->version = 1; + conf->sign_type = ZK_SIGN_PK; return in3_plugin_register(c, PLGN_ACT_RPC_HANDLE | PLGN_ACT_INIT | PLGN_ACT_TERM | PLGN_ACT_CONFIG_GET | PLGN_ACT_CONFIG_SET | PLGN_ACT_ADD_PAYLOAD | PLGN_ACT_PAY_FOLLOWUP, handle_zksync, conf, false); From 3efe93a09276e120b377a91f5394ff15449607da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Tue, 29 Jun 2021 09:18:48 +0200 Subject: [PATCH 049/110] added yml-files for testcases --- c/src/api/eth1/testCases.yml | 32 + c/src/pay/zksync/testCases.yml | 1059 +++++++++++++++++++++++ c/src/verifier/btc/testCases.yml | 390 +++++++++ c/src/verifier/eth1/basic/testCases.yml | 537 ++++++++++++ c/src/verifier/eth1/full/testCases.yml | 29 + c/src/verifier/eth1/nano/testCases.yml | 42 + c/src/verifier/ipfs/testCases.yml | 27 + 7 files changed, 2116 insertions(+) create mode 100644 c/src/api/eth1/testCases.yml create mode 100644 c/src/pay/zksync/testCases.yml create mode 100644 c/src/verifier/btc/testCases.yml create mode 100644 c/src/verifier/eth1/basic/testCases.yml create mode 100644 c/src/verifier/eth1/full/testCases.yml create mode 100644 c/src/verifier/eth1/nano/testCases.yml create mode 100644 c/src/verifier/ipfs/testCases.yml diff --git a/c/src/api/eth1/testCases.yml b/c/src/api/eth1/testCases.yml new file mode 100644 index 000000000..9fd91edd5 --- /dev/null +++ b/c/src/api/eth1/testCases.yml @@ -0,0 +1,32 @@ +utils: + + in3_abiEncode: + input: + - "getBalance(address)" + - "0x1234567890123456789012345678901234567890" + expected_output: "0xf8b2cb4f0000000000000000000000001234567890123456789012345678901234567890" + + in3_abiDecode: + input: + - "(address,uint256)" + - "0x00000000000000000000000012345678901234567890123456789012345678900000000000000000000000000000000000000000000000000000000000000005" + expected_output: + - + value: "0x1234567890123456789012345678901234567890" + type: string + - + value: "5" + type: uint256 + + in3_checksumAddress: + input: + - "0x1fe2e9bf29aa1938859af64c413361227d04059a" + - false + expected_output: "0x1Fe2E9bf29aa1938859Af64C413361227d04059a" + + in3_fromWei: + input: + - "0x234324abadefdef" + - eth + - 3 + expected_output: "0.158" \ No newline at end of file diff --git a/c/src/pay/zksync/testCases.yml b/c/src/pay/zksync/testCases.yml new file mode 100644 index 000000000..fd46f7eab --- /dev/null +++ b/c/src/pay/zksync/testCases.yml @@ -0,0 +1,1059 @@ +tokens: &tokens + USDC: + decimals: 6 + id: 2 + symbol: USDC + is_nft: false + address: '0xeb8f08a975ab53e34d8a0330e0d34de942c95926' + USDT: + decimals: 6 + id: 1 + symbol: USDT + is_nft: false + address: '0x3b00ef435fa4fcff5c209a37d1f3dcff37c705ad' + PHNX: + decimals: 18 + id: 20 + symbol: PHNX + is_nft: false + address: '0xfe1b6abc39e46cec54d275efb4b29b33be176c2a' + TRB: + decimals: 18 + id: 7 + symbol: TRB + is_nft: false + address: '0x2655f3a9eeb7f960be83098457144813ffad07a4' + TUSD: + decimals: 18 + id: 4 + symbol: TUSD + is_nft: false + address: '0xd2255612f9b045e9c81244bb874abb413ca139a3' + ZRX: + decimals: 18 + id: 8 + symbol: ZRX + is_nft: false + address: '0xdb7f2b9f6a0cb35fe5d236e5ed871d3ad4184290' + OMG: + decimals: 18 + id: 6 + symbol: OMG + is_nft: false + address: '0x2b203de02ad6109521e09985b3af9b8c62541cd6' + STORJ: + decimals: 8 + id: 11 + symbol: STORJ + is_nft: false + address: '0x8098165d982765097e4aa17138816e5b95f9fdb5' + XEM: + decimals: 0 + id: 18 + symbol: XEM + is_nft: false + address: '0xc3904a7c3a95bc265066bb5bfc4d6664b2174774' + HT: + decimals: 18 + id: 5 + symbol: HT + is_nft: false + address: '0x14700cae8b2943bad34c70bb76ae27ecf5bc5013' + LINK: + decimals: 18 + id: 3 + symbol: LINK + is_nft: false + address: '0x4da8d0795830f75be471f072a034d42c369b5d0a' + KNC: + decimals: 18 + id: 14 + symbol: KNC + is_nft: false + address: '0x290eba6ec56ecc9ff81c72e8eccc77d2c2bf63eb' + DAI: + decimals: 18 + id: 19 + symbol: DAI + is_nft: false + address: '0x2e055eee18284513b993db7568a592679ab13188' + REP: + decimals: 18 + id: 10 + symbol: REP + is_nft: false + address: '0x9cac8508b9ff26501439590a24893d80e7e84d21' + LAMB: + decimals: 18 + id: 15 + symbol: LAMB + is_nft: false + address: '0x9ecec4d48efdd96ae377af3ab868f99de865cff8' + NEXO: + decimals: 18 + id: 12 + symbol: NEXO + is_nft: false + address: '0x02d01f0835b7fdfa5d801a8f5f74c37f2bb1ae6a' + tGLM: + decimals: 18 + id: 16 + symbol: tGLM + is_nft: false + address: '0xd94e3dc39d4cad1dad634e7eb585a57a19dc7efe' + MCO: + decimals: 8 + id: 13 + symbol: MCO + is_nft: false + address: '0xd93addb2921b8061b697c2ab055979bbefe2b7ac' + ETH: + decimals: 18 + id: 0 + symbol: ETH + is_nft: false + address: '0x0000000000000000000000000000000000000000' + MLTT: + decimals: 18 + id: 17 + symbol: MLTT + is_nft: false + address: '0x690f4886c6911d81beb8130db30c825c27281f22' + BAT: + decimals: 18 + id: 9 + symbol: BAT + is_nft: false + address: '0xd2084ea2ae4bbe1424e4fe3cde25b713632fb988' + +zksync: + + zksync_set_key: + config: + proof: 'none' + experimental: true + # zksync: {} + # musig_urls: + # - "" + # - "https://approver.incubed.net" + #create_proof_method: "zk_wallet_create_signatures" + # verify_proof_method: 'zk_wallet_verify_proof' + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "ETH" + expected_output: "sync:fa88b6eee5e695db8d1170ebba4c2bb2631f092a" + mockedResponses: + - account_info: + - res: + - + jsonrpc: '2.0' + id: 1 + result: + depositing: + balances: {} + committed: + nonce: 0 + balances: + ETH: '1100000000000101000' + nfts: {} + mintedNfts: {} + pubKeyHash: 'sync:0000000000000000000000000000000000000000' + id: 167067 + verified: + nonce: 0 + balances: {} + nfts: {} + mintedNfts: {} + pubKeyHash: 'sync:0000000000000000000000000000000000000000' + address: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + + - tokens: + - res: + - + result: *tokens + - get_tx_fee: + - res: + - + result: + zkpFee: 30541131762442 + totalFee: 64600000000000 + gasTxAmount: 26200 + gasPriceWei: 1000000000 + gasFee: 34060000000000 + feeType: + ChangePubKey: + onchainPubkeyAuth: false + - tx_submit: + - res: + - + result: "sync-tx:4f8b59a5d7d4f128c3024b481eebc66de41428636c385ca68f00ea5f0d785564" + + zksync_transfer: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "0x448d2286d9d6996241ff1f87bd2e24692975cabd" + - "100000000000000000" + - "ETH" + expected_output: + type: 'Transfer' + accountId: 167067 + from: "0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c" + to: "0x448d2286d9d6996241ff1f87bd2e24692975cabd" + token: 0 + tokenId: 0 + amount: "100000000000000000" + fee: "30300000000000" + validFrom: 0 + validUntil: 4294967295 + nonce: 3 + txHash: "sync-tx:b431fad24a0b3ccc324c09b1dd3f2484ac070d944a615e46d7b822dd9e883c02" + mockedResponses: + - account_info: + - res: + - + result: + depositing: + balances: {} + committed: + nonce: 3 + balances: + ETH: '1099802600000100800' + nfts: {} + mintedNfts: {} + pubKeyHash: 'sync:ec0de4692863fc7b1459cb98c6be56ada438d991' + id: 167067 + verified: + nonce: 0 + balances: + ETH: '1100000000000101000' + nfts: {} + mintedNfts: {} + pubKeyHash: 'sync:0000000000000000000000000000000000000000' + address: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + - tokens: + - res: + - + jsonrpc: '2.0' + id: 3 + result: *tokens + + - get_tx_fee: + - res: + - + result: + zkpFee: '27570375927574' + totalFee: '30300000000000' + gasTxAmount: '2140' + gasFee: '2782000000000' + gasPriceWei: '1000000000' + feeType: TransferToNew + - tx_submit: + - res: + - + result: "sync-tx:b431fad24a0b3ccc324c09b1dd3f2484ac070d944a615e46d7b822dd9e883c02" + + zksync_deposit: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "10000000000000000" + - "ETH" + - "0x8D33cAFf9b73A3EB24c83ac79bb5eD56126f284C" + expected_output: + receipt: + contractAddress: null + transactionHash: '0x19d13637be89661646a2cf2b62017ed08dc1b88e61144eda78a95207affc7f7e' + from: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + blockHash: '0x7000c3083910c0bcb8eea45d04448af35109bb6a949c9704928c4ea43ed2c48c' + # type: '0x0' + logs: + - address: '0x82f67958a5474e40e1485742d648c0b0686b6e5d' + topics: + - '0xd0943372c08b438a88d4b39d77216901079eda9ca59d45349841c099083b6830' + transactionHash: '0x19d13637be89661646a2cf2b62017ed08dc1b88e61144eda78a95207affc7f7e' + removed: false + data: >- + 0x0000000000000000000000008d33caff9b73a3eb24c83ac79bb5ed56126f284c000000000000000000000000000000000000000000000000000000000000f8cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000085f483000000000000000000000000000000000000000000000000000000000000002d0100000000000000000000000000000000002386f26fc100008d33caff9b73a3eb24c83ac79bb5ed56126f284c00000000000000000000000000000000000000 + blockHash: '0x7000c3083910c0bcb8eea45d04448af35109bb6a949c9704928c4ea43ed2c48c' + blockNumber: '0x85b103' + transactionIndex: '0xe' + logIndex: '0x9' + - address: '0x82f67958a5474e40e1485742d648c0b0686b6e5d' + topics: + - '0x8f5f51448394699ad6a3b80cdadf4ec68c5d724c8c3fea09bea55b3c2d0e2dd0' + - '0x0000000000000000000000000000000000000000000000000000000000000000' + transactionHash: '0x19d13637be89661646a2cf2b62017ed08dc1b88e61144eda78a95207affc7f7e' + removed: false + blockHash: '0x7000c3083910c0bcb8eea45d04448af35109bb6a949c9704928c4ea43ed2c48c' + data: '0x000000000000000000000000000000000000000000000000002386f26fc10000' + blockNumber: '0x85b103' + transactionIndex: '0xe' + logIndex: '0xa' + cumulativeGasUsed: '0x158213' + transactionIndex: '0xe' + gasUsed: '0xf47e' + logsBloom: >- + 0x00000000000000000000000000100000000000000000000000000080000000000000000000000008000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000010000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000010000000000 + blockNumber: '0x85b103' + status: '0x1' + to: '0x82f67958a5474e40e1485742d648c0b0686b6e5d' + priorityOpId: 63695 + mockedResponses: + - contract_address: + - res: + - + result: + mainContract: "0x82F67958A5474e40E1485742d648C0b0686b6e5D" + govContract: "0xC8568F373484Cd51FDc1FE3675E46D8C0dc7D246" + - tokens: + - res: + - + jsonrpc: '2.0' + id: 3 + result: *tokens + - eth_getTransactionCount: + - res: + - + result: "0x5" + - eth_gasPrice: + - res: + - + result: "0x3b9aca00" + - eth_sendRawTransaction: + - res: + - + result: "0x19d13637be89661646a2cf2b62017ed08dc1b88e61144eda78a95207affc7f7e" + - eth_getTransactionReceipt: + - res: + - + jsonrpc: '2.0' + id: 12 + result: + contractAddress: null + transactionHash: '0x19d13637be89661646a2cf2b62017ed08dc1b88e61144eda78a95207affc7f7e' + from: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + blockHash: '0x7000c3083910c0bcb8eea45d04448af35109bb6a949c9704928c4ea43ed2c48c' + # type: '0x0' + logs: + - address: '0x82f67958a5474e40e1485742d648c0b0686b6e5d' + topics: + - '0xd0943372c08b438a88d4b39d77216901079eda9ca59d45349841c099083b6830' + transactionHash: '0x19d13637be89661646a2cf2b62017ed08dc1b88e61144eda78a95207affc7f7e' + removed: false + data: >- + 0x0000000000000000000000008d33caff9b73a3eb24c83ac79bb5ed56126f284c000000000000000000000000000000000000000000000000000000000000f8cf000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000085f483000000000000000000000000000000000000000000000000000000000000002d0100000000000000000000000000000000002386f26fc100008d33caff9b73a3eb24c83ac79bb5ed56126f284c00000000000000000000000000000000000000 + blockHash: '0x7000c3083910c0bcb8eea45d04448af35109bb6a949c9704928c4ea43ed2c48c' + blockNumber: '0x85b103' + transactionIndex: '0xe' + logIndex: '0x9' + - address: '0x82f67958a5474e40e1485742d648c0b0686b6e5d' + topics: + - '0x8f5f51448394699ad6a3b80cdadf4ec68c5d724c8c3fea09bea55b3c2d0e2dd0' + - '0x0000000000000000000000000000000000000000000000000000000000000000' + transactionHash: '0x19d13637be89661646a2cf2b62017ed08dc1b88e61144eda78a95207affc7f7e' + removed: false + blockHash: '0x7000c3083910c0bcb8eea45d04448af35109bb6a949c9704928c4ea43ed2c48c' + data: '0x000000000000000000000000000000000000000000000000002386f26fc10000' + blockNumber: '0x85b103' + transactionIndex: '0xe' + logIndex: '0xa' + cumulativeGasUsed: '0x158213' + transactionIndex: '0xe' + gasUsed: '0xf47e' + logsBloom: >- + 0x00000000000000000000000000100000000000000000000000000080000000000000000000000008000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000010000000000000000020000000000000000000800000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000020000000000000000000000000000000000000000000000000000000010000000000 + blockNumber: '0x85b103' + status: '0x1' + to: '0x82f67958a5474e40e1485742d648c0b0686b6e5d' + + zksync_withdraw: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + rpc: 'https://rinkeby-light.eth.linkpool.io' + zksync: + provider_url: 'https://rinkeby-light.eth.linkpool.io' + input: + - "0x8a91dc2d28b689474298d91899f0c1baf62cb85b" + - 100 + - "ETH" + expected_output: + type: 'Withdraw' + accountId: 167067 + from: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + to: '0x8a91dc2d28b689474298d91899f0c1baf62cb85b' + token: 0 + tokenId: 0 + amount: 100 + fee: 99500000000000 + validFrom: 0 + validUntil: 4294967295 + nonce: 2 + txHash: "sync-tx:46e73c497fe623fbc9d41e0f8242f808cb80447b84e2bcba42fe5970f158aefa" + mockedResponses: + - account_info: + - res: + - + jsonrpc: '2.0' + id: 2 + result: + address: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + id: 167067 + committed: + nfts: {} + balances: + ETH: '1099902100000100900' + pubKeyHash: 'sync:ec0de4692863fc7b1459cb98c6be56ada438d991' + mintedNfts: {} + nonce: 2 + verified: + nonce: 0 + nfts: {} + pubKeyHash: 'sync:0000000000000000000000000000000000000000' + mintedNfts: {} + balances: {} + depositing: + balances: {} + - tokens: + - res: + - + jsonrpc: '2.0' + id: 3 + result: *tokens + - get_tx_fee: + - res: + - + jsonrpc: '2.0' + id: 4 + result: + zkpFee: '30541131762442' + totalFee: '99500000000000' + gasPriceWei: '1000000000' + gasFee: '69030000000000' + gasTxAmount: '53100' + feeType: Withdraw + - tx_submit: + - res: + - + result: "sync-tx:46e73c497fe623fbc9d41e0f8242f808cb80447b84e2bcba42fe5970f158aefa" + - eth_chainId: + - res: + - + result: "0x4" + + zksync_emergency_withdraw: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + rpc: 'https://rinkeby-light.eth.linkpool.io' + zksync: + provider_url: 'https://rinkeby-light.eth.linkpool.io' + + input: + - ETH + expected_output: + contractAddress: null + transactionHash: '0x0557b4c73ebee5cd701c8ce86865385ee1aff57cf133ebd4d9b8ca8bd870a46c' + from: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + blockHash: '0x28feb8f6f29ec0b04a94abaae7d03bed3bc17799989232289f4d3532f284196d' + # type: '0x0' + logs: [] + cumulativeGasUsed: '0x24bbab' + transactionIndex: '0xa' + gasUsed: '0x67d1' + blockNumber: '0x85b120' + logsBloom: >- + 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + status: '0x0' + to: '0x82f67958a5474e40e1485742d648c0b0686b6e5d' + + mockedResponses: + - contract_address: + - res: + - + result: + govContract : "0xC8568F373484Cd51FDc1FE3675E46D8C0dc7D246" + mainContract : "0x82F67958A5474e40E1485742d648C0b0686b6e5D" + - tokens: + - res: + - + jsonrpc: '2.0' + id: 3 + result: *tokens + - account_info: + - res: + - + jsonrpc: '2.0' + id: 3 + result: + address: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + id: 167067 + committed: + balances: + ETH: '1019772300000100800' + nfts: {} + pubKeyHash: 'sync:ec0de4692863fc7b1459cb98c6be56ada438d991' + mintedNfts: {} + nonce: 4 + verified: + nonce: 4 + balances: + ETH: '999772300000100800' + pubKeyHash: 'sync:ec0de4692863fc7b1459cb98c6be56ada438d991' + mintedNfts: {} + nfts: {} + depositing: + balances: {} + - eth_getTransactionCount: + - res: + - + jsonrpc: "2.0" + result: "0x6" + - eth_gasPrice: + - res: + - + jsonrpc: "2.0" + result: "0x3b9aca00" + - eth_sendRawTransaction: + - res: + - + jsonrpc: "2.0" + result: "0x0557b4c73ebee5cd701c8ce86865385ee1aff57cf133ebd4d9b8ca8bd870a46c" + - eth_getTransactionReceipt: + - res: + - + jsonrpc: '2.0' + id: 13 + result: + contractAddress: null + transactionHash: '0x0557b4c73ebee5cd701c8ce86865385ee1aff57cf133ebd4d9b8ca8bd870a46c' + from: '0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c' + blockHash: '0x28feb8f6f29ec0b04a94abaae7d03bed3bc17799989232289f4d3532f284196d' + # type: '0x0' + logs: [] + cumulativeGasUsed: '0x24bbab' + transactionIndex: '0xa' + gasUsed: '0x67d1' + blockNumber: '0x85b120' + logsBloom: >- + 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + status: '0x0' + to: '0x82f67958a5474e40e1485742d648c0b0686b6e5d' + - eth_chainId: + - res: + - + result: "0x4" + + zksync_contract_address: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + expected_output: + mainContract: "0x82f67958a5474e40e1485742d648c0b0686b6e5d" + govContract: "0xc8568f373484cd51fdc1fe3675e46d8c0dc7d246" + mockedResponses: + - contract_address: + - res: + - + result: + govContract: "0xC8568F373484Cd51FDc1FE3675E46D8C0dc7D246" + mainContract: "0x82F67958A5474e40E1485742d648C0b0686b6e5D" + + zksync_tokens: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + expected_output: + USDC: + decimals: 6 + id: 2 + symbol: USDC + address: '0xeb8f08a975ab53e34d8a0330e0d34de942c95926' + USDT: + decimals: 6 + id: 1 + symbol: USDT + address: '0x3b00ef435fa4fcff5c209a37d1f3dcff37c705ad' + PHNX: + decimals: 18 + id: 20 + symbol: PHNX + address: '0xfe1b6abc39e46cec54d275efb4b29b33be176c2a' + TRB: + decimals: 18 + id: 7 + symbol: TRB + address: '0x2655f3a9eeb7f960be83098457144813ffad07a4' + TUSD: + decimals: 18 + id: 4 + symbol: TUSD + address: '0xd2255612f9b045e9c81244bb874abb413ca139a3' + ZRX: + decimals: 18 + id: 8 + symbol: ZRX + address: '0xdb7f2b9f6a0cb35fe5d236e5ed871d3ad4184290' + OMG: + decimals: 18 + id: 6 + symbol: OMG + address: '0x2b203de02ad6109521e09985b3af9b8c62541cd6' + STORJ: + decimals: 8 + id: 11 + symbol: STORJ + address: '0x8098165d982765097e4aa17138816e5b95f9fdb5' + XEM: + decimals: 0 + id: 18 + symbol: XEM + address: '0xc3904a7c3a95bc265066bb5bfc4d6664b2174774' + HT: + decimals: 18 + id: 5 + symbol: HT + address: '0x14700cae8b2943bad34c70bb76ae27ecf5bc5013' + LINK: + decimals: 18 + id: 3 + symbol: LINK + address: '0x4da8d0795830f75be471f072a034d42c369b5d0a' + KNC: + decimals: 18 + id: 14 + symbol: KNC + address: '0x290eba6ec56ecc9ff81c72e8eccc77d2c2bf63eb' + DAI: + decimals: 18 + id: 19 + symbol: DAI + address: '0x2e055eee18284513b993db7568a592679ab13188' + REP: + decimals: 18 + id: 10 + symbol: REP + address: '0x9cac8508b9ff26501439590a24893d80e7e84d21' + LAMB: + decimals: 18 + id: 15 + symbol: LAMB + address: '0x9ecec4d48efdd96ae377af3ab868f99de865cff8' + NEXO: + decimals: 18 + id: 12 + symbol: NEXO + address: '0x02d01f0835b7fdfa5d801a8f5f74c37f2bb1ae6a' + tGLM: + decimals: 18 + id: 16 + symbol: tGLM + address: '0xd94e3dc39d4cad1dad634e7eb585a57a19dc7efe' + MCO: + decimals: 8 + id: 13 + symbol: MCO + address: '0xd93addb2921b8061b697c2ab055979bbefe2b7ac' + ETH: + decimals: 18 + id: 0 + symbol: ETH + address: '0x0000000000000000000000000000000000000000' + MLTT: + decimals: 18 + id: 17 + symbol: MLTT + address: '0x690f4886c6911d81beb8130db30c825c27281f22' + BAT: + decimals: 18 + id: 9 + symbol: BAT + address: '0xd2084ea2ae4bbe1424e4fe3cde25b713632fb988' + mockedResponses: + - tokens: + - res: + - + result: *tokens + + zksync_pubkeyhash: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "0x5303a0015f8d5a8fef6cb1d60a034ef28dc4ac6aefa33c936d5aa0927f7c169a" + expected_output: "sync:827a841d753a8eefe82e02b25b5158305dab4d58" + + zksync_pubkey: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + expected_output: "0xd274ec1a5e9a513ff8f4eeb344fc02ca61e0823a7821c76e459ea0e8c5140826" + + zksync_account_address: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + expected_output: "0x8d33caff9b73a3eb24c83ac79bb5ed56126f284c" + + zksync_sign: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "0xaabbccddeeff" + expected_output: "0xd274ec1a5e9a513ff8f4eeb344fc02ca61e0823a7821c76e459ea0e8c5140826d78eb2c9661541f31ca097f5d38dc39aa9813017b4db929242e8e633839bdc80e4df4cbc14f9c8ca530c95ac005646c4b4b00f0a52a3dcb588db14b86fd66f02" + + zksync_verify: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "0xaabbccddeeff" + - "0x5303a0015f8d5a8fef6cb1d60a034ef28dc4ac6aefa33c936d5aa0927f7c169a52196178c5023fe88a56872439330bdd1c6c9578cb6e996dfcb704c52ae24a837e6acd5024aca9f5b5507e61cd4388c848a5752ef5e961e10d73b29b4a6b3902" + expected_output: 1 + + zksync_get_token_price: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "ETH" + expected_output: 214.996782624198 + mockedResponses: + - get_token_price: + - res: + - + result: "214.9967826241980000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + + zksync_get_tx_fee: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "Transfer" + - "0xabea9132b05a70803a4e85094fd0e1800777fbef" + - "BAT" + expected_output: + zkpFee: 9488974513464088 + totalFee: 10410000000000000 + gasPriceWei: 1000000000 + gasFee: 928245040812996 + gasTxAmount: 700 + feeType: 'Transfer' + mockedResponses: + - get_tx_fee: + - + res: + - + result: + zkpFee : "9488974513464088" + totalFee : "10410000000000000" + gasPriceWei : "1000000000" + gasFee : "928245040812996" + gasTxAmount : "700" + feeType : "Transfer" + + zksync_sync_key: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + expected_output: "0x0492fb6558207a6e006870bdaeab911e490ff9cedb0c8eca67560122ac2f7256" + + zksync_aggregate_pubkey: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "0x0f61bfe164cc43b5a112bfbfb0583004e79dbfafc97a7daad14c5d511fea8e2435065ddd04329ec94be682bf004b03a5a4eeca9bf50a8b8b6023942adc0b3409" + expected_output: "0x9ce5b6f8db3fbbe66a3bdbd3b4731f19ec27f80ee03ead3c0708798dd949882b" + + zksync_tx_data: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + debug: true + zksync: + rest_api: "https://rinkeby-api.zksync.io/api/v0.1" + input: + - "0x9b9f20c7c136a64f26bc3c63ef857e3c91e8ce307ae110f1dc1945bb41e629c1" + expected_output: + from: "0x3169131f0e744c1b8ef1ca8371c20d328f7f204d" + amount: 1 + tx_type: "Transfer" + created_at: "2021-06-10T13:16:55.148346" + fail_reason: null + tx: + from: "0x3169131f0e744c1b8ef1ca8371c20d328f7f204d" + amount: 1 + accountId: 7873 + nonce: 8724 + signature: + signature: "93f872d67e8746770e6cabd6777395d03c546fadf19dd5731fecd6795924f31059d425ee597c8c6eaf2653cb548ac5eee0404141bd428eb5819c0893ee777c02" + pubKey: "cbe5d99bb60441dbc8f457372e305608a513a343dd564b2c11c5c0733f779fa9" + validFrom: 0, + fee: 0 + type: "Transfer" + to: "0x8c469877b27932abdd2313c4b6bf7cff5667fdb9" + token: 0 + validUntil: 184467440737095 + fee: 0 + token: 0 + block_number: 32027 + to: "0x8c469877b27932abdd2313c4b6bf7cff5667fdb9" + nonce: 8724 + + mockedResponses: + - in3_http: + - + res: + - + result: + from: '0x3169131f0e744c1b8ef1ca8371c20d328f7f204d' + fail_reason: null + amount: '1' + tx_type: Transfer + created_at: '2021-06-10T13:16:55.148346' + tx: + from: '0x3169131f0e744c1b8ef1ca8371c20d328f7f204d' + amount: '1' + accountId: 7873 + nonce: 8724 + signature: + signature: >- + 93f872d67e8746770e6cabd6777395d03c546fadf19dd5731fecd6795924f31059d425ee597c8c6eaf2653cb548ac5eee0404141bd428eb5819c0893ee777c02 + pubKey: cbe5d99bb60441dbc8f457372e305608a513a343dd564b2c11c5c0733f779fa9 + validFrom: 0 + fee: '0' + type: Transfer + to: '0x8c469877b27932abdd2313c4b6bf7cff5667fdb9' + token: 0 + validUntil: 184467440737095 + fee: '0' + token: 0 + block_number: 32027 + to: '0x8c469877b27932abdd2313c4b6bf7cff5667fdb9' + nonce: 8724 + + zksync_account_history: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + zksync: + rest_api: "http://localhost:8080" + input: + - "0x3169131f0e744c1b8ef1ca8371c20d328f7f204d" + expected_output: + - hash: 'sync-tx:e435e847df064018e53b6173151dad867c15701054b7dd5c73ccb884fdc70732' + pq_id: null + tx: + amount: 2 + from: '0x3169131f0e744c1b8ef1ca8371c20d328f7f204d' + token: ETH + accountId: 7873 + validFrom: 0 + signature: + signature: >- + 4838bd78393fc2f129a95b00ea76aace63ee3839296e25abb2d77cfc19f92d06382f715bbdbd326ccde9216c97d053a71e335e0ce57c24ca724d5575c8761701 + pubKey: cbe5d99bb60441dbc8f457372e305608a513a343dd564b2c11c5c0733f779fa9 + fee: 0 + type: Transfer + to: '0x8c469877b27932abdd2313c4b6bf7cff5667fdb9' + validUntil: 184467440737095 + nonce: 8738 + created_at: '2021-06-10T15:04:24.632399Z' + success: true + commited: true + verified: false + fail_reason: null + tx_id: '32069,47' + eth_block: null + - hash: 'sync-tx:c54dc9e117c9b1e461b078b64d5f4cd7bd180b0cdfb06793189332cd522328be' + pq_id: null + tx: + amount: 3 + from: '0x3169131f0e744c1b8ef1ca8371c20d328f7f204d' + accountId: 7873 + type: Transfer + signature: + pubKey: cbe5d99bb60441dbc8f457372e305608a513a343dd564b2c11c5c0733f779fa9 + signature: >- + 5b501751a9fabc613b1327f204655f8b16065545cf57ad38c5dff9ac39dd90a73fafe218d574569280e47e7cd053db500ec1bdb6fca377aee96d940a7851b601 + validFrom: 0 + fee: 0 + token: ETH + to: '0x8c469877b27932abdd2313c4b6bf7cff5667fdb9' + validUntil: 184467440737095 + nonce: 8737 + created_at: '2021-06-10T14:50:56.793876Z' + success: true + commited: true + verified: false + fail_reason: null + eth_block: null + tx_id: '32067,5' + mockedResponses: + - in3_http: + - + res: + - + result: + - hash: 'sync-tx:e435e847df064018e53b6173151dad867c15701054b7dd5c73ccb884fdc70732' + pq_id: null + tx: + amount: '2' + from: '0x3169131f0e744c1b8ef1ca8371c20d328f7f204d' + token: ETH + accountId: 7873 + validFrom: 0 + signature: + signature: >- + 4838bd78393fc2f129a95b00ea76aace63ee3839296e25abb2d77cfc19f92d06382f715bbdbd326ccde9216c97d053a71e335e0ce57c24ca724d5575c8761701 + pubKey: cbe5d99bb60441dbc8f457372e305608a513a343dd564b2c11c5c0733f779fa9 + fee: '0' + type: Transfer + to: '0x8c469877b27932abdd2313c4b6bf7cff5667fdb9' + validUntil: 184467440737095 + nonce: 8738 + created_at: '2021-06-10T15:04:24.632399Z' + success: true + commited: true + verified: false + fail_reason: null + tx_id: '32069,47' + eth_block: null + - hash: 'sync-tx:c54dc9e117c9b1e461b078b64d5f4cd7bd180b0cdfb06793189332cd522328be' + pq_id: null + tx: + amount: '3' + from: '0x3169131f0e744c1b8ef1ca8371c20d328f7f204d' + accountId: 7873 + type: Transfer + signature: + pubKey: cbe5d99bb60441dbc8f457372e305608a513a343dd564b2c11c5c0733f779fa9 + signature: >- + 5b501751a9fabc613b1327f204655f8b16065545cf57ad38c5dff9ac39dd90a73fafe218d574569280e47e7cd053db500ec1bdb6fca377aee96d940a7851b601 + validFrom: 0 + fee: '0' + token: ETH + to: '0x8c469877b27932abdd2313c4b6bf7cff5667fdb9' + validUntil: 184467440737095 + nonce: 8737 + created_at: '2021-06-10T14:50:56.793876Z' + success: true + commited: true + verified: false + fail_reason: null + eth_block: null + tx_id: '32067,5' + + zksync_account_info: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "0x0e8b4fe889b126b9b502b244c9130912510f014f" + expected_output: + address: '0x0e8b4fe889b126b9b502b244c9130912510f014f' + id: null + committed: + nonce: 0 + balances: {} + pubKeyHash: 'sync:0000000000000000000000000000000000000000' + mintedNfts: {} + nfts: {} + verified: + nonce: 0 + balances: {} + pubKeyHash: 'sync:0000000000000000000000000000000000000000' + mintedNfts: {} + nfts: {} + depositing: + balances: {} + mockedResponses: + - account_info: + - res: + - + result: + address: '0x0e8b4fe889b126b9b502b244c9130912510f014f' + id: null + committed: + nonce: 0 + balances: {} + pubKeyHash: 'sync:0000000000000000000000000000000000000000' + mintedNfts: {} + nfts: {} + verified: + nonce: 0 + balances: {} + pubKeyHash: 'sync:0000000000000000000000000000000000000000' + mintedNfts: {} + nfts: {} + depositing: + balances: {} + + zksync_tx_info: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - "sync-tx:e41d2489571d322189246dafa5ebde1f4699f498000000000000000000000000" + expected_output: + executed : false + failReason : null + block : null + success : null + mockedResponses: + - tx_info: + - res: + - + result: + executed : false + failReason : null + block : null + success : null + + zksync_ethop_info: + config: + proof: 'none' + experimental: true + pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" + input: + - 1 + expected_output: + block: + blockNumber: 4 + committed: true + verified: true + executed : true + mockedResponses: + - ethop_info: + - res: + - + result: + block: + blockNumber: 4 + committed: true + verified: true + executed : true diff --git a/c/src/verifier/btc/testCases.yml b/c/src/verifier/btc/testCases.yml new file mode 100644 index 000000000..226851632 --- /dev/null +++ b/c/src/verifier/btc/testCases.yml @@ -0,0 +1,390 @@ +btc_full_with_tx_hash: &btc_full_with_tx_hash + hash: 00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d + confirmations: 563017 + strippedsize: 1496 + size: 1496 + weight: 5984 + height: 125552 + version: 1 + versionHex: '00000001' + merkleroot: 2b12fcf1b09288fcaff797d71e950e71ae42b91e8bdb2304758dfcffc2b620e3 + tx: + - "51d37bdd871c9e1f4d5541be67a6ab625e32028744d7d4609d0c37747b40cd2d" + - "60c25dda8d41f8d3d7d5c6249e2ea1b05a25bf7ae2ad6d904b512b31f997e1a1" + - "01f314cdd8566d3e5dbdd97de2d9fbfbfd6873e916a00d48758282cbb81a45b9" + - "b519286a1040da6ad83c783eb2872659eaf57b1bec088e614776ffe7dc8f6d01" + time: 1305998791 + mediantime: 1305995943 + nonce: 2504433986 + bits: 1a44b9f2 + difficulty: 244112.4877743364 + chainwork: 0000000000000000000000000000000000000000000000006aa84fd45b2350c9 + nTx: 4 + previousblockhash: 00000000000008a3a41b85b8b29ad444def299fee21793cd8b9e567eab02cd81 + nextblockhash: 0000000000001c0533ea776756cb6fdedbd952d3ab8bc71de3cd3f8a44cbaf85 + +btc_full_with_tx: &btc_full_with_tx + hash: 00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d + confirmations: 563017 + strippedsize: 1496 + size: 1496 + weight: 5984 + height: 125552 + version: 1 + versionHex: '00000001' + merkleroot: 2b12fcf1b09288fcaff797d71e950e71ae42b91e8bdb2304758dfcffc2b620e3 + tx: + - txid: 51d37bdd871c9e1f4d5541be67a6ab625e32028744d7d4609d0c37747b40cd2d + hash: 51d37bdd871c9e1f4d5541be67a6ab625e32028744d7d4609d0c37747b40cd2d + version: 1 + size: 135 + vsize: 135 + weight: 540 + locktime: 0 + vin: + - coinbase: 04f2b9441a022a01 + sequence: 4294967295 + vout: + - value: 50.01 + 'n': 0 + scriptPubKey: + asm: >- + 04d879d5ef8b70cf0a33925101b64429ad7eb370da8ad0b05c9cd60922c363a1eada85bcc2843b7378e226735048786c790b30b28438d22acfade24ef047b5f865 + OP_CHECKSIG + hex: >- + 4104d879d5ef8b70cf0a33925101b64429ad7eb370da8ad0b05c9cd60922c363a1eada85bcc2843b7378e226735048786c790b30b28438d22acfade24ef047b5f865ac + reqSigs: 1 + type: pubkey + addresses: + - 15nNvBTUdMaiZ6d3GWCeXFu2MagXL3XM1q + hex: >- + 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804f2b9441a022a01ffffffff014034152a01000000434104d879d5ef8b70cf0a33925101b64429ad7eb370da8ad0b05c9cd60922c363a1eada85bcc2843b7378e226735048786c790b30b28438d22acfade24ef047b5f865ac00000000 + - txid: 60c25dda8d41f8d3d7d5c6249e2ea1b05a25bf7ae2ad6d904b512b31f997e1a1 + hash: 60c25dda8d41f8d3d7d5c6249e2ea1b05a25bf7ae2ad6d904b512b31f997e1a1 + version: 1 + size: 259 + vsize: 259 + weight: 1036 + locktime: 0 + vin: + - txid: 738d466ff93e7857d07138b5a5a75e83a964e3c9977d2603308ecc9b667962ad + vout: 0 + scriptSig: + asm: >- + 30460221009805aa00cb6f80ca984584d4ca40f637fc948e3dbe159ea5c4eb6941bf4eb763022100e1cc0852d3f6eb87839edca1f90169088ed3502d8cde2f495840acac69eefc98[ALL] + 0486477e6a23cb25c9a99f0c467c6fc86197e718ebfd41d1aef7cc3cbd75197c1f1aaba985b22b366a0729ccb8aa38277809d6d218cf4077ac9f29a953b5435222 + hex: >- + 4930460221009805aa00cb6f80ca984584d4ca40f637fc948e3dbe159ea5c4eb6941bf4eb763022100e1cc0852d3f6eb87839edca1f90169088ed3502d8cde2f495840acac69eefc9801410486477e6a23cb25c9a99f0c467c6fc86197e718ebfd41d1aef7cc3cbd75197c1f1aaba985b22b366a0729ccb8aa38277809d6d218cf4077ac9f29a953b5435222 + sequence: 4294967295 + vout: + - value: 0.5 + 'n': 0 + scriptPubKey: + asm: >- + OP_DUP OP_HASH160 6f31097e564b9d54ebad662d5c4b5621c18ff523 + OP_EQUALVERIFY OP_CHECKSIG + hex: 76a9146f31097e564b9d54ebad662d5c4b5621c18ff52388ac + reqSigs: 1 + type: pubkeyhash + addresses: + - 1B8vkT58i8KUPVJvvyQfrbc8Wjwu3vEarQ + - value: 29 + 'n': 1 + scriptPubKey: + asm: >- + OP_DUP OP_HASH160 7228033b48b380900501c39c61da4ab453ca88e8 + OP_EQUALVERIFY OP_CHECKSIG + hex: 76a9147228033b48b380900501c39c61da4ab453ca88e888ac + reqSigs: 1 + type: pubkeyhash + addresses: + - 1BQbxzgRSLEsmv1JNc8MG76wdUgMwbsaww + hex: >- + 0100000001ad6279669bcc8e3003267d97c9e364a9835ea7a5b53871d057783ef96f468d73000000008c4930460221009805aa00cb6f80ca984584d4ca40f637fc948e3dbe159ea5c4eb6941bf4eb763022100e1cc0852d3f6eb87839edca1f90169088ed3502d8cde2f495840acac69eefc9801410486477e6a23cb25c9a99f0c467c6fc86197e718ebfd41d1aef7cc3cbd75197c1f1aaba985b22b366a0729ccb8aa38277809d6d218cf4077ac9f29a953b5435222ffffffff0280f0fa02000000001976a9146f31097e564b9d54ebad662d5c4b5621c18ff52388ac007ddaac000000001976a9147228033b48b380900501c39c61da4ab453ca88e888ac00000000 + - txid: 01f314cdd8566d3e5dbdd97de2d9fbfbfd6873e916a00d48758282cbb81a45b9 + hash: 01f314cdd8566d3e5dbdd97de2d9fbfbfd6873e916a00d48758282cbb81a45b9 + version: 1 + size: 617 + vsize: 617 + weight: 2468 + locktime: 0 + vin: + - txid: c9b85295d9301d18e319bfe395ccaed6953c85c437dfc7cef97120c441f3195a + vout: 0 + scriptSig: + asm: >- + 3044022025bca5dc0fe42aca5f07c9b3fe1b3f72113ffbc3522f8d3ebb2457f5bdf8f9b2022030ff687c00a63e810b21e447d3a57b2749ebea553cab763eb9b99e1b9839653b[ALL] + 04469f7eb54b90d90106b1a5412b41a23516028e81ad35e0418a4460707ae39a4bf0101b632260fb08979aba0ceea576b5400c7cf30b539b055ec4c0b96ab00984 + hex: >- + 473044022025bca5dc0fe42aca5f07c9b3fe1b3f72113ffbc3522f8d3ebb2457f5bdf8f9b2022030ff687c00a63e810b21e447d3a57b2749ebea553cab763eb9b99e1b9839653b014104469f7eb54b90d90106b1a5412b41a23516028e81ad35e0418a4460707ae39a4bf0101b632260fb08979aba0ceea576b5400c7cf30b539b055ec4c0b96ab00984 + sequence: 4294967295 + - txid: dac1581d713ef11db9710f202f2103cc918af29499ddbd11352bb7b6f4d3725b + vout: 0 + scriptSig: + asm: >- + 3046022100fbef2589b7c52a3be0fd8dd3624445da9c8930f0e51f6a33d76dc0ca0304473d0221009ec433ca6a9f16184db46468ff39cafaa9643021e0c66a1de1e6f9a612092790[ALL] + 04b27f4de096ac6431eec4b807a0d3db3e9f9be48faab692d5559624acb1faf4334dd440ebf32a81506b7c49d8cf40e4b3f5c6b6e99fcb6d3e8a298174bd2b348d + hex: >- + 493046022100fbef2589b7c52a3be0fd8dd3624445da9c8930f0e51f6a33d76dc0ca0304473d0221009ec433ca6a9f16184db46468ff39cafaa9643021e0c66a1de1e6f9a612092790014104b27f4de096ac6431eec4b807a0d3db3e9f9be48faab692d5559624acb1faf4334dd440ebf32a81506b7c49d8cf40e4b3f5c6b6e99fcb6d3e8a298174bd2b348d + sequence: 4294967295 + - txid: 430fbe9aea0fc6ceb6065bf3a0e911a8c6b1ca438e16a3338471518873942e29 + vout: 1 + scriptSig: + asm: >- + 30440220582813f2c2d7cbb84521f81d6c2a1147e5296e90bee05f583b3df108fdac72010220232b43a2e596cef59f82c8bfff1a310d85e7beb3e607076ff8966d6d374dc12b[ALL] + 04a8514ca51137c6d8a4befa476a7521197b886fceafa9f5c2830bea6df62792a6dd46f2b26812b250f13fad473e5cab6dcceaa2d53cf2c82e8e03d95a0e70836b + hex: >- + 4730440220582813f2c2d7cbb84521f81d6c2a1147e5296e90bee05f583b3df108fdac72010220232b43a2e596cef59f82c8bfff1a310d85e7beb3e607076ff8966d6d374dc12b014104a8514ca51137c6d8a4befa476a7521197b886fceafa9f5c2830bea6df62792a6dd46f2b26812b250f13fad473e5cab6dcceaa2d53cf2c82e8e03d95a0e70836b + sequence: 4294967295 + vout: + - value: 0.01 + 'n': 0 + scriptPubKey: + asm: >- + OP_DUP OP_HASH160 429e6bd3c9a9ca4be00a4b2b02fd4f5895c14059 + OP_EQUALVERIFY OP_CHECKSIG + hex: 76a914429e6bd3c9a9ca4be00a4b2b02fd4f5895c1405988ac + reqSigs: 1 + type: pubkeyhash + addresses: + - 175FNxcLc1YrTwwG6TcsywcsHYdVqyhbwC + - value: 4.85 + 'n': 1 + scriptPubKey: + asm: >- + OP_DUP OP_HASH160 e55756cb5395a4b39369d0f1f0a640c12fd867b2 + OP_EQUALVERIFY OP_CHECKSIG + hex: 76a914e55756cb5395a4b39369d0f1f0a640c12fd867b288ac + reqSigs: 1 + type: pubkeyhash + addresses: + - 1MueNMRJmcqVQeqE7v4dqogpNbhyxqq8R6 + hex: >- + 01000000035a19f341c42071f9cec7df37c4853c95d6aecc95e3bf19e3181d30d99552b8c9000000008a473044022025bca5dc0fe42aca5f07c9b3fe1b3f72113ffbc3522f8d3ebb2457f5bdf8f9b2022030ff687c00a63e810b21e447d3a57b2749ebea553cab763eb9b99e1b9839653b014104469f7eb54b90d90106b1a5412b41a23516028e81ad35e0418a4460707ae39a4bf0101b632260fb08979aba0ceea576b5400c7cf30b539b055ec4c0b96ab00984ffffffff5b72d3f4b6b72b3511bddd9994f28a91cc03212f200f71b91df13e711d58c1da000000008c493046022100fbef2589b7c52a3be0fd8dd3624445da9c8930f0e51f6a33d76dc0ca0304473d0221009ec433ca6a9f16184db46468ff39cafaa9643021e0c66a1de1e6f9a612092790014104b27f4de096ac6431eec4b807a0d3db3e9f9be48faab692d5559624acb1faf4334dd440ebf32a81506b7c49d8cf40e4b3f5c6b6e99fcb6d3e8a298174bd2b348dffffffff292e94738851718433a3168e43cab1c6a811e9a0f35b06b6cec60fea9abe0f43010000008a4730440220582813f2c2d7cbb84521f81d6c2a1147e5296e90bee05f583b3df108fdac72010220232b43a2e596cef59f82c8bfff1a310d85e7beb3e607076ff8966d6d374dc12b014104a8514ca51137c6d8a4befa476a7521197b886fceafa9f5c2830bea6df62792a6dd46f2b26812b250f13fad473e5cab6dcceaa2d53cf2c82e8e03d95a0e70836bffffffff0240420f00000000001976a914429e6bd3c9a9ca4be00a4b2b02fd4f5895c1405988ac4083e81c000000001976a914e55756cb5395a4b39369d0f1f0a640c12fd867b288ac00000000 + - txid: b519286a1040da6ad83c783eb2872659eaf57b1bec088e614776ffe7dc8f6d01 + hash: b519286a1040da6ad83c783eb2872659eaf57b1bec088e614776ffe7dc8f6d01 + version: 1 + size: 404 + vsize: 404 + weight: 1616 + locktime: 0 + vin: + - txid: 7ae1847583b78ea9534b2da74134aa89a4d013a6b31631e71a27b9026435a8c8 + vout: 1 + scriptSig: + asm: >- + 30440220771ae3ed7f2507f5682d6f63f59fa17187f1c4bdb33aa96373e73d42795d23b702206545376155d36db49560cf9c959d009f8e8ea668d93f47a4c8e9b27dc6b33023[ALL] + 048a976a8aa3f805749bf62df59168e49c163abafde1d2b596d685985807a221cbddf5fb72687678c41e35de46db82b49a48a2b9accea3648407c9ce2430724829 + hex: >- + 4730440220771ae3ed7f2507f5682d6f63f59fa17187f1c4bdb33aa96373e73d42795d23b702206545376155d36db49560cf9c959d009f8e8ea668d93f47a4c8e9b27dc6b330230141048a976a8aa3f805749bf62df59168e49c163abafde1d2b596d685985807a221cbddf5fb72687678c41e35de46db82b49a48a2b9accea3648407c9ce2430724829 + sequence: 4294967295 + - txid: fec71848ed96aeef4bc10303b182aab03e565648ed3f6e0b36f748921c11f0a4 + vout: 1 + scriptSig: + asm: >- + 304602210087fc57bd3ce0a03f0f7a3300a84dde8d5eba23dfdc64b8f2c17950c5213158d102210098141fbd22da33629cfc25b84d49b397144e1ec6287e0edd53dbb426aa6a72ed[ALL] + 04dee3ef362ae99b46422c8028f900a138c872776b2fcffed3f9cd02ee4b068a6df516a50249ae6d8f420f9ce19cdfc4663961296a71cd62b04a2c8a14ff89b1d0 + hex: >- + 49304602210087fc57bd3ce0a03f0f7a3300a84dde8d5eba23dfdc64b8f2c17950c5213158d102210098141fbd22da33629cfc25b84d49b397144e1ec6287e0edd53dbb426aa6a72ed014104dee3ef362ae99b46422c8028f900a138c872776b2fcffed3f9cd02ee4b068a6df516a50249ae6d8f420f9ce19cdfc4663961296a71cd62b04a2c8a14ff89b1d0 + sequence: 4294967295 + vout: + - value: 0.15 + 'n': 0 + scriptPubKey: + asm: >- + OP_DUP OP_HASH160 e43f7c61b3ef143b0fe4461c7d26f67377fd2075 + OP_EQUALVERIFY OP_CHECKSIG + hex: 76a914e43f7c61b3ef143b0fe4461c7d26f67377fd207588ac + reqSigs: 1 + type: pubkeyhash + addresses: + - 1Mos7p8fqJKBcYNRG1TdT5hBRxdMP6YHPy + hex: >- + 0100000002c8a8356402b9271ae73116b3a613d0a489aa3441a72d4b53a98eb7837584e17a010000008a4730440220771ae3ed7f2507f5682d6f63f59fa17187f1c4bdb33aa96373e73d42795d23b702206545376155d36db49560cf9c959d009f8e8ea668d93f47a4c8e9b27dc6b330230141048a976a8aa3f805749bf62df59168e49c163abafde1d2b596d685985807a221cbddf5fb72687678c41e35de46db82b49a48a2b9accea3648407c9ce2430724829ffffffffa4f0111c9248f7360b6e3fed4856563eb0aa82b10303c14befae96ed4818c7fe010000008c49304602210087fc57bd3ce0a03f0f7a3300a84dde8d5eba23dfdc64b8f2c17950c5213158d102210098141fbd22da33629cfc25b84d49b397144e1ec6287e0edd53dbb426aa6a72ed014104dee3ef362ae99b46422c8028f900a138c872776b2fcffed3f9cd02ee4b068a6df516a50249ae6d8f420f9ce19cdfc4663961296a71cd62b04a2c8a14ff89b1d0ffffffff01c0e1e400000000001976a914e43f7c61b3ef143b0fe4461c7d26f67377fd207588ac00000000 + time: 1305998791 + mediantime: 1305995943 + nonce: 2504433986 + bits: 1a44b9f2 + difficulty: 244112.4877743364 + chainwork: 0000000000000000000000000000000000000000000000006aa84fd45b2350c9 + nTx: 4 + previousblockhash: 00000000000008a3a41b85b8b29ad444def299fee21793cd8b9e567eab02cd81 + nextblockhash: 0000000000001c0533ea776756cb6fdedbd952d3ab8bc71de3cd3f8a44cbaf85 + +btc_full_tx: &btc_full_tx + txid: 1427c7d1698e61afe061950226f1c149990b8c1e1b157320b0c4acf7d6b5605d + hash: 371d1b497b6a9930b1f40c30ea18df4027bf452bb312c5945648d85d1f56dad5 + version: 2 + size: 225 + vsize: 143 + weight: 570 + locktime: 633980 + vin: + - txid: 7c6c587fa6c48cd3d4f10e5d23fe63ec2d159eca61f08567293023846f29baad + vout: 0 + scriptSig: + asm: '' + hex: '' + txinwitness: + - >- + 3045022100a1c74e429c4e40ef90d915556ce4b54a9aa4a83872622d0dbbaca3029f07f2d802204d99cd230b2e1d7378401d502cf589227272173f93b3ccc4aed6f97988067e7801 + - 035ad17694971c7dadab72369ab2444e355ae7d17ed8fba67aab80da9a3556d37c + sequence: 4294967294 + vout: + - value: 0.5 + 'n': 0 + scriptPubKey: + asm: OP_HASH160 e9f20f1225a9528739495649405861ae5d77ba1e OP_EQUAL + hex: a914e9f20f1225a9528739495649405861ae5d77ba1e87 + reqSigs: 1 + type: scripthash + addresses: + - 3P21LnWRCWp92mPNuY2HWvbi4JFrLx1Kwr + - value: 0.98552092 + 'n': 1 + scriptPubKey: + asm: OP_HASH160 1abf9a43d3a56f06930b95b1a8f0161bc0b0c9be OP_EQUAL + hex: a9141abf9a43d3a56f06930b95b1a8f0161bc0b0c9be87 + reqSigs: 1 + type: scripthash + addresses: + - 348T2K7sdJSH6zdgvdan5pxqmDfg5zSYxK + hex: >- + 02000000000101adba296f842330296785f061ca9e152dec63fe235d0ef1d4d38cc4a67f586c7c0000000000feffffff0280f0fa020000000017a914e9f20f1225a9528739495649405861ae5d77ba1e871cc9df050000000017a9141abf9a43d3a56f06930b95b1a8f0161bc0b0c9be8702483045022100a1c74e429c4e40ef90d915556ce4b54a9aa4a83872622d0dbbaca3029f07f2d802204d99cd230b2e1d7378401d502cf589227272173f93b3ccc4aed6f97988067e780121035ad17694971c7dadab72369ab2444e355ae7d17ed8fba67aab80da9a3556d37c7cac0900 + blockhash: 0000000000000000000cd3c5d7638014e78a5fba33be5fa5cb10ef9f03d99e60 + confirmations: 54557 + time: 1591782412 + blocktime: 1591782412 + + +btc: + getblockheader: + config: + proof: 'none' + input: + - "00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d" + expected_output: + options: + bytes: "0100000081cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122bc7f5d74df2b9441a42a14695" + btcblockheader: + hash: "00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d" + confirmations: 560364 + height: 125552 + version: 1 + versionHex: "00000001" + merkleroot: "2b12fcf1b09288fcaff797d71e950e71ae42b91e8bdb2304758dfcffc2b620e3" + time: 1305998791 + mediantime: 1305995943 + nonce: 2504433986 + bits: 1a44b9f2 + difficulty: 244112.4877743364 + chainwork: 0000000000000000000000000000000000000000000000006aa84fd45b2350c9 + nTx: 4 + previousblockhash: "00000000000008a3a41b85b8b29ad444def299fee21793cd8b9e567eab02cd81" + nextblockhash: "0000000000001c0533ea776756cb6fdedbd952d3ab8bc71de3cd3f8a44cbaf85" + mockedResponses: + options: + bytes: + - getblockheader: + - res: + - + result: 0100000081cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122bc7f5d74df2b9441a42a14695 + btcblockheader: + - getblockheader: + - res: + - result: + hash: "00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d" + confirmations: 560364 + height: 125552 + version: 1 + versionHex: "00000001" + merkleroot: "2b12fcf1b09288fcaff797d71e950e71ae42b91e8bdb2304758dfcffc2b620e3" + time: 1305998791 + mediantime: 1305995943 + nonce: 2504433986 + bits: 1a44b9f2 + difficulty: 244112.4877743364 + chainwork: 0000000000000000000000000000000000000000000000006aa84fd45b2350c9 + nTx: 4 + previousblockhash: "00000000000008a3a41b85b8b29ad444def299fee21793cd8b9e567eab02cd81" + nextblockhash: "0000000000001c0533ea776756cb6fdedbd952d3ab8bc71de3cd3f8a44cbaf85" + + getblock: + config: + proof: 'none' + input: + - "00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d" + expected_output: + options: + bytes: "0100000081cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122bc7f5d74df2b9441a42a146950401000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804f2b9441a022a01ffffffff014034152a01000000434104d879d5ef8b70cf0a33925101b64429ad7eb370da8ad0b05c9cd60922c363a1eada85bcc2843b7378e226735048786c790b30b28438d22acfade24ef047b5f865ac000000000100000001ad6279669bcc8e3003267d97c9e364a9835ea7a5b53871d057783ef96f468d73000000008c4930460221009805aa00cb6f80ca984584d4ca40f637fc948e3dbe159ea5c4eb6941bf4eb763022100e1cc0852d3f6eb87839edca1f90169088ed3502d8cde2f495840acac69eefc9801410486477e6a23cb25c9a99f0c467c6fc86197e718ebfd41d1aef7cc3cbd75197c1f1aaba985b22b366a0729ccb8aa38277809d6d218cf4077ac9f29a953b5435222ffffffff0280f0fa02000000001976a9146f31097e564b9d54ebad662d5c4b5621c18ff52388ac007ddaac000000001976a9147228033b48b380900501c39c61da4ab453ca88e888ac0000000001000000035a19f341c42071f9cec7df37c4853c95d6aecc95e3bf19e3181d30d99552b8c9000000008a473044022025bca5dc0fe42aca5f07c9b3fe1b3f72113ffbc3522f8d3ebb2457f5bdf8f9b2022030ff687c00a63e810b21e447d3a57b2749ebea553cab763eb9b99e1b9839653b014104469f7eb54b90d90106b1a5412b41a23516028e81ad35e0418a4460707ae39a4bf0101b632260fb08979aba0ceea576b5400c7cf30b539b055ec4c0b96ab00984ffffffff5b72d3f4b6b72b3511bddd9994f28a91cc03212f200f71b91df13e711d58c1da000000008c493046022100fbef2589b7c52a3be0fd8dd3624445da9c8930f0e51f6a33d76dc0ca0304473d0221009ec433ca6a9f16184db46468ff39cafaa9643021e0c66a1de1e6f9a612092790014104b27f4de096ac6431eec4b807a0d3db3e9f9be48faab692d5559624acb1faf4334dd440ebf32a81506b7c49d8cf40e4b3f5c6b6e99fcb6d3e8a298174bd2b348dffffffff292e94738851718433a3168e43cab1c6a811e9a0f35b06b6cec60fea9abe0f43010000008a4730440220582813f2c2d7cbb84521f81d6c2a1147e5296e90bee05f583b3df108fdac72010220232b43a2e596cef59f82c8bfff1a310d85e7beb3e607076ff8966d6d374dc12b014104a8514ca51137c6d8a4befa476a7521197b886fceafa9f5c2830bea6df62792a6dd46f2b26812b250f13fad473e5cab6dcceaa2d53cf2c82e8e03d95a0e70836bffffffff0240420f00000000001976a914429e6bd3c9a9ca4be00a4b2b02fd4f5895c1405988ac4083e81c000000001976a914e55756cb5395a4b39369d0f1f0a640c12fd867b288ac000000000100000002c8a8356402b9271ae73116b3a613d0a489aa3441a72d4b53a98eb7837584e17a010000008a4730440220771ae3ed7f2507f5682d6f63f59fa17187f1c4bdb33aa96373e73d42795d23b702206545376155d36db49560cf9c959d009f8e8ea668d93f47a4c8e9b27dc6b330230141048a976a8aa3f805749bf62df59168e49c163abafde1d2b596d685985807a221cbddf5fb72687678c41e35de46db82b49a48a2b9accea3648407c9ce2430724829ffffffffa4f0111c9248f7360b6e3fed4856563eb0aa82b10303c14befae96ed4818c7fe010000008c49304602210087fc57bd3ce0a03f0f7a3300a84dde8d5eba23dfdc64b8f2c17950c5213158d102210098141fbd22da33629cfc25b84d49b397144e1ec6287e0edd53dbb426aa6a72ed014104dee3ef362ae99b46422c8028f900a138c872776b2fcffed3f9cd02ee4b068a6df516a50249ae6d8f420f9ce19cdfc4663961296a71cd62b04a2c8a14ff89b1d0ffffffff01c0e1e400000000001976a914e43f7c61b3ef143b0fe4461c7d26f67377fd207588ac00000000" + btcblock: *btc_full_with_tx_hash + btcblockWithTx: *btc_full_with_tx + mockedResponses: + options: + bytes: + - getblock: + - res: + - + result: "0100000081cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122bc7f5d74df2b9441a42a146950401000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0804f2b9441a022a01ffffffff014034152a01000000434104d879d5ef8b70cf0a33925101b64429ad7eb370da8ad0b05c9cd60922c363a1eada85bcc2843b7378e226735048786c790b30b28438d22acfade24ef047b5f865ac000000000100000001ad6279669bcc8e3003267d97c9e364a9835ea7a5b53871d057783ef96f468d73000000008c4930460221009805aa00cb6f80ca984584d4ca40f637fc948e3dbe159ea5c4eb6941bf4eb763022100e1cc0852d3f6eb87839edca1f90169088ed3502d8cde2f495840acac69eefc9801410486477e6a23cb25c9a99f0c467c6fc86197e718ebfd41d1aef7cc3cbd75197c1f1aaba985b22b366a0729ccb8aa38277809d6d218cf4077ac9f29a953b5435222ffffffff0280f0fa02000000001976a9146f31097e564b9d54ebad662d5c4b5621c18ff52388ac007ddaac000000001976a9147228033b48b380900501c39c61da4ab453ca88e888ac0000000001000000035a19f341c42071f9cec7df37c4853c95d6aecc95e3bf19e3181d30d99552b8c9000000008a473044022025bca5dc0fe42aca5f07c9b3fe1b3f72113ffbc3522f8d3ebb2457f5bdf8f9b2022030ff687c00a63e810b21e447d3a57b2749ebea553cab763eb9b99e1b9839653b014104469f7eb54b90d90106b1a5412b41a23516028e81ad35e0418a4460707ae39a4bf0101b632260fb08979aba0ceea576b5400c7cf30b539b055ec4c0b96ab00984ffffffff5b72d3f4b6b72b3511bddd9994f28a91cc03212f200f71b91df13e711d58c1da000000008c493046022100fbef2589b7c52a3be0fd8dd3624445da9c8930f0e51f6a33d76dc0ca0304473d0221009ec433ca6a9f16184db46468ff39cafaa9643021e0c66a1de1e6f9a612092790014104b27f4de096ac6431eec4b807a0d3db3e9f9be48faab692d5559624acb1faf4334dd440ebf32a81506b7c49d8cf40e4b3f5c6b6e99fcb6d3e8a298174bd2b348dffffffff292e94738851718433a3168e43cab1c6a811e9a0f35b06b6cec60fea9abe0f43010000008a4730440220582813f2c2d7cbb84521f81d6c2a1147e5296e90bee05f583b3df108fdac72010220232b43a2e596cef59f82c8bfff1a310d85e7beb3e607076ff8966d6d374dc12b014104a8514ca51137c6d8a4befa476a7521197b886fceafa9f5c2830bea6df62792a6dd46f2b26812b250f13fad473e5cab6dcceaa2d53cf2c82e8e03d95a0e70836bffffffff0240420f00000000001976a914429e6bd3c9a9ca4be00a4b2b02fd4f5895c1405988ac4083e81c000000001976a914e55756cb5395a4b39369d0f1f0a640c12fd867b288ac000000000100000002c8a8356402b9271ae73116b3a613d0a489aa3441a72d4b53a98eb7837584e17a010000008a4730440220771ae3ed7f2507f5682d6f63f59fa17187f1c4bdb33aa96373e73d42795d23b702206545376155d36db49560cf9c959d009f8e8ea668d93f47a4c8e9b27dc6b330230141048a976a8aa3f805749bf62df59168e49c163abafde1d2b596d685985807a221cbddf5fb72687678c41e35de46db82b49a48a2b9accea3648407c9ce2430724829ffffffffa4f0111c9248f7360b6e3fed4856563eb0aa82b10303c14befae96ed4818c7fe010000008c49304602210087fc57bd3ce0a03f0f7a3300a84dde8d5eba23dfdc64b8f2c17950c5213158d102210098141fbd22da33629cfc25b84d49b397144e1ec6287e0edd53dbb426aa6a72ed014104dee3ef362ae99b46422c8028f900a138c872776b2fcffed3f9cd02ee4b068a6df516a50249ae6d8f420f9ce19cdfc4663961296a71cd62b04a2c8a14ff89b1d0ffffffff01c0e1e400000000001976a914e43f7c61b3ef143b0fe4461c7d26f67377fd207588ac00000000" + btcblock: + - getblock: + - res: + - + result: *btc_full_with_tx_hash + btcblockWithTx: + - getblock: + - res: + - + result: *btc_full_with_tx + + getrawtransaction: + config: + proof: 'none' + input: + - "1427c7d1698e61afe061950226f1c149990b8c1e1b157320b0c4acf7d6b5605d" + expected_output: + options: + bytes: "02000000000101adba296f842330296785f061ca9e152dec63fe235d0ef1d4d38cc4a67f586c7c0000000000feffffff0280f0fa020000000017a914e9f20f1225a9528739495649405861ae5d77ba1e871cc9df050000000017a9141abf9a43d3a56f06930b95b1a8f0161bc0b0c9be8702483045022100a1c74e429c4e40ef90d915556ce4b54a9aa4a83872622d0dbbaca3029f07f2d802204d99cd230b2e1d7378401d502cf589227272173f93b3ccc4aed6f97988067e780121035ad17694971c7dadab72369ab2444e355ae7d17ed8fba67aab80da9a3556d37c7cac0900" + btctransaction: *btc_full_tx + mockedResponses: + options: + bytes: + - getrawtransaction: + - res: + - + result: "02000000000101adba296f842330296785f061ca9e152dec63fe235d0ef1d4d38cc4a67f586c7c0000000000feffffff0280f0fa020000000017a914e9f20f1225a9528739495649405861ae5d77ba1e871cc9df050000000017a9141abf9a43d3a56f06930b95b1a8f0161bc0b0c9be8702483045022100a1c74e429c4e40ef90d915556ce4b54a9aa4a83872622d0dbbaca3029f07f2d802204d99cd230b2e1d7378401d502cf589227272173f93b3ccc4aed6f97988067e780121035ad17694971c7dadab72369ab2444e355ae7d17ed8fba67aab80da9a3556d37c7cac0900" + btctransaction: + - getrawtransaction: + - res: + - + result: *btc_full_tx + + getblockcount: + config: + proof: 'none' + expected_output: 688582 + mockedResponses: + - getblockcount: + - res: + - + result: 688582 + + getdifficulty: + config: + proof: 'none' + expected_output: 19932791027262.74 + mockedResponses: + - getdifficulty: + - res: + - + result: 19932791027262.74 + + getbestblockhash: + config: + proof: 'none' + expected_output: "00000000000000000007337908f2581dc58cecd2d6e1aaaafe2260461e946096" + mockedResponses: + - getbestblockhash: + - res: + - + result: "00000000000000000007337908f2581dc58cecd2d6e1aaaafe2260461e946096" \ No newline at end of file diff --git a/c/src/verifier/eth1/basic/testCases.yml b/c/src/verifier/eth1/basic/testCases.yml new file mode 100644 index 000000000..555766947 --- /dev/null +++ b/c/src/verifier/eth1/basic/testCases.yml @@ -0,0 +1,537 @@ +eth_getBlock_full: &blockdata + difficulty: "0x1b168dd882369a" + extraData: "0xe4b883e5bda9e7a59ee4bb99e9b1bc000221" + gasLimit: "0xe4e1b2" + gasUsed: "0xe092e3" + hash: "0x250e327cbffe74b4de28ee3f7ebb77b0c2a8a712b93a9cd7413d6ac7ca3264c6" + logsBloom: "0x00200000000000800000000080000000001000000000000000010000000000000000000000000000000000000000000002080000080000000000000008200000000000080000000000000008000000200000000000000000000000000000000000000000020000008000000000008800000100000010000200000010000000000000000000000000004000000000000000000000000000080000004000000240820000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000001000000000000020000010220000000000000000000000000000000000004000000000000000000000" + miner: "0x829bd824b016326a401d083b33d092293333a830" + # mixHash: "0xb5a73cd8c00d2a6f545e46f583311256f4f7106b48b0d225db393babc77c9594" + nonce: "0xaf95878ec21c6cdc" + number: "0xbf920c" + parentHash: "0x948db2300a90125258b50c2033f3a2f419cb5580c36ecaeefe5eb47393286315" + receiptsRoot: "0x1cd93548ea4e900b4fa4537e64715805d37ef6ff8d6712a222cb4eed5a901330" + sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + size: "0x280" + stateRoot: "0x04062f1e69f3df90851288d6be60ae937e6cf5092d2e292daf566a19308d93b9" + timestamp: "0x60b769a7" + totalDifficulty: "0x56d829bfeb2fd2b3dc1" + transactions: + - + blockHash: "0x250e327cbffe74b4de28ee3f7ebb77b0c2a8a712b93a9cd7413d6ac7ca3264c6" + blockNumber: "0xbf920c" + from: "0xbbed1c61b6e68c397b021c1274080a2005042c08" + gas: "0xe4e1b2" + gasPrice: "0x0" + hash: "0x9b18c61b377930f49de6a950a125564581e4b36a5f52e11727a52c866c30f717" + input: "0x" + nonce: "0x3b2" + to: "0xf20c85c6004f5091fb522e42a0d208cb977efa49" + transactionIndex: "0x0" + value: "0x0" + # type: "0x0" + v: "0x25" + r: "0xbdef0d47f4b93bd9f76fec4f0cdac17946fe740e004c24160b9ffc8fbd13f42" + s: "0xd8b2e4c00e767960baccacceccd6e3e1d68e9db47f13d9d906065b7b3c006dc" + transactionsRoot: "0x4ef7e5d9d75b2598430b2de32f62b3272a3aa42e56e72b9dcf4def35bc8b35f5" + uncles: [] + +eth_getBlock: &blockdataWithTxHashes + difficulty: "0x1b168dd882369a" + extraData: "0xe4b883e5bda9e7a59ee4bb99e9b1bc000221" + gasLimit: "0xe4e1b2" + gasUsed: "0xe092e3" + hash: "0x250e327cbffe74b4de28ee3f7ebb77b0c2a8a712b93a9cd7413d6ac7ca3264c6" + logsBloom: "0x00200000000000800000000080000000001000000000000000010000000000000000000000000000000000000000000002080000080000000000000008200000000000080000000000000008000000200000000000000000000000000000000000000000020000008000000000008800000100000010000200000010000000000000000000000000004000000000000000000000000000080000004000000240820000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000001000000000000020000010220000000000000000000000000000000000004000000000000000000000" + miner: "0x829bd824b016326a401d083b33d092293333a830" + ## mixHash: "0xb5a73cd8c00d2a6f545e46f583311256f4f7106b48b0d225db393babc77c9594" + nonce: "0xaf95878ec21c6cdc" + number: "0xbf920c" + parentHash: "0x948db2300a90125258b50c2033f3a2f419cb5580c36ecaeefe5eb47393286315" + receiptsRoot: "0x1cd93548ea4e900b4fa4537e64715805d37ef6ff8d6712a222cb4eed5a901330" + sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + size: "0x280" + stateRoot: "0x04062f1e69f3df90851288d6be60ae937e6cf5092d2e292daf566a19308d93b9" + timestamp: "0x60b769a7" + totalDifficulty: "0x56d829bfeb2fd2b3dc1" + transactions: + - "0x9b18c61b377930f49de6a950a125564581e4b36a5f52e11727a52c866c30f717" + transactionsRoot: "0x4ef7e5d9d75b2598430b2de32f62b3272a3aa42e56e72b9dcf4def35bc8b35f5" + uncles: [] + +result_block_with_tx: &result_blockfull + difficulty: "0x1b168dd882369a" + extraData: "0xe4b883e5bda9e7a59ee4bb99e9b1bc000221" + gasLimit: 14999986 + gasUsed: 14717667 + hash: "0x250e327cbffe74b4de28ee3f7ebb77b0c2a8a712b93a9cd7413d6ac7ca3264c6" + logsBloom: "0x00200000000000800000000080000000001000000000000000010000000000000000000000000000000000000000000002080000080000000000000008200000000000080000000000000008000000200000000000000000000000000000000000000000020000008000000000008800000100000010000200000010000000000000000000000000004000000000000000000000000000080000004000000240820000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000001000000000000020000010220000000000000000000000000000000000004000000000000000000000" + miner: "0x829bd824b016326a401d083b33d092293333a830" + # mixHash: "0xb5a73cd8c00d2a6f545e46f583311256f4f7106b48b0d225db393babc77c9594" + nonce: "0xaf95878ec21c6cdc" + number: 12554764 + parentHash: "0x948db2300a90125258b50c2033f3a2f419cb5580c36ecaeefe5eb47393286315" + receiptsRoot: "0x1cd93548ea4e900b4fa4537e64715805d37ef6ff8d6712a222cb4eed5a901330" + sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + size: 640 + stateRoot: "0x04062f1e69f3df90851288d6be60ae937e6cf5092d2e292daf566a19308d93b9" + timestamp: 1622632871 + totalDifficulty: "0x56d829bfeb2fd2b3dc1" + transactions: + - + blockHash: "0x250e327cbffe74b4de28ee3f7ebb77b0c2a8a712b93a9cd7413d6ac7ca3264c6" + blockNumber: "0xbf920c" + from: "0xbbed1c61b6e68c397b021c1274080a2005042c08" + gas: "0xe4e1b2" + gasPrice: "0x0" + hash: "0x9b18c61b377930f49de6a950a125564581e4b36a5f52e11727a52c866c30f717" + input: "0x" + nonce: "0x3b2" + to: "0xf20c85c6004f5091fb522e42a0d208cb977efa49" + transactionIndex: "0x0" + value: "0x0" + # type: "0x0" + v: "0x25" + r: "0xbdef0d47f4b93bd9f76fec4f0cdac17946fe740e004c24160b9ffc8fbd13f42" + s: "0xd8b2e4c00e767960baccacceccd6e3e1d68e9db47f13d9d906065b7b3c006dc" + transactionsRoot: "0x4ef7e5d9d75b2598430b2de32f62b3272a3aa42e56e72b9dcf4def35bc8b35f5" + uncles: [] + +result_block_without_tx: &result_blockfull_without_tx + difficulty: "0x1b168dd882369a" + extraData: "0xe4b883e5bda9e7a59ee4bb99e9b1bc000221" + gasLimit: 14999986 + gasUsed: 14717667 + hash: "0x250e327cbffe74b4de28ee3f7ebb77b0c2a8a712b93a9cd7413d6ac7ca3264c6" + logsBloom: "0x00200000000000800000000080000000001000000000000000010000000000000000000000000000000000000000000002080000080000000000000008200000000000080000000000000008000000200000000000000000000000000000000000000000020000008000000000008800000100000010000200000010000000000000000000000000004000000000000000000000000000080000004000000240820000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000001000000000000020000010220000000000000000000000000000000000004000000000000000000000" + miner: "0x829bd824b016326a401d083b33d092293333a830" + # mixHash: "0xb5a73cd8c00d2a6f545e46f583311256f4f7106b48b0d225db393babc77c9594" + nonce: "0xaf95878ec21c6cdc" + number: 12554764 + parentHash: "0x948db2300a90125258b50c2033f3a2f419cb5580c36ecaeefe5eb47393286315" + receiptsRoot: "0x1cd93548ea4e900b4fa4537e64715805d37ef6ff8d6712a222cb4eed5a901330" + sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + size: 640 + stateRoot: "0x04062f1e69f3df90851288d6be60ae937e6cf5092d2e292daf566a19308d93b9" + timestamp: 1622632871 + totalDifficulty: "0x56d829bfeb2fd2b3dc1" + transactions: + - "0x9b18c61b377930f49de6a950a125564581e4b36a5f52e11727a52c866c30f717" + transactionsRoot: "0x4ef7e5d9d75b2598430b2de32f62b3272a3aa42e56e72b9dcf4def35bc8b35f5" + uncles: [] + +rpc_eth_getTransactionByBlock: &rpc_eth_getTransactionByBlock + blockHash: "0xca0e20a9e930af17c7422be3d991e925235b5350f8912a5ca4aaea734b4a88c5" + blockNumber: "0x9d6e99" + from: "0xea674fdde714fd979de3edf0f56aa9716b898ec8" + gas: "0xc350" + gasPrice: "0x3b9aca00" + hash: "0x02fb01822450cf847961e34edd4d30e8225bed8742a573fb3eb27205931b9637" + input: "0x" + nonce: "0x195b47b" + r: "0x8950fa5d5cb49fa031730d7457b74b80117d274592a7104eba75132e589604be" + s: "0x22d957a39462c2a8c14894a42045aae2e5967d8977a5f4912563401bfba7e150" + to: "0x3fdd30eb8a18283cf687666e5f2b1693eb72e442" + transactionIndex: "0x2" + v: "0x26" + value: "0xe1d75bb46cae38" + +output_eth_getTransactionByBlock: &output_eth_getTransactionByBlock + blockHash: "0xca0e20a9e930af17c7422be3d991e925235b5350f8912a5ca4aaea734b4a88c5" + blockNumber: "0x9d6e99" + from: "0xea674fdde714fd979de3edf0f56aa9716b898ec8" + gas: "0xc350" + gasPrice: "0x3b9aca00" + hash: "0x02fb01822450cf847961e34edd4d30e8225bed8742a573fb3eb27205931b9637" + input: "0x" + nonce: "0x195b47b" + r: "0x8950fa5d5cb49fa031730d7457b74b80117d274592a7104eba75132e589604be" + s: "0x22d957a39462c2a8c14894a42045aae2e5967d8977a5f4912563401bfba7e150" + to: "0x3fdd30eb8a18283cf687666e5f2b1693eb72e442" + transactionIndex: "0x2" + v: "0x26" + value: "0xe1d75bb46cae38" + +test_eth_getlogs: &test_eth_getlogs + - + address: "0xdac17f958d2ee523a2206206994597c13d831ec7" + blockHash: "0xcc66dc39266f60a86380bf2df8263e24818bd33e6ffffd7002a4b2d73b37efdc" + blockNumber: "0x834b77" + data: "0x0000000000000000000000000000000000000000000000000000000349d05c5c" + logIndex: "0x24" + removed: false + topics: + - "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" + - "0x00000000000000000000000031826a1613470fc3d2eb794e93af7477ee8fe0ad" + - "0x0000000000000000000000009e6adb80dd43d07df9f2f43f8434080c4528102f" + transactionHash: "0x20be6d27ed6a4c99c5dbeeb9081e114a9b400c52b80c4d10096c94ad7d3c1af6" + transactionIndex: "0x25" + transactionLogIndex: "0x0" + type: "mined" + +eth: + eth_blockNumber: + input: [] + expected_output: 3220 + mockedResponses: + - eth_blockNumber: + - res: + - + jsonrpc: "2.0" + result: "0xc94" + + eth_getBlockByNumber: + config: + proof: 'none' + input: + - "0xbf920c" + expected_output: + options: + blockdata: *result_blockfull + blockdataWithTxHashes: *result_blockfull_without_tx + mockedResponses: + options: + blockdata: + - eth_getBlockByNumber: + - res: + - + jsonrpc: "2.0" + result: *blockdata + blockdataWithTxHashes: + - eth_getBlockByNumber: + - res: + - + jsonrpc: "2.0" + result: *blockdataWithTxHashes + + eth_getBlockByHash: + config: + proof: 'none' + input: + - "0x250e327cbffe74b4de28ee3f7ebb77b0c2a8a712b93a9cd7413d6ac7ca3264c6" + expected_output: + options: + blockdata: *result_blockfull + blockdataWithTxHashes: *result_blockfull_without_tx + mockedResponses: + options: + blockdata: + - eth_getBlockByHash: + - res: + - + jsonrpc: "2.0" + result: *blockdata + blockdataWithTxHashes: + - eth_getBlockByHash: + - res: + - + jsonrpc: "2.0" + result: *blockdataWithTxHashes + + eth_getBlockTransactionCountByHash: + config: + proof: 'none' + input: + - "0x0c0728467cee3a0b1b1322e88596d0f9f2a8fa2018fc5447d5072805d3bf9d13" + expected_output: 204 + mockedResponses: + - eth_getBlockTransactionCountByHash: + - res: + - + jsonrpc: "2.0" + result: "0xcc" + + eth_getBlockTransactionCountByNumber: + config: + proof: 'none' + input: + - "0x9d6a46" + expected_output: 204 + mockedResponses: + - eth_getBlockTransactionCountByNumber: + - res: + - + jsonrpc: "2.0" + result: "0xcc" + + eth_getUncleCountByBlockHash: + config: + proof: 'none' + input: + - "0x884aaab2f9116742e693ced034a2dff840b45f21709025f7d69cde26d071068b" + expected_output: 1 + mockedResponses: + - eth_getUncleCountByBlockHash: + - res: + - + jsonrpc: "2.0" + result: "0x1" + + eth_getUncleCountByBlockNumber: + config: + proof: 'none' + input: + - 9830239 + expected_output: 1 + mockedResponses: + - eth_getUncleCountByBlockNumber: + - res: + - + jsonrpc: "2.0" + result: "0x1" + + eth_getTransactionByBlockHashAndIndex: + config: + proof: 'none' + input: + - "0xca0e20a9e930af17c7422be3d991e925235b5350f8912a5ca4aaea734b4a88c5" + - 2 + expected_output: *output_eth_getTransactionByBlock + mockedResponses: + - eth_getTransactionByBlockHashAndIndex: + - res: + - + jsonrpc: "2.0" + result: *rpc_eth_getTransactionByBlock + + eth_getTransactionByBlockNumberAndIndex: + config: + proof: 'none' + input: + - 10317465 + - 2 + expected_output: *output_eth_getTransactionByBlock + mockedResponses: + - eth_getTransactionByBlockNumberAndIndex: + - res: + - + jsonrpc: "2.0" + result: *rpc_eth_getTransactionByBlock + + eth_getTransactionByHash: + config: + proof: 'none' + input: + - "0x02fb01822450cf847961e34edd4d30e8225bed8742a573fb3eb27205931b9637" + expected_output: *output_eth_getTransactionByBlock + mockedResponses: + - eth_getTransactionByHash: + - res: + - + jsonrpc: "2.0" + result: *rpc_eth_getTransactionByBlock + + eth_getLogs: + config: + proof: 'none' + input: + - + fromBlock: "0x834B77" + toBlock: "0x834B77" + address: "0xdac17f958d2ee523a2206206994597c13d831ec7" + expected_output: *test_eth_getlogs + mockedResponses: + - eth_getLogs: + - res: + - + jsonrpc: "2.0" + result: *test_eth_getlogs + + eth_getBalance: + config: + proof: 'none' + input: + - "0x4144FFD5430a8518fa2d84ef5606Fd7e1921cE27" + expected_output: "0x329a1e26bab74000" + mockedResponses: + - eth_getBalance: + - res: + - + jsonrpc: "2.0" + result: "0x329a1e26bab74000" + + eth_getTransactionCount: + config: + proof: 'none' + input: + - "0xea674fdde714fd979de3edf0f56aa9716b898ec8" + expected_output: 26588838 + mockedResponses: + - eth_getTransactionCount: + - res: + - + jsonrpc: "2.0" + result: "0x195b6a6" + + eth_getCode: + config: + proof: 'none' + chainId: 'goerli' + input: + - "0xf62A53c356f9DC6Ee521A74934236eD1e4D9F71a" + expected_output: "0x60806040526001600160a01b036000541663530ca43760e11b6000351415602a578060005260206000f35b3660008037600080366000845af43d6000803e806046573d6000fd5b3d6000f3fea265627a7a723158203f36691c16ad212e606ff2acbeb8ed1efb9c7d0f4f2c44903f1d6dcb82754f6c64736f6c63430005110032" + mockedResponses: + - eth_getCode: + - res: + - + jsonrpc: "2.0" + result: "0x60806040526001600160a01b036000541663530ca43760e11b6000351415602a578060005260206000f35b3660008037600080366000845af43d6000803e806046573d6000fd5b3d6000f3fea265627a7a723158203f36691c16ad212e606ff2acbeb8ed1efb9c7d0f4f2c44903f1d6dcb82754f6c64736f6c63430005110032" + + eth_getStorageAt: + config: + proof: 'none' + input: + - "0x862174623bc39e57de552538f424806b947d3d05" + - "0x0" + expected_output: "0x0" + mockedResponses: + - eth_getStorageAt: + - res: + - + jsonrpc: "2.0" + result: "0x0" + + eth_sendTransaction: + config: + proof: 'none' + pk: "0x4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7" + chainId: 'goerli' + + input: + - + to: "0x1234567890123456789012345678901234567890" + from: "0x00a329c0648769a73afac7f9381e08fb43dbea72" + data: "0x4faa8a2600000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72" + nonce: 31 + gasPrice: 1000000000 + expected_output: "0xd5651b7c0b396c16ad9dc44ef0770aa215ca795702158395713facfbc9b55f38" + mockedResponses: + - eth_sendRawTransaction: + - res: + - + jsonrpc: "2.0" + result: "0xd5651b7c0b396c16ad9dc44ef0770aa215ca795702158395713facfbc9b55f38" + + eth_sendTransactionAndWait: + config: + proof: 'none' + pk: "0x4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7" + chainId: 'goerli' + input: + - + to: "0x1234567890123456789012345678901234567890" + from: "0x00a329c0648769a73afac7f9381e08fb43dbea72" + data: "0x4faa8a2600000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72" + nonce: 31 + gasPrice: 1000000000 + expected_output: + blockHash: "0xa3c56c1f5bf0fccab818b7722153737977b72b44ac10a8511ccb364da39f3582" + blockNumber: "0x452c23" + contractAddress: null + cumulativeGasUsed: "0x402945" + from: "0x00a329c0648769a73afac7f9381e08fb43dbea72" + gasUsed: "0x12e64" + logs: + - + address: "0xe2b01f3978c03d6dda5ae36b2f3ac0d66c54a6d5" + blockHash: "0xa3c56c1f5bf0fccab818b7722153737977b72b44ac10a8511ccb364da39f3582" + blockNumber: "0x452c23" + data: "0x000000000000000000000000000000000000000000000000007be973a2f6ba00" + logIndex: "0x17" + removed: false + topics: + - "0x3e799b2d61372379e767ef8f04d65089179b7a6f63f9be3065806456c7309f1b" + - "0x00000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72" + - "0x00000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72" + transactionHash: "0x02de07114d5c6e5a81e73e164b4cb623727024822318b300b93bad54482a6416" + transactionIndex: "0x22" + transactionLogIndex: "0x0" + type: "mined" + - + address: "0xeaa852323826c71cd7920c3b4c007184234c3945" + blockHash: "0xa3c56c1f5bf0fccab818b7722153737977b72b44ac10a8511ccb364da39f3582" + blockNumber: "0x452c23" + data: "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000007be973a2f6ba00" + logIndex: "0x18" + removed: false + topics: + - "0x103fed9db65eac19c4d870f49ab7520fe03b99f1838e5996caf47e9e43308392" + - "0x0000000000000000000000000000000000000000000000000000000000002534" + - "0x000000000000000000000000b5505a6d998549090530911180f38ac5130101c6" + transactionHash: "0x02de07114d5c6e5a81e73e164b4cb623727024822318b300b93bad54482a6416" + transactionIndex: "0x22" + transactionLogIndex: "0x1" + type: mined + logsBloom: "0x00000000000000080000000080000000000000000000000000000000000000000000000000000000000400080000000000000000000000000000000000000000000000000000000050000002000000000000100000000000000000000000000000080000000000000000000000000010000000000000000000000000000000000000000010000000000000000000000004000000000000000000000000080000000000000200000000000000000000004000800000000800000000000000000000008000000000000000000000000002000000000000000000000000000000000000000000000020000000000000000000000000000000000000008000000000" + status: "0x1" + to: "0xbbd7cbfa79faee899eaf900f13c9065bf03b1a74" + transactionHash: "0x02de07114d5c6e5a81e73e164b4cb623727024822318b300b93bad54482a6416" + transactionIndex: "0x22" + mockedResponses: + - eth_sendRawTransaction: + - res: + - + jsonrpc: "2.0" + result: "0xd5651b7c0b396c16ad9dc44ef0770aa215ca795702158395713facfbc9b55f38" + - eth_getTransactionReceipt: + - res: + - + jsonrpc: "2.0" + result: + blockHash: "0xa3c56c1f5bf0fccab818b7722153737977b72b44ac10a8511ccb364da39f3582" + blockNumber: "0x452c23" + contractAddress: null + cumulativeGasUsed: "0x402945" + from: "0x00a329c0648769a73afac7f9381e08fb43dbea72" + gasUsed: "0x12e64" + logs: + - + address: "0xe2b01f3978c03d6dda5ae36b2f3ac0d66c54a6d5" + blockHash: "0xa3c56c1f5bf0fccab818b7722153737977b72b44ac10a8511ccb364da39f3582" + blockNumber: "0x452c23" + data: "0x000000000000000000000000000000000000000000000000007be973a2f6ba00" + logIndex: "0x17" + removed: false + topics: + - "0x3e799b2d61372379e767ef8f04d65089179b7a6f63f9be3065806456c7309f1b" + - "0x00000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72" + - "0x00000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72" + transactionHash: "0x02de07114d5c6e5a81e73e164b4cb623727024822318b300b93bad54482a6416" + transactionIndex: "0x22" + transactionLogIndex: "0x0" + type: "mined" + - + address: "0xeaa852323826c71cd7920c3b4c007184234c3945" + blockHash: "0xa3c56c1f5bf0fccab818b7722153737977b72b44ac10a8511ccb364da39f3582" + blockNumber: "0x452c23" + data: "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000010087a7811f4bfedea3d341ad165680ae306b01aaeacc205d227629cf157dd9f821000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000a329c0648769a73afac7f9381e08fb43dbea72000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000007be973a2f6ba00" + logIndex: "0x18" + removed: false + topics: + - "0x103fed9db65eac19c4d870f49ab7520fe03b99f1838e5996caf47e9e43308392" + - "0x0000000000000000000000000000000000000000000000000000000000002534" + - "0x000000000000000000000000b5505a6d998549090530911180f38ac5130101c6" + transactionHash: "0x02de07114d5c6e5a81e73e164b4cb623727024822318b300b93bad54482a6416" + transactionIndex: "0x22" + transactionLogIndex: "0x1" + type: mined + logsBloom: "0x00000000000000080000000080000000000000000000000000000000000000000000000000000000000400080000000000000000000000000000000000000000000000000000000050000002000000000000100000000000000000000000000000080000000000000000000000000010000000000000000000000000000000000000000010000000000000000000000004000000000000000000000000080000000000000200000000000000000000004000800000000800000000000000000000008000000000000000000000000002000000000000000000000000000000000000000000000020000000000000000000000000000000000000008000000000" + status: "0x1" + to: "0xbbd7cbfa79faee899eaf900f13c9065bf03b1a74" + transactionHash: "0x02de07114d5c6e5a81e73e164b4cb623727024822318b300b93bad54482a6416" + transactionIndex: "0x22" + + eth_sendRawTransaction: + config: + proof: 'none' + pk: "0x4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7" + chainId: 'goerli' + input: + - "0xf86d8206aa85438558d400825208941ebd5c8cfec45650cf9c80adfeb5488ae36859c3872386f26fc10000801ba06df6fc901a78cea1dfc02baead56c8ec0d8d008c505efcfc3b4462b1a659be25a065152fd2e0dbf04b8e1baac46f31df9033f9c72b9dfad1b4fe41f89ef32c9a53" + expected_output: "0x9c8024cc5a409df58f3949848f39c17d1e1d6e53bfe607adac77117fc2724fd2" + mockedResponses: + - eth_sendRawTransaction: + - res: + - + jsonrpc: "2.0" + result: "0x9c8024cc5a409df58f3949848f39c17d1e1d6e53bfe607adac77117fc2724fd2" \ No newline at end of file diff --git a/c/src/verifier/eth1/full/testCases.yml b/c/src/verifier/eth1/full/testCases.yml new file mode 100644 index 000000000..770f0fdb4 --- /dev/null +++ b/c/src/verifier/eth1/full/testCases.yml @@ -0,0 +1,29 @@ +eth: + + eth_estimateGas: + config: + proof: 'none' + input: + - + to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" + data: "0x18160ddd" + expected_output: 2000000 + mockedResponses: + - eth_estimateGas: + - res: + - + result: "0x1E8480" + + eth_call: + config: + proof: 'none' + input: + - + to: "0x2736D225f85740f42D17987100dc8d58e9e16252" + data: "0x5cf0f3570000000000000000000000000000000000000000000000000000000000000001" + expected_output: "0x00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000bc0ea09c1651a3d5d40bacb4356fb59159a99564000000000000000000000000000000000000000000000000000000000000ffff000000000000000000000000000000000000000000000000000000000000ffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002168747470733a2f2f696e332e736c6f636b2e69742f6d61696e6e65742f6e642d3400000000000000000000000000000000000000000000000000000000000000" + mockedResponses: + - eth_call: + - res: + - + result: "0x00000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000bc0ea09c1651a3d5d40bacb4356fb59159a99564000000000000000000000000000000000000000000000000000000000000ffff000000000000000000000000000000000000000000000000000000000000ffff000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002168747470733a2f2f696e332e736c6f636b2e69742f6d61696e6e65742f6e642d3400000000000000000000000000000000000000000000000000000000000000" diff --git a/c/src/verifier/eth1/nano/testCases.yml b/c/src/verifier/eth1/nano/testCases.yml new file mode 100644 index 000000000..47fe90b7d --- /dev/null +++ b/c/src/verifier/eth1/nano/testCases.yml @@ -0,0 +1,42 @@ +eth_tx_receipt: ð_tx_receipt + blockHash: '0x8220e66456e40636bff3a440832c9f179e4811d4e28269c7ab70142c3e5f9be2' + blockNumber: '0x8c2e8a' + contractAddress: null + cumulativeGasUsed: '0xa11af' + from: '0x3a9e354dee60df25c0389badafec8457e36ebfd2' + gasUsed: '0xa4b1' + logs: + - address: '0x5b8174e20996ec743f01d3b55a35dd376429c596' + blockHash: '0x8220e66456e40636bff3a440832c9f179e4811d4e28269c7ab70142c3e5f9be2' + blockNumber: '0x8c2e8a' + data: '0x000000000000000000000000000000000000000000000029097c413dfab40000' + logIndex: '0x1' + removed: false + topics: + - '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef' + - '0x0000000000000000000000003a9e354dee60df25c0389badafec8457e36ebfd2' + - '0x000000000000000000000000544d972d551061fc8e15e600f24f19021b8dfcfd' + transactionHash: '0x6188bf0672c005e30ad7c2542f2f048521662e30c91539d976408adf379bdae2' + transactionIndex: '0x1d' + transactionLogIndex: '0x0' + type: mined + logsBloom: >- + 0x00000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000010000000010004000000000000000000000000000000000000000000000000002000000000000000000000100000000000000000000000000000000000000000000000000000001002000000080000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000 + status: '0x1' + to: '0x5b8174e20996ec743f01d3b55a35dd376429c596' + transactionHash: '0x6188bf0672c005e30ad7c2542f2f048521662e30c91539d976408adf379bdae2' + transactionIndex: '0x1d' + +eth: + + eth_getTransactionReceipt: + config: + proof: 'none' + input: + - "0x6188bf0672c005e30ad7c2542f2f048521662e30c91539d976408adf379bdae2" + expected_output: *eth_tx_receipt + mockedResponses: + - eth_getTransactionReceipt: + - res: + - + result: *eth_tx_receipt \ No newline at end of file diff --git a/c/src/verifier/ipfs/testCases.yml b/c/src/verifier/ipfs/testCases.yml new file mode 100644 index 000000000..96f85f1f0 --- /dev/null +++ b/c/src/verifier/ipfs/testCases.yml @@ -0,0 +1,27 @@ +ipfs: + + ipfs_get: + config: + proof: 'none' + input: + - Qmb5Z7B4mCCRSBTtqzF8cvejA9UqiZ3EoZFPVh21Vx2UoH + - utf8 + expected_output: "I love Incubed" + mockedResponses: + - ipfs_get: + - res: + - + result: "I love Incubed" + + ipfs_put: + config: + proof: 'none' + input: + - "I love incubed" + - "utf8" + expected_output: "Qmb5Z7B4mCCRSBTtqzF8cvejA9UqiZ3EoZFPVh21Vx2UoH" + mockedResponses: + - ipfs_put: + - res: + - + result: "Qmb5Z7B4mCCRSBTtqzF8cvejA9UqiZ3EoZFPVh21Vx2UoH" \ No newline at end of file From 5ad6585eaa95ff8d3a62dcf871228d8d086cfa24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Tue, 29 Jun 2021 09:20:59 +0200 Subject: [PATCH 050/110] updated zksync-rpc-file --- c/src/pay/zksync/rpc.yml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/c/src/pay/zksync/rpc.yml b/c/src/pay/zksync/rpc.yml index 5df6ed25f..286bc354c 100644 --- a/c/src/pay/zksync/rpc.yml +++ b/c/src/pay/zksync/rpc.yml @@ -27,6 +27,16 @@ types: txHash: descr: the transactionHash, which can be used to track the tx type: string + tokenId: + descr: the token id + type: uint64 + validFrom: + descr: valid from + type: uint64 + validUntil: + descr: valid until + type: uint64 + zk_tx: accountId: @@ -65,6 +75,10 @@ types: signature: descr: the signature type: bytes + type: + descr: the transaction type + type: string + optional: true zk_history: tx_id: @@ -316,6 +330,7 @@ zksync: cmd: zcpm optional: true + # rpc zksync_contract_address: descr: returns the contract address @@ -403,6 +418,14 @@ zksync: pubKeyHash: descr: the pubKeyHash set for the requested account or `0x0000...` if not set yet. type: address + mintedNfts: + descr: the minted NFTs + key: the token + type: uint256 + nfts: + descr: the minted NFTs + key: the token + type: uint256 depositing: descr: the state of all depositing-tx. type: @@ -427,6 +450,14 @@ zksync: pubKeyHash: descr: the pubKeyHash set for the requested account or `0x0000...` if not set yet. type: address + mintedNfts: + descr: the minted NFTs + key: the token + type: uint256 + nfts: + descr: the minted NFTs + key: the token + type: uint256 example: cmdParams: -x -pk 0xe41d2489571d322189246dafa5ebde1f4699f498000000000000000000000000 response: @@ -523,6 +554,10 @@ zksync: tx: descr: the tx input data type: zk_tx + fail_reason: + descr: the fail reason + type: string + optional: true example: cmdParams: -x -zkr https://rinkeby-api.zksync.io/api/v0.1 @@ -1095,6 +1130,6 @@ zksync: - '0x0f61bfe164cc43b5a112bfbfb0583004e79dbfafc97a7daad14c5d511fea8e2435065ddd04329ec94be682bf004b03a5a4eeca9bf50a8b8b6023942adc0b3409' response: '0x9ce5b6f8db3fbbe66a3bdbd3b4731f19ec27f80ee03ead3c0708798dd949882b' - + From 869f4f154ddb353fad82efbce7253290e1910efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Tue, 29 Jun 2021 09:21:56 +0200 Subject: [PATCH 051/110] updated btc rpc.yaml --- c/src/verifier/btc/rpc.yml | 122 ++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/c/src/verifier/btc/rpc.yml b/c/src/verifier/btc/rpc.yml index 74dd4cb02..14c32ac6f 100644 --- a/c/src/verifier/btc/rpc.yml +++ b/c/src/verifier/btc/rpc.yml @@ -46,6 +46,95 @@ types: descr: The hash of the next block type: bytes32 + btcblocktransaction: + txid: + descr: txid + type: bytes32 + hex: + descr: The serialized, hex-encoded data for `txid` + type: bytes + hash: + descr: The transaction hash (differs from txid for witness transactions) + type: bytes32 + size: + descr: The serialized transaction size + type: uint64 + vsize: + descr: The virtual transaction size (differs from size for witness transactions) + type: uint64 + weight: + descr: The transaction's weight (between `vsize`\*4-3 and `vsize`\*4) + type: uint64 + version: + descr: The version + type: int + locktime: + descr: The lock time + type: uint64 + vin: + descr: array of json objects of incoming txs to be used + array: true + type: + txid: + descr: the transaction id + type: bytes32 + optional: true + vout: + descr: the index of the transaction out to be used + type: uint64 + optional: true + scriptSig: + descr: the script + type: + asm: + descr: the asm-codes + type: string + hex: + descr: hex representation + type: string + optional: true + sequence: + descr: The script sequence number + type: uint64 + txinwitness: + array: true + descr: hex-encoded witness data (if any) + type: string + optional: true + coinbase: + descr: the coinbase + type: bytes32 + optional: true + vout: + descr: array of json objects describing the tx outputs + array: true + type: + value: + descr: The Value in BTC + type: float + n: + descr: the index + type: int + scriptPubKey: + descr: the script pubkey + type: + asm: + descr: asm + type: string + hex: + descr: hex representation of the script + type: string + reqSigs: + descr: the required signatures + type: int + type: + descr: The type, eg 'pubkeyhash' + type: string + addresses: + descr: Array of address(each representing a bitcoin adress) + array: true + type: string + btctransaction: txid: descr: txid @@ -53,6 +142,7 @@ types: in_active_chain: descr: Whether specified block is in the active chain or not (only present with explicit "blockhash" argument) type: bool + optional: true hex: descr: The serialized, hex-encoded data for `txid` type: bytes @@ -77,13 +167,15 @@ types: vin: descr: array of json objects of incoming txs to be used array: true - type: + type: txid: descr: the transaction id type: bytes32 + optional: true vout: descr: the index of the transaction out to be used type: uint64 + optional: true scriptSig: descr: the script type: @@ -93,6 +185,7 @@ types: hex: descr: hex representation type: string + optional: true sequence: descr: The script sequence number type: uint64 @@ -100,6 +193,11 @@ types: array: true descr: hex-encoded witness data (if any) type: string + optional: true + coinbase: + descr: the coinbase + type: bytes32 + optional: true vout: descr: array of json objects describing the tx outputs array: true @@ -185,13 +283,22 @@ types: tx: descr: the array of transactions either as ids (verbose=1) or full transaction (verbose=2) array: true - type: btctransaction + type: btcblocktransaction previousblockhash: descr: The hash of the previous block type: bytes32 nextblockhash: descr: The hash of the next block type: bytes32 + strippedsize: + descr: The block size excluding witness data + type: int + weight: + descr: The block weight as defined in BIP 141 + type: int + size: + descr: The block size + type: int btcblock: hash: @@ -202,7 +309,7 @@ types: type: int height: descr: The block height or index - type: uint256 + type: uint64 version: descr: The block version type: int @@ -243,6 +350,15 @@ types: nextblockhash: descr: The hash of the next block type: bytes32 + strippedsize: + descr: The block size excluding witness data + type: int + weight: + descr: The block weight as defined in BIP 141 + type: int + size: + descr: The block size + type: int btc: descr: | From b0ffb2f75afed73dab912cbec85f065980feada4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Tue, 29 Jun 2021 09:24:54 +0200 Subject: [PATCH 052/110] updated rpc for nano --- c/src/verifier/eth1/nano/rpc.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/c/src/verifier/eth1/nano/rpc.yml b/c/src/verifier/eth1/nano/rpc.yml index 37a7ee990..4025b17eb 100644 --- a/c/src/verifier/eth1/nano/rpc.yml +++ b/c/src/verifier/eth1/nano/rpc.yml @@ -71,6 +71,13 @@ types: transactionIndex: descr: transactionIndex within the containing block. type: int + from: + descr: address of the sender. + type: address + to: + descr: address of the receiver. null when its a contract creation transaction. + type: address + optional: true eth: descr: | From 7157ae22d868c7162d79dcf7391b1ed5bd7ec041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Tue, 29 Jun 2021 09:35:24 +0200 Subject: [PATCH 053/110] updated generate script --- scripts/generator/generate.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/generator/generate.js b/scripts/generator/generate.js index 83bdb30e1..df3425f62 100755 --- a/scripts/generator/generate.js +++ b/scripts/generator/generate.js @@ -42,7 +42,7 @@ const main_help = [] const main_aliases = [] const bool_props = [] -let docs = {}, config = {}, types = {} +let docs = {}, config = {}, types = {}, testCases = {} function scan(dir) { @@ -68,6 +68,13 @@ function scan(dir) { lastAPI = k } } + else if(f.name == 'testCases.yml'){ + console.error('parse ' + dir + '/' + f.name) + const ob = yaml.parse(fs.readFileSync(dir + '/' + f.name, 'utf-8')) + for (const k of Object.keys(ob)) { + testCases[k]={...testCases[k],...ob[k]} + } + } else if (f.isDirectory()) scan(dir + '/' + f.name) } } @@ -260,7 +267,7 @@ for (const s of Object.keys(docs).sort()) { console.log('generate ' + s + '\n ' + Object.keys(rpcs).join('\n ')) if (Object.values(rpcs).filter(_ => !_.skipApi).length) - generators.forEach(_ => _.generateAPI(s, rpcs, rdescr, types)) + generators.forEach(_ => _.generateAPI(s, rpcs, rdescr, types, testCases[s])) } From 384a9f2ccda34654f7c647abc63b782833aa32a7 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 29 Jun 2021 12:12:56 +0200 Subject: [PATCH 054/110] fix fromWei --- c/src/api/eth1/rpc.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/src/api/eth1/rpc.yml b/c/src/api/eth1/rpc.yml index 0919200a6..903066e1b 100644 --- a/c/src/api/eth1/rpc.yml +++ b/c/src/api/eth1/rpc.yml @@ -109,13 +109,13 @@ utils: optional: true result: descr: the value as string. - type: string + type: double example: request: - "0x234324abadefdef" - eth - 3 - response: "0.158" + response: 0.158 in3_calcDeployAddress: descr: calculates the address of a contract about to deploy. The address depends on the senders nonce. From 4fc5c8d97396d00487ab55a0f4b1fb447895511f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Tue, 29 Jun 2021 14:51:33 +0200 Subject: [PATCH 055/110] testCases for account --- c/src/api/eth1/rpc.yml | 67 ++++++++++++++++++-- c/src/api/eth1/testCases.yml | 116 ++++++++++++++++++++++++++++++++++- 2 files changed, 177 insertions(+), 6 deletions(-) diff --git a/c/src/api/eth1/rpc.yml b/c/src/api/eth1/rpc.yml index 0919200a6..9a4e2f901 100644 --- a/c/src/api/eth1/rpc.yml +++ b/c/src/api/eth1/rpc.yml @@ -1,3 +1,57 @@ +types: + keyparams: + version: + descr: the version + type: string + id: + descr: the id + type: string + address: + descr: the address + type: string + crypto: + descr: the cryptoparams + type: cryptoParams + + cryptoParams: + ciphertext: + descr: the cipher text + type: string + cipherparams: + descr: the cipherparams + type: cipherParams + cipher: + descr: the cipher + type: string + kdf: + descr: the kdf + type: string + kdfparams: + descr: the kdfparams + type: kdfParams + mac: + descr: the mac + type: string + + cipherParams: + iv: + descr: the iv + type: string + + kdfParams: + dklen: + descr: the dklen + type: uint64 + salt: + descr: the salt + type: string + c: + descr: the c + type: uint64 + prf: + descr: the prf + type: string + utils: descr: | @@ -109,13 +163,13 @@ utils: optional: true result: descr: the value as string. - type: string + type: float example: request: - "0x234324abadefdef" - eth - 3 - response: "0.158" + response: 0.158 in3_calcDeployAddress: descr: calculates the address of a contract about to deploy. The address depends on the senders nonce. @@ -282,7 +336,7 @@ account: type: bytes32 v: descr: the recovery value (0|1) + 27 - type: byte + type: uint32 example: request: @@ -302,8 +356,11 @@ account: descr: decrypts a JSON Keystore file as defined in the [Web3 Secret Storage Definition](https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition). The result is the raw private key. params: key: - descr: Keydata as object as defined in the keystorefile - type: string + type: keyparams + descr: the keyparams + + # descr: Keydata as object as defined in the keystorefile + # type: string passphrase: descr: the password to decrypt it. type: string diff --git a/c/src/api/eth1/testCases.yml b/c/src/api/eth1/testCases.yml index 9fd91edd5..4147eb77d 100644 --- a/c/src/api/eth1/testCases.yml +++ b/c/src/api/eth1/testCases.yml @@ -29,4 +29,118 @@ utils: - "0x234324abadefdef" - eth - 3 - expected_output: "0.158" \ No newline at end of file + expected_output: "0.158" + + in3_calcDeployAddress: + input: + - "0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c" + - 6054986 + expected_output: "0xba866e7bd2573be3eaf5077b557751bb6d58076e" + +account: + + in3_pk2address: + input: + - "0x0fd65f7da55d811634495754f27ab318a3309e8b4b8a978a50c20a661117435a" + expected_output: "0xdc5c4280d8a286f0f9c8f7f55a5a0c67125efcfd" + + in3_pk2public: + input: + - "0x0fd65f7da55d811634495754f27ab318a3309e8b4b8a978a50c20a661117435a" + expected_output: "0x0903329708d9380aca47b02f3955800179e18bffbb29be3a644593c5f87e4c7fa960983f78186577eccc909cec71cb5763acd92ef4c74e5fa3c43f3a172c6de1" + + in3_ecrecover: + input: + - "0x487b2cbb7997e45b4e9771d14c336b47c87dc2424b11590e32b3a8b9ab327999" + - "0x0f804ff891e97e8a1c35a2ebafc5e7f129a630a70787fb86ad5aec0758d98c7b454dee5564310d497ddfe814839c8babd3a727692be40330b5b41e7693a445b71c" + - "hash" + expected_output: + publicKey: "0x94b26bafa6406d7b636fbb4de4edd62a2654eeecda9505e9a478a66c4f42e504c4481bad171e5ba6f15a5f11c26acfc620f802c6768b603dbcbe5151355bbffb" + address: "0xf68a4703314e9a9cf65be688bd6d9b3b34594ab4" + + in3_prepareTx: + config: + proof: 'none' + input: + - to: "0x63f666a23cbd135a91187499b5cc51d589c302a0" + value: "0x100000000" + from: "0xc2b2f4ad0d234b8c135c39eea8409b448e5e496f" + expected_output: "0xe480808252089463f666a23cbd135a91187499b5cc51d589c302a085010000000080018080" + mockedResponses: + - eth_getTransactionCount: + - res: + - + result: "0x0" + - eth_gasPrice: + - res: + - + result: "0x0" + + in3_signTx: + config: + proof: "none" + pk: "0xe20eb92b34a3c5bd2ef0802a4bc443a90e73fc4a0edc4781446d7b22a44cc5d8" + input: + - "0xe480808252089463f666a23cbd135a91187499b5cc51d589c302a085010000000080018080" + - "0x8A91DC2D28b689474298D91899f0c1baF62cB85b" + expected_output: "0xf86480808252089463f666a23cbd135a91187499b5cc51d589c302a08501000000008025a04c2539db491cd2b4fa0c54a81351aacd726e2460b43718f39300b0bf812eb0eba02913c456e34e5735333d8b39193775aac0e59c9179aaa7fd539571f0f319d594" + + in3_signData: + config: + proof: "none" + pk: "0xe20eb92b34a3c5bd2ef0802a4bc443a90e73fc4a0edc4781446d7b22a44cc5d8" + input: + - "0x0102030405060708090a0b0c0d0e0f" + - "0xa8b8759ec8b59d7c13ef3630e8530f47ddb47eba12f00f9024d3d48247b62852" + - "raw" + expected_output: + message: "0x0102030405060708090a0b0c0d0e0f" + messageHash: "0x1d4f6fccf1e27711667605e29b6f15adfda262e5aedfc5db904feea2baa75e67" + signature: "0xa5dea9537d27e4e20b6dfc89fa4b3bc4babe9a2375d64fb32a2eab04559e95792264ad1fb83be70c145aec69045da7986b95ee957fb9c5b6d315daa5c0c3e1521b" + r: "0xa5dea9537d27e4e20b6dfc89fa4b3bc4babe9a2375d64fb32a2eab04559e9579" + s: "0x2264ad1fb83be70c145aec69045da7986b95ee957fb9c5b6d315daa5c0c3e152" + v: 27 + + in3_decryptKey: + input: + - version: 3, + id: "f6b5c0b1-ba7a-4b67-9086-a01ea54ec638" + address: "08aa30739030f362a8dd597fd3fcde283e36f4a1" + crypto: + ciphertext: "d5c5aafdee81d25bb5ac4048c8c6954dd50c595ee918f120f5a2066951ef992d" + cipherparams: + iv: "415440d2b1d6811d5c8a3f4c92c73f49" + cipher: "aes-128-ctr" + kdf: pbkdf2 + kdfparams: + dklen: 32 + salt: "691e9ad0da2b44404f65e0a60cf6aabe3e92d2c23b7410fd187eeeb2c1de4a0d" + c: 16384 + prf: hmac-sha256 + mac: "de651c04fc67fd552002b4235fa23ab2178d3a500caa7070b554168e73359610" + - "test" + expected_output: "0x1ff25594a5e12c1e31ebd8112bdf107d217c1393da8dc7fc9d57696263457546" + + eth_sign: + config: + proof: "none" + pk: "0xe20eb92b34a3c5bd2ef0802a4bc443a90e73fc4a0edc4781446d7b22a44cc5d8" + input: + - "0x8A91DC2D28b689474298D91899f0c1baF62cB85b" + - "0xdeadbeaf" + expected_output: "0xcbb6128a29ae206532e206d9e5cb4155d34bd82a1c1db0faf7c77230febb004d0a12270bf192d501f954e01ebf67c1a29d4972543888dad1b60933a7a2cd7af91b" + + eth_signTransaction: + config: + proof: 'none' + pk: "0x4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7" + chainId: 'goerli' + input: + - + from: "0x00a329c0648769a73afac7f9381e08fb43dbea72" + to: "0x2c055df8d095a98099dc8942510a65d51480840e" + data: "0x" + value: "15023483000000000" + gasPrice: 1000000000 + nonce: 32 + expected_output: "0xf86a20843b9aca00825208942c055df8d095a98099dc8942510a65d51480840e87355fc737810e00802da0fd2f892a7d154aa699ead599152d93674765eef4e6c384ffbc50db394ec3e3cea055ce9aee6e61256f7efaa9c714e4c342e21074d900f1d8399be720c56cc5f415" \ No newline at end of file From 06affdaadb85b40283aa85ba6d3c31eea04baa94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Tue, 29 Jun 2021 16:46:39 +0200 Subject: [PATCH 056/110] removed debug --- c/src/pay/zksync/testCases.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/c/src/pay/zksync/testCases.yml b/c/src/pay/zksync/testCases.yml index fd46f7eab..0248fab64 100644 --- a/c/src/pay/zksync/testCases.yml +++ b/c/src/pay/zksync/testCases.yml @@ -790,7 +790,6 @@ zksync: proof: 'none' experimental: true pk: "0xf5f297cd9e2f7e02944e283bc920075a98c8250ca8fe4576743b1e8e044abee9" - debug: true zksync: rest_api: "https://rinkeby-api.zksync.io/api/v0.1" input: From 153ac2a1586c06b79068bde71726f774c1ed133a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 30 Jun 2021 13:42:03 +0200 Subject: [PATCH 057/110] update typeNames --- c/src/api/eth1/rpc.yml | 6 ++-- c/src/nodeselect/full/rpc.yml | 5 +++- c/src/pay/zksync/rpc.yml | 21 ++++++++++++-- c/src/verifier/btc/rpc.yml | 9 ++++++ c/src/verifier/eth1/basic/rpc.yml | 47 ++++++++++++++++--------------- c/src/verifier/eth1/full/rpc.yml | 4 +-- c/src/verifier/eth1/nano/rpc.yml | 4 +-- 7 files changed, 64 insertions(+), 32 deletions(-) diff --git a/c/src/api/eth1/rpc.yml b/c/src/api/eth1/rpc.yml index 457b69854..02214d3ea 100644 --- a/c/src/api/eth1/rpc.yml +++ b/c/src/api/eth1/rpc.yml @@ -244,6 +244,7 @@ account: optional: true result: descr: the extracted public key and address + typeName: ECRecoverResult type: publicKey: descr: the public Key of the signer (64 bytes) @@ -265,7 +266,7 @@ account: params: tx: descr: the tx-object, which is the same as specified in [eth_sendTransaction](https://eth.wiki/json-rpc/API#eth_sendTransaction). - type: transaction + type: eth_transaction result: descr: the unsigned raw transaction as hex. @@ -311,6 +312,7 @@ account: result: descr: the signature + typeName: SignResult type: message: descr: original message used @@ -411,7 +413,7 @@ account: params: tx: descr: transaction to sign - type: transaction + type: eth_transaction result: descr: the raw signed transaction example: diff --git a/c/src/nodeselect/full/rpc.yml b/c/src/nodeselect/full/rpc.yml index 2c137d18a..58dd1249d 100644 --- a/c/src/nodeselect/full/rpc.yml +++ b/c/src/nodeselect/full/rpc.yml @@ -153,7 +153,7 @@ nodelist: descr: the current nodelist type: nodes: - typeName: Node + typeName: IN3Node array: true descr: a array of node definitions. type: @@ -358,6 +358,7 @@ nodelist: params: blocks: descr: array of requested blocks. + typeName: In3SignBlock type: blockNumber: descr: the blockNumber to sign @@ -369,6 +370,7 @@ nodelist: result: descr: the Array with signatures of all the requires blocks. + typeName: In3SignedBlockHash type: blockHash: descr: the blockhash which was signed. @@ -407,6 +409,7 @@ nodelist: type: address result: descr: the whitelisted addresses + typeName: In3WhiteList type: nodes: descr: array of whitelisted nodes addresses. diff --git a/c/src/pay/zksync/rpc.yml b/c/src/pay/zksync/rpc.yml index 286bc354c..23ed810f9 100644 --- a/c/src/pay/zksync/rpc.yml +++ b/c/src/pay/zksync/rpc.yml @@ -68,6 +68,7 @@ types: type: uint64 signature: descr: the sync signature + typeName: ZkTxSignature type: pubKey: descr: the public key of the signer @@ -114,6 +115,7 @@ types: type: string tx: descr: the transaction data + typeName: ZkTxHistoryInput type: type: descr: Type of the transaction. `Transfer`, `ChangePubKey` or `Withdraw` @@ -157,6 +159,7 @@ types: signature: optional: true descr: the sync signature + typeName: ZkTxSignature type: pubKey: descr: the public key of the signer @@ -179,6 +182,7 @@ types: priority_op: descr: the description of a priority operation like `Deposit` optional: true + typeName: ZkTxHistoryPriorityOp type: from: descr: The sender of the address @@ -195,6 +199,7 @@ types: ethAuthData: descr: the 2fa euth authorition optional: true + typeName: ZkTxHistoryEthAuthData type: type: descr: the type which should be CREATE2, ECDSA @@ -336,6 +341,7 @@ zksync: descr: returns the contract address result: descr: fetches the contract addresses from the zksync server. This request also caches them and will return the results from cahe if available. + typeName: ZkSyncContractDefinition type: govContract: descr: the address of the govement contract @@ -355,6 +361,7 @@ zksync: result: key: token symbol descr: a array of tokens-definitions. This request also caches them and will return the results from cahe if available. + typeName: ZkSyncToken type: address: descr: the address of the ERC2-Contract or 0x00000..000 in case of the native token (eth) @@ -401,12 +408,14 @@ zksync: optional: true result: descr: the current state of the requested account. + typeName: ZkSyncAccountInfo type: address: descr: the address of the account type: address committed: descr: the state of the zksync operator after executing transactions successfully, but not not verified on L1 yet. + typeName: ZkSyncAccountState type: balances: descr: the token-balance @@ -428,6 +437,7 @@ zksync: type: uint256 depositing: descr: the state of all depositing-tx. + typeName: ZkSyncAccountInfoDepositing type: balances: descr: the token-values. @@ -439,6 +449,7 @@ zksync: optional: true verified: descr: the state after the rollup was verified in L1. + typeName: ZkSyncAccountState type: balances: descr: the token-balances. @@ -483,6 +494,7 @@ zksync: type: bytes32 result: descr: the current state of the requested tx. + typeName: ZkSyncTxInfo type: block: descr: the blockNumber containing the tx or `null` if still pending @@ -518,6 +530,7 @@ zksync: type: bytes32 result: descr: the data and state of the requested tx. + typeName: ZkSyncTxData type: block_number: descr: the blockNumber containing the tx or `null` if still pending @@ -840,9 +853,11 @@ zksync: type: uint64 result: descr: state of the PriorityOperation + typeName: ZkSyncEthopInfo type: block: descr: the block + typeName: ZkSyncEthopInfoBlock type: committed: descr: state of the operation @@ -898,6 +913,7 @@ zksync: type: string result: descr: the fees split up into single values + typeName: ZkSyncFeeInfo type: feeType: descr: Type of the transaaction @@ -958,10 +974,11 @@ zksync: optional: true result: descr: the receipt and the receipopId. You can use `zksync_ethop_info` to follow the state-changes. + typeName: ZkSyncDepositResult type: receipt: descr: the transactionreceipt - type: transactionReceipt + type: eth_transactionReceipt priorityOpId: descr: the operationId to rack to progress type: uint64 @@ -1082,7 +1099,7 @@ zksync: type: string result: descr: the transactionReceipt - type: transactionReceipt + type: eth_transactionReceipt example: cmdParams: -x -pk 0xb0f60e4783ccc1f6234deed9e21f16d460c4176fd7adbd4f31d17e283b8cfb1c request: diff --git a/c/src/verifier/btc/rpc.yml b/c/src/verifier/btc/rpc.yml index 14c32ac6f..4e87e1ec9 100644 --- a/c/src/verifier/btc/rpc.yml +++ b/c/src/verifier/btc/rpc.yml @@ -72,6 +72,7 @@ types: descr: The lock time type: uint64 vin: + typeName: BtcTxVin descr: array of json objects of incoming txs to be used array: true type: @@ -85,6 +86,7 @@ types: optional: true scriptSig: descr: the script + typeName: BtcTxScriptSig type: asm: descr: the asm-codes @@ -108,6 +110,7 @@ types: vout: descr: array of json objects describing the tx outputs array: true + typeName: BtcTxVout type: value: descr: The Value in BTC @@ -117,6 +120,7 @@ types: type: int scriptPubKey: descr: the script pubkey + typeName: BtcTxScriptPubKey type: asm: descr: asm @@ -165,6 +169,7 @@ types: descr: The lock time type: uint64 vin: + typeName: BtcTxVin descr: array of json objects of incoming txs to be used array: true type: @@ -177,6 +182,7 @@ types: type: uint64 optional: true scriptSig: + typeName: BtcTxScriptSig descr: the script type: asm: @@ -199,6 +205,7 @@ types: type: bytes32 optional: true vout: + typeName: BtcTxVout descr: array of json objects describing the tx outputs array: true type: @@ -210,6 +217,7 @@ types: type: int scriptPubKey: descr: the script pubkey + typeName: BtcTxScriptPubKey type: asm: descr: asm @@ -905,6 +913,7 @@ btc: result: array: true + typeName: BtcProofTargetResult type: dap: descr: the difficulty adjustement period diff --git a/c/src/verifier/eth1/basic/rpc.yml b/c/src/verifier/eth1/basic/rpc.yml index ec6857634..f4ce0668b 100644 --- a/c/src/verifier/eth1/basic/rpc.yml +++ b/c/src/verifier/eth1/basic/rpc.yml @@ -1,6 +1,6 @@ types: - transaction: + eth_transaction: to: descr: receipient of the transaction. type: address @@ -40,7 +40,7 @@ types: optional: true - blockheader: + eth_blockheader: number: descr: the block number. `null` when its pending block. type: uint64 @@ -98,21 +98,21 @@ types: array: true type: bytes32 - blockdataWithTxHashes: - _extends: blockheader + eth_blockdataWithTxHashes: + _extends: eth_blockheader transactions: descr: Array of transaction hashes array: true type: bytes32 - blockdata: - _extends: blockheader + eth_blockdata: + _extends: eth_blockheader transactions: descr: Array of transaction objects array: true - type: transactiondata + type: eth_transactiondata - transactiondata: + eth_transactiondata: to: descr: receipient of the transaction. type: address @@ -195,15 +195,15 @@ eth: name: getBlock descr: returns the given Block by number with transactionHashes. if no blocknumber is specified the latest block will be returned. result: - type: blockdataWithTxHashes + type: eth_blockdataWithTxHashes - params: fullTx: true name: getBlockWithTx descr: returns the given Block by number with full transaction data. if no blocknumber is specified the latest block will be returned. result: - type: blockdata + type: eth_blockdata descr: the blockdata, or in case the block with that number does not exist, `null` will be returned. - type: blockdata + type: eth_blockdata example: @@ -326,15 +326,15 @@ eth: name: getBlockByHash descr: returns the given Block by hash with transactionHashes result: - type: blockdataWithTxHashes + type: eth_blockdataWithTxHashes - params: fullTx: true name: getBlockByHashWithTx descr: returns the given Block by hash with full transaction data result: - type: blockdata + type: eth_blockdata descr: the blockdata, or in case the block with that number does not exist, `null` will be returned. - type: blockdata + type: eth_blockdata proof: alias: eth_getBlockByNumber @@ -459,7 +459,7 @@ eth: result: optional: true descr: the transactiondata or `null` if it does not exist - type: transactiondata + type: eth_transactiondata proof: alias: eth_getTransactionByHash @@ -485,7 +485,7 @@ eth: s: '0x6b530c2613f543f9e26ef9c27a7986c748fbc856aaeacd6000a8ff46d2a2dd78' in3: proof: - type: transactionProof + type: eth_transactionProof block: '0xf90212a033a7afd1b9...fa16cf2' merkleProof: - '0xf90131a0...91604f2f58080808080808080' @@ -512,7 +512,7 @@ eth: result: optional: true descr: the transactiondata or `null` if it does not exist - type: transactiondata + type: eth_transactiondata proof: alias: eth_getTransactionByHash @@ -538,7 +538,7 @@ eth: s: '0x6b530c2613f543f9e26ef9c27a7986c748fbc856aaeacd6000a8ff46d2a2dd78' in3: proof: - type: transactionProof + type: eth_transactionProof block: '0xf90212a033a7afd1b9...fa16cf2' merkleProof: - '0xf90131a0...91604f2f58080808080808080' @@ -562,7 +562,7 @@ eth: result: optional: true descr: the transactiondata or `null` if it does not exist - type: transactiondata + type: eth_transactiondata example: @@ -586,7 +586,7 @@ eth: s: '0x6b530c2613f543f9e26ef9c27a7986c748fbc856aaeacd6000a8ff46d2a2dd78' in3: proof: - type: transactionProof + type: eth_transactionProof block: '0xf90212a033a7afd1b9...fa16cf2' merkleProof: - '0xf90131a0...91604f2f58080808080808080' @@ -736,6 +736,7 @@ eth: params: filter: descr: The filter criteria for the events. + typeName: EthLogFilter type: fromBlock: descr: Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions. @@ -1115,7 +1116,7 @@ eth: params: tx: descr: the transactiondata to send - type: transaction + type: eth_transaction result: descr: the transactionHash proof: @@ -1126,10 +1127,10 @@ eth: params: tx: descr: the transactiondata to send - type: transaction + type: eth_transaction result: descr: the transactionReceipt - type: transactionReceipt + type: eth_transactionReceipt eth_sendRawTransaction: diff --git a/c/src/verifier/eth1/full/rpc.yml b/c/src/verifier/eth1/full/rpc.yml index b83d1d2f8..6e55fb2f9 100644 --- a/c/src/verifier/eth1/full/rpc.yml +++ b/c/src/verifier/eth1/full/rpc.yml @@ -5,7 +5,7 @@ eth: params: tx: descr: the tx-object, which is the same as specified in [eth_sendTransaction](https://eth.wiki/json-rpc/API#eth_sendTransaction). - type: transaction + type: eth_transaction block: internalDefault : latest optionalAPI: true @@ -24,7 +24,7 @@ eth: params: tx: descr: the tx-object, which is the same as specified in [eth_sendTransaction](https://eth.wiki/json-rpc/API#eth_sendTransaction). - type: transaction + type: eth_transaction block: internalDefault : latest optionalAPI: true diff --git a/c/src/verifier/eth1/nano/rpc.yml b/c/src/verifier/eth1/nano/rpc.yml index 4025b17eb..da430cf7c 100644 --- a/c/src/verifier/eth1/nano/rpc.yml +++ b/c/src/verifier/eth1/nano/rpc.yml @@ -38,7 +38,7 @@ types: type: string optional: true - transactionReceipt: + eth_transactionReceipt: blockNumber: descr: the blockNumber type: uint64 @@ -116,7 +116,7 @@ eth: result: optional: true descr: the TransactionReceipt or `null` if it does not exist. - type: transactionReceipt + type: eth_transactionReceipt example: request: From 1b9999ac72b28d783a736ca47462ecef9e4c6e21 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 30 Jun 2021 23:53:02 +0200 Subject: [PATCH 058/110] fix fail_reason --- c/src/pay/zksync/rpc.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/c/src/pay/zksync/rpc.yml b/c/src/pay/zksync/rpc.yml index 23ed810f9..892ccbf90 100644 --- a/c/src/pay/zksync/rpc.yml +++ b/c/src/pay/zksync/rpc.yml @@ -536,10 +536,6 @@ zksync: descr: the blockNumber containing the tx or `null` if still pending type: uint64 optional: true - failReason: - descr: if executed and failed this will include an error message - type: string - optional: true tx_type: descr: Type of the transaction. `Transfer`, `ChangePubKey` or `Withdraw` type: string From 794ebe789353c0d7506f4b255bc39d33d42b651d Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 1 Jul 2021 22:54:02 +0200 Subject: [PATCH 059/110] add param macro --- c/src/core/util/debug.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/c/src/core/util/debug.h b/c/src/core/util/debug.h index 04abd97aa..c21721c6d 100644 --- a/c/src/core/util/debug.h +++ b/c/src/core/util/debug.h @@ -173,6 +173,28 @@ static inline void add_hex(sb_t* sb, char prefix, const char* property, bytes_t if (!(cond)) return req_set_error(ctx, "argument at index " #index " must match " #cond, IN3_EINVAL); \ } +#define TRY_PARAM_GET_INT(target, ctx, index, def) \ + { \ + const d_token_t* t = d_get_at(ctx->params, index); \ + if (d_type(t) == T_NULL) \ + target = def; \ + else if (d_type(t) != T_INTEGER) \ + return req_set_error(ctx->req, "Param at " #index " must be an integer!", IN3_EINVAL); \ + else \ + target = d_int(t); \ + } + +#define TRY_PARAM_GET_ADDRESS(target, ctx, index, def) \ + { \ + const d_token_t* t = d_get_at(ctx->params, index); \ + if (d_type(t) == T_NULL) \ + target = def; \ + else if (d_type(t) != T_BYTES || d_len(t) != 20) \ + return req_set_error(ctx->req, "Param at " #index " must be a valid address!", IN3_EINVAL); \ + else \ + target = t->data; \ + } + /** used for exeuting a function based on the name. This macro will return if the name matches. */ #endif /* DEBUG_H */ \ No newline at end of file From e5a0ec85886e83ba1e4bc5efb1bdf937bec990bc Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 1 Jul 2021 22:54:12 +0200 Subject: [PATCH 060/110] fix generator --- scripts/generator/generate.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/generator/generate.js b/scripts/generator/generate.js index df3425f62..c42bd70c0 100755 --- a/scripts/generator/generate.js +++ b/scripts/generator/generate.js @@ -60,7 +60,7 @@ function scan(dir) { delete ob[k].config if (!generators.length && ob[k].fields && lastAPI) { delete ob[k].fields - for (const n of Object.keys(ob[k]).filter(_ => !docs[lastAPI][_])) delete ob[k][n] + for (const n of Object.keys(ob[k]).filter(_ => docs[lastAPI][_])) delete ob[k][n] docs[lastAPI] = { ...docs[lastAPI], ...ob[k] } } else @@ -68,11 +68,11 @@ function scan(dir) { lastAPI = k } } - else if(f.name == 'testCases.yml'){ + else if (f.name == 'testCases.yml') { console.error('parse ' + dir + '/' + f.name) const ob = yaml.parse(fs.readFileSync(dir + '/' + f.name, 'utf-8')) for (const k of Object.keys(ob)) { - testCases[k]={...testCases[k],...ob[k]} + testCases[k] = { ...testCases[k], ...ob[k] } } } else if (f.isDirectory()) scan(dir + '/' + f.name) @@ -184,7 +184,7 @@ for (const s of Object.keys(docs).sort()) { if (rdescr) rpc_doc.push(rdescr + '\n') delete rpcs.descr - for (const rpc of Object.keys(rpcs).filter(_ => _ != 'fields').sort()) { + for (const rpc of Object.keys(rpcs).filter(_ => _ != 'fields' && !_.startsWith('_')).sort()) { const def = rpcs[rpc] def.returns = def.returns || def.result def.result = def.returns || def.result From 33a0745490c50ab2868e23fd05c7c6331ee94661 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 2 Jul 2021 09:39:00 +0200 Subject: [PATCH 061/110] added helper eth_create_prefixed_msg_hash --- c/src/signer/pk-signer/signer.c | 22 +++++++++++++--------- c/src/signer/pk-signer/signer.h | 2 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/c/src/signer/pk-signer/signer.c b/c/src/signer/pk-signer/signer.c index 84ef932f7..046645950 100644 --- a/c/src/signer/pk-signer/signer.c +++ b/c/src/signer/pk-signer/signer.c @@ -90,6 +90,17 @@ static bool add_key(in3_t* c, bytes32_t pk) { return true; } +void eth_create_prefixed_msg_hash(bytes32_t dst, bytes_t msg) { + struct SHA3_CTX kctx; + sha3_256_Init(&kctx); + const char* PREFIX = "\x19" + "Ethereum Signed Message:\n"; + sha3_Update(&kctx, (uint8_t*) PREFIX, strlen(PREFIX)); + sha3_Update(&kctx, dst, sprintf((char*) dst, "%d", (int) msg.len)); + if (msg.len) sha3_Update(&kctx, msg.data, msg.len); + keccak_Final(&kctx, dst); +} + static in3_ret_t eth_sign_pk(void* data, in3_plugin_act_t action, void* action_ctx) { signer_key_t* k = data; switch (action) { @@ -102,15 +113,8 @@ static in3_ret_t eth_sign_pk(void* data, in3_plugin_act_t action, void* action_c return ec_sign_pk_raw(ctx->message.data, k->pk, ctx->signature.data); case SIGN_EC_PREFIX: { - bytes32_t hash; - struct SHA3_CTX kctx; - sha3_256_Init(&kctx); - const char* PREFIX = "\x19" - "Ethereum Signed Message:\n"; - sha3_Update(&kctx, (uint8_t*) PREFIX, strlen(PREFIX)); - sha3_Update(&kctx, hash, sprintf((char*) hash, "%d", (int) ctx->message.len)); - if (ctx->message.len) sha3_Update(&kctx, ctx->message.data, ctx->message.len); - keccak_Final(&kctx, hash); + bytes32_t hash; + eth_create_prefixed_msg_hash(hash, ctx->message); return ec_sign_pk_raw(hash, k->pk, ctx->signature.data); } case SIGN_EC_HASH: diff --git a/c/src/signer/pk-signer/signer.h b/c/src/signer/pk-signer/signer.h index 5e5a02dc4..efa941c83 100644 --- a/c/src/signer/pk-signer/signer.h +++ b/c/src/signer/pk-signer/signer.h @@ -88,6 +88,8 @@ in3_ret_t ec_sign_pk_hash(uint8_t* message, size_t len, uint8_t* pk, hasher_t ha /** Signs message raw with the given private key*/ in3_ret_t ec_sign_pk_raw(uint8_t* message, uint8_t* pk, uint8_t* dst); +/** hashes the msg by adding the Ethereum Signed Message-Prefix */ +void eth_create_prefixed_msg_hash(bytes32_t dst, bytes_t msg); #ifdef __cplusplus } #endif From 6dd882aed95f38962cbdaa429c5d1b864174bb41 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Jul 2021 09:20:04 +0200 Subject: [PATCH 062/110] fix NONULL --- c/src/verifier/eth1/basic/eth_basic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/verifier/eth1/basic/eth_basic.h b/c/src/verifier/eth1/basic/eth_basic.h index 4d24efc44..070a82574 100644 --- a/c/src/verifier/eth1/basic/eth_basic.h +++ b/c/src/verifier/eth1/basic/eth_basic.h @@ -149,6 +149,6 @@ RETURNS_NONULL NONULL char* eth_wallet_sign(const char* key, const char* data); /** * determines the from-address in case no from-address has been specified. */ -NONULL in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res); +in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res); #endif // in3_eth_basic_h__ \ No newline at end of file From c9275832890313b900012453d2b678b9382b706f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Jul 2021 10:40:10 +0200 Subject: [PATCH 063/110] better error msg --- c/src/core/client/client_init.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/c/src/core/client/client_init.c b/c/src/core/client/client_init.c index bf608e531..ced7b1ef4 100644 --- a/c/src/core/client/client_init.c +++ b/c/src/core/client/client_init.c @@ -239,10 +239,11 @@ char* in3_configure(in3_t* c, const char* config) { if (!json || !json->result) return config_err("in3_configure: parse error", config); // the error-message we will return in case of an error. - char* res = NULL; + char* res = NULL; + int prop_index = 0; // we iterate over the root-props - for (d_iterator_t iter = d_iter(json->result); iter.left; d_iter_next(&iter)) { + for (d_iterator_t iter = d_iter(json->result); iter.left; d_iter_next(&iter), prop_index++) { d_token_t* token = iter.token; if (token->key == CONFIG_KEY("autoUpdateList")) { @@ -380,7 +381,11 @@ char* in3_configure(in3_t* c, const char* config) { } } - if (!handled) EXPECT_TOK(token, false, "unsupported config option!"); + if (!handled) { + char tmp[100]; + sprintf(tmp, "The config with index %d is unknown or not supported!", prop_index); + EXPECT_TOK(token, false, tmp); + } } } From 150156f4b728338597164bd2bbfbbcc7d03df83f Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Jul 2021 15:20:33 +0200 Subject: [PATCH 064/110] fix defines --- c/options.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/c/options.cmake b/c/options.cmake index 58fc2cc1b..325c8cbc4 100644 --- a/c/options.cmake +++ b/c/options.cmake @@ -110,11 +110,14 @@ endif() if(ETH_FULL) ADD_DEFINITIONS(-DETH_FULL) + ADD_DEFINITIONS(-DETH_BASIC) + ADD_DEFINITIONS(-DETH_NANO) set(IN3_VERIFIER eth_full) set(ETH_BASIC true) set(ETH_NANO true) elseif(ETH_BASIC) ADD_DEFINITIONS(-DETH_BASIC) + ADD_DEFINITIONS(-DETH_NANO) set(IN3_VERIFIER eth_basic) set(ETH_NANO true) elseif(ETH_NANO) From 65175de7caba0c20b5ae86532cf99390c7db46b3 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 5 Jul 2021 16:59:33 +0200 Subject: [PATCH 065/110] fix missing ETH_BASIC --- c/src/api/eth1/eth_api.c | 22 ++++++++++++++++++++++ c/src/cmd/in3/rpc_handler.c | 6 +++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/c/src/api/eth1/eth_api.c b/c/src/api/eth1/eth_api.c index 13ebc196d..553f3bf70 100644 --- a/c/src/api/eth1/eth_api.c +++ b/c/src/api/eth1/eth_api.c @@ -462,11 +462,18 @@ in3_ret_t eth_newPendingTransactionFilter(in3_t* in3) { } bool eth_uninstallFilter(in3_t* in3, size_t id) { +#ifdef ETH_BASIC return filter_remove(eth_basic_get_filters(in3), id); +#else + UNUSED_VAR(in3); + UNUSED_VAR(id); + return false; +#endif } // same as "eth_getFilterChanges" // or "eth_getFilterLogs" in3_ret_t eth_getFilterChanges(in3_t* in3, size_t id, bytes32_t** block_hashes, eth_log_t** logs) { +#ifdef ETH_BASIC in3_filter_handler_t* filters = eth_basic_get_filters(in3); if (filters == NULL) return IN3_EFIND; if (id == 0 || id > filters->count) @@ -509,9 +516,18 @@ in3_ret_t eth_getFilterChanges(in3_t* in3, size_t id, bytes32_t** block_hashes, default: return IN3_ENOTSUP; } +#else + UNUSED_VAR(in3); + UNUSED_VAR(id); + UNUSED_VAR(block_hashes); + UNUSED_VAR(logs); + + return IN3_ENOTSUP; +#endif } in3_ret_t eth_getFilterLogs(in3_t* in3, size_t id, eth_log_t** logs) { +#ifdef ETH_BASIC in3_filter_handler_t* filters = eth_basic_get_filters(in3); if (filters == NULL) return IN3_EFIND; if (id == 0 || id > filters->count) @@ -528,6 +544,12 @@ in3_ret_t eth_getFilterLogs(in3_t* in3, size_t id, eth_log_t** logs) { default: return IN3_ENOTSUP; } +#else + UNUSED_VAR(in3); + UNUSED_VAR(id); + UNUSED_VAR(logs); + return IN3_ENOTSUP; +#endif } void eth_log_free(eth_log_t* log) { diff --git a/c/src/cmd/in3/rpc_handler.c b/c/src/cmd/in3/rpc_handler.c index 6eafad143..15eb8c748 100644 --- a/c/src/cmd/in3/rpc_handler.c +++ b/c/src/cmd/in3/rpc_handler.c @@ -102,12 +102,12 @@ static bool _ipfs_get(in3_t* c, sb_t* args) { args->data[size - 2] = 0; #ifdef IPFS bytes_t* content = ipfs_get(c, args->data + 2); -#else - die("ipfs is not supported. Please compile with -DIPFS=true"); -#endif if (!content) die("IPFS hash not found!"); fwrite(content->data, content->len, 1, stdout); fflush(stdout); +#else + die("ipfs is not supported. Please compile with -DIPFS=true"); +#endif return true; } From 0ccf73d3134d8da8647af70cda1c24b9b63b6452 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 8 Jul 2021 12:35:55 +0200 Subject: [PATCH 066/110] add ABI-macros --- c/src/core/util/utils.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/c/src/core/util/utils.h b/c/src/core/util/utils.h index 0020e3095..f070628ab 100644 --- a/c/src/core/util/utils.h +++ b/c/src/core/util/utils.h @@ -272,6 +272,31 @@ static inline bool memiszero(uint8_t* ptr, size_t l) { return true; } +/** calculates the address of a word in a abi-encoded data (assuming data = bytes_t res exists) */ +#define WORD_ADR(index, right) (res.data + 4 + (index) *32 + 32 - (right)) +/** sets an address at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_ADDRESS(index, adr) \ + { \ + if (adr) memcpy(WORD_ADR(index, 20), adr, 20); \ + } +/** sets an int at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_UINT32(index, val) int_to_bytes(val, WORD_ADR(index, 4)) +/** sets an uint256 as bytes at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_UINT256(index, data, len) memcpy(WORD_ADR(index, len), data, len) +/** writes the bytes at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_BYTES(index, bytes) \ + { \ + if (bytes.data) memcpy(WORD_ADR(index, 32), bytes.data, bytes.len); \ + } +/** writes the functionhash in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_FNC(hash) memcpy(res.data, (void*) hash, 4) +/**allocates memory filled with zeros with the size words*32 +4 for e3ncoding abi-data */ +#define ABI_BYTES_CALLOC(words) bytes(_calloc(4 + (words) *32, 1), 4 + (words) *32) +/** calculates the number of words (32 bytes) needed to hold the specified bytes */ +#define ABI_WORDS(byte_len) ((byte_len + 31) / 32) +/** writes the offset (as word) at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_OFFSET(index, word) ABI_UINT32(index, (word * 32)) + /** * Pluggable functions: * Mechanism to replace library functions with custom alternatives. This is particularly useful for From 39dd989e8c6dab2054812f7662ff989831df9138 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 8 Jul 2021 13:05:30 +0200 Subject: [PATCH 067/110] fix ABI_ADDRESS --- c/src/core/util/utils.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/c/src/core/util/utils.h b/c/src/core/util/utils.h index f070628ab..6885b8a8f 100644 --- a/c/src/core/util/utils.h +++ b/c/src/core/util/utils.h @@ -275,10 +275,7 @@ static inline bool memiszero(uint8_t* ptr, size_t l) { /** calculates the address of a word in a abi-encoded data (assuming data = bytes_t res exists) */ #define WORD_ADR(index, right) (res.data + 4 + (index) *32 + 32 - (right)) /** sets an address at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ -#define ABI_ADDRESS(index, adr) \ - { \ - if (adr) memcpy(WORD_ADR(index, 20), adr, 20); \ - } +#define ABI_ADDRESS(index, adr) memcpy(WORD_ADR(index, 20), adr, 20) /** sets an int at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ #define ABI_UINT32(index, val) int_to_bytes(val, WORD_ADR(index, 4)) /** sets an uint256 as bytes at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ From 4b9f7f398357e9c3cc480fa7ad6158cdf28f89a5 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 9 Jul 2021 08:08:05 +0200 Subject: [PATCH 068/110] update headers --- c/include/in3/eth_basic.h | 2 +- c/include/in3/signer.h | 2 ++ c/include/in3/utils.h | 26 ++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/c/include/in3/eth_basic.h b/c/include/in3/eth_basic.h index b730dc142..f3a54b6bb 100644 --- a/c/include/in3/eth_basic.h +++ b/c/include/in3/eth_basic.h @@ -149,6 +149,6 @@ RETURNS_NONULL NONULL char* eth_wallet_sign(const char* key, const char* data); /** * determines the from-address in case no from-address has been specified. */ -NONULL in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res); +in3_ret_t get_from_address(d_token_t* tx, in3_req_t* ctx, address_t res); #endif // in3_eth_basic_h__ \ No newline at end of file diff --git a/c/include/in3/signer.h b/c/include/in3/signer.h index b7e5d4935..ba19a5313 100644 --- a/c/include/in3/signer.h +++ b/c/include/in3/signer.h @@ -88,6 +88,8 @@ in3_ret_t ec_sign_pk_hash(uint8_t* message, size_t len, uint8_t* pk, hasher_t ha /** Signs message raw with the given private key*/ in3_ret_t ec_sign_pk_raw(uint8_t* message, uint8_t* pk, uint8_t* dst); +/** hashes the msg by adding the Ethereum Signed Message-Prefix */ +void eth_create_prefixed_msg_hash(bytes32_t dst, bytes_t msg); #ifdef __cplusplus } #endif diff --git a/c/include/in3/utils.h b/c/include/in3/utils.h index 73ef193d9..6885b8a8f 100644 --- a/c/include/in3/utils.h +++ b/c/include/in3/utils.h @@ -272,6 +272,28 @@ static inline bool memiszero(uint8_t* ptr, size_t l) { return true; } +/** calculates the address of a word in a abi-encoded data (assuming data = bytes_t res exists) */ +#define WORD_ADR(index, right) (res.data + 4 + (index) *32 + 32 - (right)) +/** sets an address at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_ADDRESS(index, adr) memcpy(WORD_ADR(index, 20), adr, 20) +/** sets an int at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_UINT32(index, val) int_to_bytes(val, WORD_ADR(index, 4)) +/** sets an uint256 as bytes at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_UINT256(index, data, len) memcpy(WORD_ADR(index, len), data, len) +/** writes the bytes at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_BYTES(index, bytes) \ + { \ + if (bytes.data) memcpy(WORD_ADR(index, 32), bytes.data, bytes.len); \ + } +/** writes the functionhash in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_FNC(hash) memcpy(res.data, (void*) hash, 4) +/**allocates memory filled with zeros with the size words*32 +4 for e3ncoding abi-data */ +#define ABI_BYTES_CALLOC(words) bytes(_calloc(4 + (words) *32, 1), 4 + (words) *32) +/** calculates the number of words (32 bytes) needed to hold the specified bytes */ +#define ABI_WORDS(byte_len) ((byte_len + 31) / 32) +/** writes the offset (as word) at the word index in a abi-encoded data (assuming data = bytes_t res exists) */ +#define ABI_OFFSET(index, word) ABI_UINT32(index, (word * 32)) + /** * Pluggable functions: * Mechanism to replace library functions with custom alternatives. This is particularly useful for @@ -329,6 +351,10 @@ int64_t parse_float_val(const char* data, /**< the data string*/ */ void b256_add(bytes32_t a, uint8_t* b, wlen_t len_b); +/** + * prints a bytes into a string + */ +char* bytes_to_hex_string(char* out, const char* prefix, const bytes_t b, const char* postfix); #ifdef THREADSAFE #define _NAME(x, y) x##y #if defined(_MSC_VER) || defined(__MINGW32__) From 6a8efd76392c5ebb6de14d6f8b74b3283a44dd97 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 12 Jul 2021 13:46:57 +0200 Subject: [PATCH 069/110] add NULL_BYTES-macro --- c/include/in3/bytes.h | 2 ++ c/src/api/btc/btc_api.c | 2 +- c/src/api/eth1/abi_encode.c | 2 +- c/src/api/eth1/rpc_api.c | 4 ++-- c/src/api/usn/usn_api.c | 4 ++-- c/src/cmd/tools/data.c | 4 ++-- c/src/core/client/execute.c | 2 +- c/src/core/util/bytes.h | 2 ++ c/src/core/util/scache.h | 2 +- c/src/nodeselect/full/nodeselect_def_cfg.h | 2 +- .../full/nodeselect_def_cfg_template.h | 2 +- c/src/pay/eth/pay_eth.c | 4 ++-- c/src/pay/zksync/zk_incentive.c | 6 ++--- c/src/pay/zksync/zk_message.c | 4 ++-- c/src/pay/zksync/zk_musig.c | 2 +- c/src/pay/zksync/zk_setkey.c | 2 +- c/src/pay/zksync/zk_transfer.c | 2 +- c/src/signer/multisig/multisig.c | 24 +++++++++---------- c/src/verifier/btc/btc_serialize.c | 2 +- c/src/verifier/btc/btc_target.c | 2 +- c/src/verifier/eth1/basic/eth_getLog.c | 4 ++-- c/src/verifier/eth1/basic/sign_tx.c | 6 ++--- c/src/verifier/eth1/basic/trie.c | 2 +- c/src/verifier/eth1/evm/opcodes.c | 4 ++-- c/test/unit_tests/test_nanoledger.c | 2 +- c/test/unit_tests/test_sign.c | 2 +- 26 files changed, 50 insertions(+), 46 deletions(-) diff --git a/c/include/in3/bytes.h b/c/include/in3/bytes.h index df7f48712..c17f20b67 100644 --- a/c/include/in3/bytes.h +++ b/c/include/in3/bytes.h @@ -81,6 +81,8 @@ typedef struct { bytes_t b; /**< the bytes struct */ } bytes_builder_t; +#define NULL_BYTES ((bytes_t){0}) /**< empty bytes as struct */ + RETURNS_NONULL bytes_t* b_new(const uint8_t* data, uint32_t len); /**< allocates a new byte array with 0 filled */ NONULL uint8_t* b_get_data(const bytes_t* b); /**< gets the data field from an input byte array */ NONULL uint32_t b_get_len(const bytes_t* b); /**< gets the len field from an input byte array */ diff --git a/c/src/api/btc/btc_api.c b/c/src/api/btc/btc_api.c index 3b8f808d0..04d13d83b 100644 --- a/c/src/api/btc/btc_api.c +++ b/c/src/api/btc/btc_api.c @@ -125,7 +125,7 @@ static in3_ret_t fill_tx(d_token_t* t, btc_transaction_t* res, void* data, bytes btc_transaction_in_t* r = res->vin + i; r->script = vin.script; r->sequence = vin.sequence; - r->txinwitness = bytes(NULL, 0); + r->txinwitness = NULL_BYTES; r->vout = vin.prev_tx_index; memcpy(r->txid, vin.prev_tx_hash, 32); } diff --git a/c/src/api/eth1/abi_encode.c b/c/src/api/eth1/abi_encode.c index a29434dc7..19ad7ff5f 100644 --- a/c/src/api/eth1/abi_encode.c +++ b/c/src/api/eth1/abi_encode.c @@ -187,5 +187,5 @@ bytes_t abi_encode(abi_sig_t* s, d_token_t* src, char** error) { if (!memiszero(s->fn_hash, 4)) bb_write_raw_bytes(&bb, s->fn_hash, 4); if (encode_tuple(s->input, src, &bb, error) && bb.b.data) _free(bb.b.data); - return *error ? bytes(NULL, 0) : bb.b; + return *error ? NULL_BYTES : bb.b; } diff --git a/c/src/api/eth1/rpc_api.c b/c/src/api/eth1/rpc_api.c index 90ad9ac6b..c15f84cd0 100644 --- a/c/src/api/eth1/rpc_api.c +++ b/c/src/api/eth1/rpc_api.c @@ -433,7 +433,7 @@ static in3_ret_t in3_sign_data(in3_rpc_handle_ctx_t* ctx) { in3_sign_ctx_t sc = {0}; sc.req = ctx->req; sc.message = data; - sc.account = pk ? *pk : bytes(NULL, 0); + sc.account = pk ? *pk : NULL_BYTES; sc.type = strcmp(sig_type, "hash") == 0 ? SIGN_EC_RAW : SIGN_EC_HASH; if ((sc.account.len == 20 || sc.account.len == 0) && in3_plugin_is_registered(ctx->req->client, PLGN_ACT_SIGN)) { @@ -544,7 +544,7 @@ static in3_ret_t in3_prepareTx(in3_rpc_handle_ctx_t* ctx) { static in3_ret_t in3_signTx(in3_rpc_handle_ctx_t* ctx) { CHECK_PARAMS_LEN(ctx->req, ctx->params, 1) d_token_t* tx_data = ctx->params + 1; - bytes_t tx_raw = bytes(NULL, 0); + bytes_t tx_raw = NULL_BYTES; bytes_t* from_b = NULL; bytes_t* data = NULL; if (strcmp(ctx->method, "eth_signTransaction") == 0 || d_type(tx_data) == T_OBJECT) { diff --git a/c/src/api/usn/usn_api.c b/c/src/api/usn/usn_api.c index 57be4dc89..404062df2 100644 --- a/c/src/api/usn/usn_api.c +++ b/c/src/api/usn/usn_api.c @@ -389,7 +389,7 @@ in3_ret_t usn_update_bookings(usn_device_conf_t* conf) { usn_device_t* device = conf->devices + i; // get the number of bookings and manage memory - if (0 > (res = exec_eth_call(conf, "0x3fce7fcf", device->id, bytes(NULL, 0), tmp, 32))) return res; + if (0 > (res = exec_eth_call(conf, "0x3fce7fcf", device->id, NULL_BYTES, tmp, 32))) return res; if (device->bookings) _free(device->bookings); #ifdef __clang_analyzer__ @@ -567,7 +567,7 @@ in3_ret_t usn_price(in3_t* c, address_t contract, address_t token, char* url, ui if (controller) memcpy(params + 12, controller, 20); int_to_bytes(seconds, params + 60); if (token) memcpy(params + 64 + 12, token, 20); - return exec_eth_call(&conf, "0xf44fb0a4", purl.device_id, bytes(NULL, 0), price, 32) < 0 ? IN3_EINVALDT : IN3_OK; + return exec_eth_call(&conf, "0xf44fb0a4", purl.device_id, NULL_BYTES, price, 32) < 0 ? IN3_EINVALDT : IN3_OK; // function price(bytes32 id, address user, uint32 secondsToRent, address token) public constant returns (uint128); } diff --git a/c/src/cmd/tools/data.c b/c/src/cmd/tools/data.c index 9af9cb8f7..f4cbdaa17 100644 --- a/c/src/cmd/tools/data.c +++ b/c/src/cmd/tools/data.c @@ -50,7 +50,7 @@ bytes_t read_from_stdin(FILE* file) { if (file == NULL) { printf("File not found!"); _Exit(1); - return bytes(NULL, 0); + return NULL_BYTES; } size_t allocated = 1024; @@ -223,7 +223,7 @@ static void print_debug(bytes_t* data) { } int main(int argc, char* argv[]) { - bytes_t input = bytes(NULL, 0); + bytes_t input = NULL_BYTES; char* format = "auto"; bool debug = false; diff --git a/c/src/core/client/execute.c b/c/src/core/client/execute.c index ad945ac0d..219c2eae9 100644 --- a/c/src/core/client/execute.c +++ b/c/src/core/client/execute.c @@ -647,7 +647,7 @@ static void init_sign_ctx(in3_req_t* ctx, in3_sign_ctx_t* sign_ctx) { sign_ctx->account = d_to_bytes(d_get_at(params, 1)); sign_ctx->type = SIGN_EC_HASH; sign_ctx->req = ctx; - sign_ctx->signature = bytes(NULL, 0); + sign_ctx->signature = NULL_BYTES; } in3_sign_ctx_t* create_sign_ctx(in3_req_t* ctx) { diff --git a/c/src/core/util/bytes.h b/c/src/core/util/bytes.h index df7f48712..c17f20b67 100644 --- a/c/src/core/util/bytes.h +++ b/c/src/core/util/bytes.h @@ -81,6 +81,8 @@ typedef struct { bytes_t b; /**< the bytes struct */ } bytes_builder_t; +#define NULL_BYTES ((bytes_t){0}) /**< empty bytes as struct */ + RETURNS_NONULL bytes_t* b_new(const uint8_t* data, uint32_t len); /**< allocates a new byte array with 0 filled */ NONULL uint8_t* b_get_data(const bytes_t* b); /**< gets the data field from an input byte array */ NONULL uint32_t b_get_len(const bytes_t* b); /**< gets the len field from an input byte array */ diff --git a/c/src/core/util/scache.h b/c/src/core/util/scache.h index 03f9711ba..d6024f7d8 100644 --- a/c/src/core/util/scache.h +++ b/c/src/core/util/scache.h @@ -109,7 +109,7 @@ NONULL static inline cache_entry_t* in3_cache_add_ptr( cache_entry_t** cache, /**< the root entry of the linked list. */ void* ptr /**< pointer to memory which shold be freed. */ ) { - return in3_cache_add_entry(cache, bytes(NULL, 0), bytes((uint8_t*) ptr, 1)); + return in3_cache_add_entry(cache, NULL_BYTES, bytes((uint8_t*) ptr, 1)); } #ifdef __cplusplus diff --git a/c/src/nodeselect/full/nodeselect_def_cfg.h b/c/src/nodeselect/full/nodeselect_def_cfg.h index a1a62bece..22a0fd543 100644 --- a/c/src/nodeselect/full/nodeselect_def_cfg.h +++ b/c/src/nodeselect/full/nodeselect_def_cfg.h @@ -350,7 +350,7 @@ static inline bytes_t nodeselect_def_cfg_data(chain_id_t chain_id) { return bytes((uint8_t*) BOOT_NODES_LOCAL_BIN, BOOT_NODES_LOCAL_BIN_LEN); #endif // NO_BOOT_NODES_LOCAL - return bytes(NULL, 0); + return NULL_BYTES; } static inline json_ctx_t* nodeselect_def_cfg(chain_id_t chain_id) { diff --git a/c/src/nodeselect/full/nodeselect_def_cfg_template.h b/c/src/nodeselect/full/nodeselect_def_cfg_template.h index 800a4592e..50d56ba8c 100644 --- a/c/src/nodeselect/full/nodeselect_def_cfg_template.h +++ b/c/src/nodeselect/full/nodeselect_def_cfg_template.h @@ -198,7 +198,7 @@ static inline bytes_t nodeselect_def_cfg_data(chain_id_t chain_id) { return bytes((uint8_t*) BOOT_NODES_LOCAL_BIN, BOOT_NODES_LOCAL_BIN_LEN); #endif // NO_BOOT_NODES_LOCAL - return bytes(NULL, 0); + return NULL_BYTES; } static inline json_ctx_t* nodeselect_def_cfg(chain_id_t chain_id) { diff --git a/c/src/pay/eth/pay_eth.c b/c/src/pay/eth/pay_eth.c index dbf149292..2dc0c8ad9 100644 --- a/c/src/pay/eth/pay_eth.c +++ b/c/src/pay/eth/pay_eth.c @@ -125,13 +125,13 @@ static void create_signed_tx(in3_pay_eth_t* data, bytes32_t key, sb_t* sb, addre long_to_bytes(data->gas_price, gas_price.data); long_to_bytes(21000, gas_limit.data); // create raw without signature - bytes_t* raw = serialize_tx_raw(nonce, gas_price, gas_limit, bytes(to, 20), value, bytes(NULL, 0), chainId, bytes(NULL, 0), bytes(NULL, 0)); + bytes_t* raw = serialize_tx_raw(nonce, gas_price, gas_limit, bytes(to, 20), value, NULL_BYTES, chainId, NULL_BYTES, NULL_BYTES); // sign it if (ecdsa_sign(&secp256k1, HASHER_SHA3K, key, raw->data, raw->len, sig, sig + 64, NULL) < 0) return; b_free(raw); - raw = serialize_tx_raw(nonce, gas_price, gas_limit, bytes(to, 20), value, bytes(NULL, 0), 27 + sig[64] + (chainId ? (chainId * 2 + 8) : 0), bytes(sig, 32), bytes(sig + 32, 32)); + raw = serialize_tx_raw(nonce, gas_price, gas_limit, bytes(to, 20), value, NULL_BYTES, 27 + sig[64] + (chainId ? (chainId * 2 + 8) : 0), bytes(sig, 32), bytes(sig + 32, 32)); sb_add_bytes(sb, NULL, raw, 1, false); b_free(raw); } diff --git a/c/src/pay/zksync/zk_incentive.c b/c/src/pay/zksync/zk_incentive.c index e0ec3cd2c..82a717d06 100644 --- a/c/src/pay/zksync/zk_incentive.c +++ b/c/src/pay/zksync/zk_incentive.c @@ -179,7 +179,7 @@ static in3_ret_t find_acceptable_offer(in3_req_t* ctx, pay_criteria_t* criteria, } static in3_ret_t add_to_payed_nodelist(in3_req_t* ctx, address_t address, unsigned int nodelen) { - bytes_t payed_addresses = bytes(NULL, 0); + bytes_t payed_addresses = NULL_BYTES; TRY(get_payed_addresses(ctx, &payed_addresses)) uint8_t* addresses = alloca(payed_addresses.len + 20); if (payed_addresses.data) { @@ -202,7 +202,7 @@ static in3_ret_t add_to_payed_nodelist(in3_req_t* ctx, address_t address, unsign } in3_ret_t update_nodelist_from_cache(in3_req_t* ctx, unsigned int nodelen) { - bytes_t payed_addresses = bytes(NULL, 0); + bytes_t payed_addresses = NULL_BYTES; TRY(get_payed_addresses(ctx, &payed_addresses)) if (payed_addresses.len) @@ -272,7 +272,7 @@ in3_ret_t zksync_check_payment(zksync_config_t* conf, in3_pay_followup_ctx_t* ct sb_add_chars(&sb, "]}"); // add data as cache, so we can add it when we create the next payload. - in3_cache_add_entry(&ctx->req->cache, bytes(NULL, 0), bytes((void*) sb.data, strlen(sb.data)))->props = CACHE_PROP_MUST_FREE | CACHE_PROP_PAYMENT; + in3_cache_add_entry(&ctx->req->cache, NULL_BYTES, bytes((void*) sb.data, strlen(sb.data)))->props = CACHE_PROP_MUST_FREE | CACHE_PROP_PAYMENT; // now we make sure we try again. TRY(in3_retry_same_node(ctx->req)) diff --git a/c/src/pay/zksync/zk_message.c b/c/src/pay/zksync/zk_message.c index 765a05176..a53e4d891 100644 --- a/c/src/pay/zksync/zk_message.c +++ b/c/src/pay/zksync/zk_message.c @@ -170,7 +170,7 @@ in3_ret_t zksync_sign_transfer(sb_t* sb, zksync_tx_data_t* data, in3_req_t* ctx, // fix valid.to first if (!data->valid.to) data->valid.to = 0xffffffffl; - bytes_t signature = bytes(NULL, 0); + bytes_t signature = NULL_BYTES; if (data->conf->sign_type != ZK_SIGN_CREATE2) { char msg_data[256]; @@ -287,7 +287,7 @@ in3_ret_t zksync_sign_change_pub_key(sb_t* sb, in3_req_t* ctx, uint8_t* sync_pub // create 2fa-message to be signed with the eth-signer uint8_t ethmsg[60]; - bytes_t signature = bytes(NULL, 0); + bytes_t signature = NULL_BYTES; memcpy(ethmsg, sync_pub_key, 20); // pubkeyhash (20) int_to_bytes(nonce, ethmsg + 20); // nonce (4) int_to_bytes(conf->account_id, ethmsg + 24); // acount_id (4 bytes) diff --git a/c/src/pay/zksync/zk_musig.c b/c/src/pay/zksync/zk_musig.c index c94bf10d2..c840f39a1 100644 --- a/c/src/pay/zksync/zk_musig.c +++ b/c/src/pay/zksync/zk_musig.c @@ -254,7 +254,7 @@ in3_ret_t zksync_musig_sign(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { TRY(zksync_get_sync_key(conf, ctx->req, NULL)) char* proof_data = NULL; - bytes_t pub_keys = result ? d_to_bytes(d_get(result, key("pub_keys"))) : bytes(NULL, 0); + bytes_t pub_keys = result ? d_to_bytes(d_get(result, key("pub_keys"))) : NULL_BYTES; if (!pub_keys.data && conf->musig_pub_keys.data) pub_keys = conf->musig_pub_keys; if (!pub_keys.data) return req_set_error(ctx->req, "no public keys found for musig signature", IN3_EINVAL); int pos = get_pubkey_pos(conf, pub_keys, ctx->req); diff --git a/c/src/pay/zksync/zk_setkey.c b/c/src/pay/zksync/zk_setkey.c index 132a929d2..eece5a302 100644 --- a/c/src/pay/zksync/zk_setkey.c +++ b/c/src/pay/zksync/zk_setkey.c @@ -109,7 +109,7 @@ in3_ret_t zksync_set_key(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, bool if (ret && sb.data) _free(sb.data); TRY(ret) if (!sb.data) return IN3_EUNKNOWN; - cached = in3_cache_add_entry(&ctx->req->cache, bytes(NULL, 0), bytes((void*) sb.data, strlen(sb.data))); + cached = in3_cache_add_entry(&ctx->req->cache, NULL_BYTES, bytes((void*) sb.data, strlen(sb.data))); cached->props = ckey; } diff --git a/c/src/pay/zksync/zk_transfer.c b/c/src/pay/zksync/zk_transfer.c index 83bae35d9..bcb271d17 100644 --- a/c/src/pay/zksync/zk_transfer.c +++ b/c/src/pay/zksync/zk_transfer.c @@ -65,7 +65,7 @@ in3_ret_t zksync_transfer(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx, zk_m if (ret && sb.data) _free(sb.data); TRY(ret) if (!sb.data) return IN3_EUNKNOWN; - cached = in3_cache_add_entry(&ctx->req->cache, bytes(NULL, 0), bytes((void*) sb.data, strlen(sb.data))); + cached = in3_cache_add_entry(&ctx->req->cache, NULL_BYTES, bytes((void*) sb.data, strlen(sb.data))); cached->props = CACHE_PROP_MUST_FREE | 0xF100; } diff --git a/c/src/signer/multisig/multisig.c b/c/src/signer/multisig/multisig.c index 302a1330d..f37edc250 100644 --- a/c/src/signer/multisig/multisig.c +++ b/c/src/signer/multisig/multisig.c @@ -237,12 +237,12 @@ static in3_ret_t fill_signature(in3_req_t* ctx, bytes_t* signatures, uint32_t* s memset(sig_data + index, 0, sizeof(sig_data_t)); memcpy(sig_data[index].sig, signatures->data + i, 65); sig_data[index].address = signatures->data + i + 12; - sig_data[index].data = bytes(NULL, 0); + sig_data[index].data = NULL_BYTES; } else if (v > 26) { if (!ecrecover_sig(tx_hash, signatures->data + i, sig_data[index].address)) return req_set_error(ctx, "could not recover the signature", IN3_EINVAL); memcpy(sig_data[index].sig, signatures->data + i, 65); - sig_data[index].data = bytes(NULL, 0); + sig_data[index].data = NULL_BYTES; } else return req_set_error(ctx, "invalid signature (v-value)", IN3_EINVAL); @@ -269,7 +269,7 @@ static in3_ret_t add_approved(in3_req_t* ctx, uint32_t* sig_count, sig_data_t* s memset(sig_data + *sig_count, 0, sizeof(sig_data_t)); memcpy(sig_data[*sig_count].sig + 12, ms->owners + i, 20); sig_data[*sig_count].address = (void*) ms->owners + i; - sig_data[*sig_count].data = bytes(NULL, 0); + sig_data[*sig_count].data = NULL_BYTES; (*sig_count)++; } } @@ -296,11 +296,11 @@ static void exec_tx(bytes_t* target, tx_data_t* tx_data, sig_data_t* signatures, rlp_encode_item(&bb, &tx_data->gas_price); // and current gas price rlp_encode_uint(&bb, bytes_to_long(tx_data->gas.data, tx_data->gas.len) + 300000); // we need to add some gas to the original because now we go through ms rlp_encode_bytes(&bb, bytes(ms, 20)); // but send it to the ms - rlp_encode_bytes(&bb, bytes(NULL, 0)); // we don't send value since this will be done from the multisig + rlp_encode_bytes(&bb, NULL_BYTES); // we don't send value since this will be done from the multisig rlp_encode_item(&bb, &data); // the functiondata rlp_encode_item(&bb, &tx_data->v); // v - rlp_encode_bytes(&bb, bytes(NULL, 0)); // empty because signature - rlp_encode_bytes(&bb, bytes(NULL, 0)); // is still missing + rlp_encode_bytes(&bb, NULL_BYTES); // empty because signature + rlp_encode_bytes(&bb, NULL_BYTES); // is still missing rlp_encode_to_list(&bb); *target = bb.b; _free(data.data); @@ -315,11 +315,11 @@ static void approve_hash(bytes_t* target, tx_data_t* tx_data, bytes32_t hash, ad rlp_encode_item(&bb, &tx_data->gas_price); // and current gas price rlp_encode_uint(&bb, 100000); // we need only 100k rlp_encode_bytes(&bb, bytes(ms, 20)); // but send it to the ms - rlp_encode_bytes(&bb, bytes(NULL, 0)); // we don't send value since this will be done from the multisig + rlp_encode_bytes(&bb, NULL_BYTES); // we don't send value since this will be done from the multisig rlp_encode_bytes(&bb, bytes(data, 36)); // the functiondata rlp_encode_item(&bb, &tx_data->v); // v - rlp_encode_bytes(&bb, bytes(NULL, 0)); // empty because signature - rlp_encode_bytes(&bb, bytes(NULL, 0)); // is still missing + rlp_encode_bytes(&bb, NULL_BYTES); // empty because signature + rlp_encode_bytes(&bb, NULL_BYTES); // is still missing rlp_encode_to_list(&bb); *target = bb.b; } @@ -399,7 +399,7 @@ in3_ret_t gs_prepare_tx(multisig_t* ms, in3_sign_prepare_ctx_t* prepare_ctx) { memset(sig_data->sig, 0, 65); // clear memcpy(sig_data->sig + 12, prepare_ctx->account, 20); // we use the address as constant part sig_data->address = prepare_ctx->account; // keep address of the owner - sig_data->data = bytes(NULL, 0); // no data needed for sig-type 1 + sig_data->data = NULL_BYTES; // no data needed for sig-type 1 sig_data->sig[64] = 1; // mark as pre approved sig_count++; // we have at least one signature now. } @@ -503,7 +503,7 @@ in3_ret_t gs_create_contract_signature(multisig_t* ms, in3_sign_ctx_t* ctx) { for (int i = 0; i < sctx.accounts_len && sig_count < ms->threshold; i++) { uint8_t* account = sctx.accounts + i * 20; if (is_valid(sig_data, ms, account, sig_count)) { - bytes_t signature = bytes(NULL, 0); + bytes_t signature = NULL_BYTES; TRY(req_require_signature(ctx->req, SIGN_EC_RAW, &signature, bytes(hash, 32), bytes(account, 20))) sig_data[sig_count].address = NULL; for (unsigned int n = 0; n < ms->owners_len; n++) { @@ -512,7 +512,7 @@ in3_ret_t gs_create_contract_signature(multisig_t* ms, in3_sign_ctx_t* ctx) { if (sig_data[sig_count].address == NULL) break; // shouldn't happen, but better safe memcpy(sig_data[sig_count].sig, signature.data, 65); // currently we only accept EOA-Signatures, contract-signatures should be supported later also! if (sig_data[sig_count].sig[64] < 2) sig_data[sig_count].sig[64] += 27; // fix chain-id later - sig_data[sig_count].data = bytes(NULL, 0); // no data needed (at least for now) + sig_data[sig_count].data = NULL_BYTES; // no data needed (at least for now) sig_count++; // we have at least one signature now. } } diff --git a/c/src/verifier/btc/btc_serialize.c b/c/src/verifier/btc/btc_serialize.c index a56d515c4..bdf9c6736 100644 --- a/c/src/verifier/btc/btc_serialize.c +++ b/c/src/verifier/btc/btc_serialize.c @@ -32,7 +32,7 @@ bytes_t btc_block_get(bytes_t block, btc_block_field field) { case BTC_B_BITS: return bytes(block.data + 72, 4); case BTC_B_NONCE: return bytes(block.data + 76, 4); case BTC_B_HEADER: return bytes(block.data, 80); - default: return bytes(NULL, 0); + default: return NULL_BYTES; } } void btc_hash(bytes_t data, bytes32_t dst) { diff --git a/c/src/verifier/btc/btc_target.c b/c/src/verifier/btc/btc_target.c index 076719990..39c87ca99 100644 --- a/c/src/verifier/btc/btc_target.c +++ b/c/src/verifier/btc/btc_target.c @@ -86,7 +86,7 @@ in3_ret_t btc_check_conf(in3_t* c, btc_target_conf_t* conf) { // did the chain_id change? if (c->chain.chain_id != conf->chain_id) { if (conf->data.data) _free(conf->data.data); - conf->data = bytes(NULL, 0); + conf->data = NULL_BYTES; conf->chain_id = c->chain.chain_id; } diff --git a/c/src/verifier/eth1/basic/eth_getLog.c b/c/src/verifier/eth1/basic/eth_getLog.c index c9d9f3479..1608e9dfe 100644 --- a/c/src/verifier/eth1/basic/eth_getLog.c +++ b/c/src/verifier/eth1/basic/eth_getLog.c @@ -249,7 +249,7 @@ in3_ret_t eth_verify_eth_getLog(in3_vctx_t* vc, int l_logs) { i++; // verify tx data first - r->data = bytes(NULL, 0); + r->data = NULL_BYTES; r->transaction_index = d_get_int(receipt.token, K_TX_INDEX); bytes_t** proof = d_create_bytes_vec(d_get(receipt.token, K_TX_PROOF)); bytes_t* path = create_tx_path(r->transaction_index); @@ -272,7 +272,7 @@ in3_ret_t eth_verify_eth_getLog(in3_vctx_t* vc, int l_logs) { // verify receipt data proof = d_create_bytes_vec(d_get(receipt.token, K_PROOF)); - r->data = bytes(NULL, 0); + r->data = NULL_BYTES; if (!proof || !trie_verify_proof(&receipt_root, path, proof, &r->data)) res = vc_err(vc, "invalid receipt proof"); diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index aca0db8e2..5c2d48db2 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -158,7 +158,7 @@ static bytes_t get_or_create_cached(in3_req_t* req, d_key_t k, int size) { cache_props_t p = (((uint32_t) k) << 16) | CACHE_PROP_MUST_FREE; cache_entry_t* cache = in3_cache_get_entry_by_prop(req->cache, p); if (!cache) { - cache = in3_cache_add_entry(&req->cache, bytes(NULL, 0), bytes(_calloc(1, size), size)); + cache = in3_cache_add_entry(&req->cache, NULL_BYTES, bytes(_calloc(1, size), size)); cache->props = p; } return cache->value; @@ -274,7 +274,7 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst, s TRY(transform_tx(ctx, tx, &to, &value, &data, &gas_limit)); // create raw without signature - bytes_t* raw = serialize_tx_raw(nonce, gas_price, gas_limit, to, value, data, get_v(chain_id), bytes(NULL, 0), bytes(NULL, 0)); + bytes_t* raw = serialize_tx_raw(nonce, gas_price, gas_limit, to, value, data, get_v(chain_id), NULL_BYTES, NULL_BYTES); *dst = *raw; _free(raw); @@ -370,7 +370,7 @@ in3_ret_t eth_sign_raw_tx(bytes_t raw_tx, in3_req_t* ctx, address_t from, bytes_ in3_ret_t handle_eth_sendTransaction(in3_req_t* ctx, d_token_t* req) { // get the transaction-object d_token_t* tx_params = d_get(req, K_PARAMS); - bytes_t unsigned_tx = bytes(NULL, 0), signed_tx = bytes(NULL, 0); + bytes_t unsigned_tx = NULL_BYTES, signed_tx = NULL_BYTES; address_t from; if (!tx_params || d_type(tx_params + 1) != T_OBJECT) return req_set_error(ctx, "invalid params", IN3_EINVAL); diff --git a/c/src/verifier/eth1/basic/trie.c b/c/src/verifier/eth1/basic/trie.c index 41e8acdc7..cd89e798a 100644 --- a/c/src/verifier/eth1/basic/trie.c +++ b/c/src/verifier/eth1/basic/trie.c @@ -71,7 +71,7 @@ trie_t* trie_new() { t->hasher = _sha3; t->codec = &rlp_codec; bytes_builder_t* ll = bb_new(); - bytes_t empty = bytes(NULL, 0); + bytes_t empty = NULL_BYTES; t->codec->encode_add(ll, &empty); t->hasher(&ll->b, t->root); bb_free(ll); diff --git a/c/src/verifier/eth1/evm/opcodes.c b/c/src/verifier/eth1/evm/opcodes.c index 43c8f39a7..ea598d59b 100644 --- a/c/src/verifier/eth1/evm/opcodes.c +++ b/c/src/verifier/eth1/evm/opcodes.c @@ -348,7 +348,7 @@ int op_datacopy(evm_t* evm, bytes_t* src, uint_fast8_t check_size) { if (check_size && !src_data.data) return EVM_ERROR_ILLEGAL_MEMORY_ACCESS; if (src_data.len < (uint32_t) data_len) - res = evm_mem_write(evm, mem_pos + src_data.len, bytes(NULL, 0), data_len - src_data.len); + res = evm_mem_write(evm, mem_pos + src_data.len, NULL_BYTES, data_len - src_data.len); if (src_data.len && res == 0) res = evm_mem_write(evm, mem_pos, src_data, src_data.len); @@ -366,7 +366,7 @@ int op_extcodecopy(evm_t* evm) { int res = evm->env(evm, EVM_ENV_CODE_COPY, address, 20, &data, code_pos, data_len); if (res < 0) // we will write 0x0 - return evm_mem_write(evm, mem_pos, bytes(NULL, 0), data_len); + return evm_mem_write(evm, mem_pos, NULL_BYTES, data_len); else return evm_mem_write(evm, mem_pos, bytes(data, res), data_len); } diff --git a/c/test/unit_tests/test_nanoledger.c b/c/test/unit_tests/test_nanoledger.c index 9582f8ffe..dccf66dbd 100644 --- a/c/test/unit_tests/test_nanoledger.c +++ b/c/test/unit_tests/test_nanoledger.c @@ -120,7 +120,7 @@ static void test_signer() { in3_sign_ctx_t sc = {0}; sc.type = SIGN_EC_HASH; sc.message = *data; - sc.account = bytes(NULL, 0); + sc.account = NULL_BYTES; sc.wallet = c->signer->wallet; sc.req = ctx; diff --git a/c/test/unit_tests/test_sign.c b/c/test/unit_tests/test_sign.c index c98fc5317..e35541700 100644 --- a/c/test/unit_tests/test_sign.c +++ b/c/test/unit_tests/test_sign.c @@ -170,7 +170,7 @@ static void test_signer() { sc.req = ctx; sc.message = *data; sc.type = SIGN_EC_RAW; - sc.account = bytes(NULL, 0); + sc.account = NULL_BYTES; TEST_ASSERT_EQUAL(IN3_OK, in3_plugin_execute_first(ctx, PLGN_ACT_SIGN, &sc)); TEST_ASSERT_FALSE(memiszero(sc.signature.data, 65)); _free(sc.signature.data); From fc431651ec7e999b4bfacb14a532906d6739f55c Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 12 Jul 2021 13:47:18 +0200 Subject: [PATCH 070/110] added param-macros --- c/src/core/util/debug.h | 10 ++++++ c/src/core/util/params.h | 75 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 c/src/core/util/params.h diff --git a/c/src/core/util/debug.h b/c/src/core/util/debug.h index c21721c6d..bcd1a48d8 100644 --- a/c/src/core/util/debug.h +++ b/c/src/core/util/debug.h @@ -40,6 +40,7 @@ #ifndef DEBUG_H #define DEBUG_H +#include "params.h" #include "stringbuilder.h" #include #include @@ -195,6 +196,15 @@ static inline void add_hex(sb_t* sb, char prefix, const char* property, bytes_t target = t->data; \ } +#define TRY_PARAM_GET_REQUIRED_ADDRESS(target, ctx, index) \ + { \ + const d_token_t* t = d_get_at(ctx->params, index); \ + if (d_type(t) != T_BYTES || d_len(t) != 20) \ + return req_set_error(ctx->req, "Param at " #index " must be a valid address!", IN3_EINVAL); \ + else \ + target = t->data; \ + } + /** used for exeuting a function based on the name. This macro will return if the name matches. */ #endif /* DEBUG_H */ \ No newline at end of file diff --git a/c/src/core/util/params.h b/c/src/core/util/params.h new file mode 100644 index 000000000..f2bb8fcfa --- /dev/null +++ b/c/src/core/util/params.h @@ -0,0 +1,75 @@ + +#ifndef IN3_PARAMS_H +#define IN3_PARAMS_H + +#include "data.h" +#include "stringbuilder.h" + +// macros for checking params +#define CHECK_PARAMS_LEN(ctx, params, len) \ + if (d_type(params) != T_ARRAY || d_len(params) < len) return req_set_error(ctx, "arguments need to be a array with at least " #len " arguments", IN3_EINVAL); +#define CHECK_PARAM_TYPE(ctx, params, index, type) \ + if (d_type(d_get_at(params, index)) != type) return req_set_error(ctx, "argument at index " #index " must be a " #type, IN3_EINVAL); +#define CHECK_PARAM_NUMBER(ctx, params, index) \ + switch (d_type(d_get_at(params, index))) { \ + case T_INTEGER: \ + case T_BYTES: break; \ + default: return req_set_error(ctx, "argument at index " #index " must be a number", IN3_EINVAL); \ + } +#define CHECK_PARAM_ADDRESS(ctx, params, index) \ + { \ + const d_token_t* val = d_get_at(params, index); \ + if (d_type(val) != T_BYTES || val->len != 20) return req_set_error(ctx, "argument at index " #index " must be a valid address", IN3_EINVAL); \ + } +#define CHECK_PARAM_LEN(ctx, params, index, len) \ + if (d_len(d_get_at(params, index)) != len) return req_set_error(ctx, "argument at index " #index " must have a length of " #len, IN3_EINVAL); +#define CHECK_PARAM_MAX_LEN(ctx, params, index, len) \ + if (d_len(d_get_at(params, index)) > len) return req_set_error(ctx, "argument at index " #index " must be smaller than " #len, IN3_EINVAL); +#define CHECK_PARAM_MIN_LEN(ctx, params, index, len) \ + if (d_len(d_get_at(params, index)) < len) return req_set_error(ctx, "argument at index " #index " must be at least " #len, IN3_EINVAL); +#define CHECK_PARAM(ctx, params, index, cond) \ + { \ + const d_token_t* val = d_get_at(params, index); \ + if (!(cond)) return req_set_error(ctx, "argument at index " #index " must match " #cond, IN3_EINVAL); \ + } + +#define TRY_PARAM_GET_INT(target, ctx, index, def) \ + { \ + const d_token_t* t = d_get_at(ctx->params, index); \ + if (d_type(t) == T_NULL) \ + target = def; \ + else if (d_type(t) != T_INTEGER) \ + return req_set_error(ctx->req, "Param at " #index " must be an integer!", IN3_EINVAL); \ + else \ + target = d_int(t); \ + } +#define TRY_PARAM_GET_REQUIRED_INT(target, ctx, index) \ + { \ + const d_token_t* t = d_get_at(ctx->params, index); \ + if (d_type(t) != T_INTEGER) \ + return req_set_error(ctx->req, "Param at " #index " must be an integer!", IN3_EINVAL); \ + else \ + target = d_int(t); \ + } + +#define TRY_PARAM_GET_ADDRESS(target, ctx, index, def) \ + { \ + const d_token_t* t = d_get_at(ctx->params, index); \ + if (d_type(t) == T_NULL) \ + target = def; \ + else if (d_type(t) != T_BYTES || d_len(t) != 20) \ + return req_set_error(ctx->req, "Param at " #index " must be a valid address!", IN3_EINVAL); \ + else \ + target = t->data; \ + } + +#define TRY_PARAM_GET_REQUIRED_ADDRESS(target, ctx, index) \ + { \ + const d_token_t* t = d_get_at(ctx->params, index); \ + if (d_type(t) != T_BYTES || d_len(t) != 20) \ + return req_set_error(ctx->req, "Param at " #index " must be a valid address!", IN3_EINVAL); \ + else \ + target = t->data; \ + } + +#endif \ No newline at end of file From d133c8dc3657a136d3777c3de051530d6bc3c2a9 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 12 Jul 2021 13:47:51 +0200 Subject: [PATCH 071/110] add json-parser-error report --- c/include/in3/data.h | 1 + c/include/in3/scache.h | 2 +- c/src/core/client/request.c | 7 ++- c/src/core/util/data.c | 88 +++++++++++++++++++++++++++---------- c/src/core/util/data.h | 1 + 5 files changed, 74 insertions(+), 25 deletions(-) diff --git a/c/include/in3/data.h b/c/include/in3/data.h index 7665dc70b..d0666d605 100644 --- a/c/include/in3/data.h +++ b/c/include/in3/data.h @@ -139,6 +139,7 @@ d_token_t* d_next(d_token_t* item); NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL char* parse_json_error(const char* js); /**< parses the json, but only return an error if the json is invalid. The returning string must be freed! */ NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ diff --git a/c/include/in3/scache.h b/c/include/in3/scache.h index 03f9711ba..d6024f7d8 100644 --- a/c/include/in3/scache.h +++ b/c/include/in3/scache.h @@ -109,7 +109,7 @@ NONULL static inline cache_entry_t* in3_cache_add_ptr( cache_entry_t** cache, /**< the root entry of the linked list. */ void* ptr /**< pointer to memory which shold be freed. */ ) { - return in3_cache_add_entry(cache, bytes(NULL, 0), bytes((uint8_t*) ptr, 1)); + return in3_cache_add_entry(cache, NULL_BYTES, bytes((uint8_t*) ptr, 1)); } #ifdef __cplusplus diff --git a/c/src/core/client/request.c b/c/src/core/client/request.c index e7bb1758c..d57ef8102 100644 --- a/c/src/core/client/request.c +++ b/c/src/core/client/request.c @@ -81,6 +81,11 @@ in3_req_t* req_new(in3_t* client, const char* req_data) { if (!ctx->request_context) { in3_log_error("Invalid json-request: %s\n", req_data); req_set_error(ctx, "Error parsing the JSON-request!", IN3_EINVAL); + char* msg = parse_json_error(req_data); + if (msg) { + req_set_error(ctx, msg, IN3_EINVAL); + _free(msg); + } return ctx; } @@ -423,7 +428,7 @@ in3_ret_t req_require_signature(in3_req_t* ctx, d_signature_type_t type, bytes_t // first try internal plugins for signing, before we create an context. if (in3_plugin_is_registered(ctx->client, PLGN_ACT_SIGN)) { - in3_sign_ctx_t sc = {.account = from, .req = ctx, .message = raw_data, .signature = bytes(NULL, 0), .type = type}; + in3_sign_ctx_t sc = {.account = from, .req = ctx, .message = raw_data, .signature = NULL_BYTES, .type = type}; in3_ret_t r = in3_plugin_execute_first_or_none(ctx, PLGN_ACT_SIGN, &sc); if (r == IN3_OK && sc.signature.data) { in3_cache_add_entry(&ctx->cache, cloned_bytes(cache_key), sc.signature); diff --git a/c/src/core/util/data.c b/c/src/core/util/data.c index 196657a5a..e56d7488f 100644 --- a/c/src/core/util/data.c +++ b/c/src/core/util/data.c @@ -52,6 +52,10 @@ #define JSON_INIT_TOKENS 10 #define JSON_INDEXD_PAGE 128 #define JSON_MAX_ALLOWED_TOKENS 1000000 +#define JSON_E_MAX_DEPTH -3 +#define JSON_E_INVALID_CHAR -2 +#define JSON_E_NUMBER_TOO_LONG -4 +#define JSON_E_END_OF_STRING -1 d_key_t keyn(const char* c, const size_t len) { d_key_t val = 0; @@ -151,7 +155,7 @@ bytes_t d_to_bytes(d_token_t* item) { } case T_NULL: default: - return bytes(NULL, 0); + return NULL_BYTES; } } @@ -323,7 +327,7 @@ d_token_t* d_next(d_token_t* item) { return item == NULL ? NULL : item + d_token_size(item); } -NONULL char next_char(json_ctx_t* jp) { +NONULL static char next_char(json_ctx_t* jp) { while (true) { switch (*jp->c) { case ' ': @@ -338,7 +342,7 @@ NONULL char next_char(json_ctx_t* jp) { } } -RETURNS_NONULL NONULL d_token_t* parsed_next_item(json_ctx_t* jp, d_type_t type, d_key_t key, int parent) { +RETURNS_NONULL NONULL static d_token_t* parsed_next_item(json_ctx_t* jp, d_type_t type, d_key_t key, int parent) { if (jp->len + 1 > jp->allocated) { jp->result = _realloc(jp->result, (jp->allocated << 1) * sizeof(d_token_t), jp->allocated * sizeof(d_token_t)); jp->allocated <<= 1; @@ -352,12 +356,12 @@ RETURNS_NONULL NONULL d_token_t* parsed_next_item(json_ctx_t* jp, d_type_t type, return n; } -NONULL int parse_key(json_ctx_t* jp) { +NONULL int static parse_key(json_ctx_t* jp) { const char* start = jp->c; int r; while (true) { switch (*(jp->c++)) { - case 0: return -2; + case 0: return JSON_E_INVALID_CHAR; case '"': r = add_key(jp, start, jp->c - start - 1); return next_char(jp) == ':' ? r : -2; @@ -368,7 +372,7 @@ NONULL int parse_key(json_ctx_t* jp) { } } -NONULL int parse_number(json_ctx_t* jp, d_token_t* item) { +NONULL int static parse_number(json_ctx_t* jp, d_token_t* item) { uint64_t value = 0; // the resulting value (if it is a integer) jp->c--; // we also need to include hte previous character! @@ -391,7 +395,14 @@ NONULL int parse_number(json_ctx_t* jp, d_token_t* item) { item->data[i] = 0; break; - default: + case ' ': + case '\n': + case '\r': + case '\t': + case '}': + case ']': + case ',': + if ((value & 0xfffffffff0000000) == 0) // is it small ennough to store it in the length ? item->len |= (uint32_t) value; // 32-bit number / no 64-bit number else { @@ -405,16 +416,19 @@ NONULL int parse_number(json_ctx_t* jp, d_token_t* item) { memcpy(item->data, p, len); } break; + default: + jp->c += i; + return JSON_E_INVALID_CHAR; } jp->c += i; return 0; } } - return -2; + return JSON_E_NUMBER_TOO_LONG; } -NONULL int parse_string(json_ctx_t* jp, d_token_t* item) { +NONULL int static parse_string(json_ctx_t* jp, d_token_t* item) { char* start = jp->c; size_t l, i; int n; @@ -424,10 +438,10 @@ NONULL int parse_string(json_ctx_t* jp, d_token_t* item) { while (true) { switch (*(jp->c++)) { case 0: - return -2; + return JSON_E_END_OF_STRING; case '\'': case '"': - if (start[-1] != jp->c[-1]) continue; + if (start[-1] != jp->c[-1]) continue; // is the kind of quote the same as the quote we used to start the string? l = jp->c - start - 1; ishex = l > 1 && *start == '0' && start[1] == 'x' && *(start - 1) != '\''; if (ishex) @@ -494,15 +508,15 @@ NONULL int parse_string(json_ctx_t* jp, d_token_t* item) { } } -NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { +NONULL int static parse_object(json_ctx_t* jp, int parent, uint32_t key) { int res, p_index = jp->len; if (jp->depth > DATA_DEPTH_MAX) - return -3; + return JSON_E_MAX_DEPTH; switch (next_char(jp)) { case 0: - return -2; + return JSON_E_END_OF_STRING; case '{': jp->depth++; parsed_next_item(jp, T_OBJECT, key, parent)->data = (uint8_t*) jp->c - 1; @@ -517,7 +531,7 @@ NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { return 0; } default: - return -2; // invalid character or end + return JSON_E_INVALID_CHAR; // invalid character or end } res = parse_object(jp, p_index, res); // parse the value if (res < 0) return res; @@ -528,7 +542,7 @@ NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { return 0; // this was the last property, so we return successfully. } default: - return -2; // unexpected character, throw. + return JSON_E_INVALID_CHAR; // unexpected character, throw. } } case '[': @@ -550,7 +564,7 @@ NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { return 0; // this was the last element, so we return successfully. } default: - return -2; // unexpected character, throw. + return JSON_E_INVALID_CHAR; // unexpected character, throw. } } case '"': @@ -563,7 +577,7 @@ NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { return 0; } else - return -2; + return JSON_E_INVALID_CHAR; case 'f': if (strncmp(jp->c, "alse", 4) == 0) { parsed_next_item(jp, T_BOOLEAN, key, parent); @@ -571,7 +585,7 @@ NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { return 0; } else - return -2; + return JSON_E_INVALID_CHAR; case 'n': if (strncmp(jp->c, "ull", 3) == 0) { parsed_next_item(jp, T_NULL, key, parent); @@ -579,7 +593,7 @@ NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { return 0; } else - return -2; + return JSON_E_INVALID_CHAR; case '0': case '1': case '2': @@ -594,15 +608,14 @@ NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { case '-': return parse_number(jp, parsed_next_item(jp, T_INTEGER, key, parent)); default: - return -2; + return JSON_E_INVALID_CHAR; } } void json_free(json_ctx_t* jp) { if (!jp || jp->result == NULL) return; if (!d_is_binary_ctx(jp)) { - size_t i; - for (i = 0; i < jp->len; i++) { + for (size_t i = 0; i < jp->len; i++) { if (jp->result[i].data != NULL && d_type(jp->result + i) < 2) _free(jp->result[i].data); } @@ -612,6 +625,35 @@ void json_free(json_ctx_t* jp) { _free(jp); } +char* parse_json_error(const char* js) { + + json_ctx_t parser = {0}; // new parser + parser.c = (char*) js; // the pointer to the string to parse + parser.allocated = JSON_INIT_TOKENS; // keep track of how many tokens we allocated memory for + parser.result = _malloc(sizeof(d_token_t) * JSON_INIT_TOKENS); // we allocate memory for the tokens and reallocate if needed. + const int res = parse_object(&parser, -1, 0); // now parse starting without parent (-1) + for (size_t i = 0; i < parser.len; i++) { + if (parser.result[i].data != NULL && d_type(parser.result + i) < 2) + _free(parser.result[i].data); + } + if (res == 0 || res < JSON_E_NUMBER_TOO_LONG) return NULL; + const char* messages[] = { + "premature end of json-string", + "Unexpected character", + "Reached max depth for parsing json", + "Number too long to parse"}; + sb_t sb = {0}; + sb_print(&sb, "Error parsing json : %s\n", messages[-1 - res]); + int l = (int) (parser.c - js) - 1; + int len = strlen(js); + int s = max(l - 30, 0); + sb_add_range(&sb, js, s, min(l - s + 30, len - s)); + sb_add_char(&sb, '\n'); + for (int n = 0; n < 30 && n < l; n++) sb_add_char(&sb, '-'); + sb_add_char(&sb, '^'); + return sb.data; +} + json_ctx_t* parse_json(const char* js) { json_ctx_t* parser = _calloc(1, sizeof(json_ctx_t)); // new parser parser->c = (char*) js; // the pointer to the string to parse diff --git a/c/src/core/util/data.h b/c/src/core/util/data.h index 7665dc70b..d0666d605 100644 --- a/c/src/core/util/data.h +++ b/c/src/core/util/data.h @@ -139,6 +139,7 @@ d_token_t* d_next(d_token_t* item); NONULL void d_serialize_binary(bytes_builder_t* bb, d_token_t* t); /**< write the token as binary data into the builder */ NONULL json_ctx_t* parse_binary(const bytes_t* data); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ NONULL json_ctx_t* parse_binary_str(const char* data, int len); /**< parses the data and returns the context with the token, which needs to be freed after usage! */ +NONULL char* parse_json_error(const char* js); /**< parses the json, but only return an error if the json is invalid. The returning string must be freed! */ NONULL json_ctx_t* parse_json(const char* js); /**< parses json-data, which needs to be freed after usage! */ NONULL json_ctx_t* parse_json_indexed(const char* js); /**< parses json-data, which needs to be freed after usage! */ NONULL void json_free(json_ctx_t* parser_ctx); /**< frees the parse-context after usage */ From a5458497268363c0249656892de21d6b0c0972a7 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 12 Jul 2021 15:08:21 +0200 Subject: [PATCH 072/110] report better errors on json response --- c/src/core/client/execute.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/c/src/core/client/execute.c b/c/src/core/client/execute.c index 219c2eae9..33dded573 100644 --- a/c/src/core/client/execute.c +++ b/c/src/core/client/execute.c @@ -250,9 +250,10 @@ NONULL static in3_ret_t ctx_parse_response(in3_req_t* ctx, char* response_data, assert_in3_req(ctx); assert(response_data); assert(len); + const is_json = response_data[0] == '{' || response_data[0] == '['; if (is_raw_http(ctx)) { - ctx->response_context = (response_data[0] == '{' || response_data[0] == '[') ? parse_json(response_data) : NULL; + ctx->response_context = is_json ? parse_json(response_data) : NULL; if (!ctx->response_context) { // we create a context only holding the raw data ctx->response_context = _calloc(1, sizeof(json_ctx_t)); @@ -267,10 +268,14 @@ NONULL static in3_ret_t ctx_parse_response(in3_req_t* ctx, char* response_data, return IN3_OK; } - ctx->response_context = (response_data[0] == '{' || response_data[0] == '[') ? parse_json(response_data) : parse_binary_str(response_data, len); + ctx->response_context = is_json ? parse_json(response_data) : parse_binary_str(response_data, len); - if (!ctx->response_context) - return req_set_error(ctx, "Error in JSON-response : ", req_set_error(ctx, str_remove_html(response_data), IN3_EINVALDT)); + if (!ctx->response_context) { + char* error = is_json ? parse_json_error(response_data) : NULL; + req_set_error(ctx, "\nError in JSON-response : ", req_set_error(ctx, error ? error : str_remove_html(response_data), IN3_EINVALDT)); + _free(error); + return IN3_EINVALDT; + } if (d_type(ctx->response_context->result) == T_OBJECT) { // it is a single result From 8533c75b31b818a5443bafb67da5b45b16dd3783 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 12 Jul 2021 15:25:24 +0200 Subject: [PATCH 073/110] fix typo --- c/src/core/client/execute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/core/client/execute.c b/c/src/core/client/execute.c index 33dded573..317969f7e 100644 --- a/c/src/core/client/execute.c +++ b/c/src/core/client/execute.c @@ -250,7 +250,7 @@ NONULL static in3_ret_t ctx_parse_response(in3_req_t* ctx, char* response_data, assert_in3_req(ctx); assert(response_data); assert(len); - const is_json = response_data[0] == '{' || response_data[0] == '['; + const bool is_json = response_data[0] == '{' || response_data[0] == '['; if (is_raw_http(ctx)) { ctx->response_context = is_json ? parse_json(response_data) : NULL; From 466ab06389d444f6e41c779bc1c07f5121c2f8c3 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 12 Jul 2021 20:25:31 +0200 Subject: [PATCH 074/110] fixed memory_leak --- c/src/core/util/data.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/c/src/core/util/data.c b/c/src/core/util/data.c index e56d7488f..6b30bb49d 100644 --- a/c/src/core/util/data.c +++ b/c/src/core/util/data.c @@ -327,7 +327,7 @@ d_token_t* d_next(d_token_t* item) { return item == NULL ? NULL : item + d_token_size(item); } -NONULL static char next_char(json_ctx_t* jp) { +static NONULL char next_char(json_ctx_t* jp) { while (true) { switch (*jp->c) { case ' ': @@ -342,7 +342,7 @@ NONULL static char next_char(json_ctx_t* jp) { } } -RETURNS_NONULL NONULL static d_token_t* parsed_next_item(json_ctx_t* jp, d_type_t type, d_key_t key, int parent) { +static RETURNS_NONULL NONULL d_token_t* parsed_next_item(json_ctx_t* jp, d_type_t type, d_key_t key, int parent) { if (jp->len + 1 > jp->allocated) { jp->result = _realloc(jp->result, (jp->allocated << 1) * sizeof(d_token_t), jp->allocated * sizeof(d_token_t)); jp->allocated <<= 1; @@ -356,7 +356,7 @@ RETURNS_NONULL NONULL static d_token_t* parsed_next_item(json_ctx_t* jp, d_type_ return n; } -NONULL int static parse_key(json_ctx_t* jp) { +static NONULL int parse_key(json_ctx_t* jp) { const char* start = jp->c; int r; while (true) { @@ -372,7 +372,7 @@ NONULL int static parse_key(json_ctx_t* jp) { } } -NONULL int static parse_number(json_ctx_t* jp, d_token_t* item) { +static NONULL int parse_number(json_ctx_t* jp, d_token_t* item) { uint64_t value = 0; // the resulting value (if it is a integer) jp->c--; // we also need to include hte previous character! @@ -428,7 +428,7 @@ NONULL int static parse_number(json_ctx_t* jp, d_token_t* item) { return JSON_E_NUMBER_TOO_LONG; } -NONULL int static parse_string(json_ctx_t* jp, d_token_t* item) { +static NONULL int parse_string(json_ctx_t* jp, d_token_t* item) { char* start = jp->c; size_t l, i; int n; @@ -508,7 +508,7 @@ NONULL int static parse_string(json_ctx_t* jp, d_token_t* item) { } } -NONULL int static parse_object(json_ctx_t* jp, int parent, uint32_t key) { +static NONULL int parse_object(json_ctx_t* jp, int parent, uint32_t key) { int res, p_index = jp->len; if (jp->depth > DATA_DEPTH_MAX) @@ -636,6 +636,7 @@ char* parse_json_error(const char* js) { if (parser.result[i].data != NULL && d_type(parser.result + i) < 2) _free(parser.result[i].data); } + _free(parser.result); if (res == 0 || res < JSON_E_NUMBER_TOO_LONG) return NULL; const char* messages[] = { "premature end of json-string", From 44dbc2bdce6ff7bf83e82dc832459e09b4f540b8 Mon Sep 17 00:00:00 2001 From: leonardotc Date: Wed, 14 Jul 2021 18:36:11 +0200 Subject: [PATCH 075/110] Fix block struct on ZkSyncTxInfo --- c/src/pay/zksync/rpc.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/c/src/pay/zksync/rpc.yml b/c/src/pay/zksync/rpc.yml index 892ccbf90..51ccd9a05 100644 --- a/c/src/pay/zksync/rpc.yml +++ b/c/src/pay/zksync/rpc.yml @@ -497,8 +497,18 @@ zksync: typeName: ZkSyncTxInfo type: block: - descr: the blockNumber containing the tx or `null` if still pending - type: uint64 + typeName: ZkSyncTransactionBlock + descr: the block + type: + blockNumber: + descr: the blockNumber containing the tx or `null` if still pending + type: uint64, + committed: + descr: true, if the block has been commited + type: boolean, + verified: + descr: true, if the block has been verified + type: boolean optional: true executed: descr: true, if the tx has been executed by the operator. If false it is still in the txpool of the operator. From 87a938d2c9de3b8f541e05fd464ee599c31ad661 Mon Sep 17 00:00:00 2001 From: leonardotc Date: Thu, 15 Jul 2021 12:10:34 +0200 Subject: [PATCH 076/110] Fix Error: Failed to execute 'fetch' on 'Window' --- wasm/src/in3.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wasm/src/in3.js b/wasm/src/in3.js index 098bef896..6b769b952 100644 --- a/wasm/src/in3.js +++ b/wasm/src/in3.js @@ -425,9 +425,11 @@ function map_header(headers, entry) { function url_queue(req) { let counter = 0 const promises = [], responses = [] + const METHODS_WITH_PAYLOAD = ['POST', 'PATCH', 'PUT'] + const hasBody = METHODS_WITH_PAYLOAD.includes(req.method) if (req.in3.config.debug) console.log("send req (" + req.ctx + ") to " + req.urls.join() + ' : ', JSON.stringify(req.payload, null, 2)) const transport = req.in3.transport || in3w.transport - req.urls.forEach((url, i) => transport(url, JSON.stringify(req.payload), req.timeout || 30000, req.method, req.headers.reduce(map_header, {})).then( + req.urls.forEach((url, i) => transport(url, hasBody ? JSON.stringify(req.payload) : undefined, req.timeout || 30000, req.method, req.headers.reduce(map_header, {})).then( response => { responses.push({ i, url, response }); trigger() }, error => { responses.push({ i, url, error }); trigger() } )) From 4c36053daea5b4f841ae49b0d7053c4004575e48 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 16 Jul 2021 13:25:15 +0200 Subject: [PATCH 077/110] chaned default gas --- c/src/verifier/eth1/basic/sign_tx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index 5c2d48db2..fa3880e06 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -237,7 +237,7 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst, s address_t from; // read the values - bytes_t gas_limit = d_get(tx, K_GAS) ? get(tx, K_GAS) : (d_get(tx, K_GAS_LIMIT) ? get(tx, K_GAS_LIMIT) : bytes((uint8_t*) "\x52\x08", 2)), + bytes_t gas_limit = d_get(tx, K_GAS) ? get(tx, K_GAS) : (d_get(tx, K_GAS_LIMIT) ? get(tx, K_GAS_LIMIT) : bytes((uint8_t*) "\x75\x30", 2)), to = getl(tx, K_TO, 20), value = get(tx, K_VALUE), data = get(tx, K_DATA), @@ -280,8 +280,8 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst, s // write state? if (meta) { - sb_add_rawbytes(meta, ",\"pre_unsigned\":\"0x", *dst, 0); - sb_add_chars(meta, "\"}"); + sb_add_rawbytes(meta, "},\"pre_unsigned\":\"0x", *dst, 0); + sb_add_chars(meta, "\""); } // do we need to change it? From 701ac4f8c7205bc4a373c9aab8fa0c2d0520e074 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 16 Jul 2021 13:25:32 +0200 Subject: [PATCH 078/110] add param bool --- c/src/core/util/debug.h | 10 ++++++++++ c/src/transport/curl/in3_curl.c | 3 +++ 2 files changed, 13 insertions(+) diff --git a/c/src/core/util/debug.h b/c/src/core/util/debug.h index bcd1a48d8..939f2caf7 100644 --- a/c/src/core/util/debug.h +++ b/c/src/core/util/debug.h @@ -184,6 +184,16 @@ static inline void add_hex(sb_t* sb, char prefix, const char* property, bytes_t else \ target = d_int(t); \ } +#define TRY_PARAM_GET_BOOL(target, ctx, index, def) \ + { \ + const d_token_t* t = d_get_at(ctx->params, index); \ + if (d_type(t) == T_NULL) \ + target = def; \ + else if (d_type(t) != T_BOOLEAN) \ + return req_set_error(ctx->req, "Param at " #index " must be an true or false!", IN3_EINVAL); \ + else \ + target = d_int(t); \ + } #define TRY_PARAM_GET_ADDRESS(target, ctx, index, def) \ { \ diff --git a/c/src/transport/curl/in3_curl.c b/c/src/transport/curl/in3_curl.c index b40862cd7..ab64f9337 100644 --- a/c/src/transport/curl/in3_curl.c +++ b/c/src/transport/curl/in3_curl.c @@ -75,6 +75,9 @@ static void readDataNonBlocking(CURLM* cm, const char* url, const char* payload, curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) payload_len); } + + // curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); + // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*) r); From 0802d7ad49a49e467a8e46c22e46d9f8f28f90e5 Mon Sep 17 00:00:00 2001 From: Leonardo Souza Date: Fri, 16 Jul 2021 14:13:47 +0200 Subject: [PATCH 079/110] Fix wrong if statement condition --- c/src/cmd/in3/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/cmd/in3/main.c b/c/src/cmd/in3/main.c index 129a8517c..01afa8d22 100644 --- a/c/src/cmd/in3/main.c +++ b/c/src/cmd/in3/main.c @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) { continue; } } - if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC) + if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && !strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC) sb_print(args, "\"%s\"", get_wei(argv[i])); else sb_print(args, From cd2ecca83f9e7de60f4e317d2add0f7c137301d2 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 16 Jul 2021 14:32:45 +0200 Subject: [PATCH 080/110] fix #764 --- c/src/api/core/core_api.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/c/src/api/core/core_api.c b/c/src/api/core/core_api.c index 8fa3546fd..2ad2c044b 100644 --- a/c/src/api/core/core_api.c +++ b/c/src/api/core/core_api.c @@ -103,11 +103,11 @@ static in3_ret_t in3_cacheClear(in3_rpc_handle_ctx_t* ctx) { } static in3_ret_t in3_createKey(in3_rpc_handle_ctx_t* ctx) { - bytes32_t hash; - FILE* r = NULL; - if (d_len(ctx->params) == 1) { - CHECK_PARAM_TYPE(ctx->req, ctx->params, 0, T_BYTES) - keccak(d_to_bytes(ctx->params + 1), hash); + bytes32_t hash; + d_token_t* arg = d_get_at(ctx->params, 0); + FILE* r = NULL; + if (d_type(arg) == T_BYTES) { + keccak(d_to_bytes(arg), hash); srand(bytes_to_int(hash, 4)); } else { From 1cfc5f0b0127d5dfd5561178262ef5ac2c7fa135 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 16 Jul 2021 15:30:10 +0200 Subject: [PATCH 081/110] fixed gas_price --- c/test/unit_tests/test_sign.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/test/unit_tests/test_sign.c b/c/test/unit_tests/test_sign.c index e35541700..607ddced2 100644 --- a/c/test/unit_tests/test_sign.c +++ b/c/test/unit_tests/test_sign.c @@ -143,7 +143,7 @@ static void test_sign_hex() { add_response("eth_gasPrice", "[]", "\"0xffff\"", NULL, NULL); add_response("eth_getTransactionCount", "[\"0xb91bd1b8624d7a0a13f1f6ccb1ae3f254d3888ba\",\"latest\"]", "\"0x1\"", NULL, NULL); - in3_req_t* ctx = in3_client_rpc_ctx(c, "eth_sendTransaction", "[{\"to\":\"0x45d45e6ff99e6c34a235d263965910298985fcfe\", \"value\":\"0xff\" }]"); + in3_req_t* ctx = in3_client_rpc_ctx(c, "eth_sendTransaction", "[{\"to\":\"0x45d45e6ff99e6c34a235d263965910298985fcfe\", \"value\":\"0xff\", \"gas\":21000 }]"); TEST_ASSERT_EQUAL(IN3_OK, req_check_response_error(ctx, 0)); TEST_ASSERT_TRUE(ctx && req_get_error(ctx, 0) == IN3_OK); req_free(ctx); @@ -152,7 +152,7 @@ static void test_sign_hex() { static void test_sign_sans_signer_and_from() { in3_t* c = in3_for_chain(CHAIN_ID_MAINNET); - in3_req_t* ctx = in3_client_rpc_ctx(c, "eth_sendTransaction", "[{\"to\":\"0x45d45e6ff99e6c34a235d263965910298985fcfe\", \"value\":\"0xff\" }]"); + in3_req_t* ctx = in3_client_rpc_ctx(c, "eth_sendTransaction", "[{\"to\":\"0x45d45e6ff99e6c34a235d263965910298985fcfe\", \"value\":\"0xff\", \"gas\":21000 }]"); TEST_ASSERT_NOT_NULL(ctx->error); req_free(ctx); in3_free(c); From d5da0fd9838411159471bbe2d836d058a5f08353 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 16 Jul 2021 15:33:48 +0200 Subject: [PATCH 082/110] fixed gas --- c/test/unit_tests/test_sign.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/test/unit_tests/test_sign.c b/c/test/unit_tests/test_sign.c index 607ddced2..660703c9a 100644 --- a/c/test/unit_tests/test_sign.c +++ b/c/test/unit_tests/test_sign.c @@ -78,7 +78,7 @@ static void test_sign() { add_response("eth_gasPrice", "[]", "\"0xffff\"", NULL, NULL); add_response("eth_getTransactionCount", "[\"0xb91bd1b8624d7a0a13f1f6ccb1ae3f254d3888ba\",\"latest\"]", "\"0x1\"", NULL, NULL); - in3_req_t* ctx = in3_client_rpc_ctx(c, "eth_sendTransaction", "[{\"to\":\"0x45d45e6ff99e6c34a235d263965910298985fcfe\", \"value\":\"0xff\" }]"); + in3_req_t* ctx = in3_client_rpc_ctx(c, "eth_sendTransaction", "[{\"to\":\"0x45d45e6ff99e6c34a235d263965910298985fcfe\", \"value\":\"0xff\", \"gas\":21000 }]"); TEST_ASSERT_EQUAL(IN3_OK, req_check_response_error(ctx, 0)); TEST_ASSERT_TRUE(ctx && req_get_error(ctx, 0) == IN3_OK); req_free(ctx); From c3e1e55711ff534f9f92c37c38dd043bbd678476 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 16 Jul 2021 16:06:42 +0200 Subject: [PATCH 083/110] fix TKTransactionBlock --- c/src/pay/zksync/rpc.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/c/src/pay/zksync/rpc.yml b/c/src/pay/zksync/rpc.yml index 51ccd9a05..210eb82e5 100644 --- a/c/src/pay/zksync/rpc.yml +++ b/c/src/pay/zksync/rpc.yml @@ -502,13 +502,13 @@ zksync: type: blockNumber: descr: the blockNumber containing the tx or `null` if still pending - type: uint64, + type: uint64 committed: descr: true, if the block has been commited - type: boolean, + type: bool verified: descr: true, if the block has been verified - type: boolean + type: bool optional: true executed: descr: true, if the tx has been executed by the operator. If false it is still in the txpool of the operator. From dad7f98e05b47b539d731215e800abfebc5ba053 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sat, 17 Jul 2021 14:36:24 +0200 Subject: [PATCH 084/110] fix zksync_history --- c/src/pay/zksync/zk_rest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/pay/zksync/zk_rest.c b/c/src/pay/zksync/zk_rest.c index 3378b9d0c..c4af67bd4 100644 --- a/c/src/pay/zksync/zk_rest.c +++ b/c/src/pay/zksync/zk_rest.c @@ -68,7 +68,7 @@ in3_ret_t zksync_account_history(zksync_config_t* conf, in3_rpc_handle_ctx_t* ct sb_add_chars(&sb, "newer_than"); else if (ref_tx->data[0] == '<' || ref_tx->data[0] == '>') { sb_add_chars(&sb, ref_tx->data[0] == '<' ? "older_than?tx_id=" : "newer_than?tx_id="); - sb_add_chars(&sb, d_string(ref_tx)); + sb_add_chars(&sb, d_string(ref_tx) + 1); sb_add_chars(&sb, "&limit="); sb_add_int(&sb, limit ? (int64_t) d_long(limit) : 100); } From 67997fef48419d7dd5aaad82902cc17c324e98f7 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 19 Jul 2021 13:12:32 +0200 Subject: [PATCH 085/110] support RPC_ONLY --- c/options.cmake | 13 +++++ c/src/api/core/core_api.c | 16 ++++++ c/src/api/eth1/rpc_api.c | 32 ++++++++++++ c/src/core/client/plugin.h | 4 ++ c/src/core/client/request.c | 8 +++ c/src/core/util/bytes.c | 1 + c/src/core/util/utils.c | 2 +- c/src/nodeselect/full/nodeselect_def.c | 16 +++--- c/src/pay/zksync/zksync.c | 36 ++++++++++++- c/src/signer/pk-signer/signer.c | 4 ++ c/src/verifier/btc/btc.c | 11 ++++ c/src/verifier/eth1/basic/eth_basic.c | 72 +++++++++++++++++++------- c/src/verifier/eth1/full/eth_full.c | 5 +- c/src/verifier/eth1/nano/eth_nano.c | 5 +- c/src/verifier/ipfs/ipfs.c | 11 ++-- 15 files changed, 200 insertions(+), 36 deletions(-) diff --git a/c/options.cmake b/c/options.cmake index 325c8cbc4..2406e1628 100644 --- a/c/options.cmake +++ b/c/options.cmake @@ -50,6 +50,7 @@ OPTION(PLGN_CLIENT_DATA "Enable client-data plugin" OFF) OPTION(THREADSAFE "uses mutex to protect shared nodelist access" ON) OPTION(SWIFT "swift API for swift bindings" OFF) OPTION(CORE_API "include basic core-utils" ON) +OPTION(RPC_ONLY "specifies a coma-seperqted list of rpc-methods which should be supported. all other rpc-methods will be removed reducing the size of executable a lot." OFF) IF (DEFINED ANDROID_ABI) @@ -206,6 +207,18 @@ if (NODESELECT_DEF) set(IN3_NODESELECT ${IN3_NODESELECT} nodeselect_def) endif() +# handle RPC +if (RPC_ONLY) + ADD_DEFINITIONS(-DRPC_ONLY) + string(REPLACE "," ";" RPC_ONLY_LIST ${RPC_ONLY}) + foreach(method ${RPC_ONLY_LIST}) + MESSAGE("<<${LETTER}>>") + string(TOUPPER ${method} UPPER_METHOD) + ADD_DEFINITIONS(-DRPC_${UPPER_METHOD}) + endforeach() +endif(RPC_ONLY) + + # handle version if (TAG_VERSION) set(PROJECT_VERSION "${TAG_VERSION}") diff --git a/c/src/api/core/core_api.c b/c/src/api/core/core_api.c index 2ad2c044b..e6164c1fb 100644 --- a/c/src/api/core/core_api.c +++ b/c/src/api/core/core_api.c @@ -140,14 +140,30 @@ static in3_ret_t handle_intern(void* pdata, in3_plugin_act_t action, void* plugi UNUSED_VAR(action); in3_rpc_handle_ctx_t* ctx = plugin_ctx; +#if !defined(RPC_ONLY) || defined(RPC_WEB3_SHA3) TRY_RPC("web3_sha3", in3_sha3(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_KECCAK) TRY_RPC("keccak", in3_sha3(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_SHA256) TRY_RPC("sha256", in3_sha256(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_WEB3_CLIENTVERSION) TRY_RPC("web3_clientVersion", web3_clientVersion(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_CONFIG) TRY_RPC("in3_config", in3_config(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_GETCONFIG) TRY_RPC("in3_getConfig", in3_getConfig(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_CACHECLEAR) TRY_RPC("in3_cacheClear", in3_cacheClear(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_CREATEKEY) TRY_RPC("in3_createKey", in3_createKey(ctx)) +#endif return IN3_EIGNORE; } diff --git a/c/src/api/eth1/rpc_api.c b/c/src/api/eth1/rpc_api.c index c15f84cd0..c5c7a2e79 100644 --- a/c/src/api/eth1/rpc_api.c +++ b/c/src/api/eth1/rpc_api.c @@ -581,25 +581,57 @@ static in3_ret_t handle_intern(void* pdata, in3_plugin_act_t action, void* plugi UNUSED_VAR(action); in3_rpc_handle_ctx_t* ctx = plugin_ctx; +#if !defined(RPC_ONLY) || defined(RPC_ETH_SIGN) TRY_RPC("eth_sign", in3_sign_data(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_SIGNTRANSACTION) TRY_RPC("eth_signTransaction", in3_signTx(ctx)) +#endif if (strncmp(ctx->method, "in3_", 4)) return IN3_EIGNORE; // shortcut +#if !defined(RPC_ONLY) || defined(RPC_IN3_ABIENCODE) TRY_RPC("in3_abiEncode", in3_abiEncode(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_ABIDECODE) TRY_RPC("in3_abiDecode", in3_abiDecode(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_CHECKSUMADDRESS) TRY_RPC("in3_checksumAddress", in3_checkSumAddress(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_ENS) TRY_RPC("in3_ens", in3_ens(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_TOWEI) TRY_RPC("in3_toWei", in3_toWei(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_FROMWEI) TRY_RPC("in3_fromWei", in3_fromWei(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_PK2ADDRESS) TRY_RPC("in3_pk2address", in3_pk2address(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_PK2PUBLIC) TRY_RPC("in3_pk2public", in3_pk2address(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_ECRECOVER) TRY_RPC("in3_ecrecover", in3_ecrecover(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_SIGNDATA) TRY_RPC("in3_signData", in3_sign_data(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_DECRYPTKEY) TRY_RPC("in3_decryptKey", in3_decryptKey(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_PREPARETX) TRY_RPC("in3_prepareTx", in3_prepareTx(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_SIGNTX) TRY_RPC("in3_signTx", in3_signTx(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_CALCDEPLOYADDRESS) TRY_RPC("in3_calcDeployAddress", in3_calcDeployAddress(ctx)) +#endif return IN3_EIGNORE; } diff --git a/c/src/core/client/plugin.h b/c/src/core/client/plugin.h index 1f9033a83..d7b9d01f5 100644 --- a/c/src/core/client/plugin.h +++ b/c/src/core/client/plugin.h @@ -129,6 +129,10 @@ NONULL in3_ret_t in3_rpc_handle_with_string(in3_rpc_handle_ctx_t* hctx, char* da */ NONULL in3_ret_t in3_rpc_handle_with_int(in3_rpc_handle_ctx_t* hctx, uint64_t value); +/** + * creates a response with bytes but without a leading 0. + */ +NONULL in3_ret_t in3_rpc_handle_with_uint256(in3_rpc_handle_ctx_t* hctx, bytes_t data); // -------------- TRANSPORT ------------- /** diff --git a/c/src/core/client/request.c b/c/src/core/client/request.c index d57ef8102..2072a80fd 100644 --- a/c/src/core/client/request.c +++ b/c/src/core/client/request.c @@ -313,6 +313,14 @@ in3_ret_t in3_rpc_handle_with_bytes(in3_rpc_handle_ctx_t* hctx, bytes_t data) { return in3_rpc_handle_finish(hctx); } +in3_ret_t in3_rpc_handle_with_uint256(in3_rpc_handle_ctx_t* hctx, bytes_t data) { + b_optimize_len(&data); + sb_t* sb = in3_rpc_handle_start(hctx); + sb_add_rawbytes(sb, "\"0x", data, -1); + sb_add_char(sb, '"'); + return in3_rpc_handle_finish(hctx); +} + in3_ret_t in3_rpc_handle_with_string(in3_rpc_handle_ctx_t* hctx, char* data) { sb_add_chars(in3_rpc_handle_start(hctx), data); return in3_rpc_handle_finish(hctx); diff --git a/c/src/core/util/bytes.c b/c/src/core/util/bytes.c index 49320a86d..8010f945b 100644 --- a/c/src/core/util/bytes.c +++ b/c/src/core/util/bytes.c @@ -73,6 +73,7 @@ void ba_print(const uint8_t* a, size_t l) { if (l < 9) { in3_log_trace(" ( %" PRId64 " ) ", bytes_to_long(a, l)); } + in3_log_trace("\n"); if (o) in3_log_enable_prefix(); } diff --git a/c/src/core/util/utils.c b/c/src/core/util/utils.c index 992ee72eb..e19168bdb 100644 --- a/c/src/core/util/utils.c +++ b/c/src/core/util/utils.c @@ -425,7 +425,7 @@ void b256_add(bytes32_t a, uint8_t* b, wlen_t len_b) { *pa = carry & 0xFF; carry >>= 8; pb--, pa--; - } while (b == pb); + } while (pb >= b); while (carry && pa >= a) { carry += *pa; diff --git a/c/src/nodeselect/full/nodeselect_def.c b/c/src/nodeselect/full/nodeselect_def.c index 75b6aca32..362c825d3 100644 --- a/c/src/nodeselect/full/nodeselect_def.c +++ b/c/src/nodeselect/full/nodeselect_def.c @@ -59,16 +59,20 @@ static in3_ret_t rpc_verify(in3_nodeselect_def_t* data, in3_vctx_t* vc) { // do we have a result? if not it is a valid error-response if (!vc->result) return IN3_OK; +#if !defined(RPC_ONLY) || defined(RPC_IN3_NODELIST) if (VERIFY_RPC("in3_nodeList")) { d_token_t* params = d_get(vc->request, K_PARAMS); return eth_verify_in3_nodelist(data, vc, d_get_int_at(params, 0), d_get_bytes_at(params, 1), d_get_at(params, 2)); } +#endif + #ifdef NODESELECT_DEF_WL - else if (strcmp(vc->method, "in3_whiteList") == 0) +#if !defined(RPC_ONLY) || defined(RPC_IN3_WHITELIST) + if (strcmp(vc->method, "in3_whiteList") == 0) return eth_verify_in3_whitelist(data, vc); #endif - else - return IN3_EIGNORE; +#endif + return IN3_EIGNORE; } static uint16_t avg_block_time_for_chain_id(chain_id_t id) { @@ -594,9 +598,9 @@ static void check_autoupdate(const in3_req_t* ctx, in3_nodeselect_def_t* data, d memcpy(data->nodelist_upd8_params->node, n->address, 20); data->nodelist_upd8_params->exp_last_block = d_get_long(response_in3, K_LAST_NODE_LIST); data->nodelist_upd8_params->timestamp = in3_time(NULL) + update_waittime(d_get_long(response_in3, K_LAST_NODE_LIST), - d_get_long(response_in3, K_CURRENT_BLOCK), - ctx->client->replace_latest_block, - data->avg_block_time); + d_get_long(response_in3, K_CURRENT_BLOCK), + ctx->client->replace_latest_block, + data->avg_block_time); } } diff --git a/c/src/pay/zksync/zksync.c b/c/src/pay/zksync/zksync.c index 09b30de3e..a12827f67 100644 --- a/c/src/pay/zksync/zksync.c +++ b/c/src/pay/zksync/zksync.c @@ -149,25 +149,57 @@ static in3_ret_t zksync_rpc(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { const cache_entry_t* cached = in3_cache_get_entry_by_prop(ctx->req->cache, ZKSYNC_CACHED_CONFIG); if (cached) conf = (void*) cached->value.data; - // handle rpc -functions + // handle rpc -functions +#if !defined(RPC_ONLY) || defined(RPC_DEPOSIT) TRY_RPC("deposit", zksync_deposit(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_TRANSFER) TRY_RPC("transfer", zksync_transfer(conf, ctx, ZK_TRANSFER)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_WITHDRAW) TRY_RPC("withdraw", zksync_transfer(conf, ctx, ZK_WITHDRAW)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_SET_KEY) TRY_RPC("set_key", zksync_set_key(conf, ctx, false)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_EMERGENCY_WITHDRAW) TRY_RPC("emergency_withdraw", zksync_emergency_withdraw(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_SYNC_KEY) TRY_RPC("sync_key", zksync_get_key(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_AGGREGATE_PUBKEY) TRY_RPC("aggregate_pubkey", zksync_aggregate_pubkey(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_PUBKEYHASH) TRY_RPC("pubkeyhash", zksync_get_pubkeyhash(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_PUBKEY) TRY_RPC("pubkey", zksync_get_pubkey(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ACCOUNT_ADDRESS) TRY_RPC("account_address", zksync_account_address(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_CONTRACT_ADDRESS) TRY_RPC("contract_address", zksync_contract_address(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_TOKENS) TRY_RPC("tokens", zksync_tokens(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_SIGN) TRY_RPC("sign", zksync_musig_sign(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_VERIFY) TRY_RPC("verify", in3_rpc_handle_with_int(ctx, conf->musig_pub_keys.data ? zkcrypto_verify_signatures(d_to_bytes(ctx->params + 1), conf->musig_pub_keys, d_to_bytes(ctx->params + 2)) : zkcrypto_verify_musig(d_to_bytes(ctx->params + 1), d_to_bytes(ctx->params + 2)))) +#endif +#if !defined(RPC_ONLY) || defined(RPC_TX_DATA) TRY_RPC("tx_data", zksync_tx_data(conf, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ACCOUNT_HISTORY) TRY_RPC("account_history", zksync_account_history(conf, ctx)) +#endif // prepare fallback to send to zksync-server str_range_t p = d_to_json(ctx->params); @@ -175,6 +207,7 @@ static in3_ret_t zksync_rpc(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { memcpy(param_string, p.data + 1, p.len - 2); param_string[p.len - 2] = 0; +#if !defined(RPC_ONLY) || defined(RPC_ZKSYNC_ACCOUNT_INFO) if (strcmp(ctx->method, "account_info") == 0) { if (*param_string == 0 || strcmp(param_string, "null") == 0) { TRY(zksync_get_account(conf, ctx->req, NULL)) @@ -184,6 +217,7 @@ static in3_ret_t zksync_rpc(zksync_config_t* conf, in3_rpc_handle_ctx_t* ctx) { else CHECK_PARAM_ADDRESS(ctx->req, ctx->params, 0) } +#endif // we need to show the arguments as integers if (strcmp(ctx->method, "ethop_info") == 0) diff --git a/c/src/signer/pk-signer/signer.c b/c/src/signer/pk-signer/signer.c index 046645950..9253df68e 100644 --- a/c/src/signer/pk-signer/signer.c +++ b/c/src/signer/pk-signer/signer.c @@ -225,8 +225,12 @@ static in3_ret_t pk_rpc(void* data, in3_plugin_act_t action, void* action_ctx) { case PLGN_ACT_RPC_HANDLE: { in3_rpc_handle_ctx_t* ctx = action_ctx; +#if !defined(RPC_ONLY) || defined(RPC_IN3_ADDRAWKEY) TRY_RPC("in3_addRawKey", add_raw_key(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_ACCOUNTS) TRY_RPC("eth_accounts", eth_accounts(ctx)) +#endif return IN3_EIGNORE; } diff --git a/c/src/verifier/btc/btc.c b/c/src/verifier/btc/btc.c index e53425fd5..b7a240383 100644 --- a/c/src/verifier/btc/btc.c +++ b/c/src/verifier/btc/btc.c @@ -445,6 +445,7 @@ static in3_ret_t in3_verify_btc(btc_target_conf_t* conf, in3_vctx_t* vc) { d_token_t* params = d_get(vc->request, K_PARAMS); bytes32_t hash; +#if !defined(RPC_ONLY) || defined(RPC_GETBLOCK) if (VERIFY_RPC("getblock")) { // mark zksync as experimental REQUIRE_EXPERIMENTAL(vc->req, "btc") @@ -454,10 +455,14 @@ static in3_ret_t in3_verify_btc(btc_target_conf_t* conf, in3_vctx_t* vc) { hex_to_bytes(d_string(block_hash), 64, hash, 32); return btc_verify_block(conf, vc, hash, d_len(params) > 1 ? d_get_int_at(params, 1) : 1, true); } +#endif +#if !defined(RPC_ONLY) || defined(RPC_GETBLOCKCOUNT) if (VERIFY_RPC("getblockcount")) { REQUIRE_EXPERIMENTAL(vc->req, "btc") return btc_verify_blockcount(conf, vc); } +#endif +#if !defined(RPC_ONLY) || defined(RPC_GETBLOCKHEADER) if (VERIFY_RPC("getblockheader")) { REQUIRE_EXPERIMENTAL(vc->req, "btc") d_token_t* block_hash = d_get_at(params, 0); @@ -465,10 +470,15 @@ static in3_ret_t in3_verify_btc(btc_target_conf_t* conf, in3_vctx_t* vc) { hex_to_bytes(d_string(block_hash), 64, hash, 32); return btc_verify_block(conf, vc, hash, d_len(params) > 1 ? d_get_int_at(params, 1) : 1, false); } +#endif +#if !defined(RPC_ONLY) || defined(RPC_BTC_PROOFTARGET) if (VERIFY_RPC("btc_proofTarget")) { REQUIRE_EXPERIMENTAL(vc->req, "btc") return btc_verify_target_proof(conf, vc, params); } +#endif +#if !defined(RPC_ONLY) || defined(RPC_GETRAWTRANSACTION) + if (VERIFY_RPC("getrawtransaction")) { REQUIRE_EXPERIMENTAL(vc->req, "btc") d_token_t* tx_id = d_get_at(params, 0); @@ -480,6 +490,7 @@ static in3_ret_t in3_verify_btc(btc_target_conf_t* conf, in3_vctx_t* vc) { if (block_hash) hex_to_bytes(d_string(block_hash), 64, hash, 32); return btc_verify_tx(conf, vc, tx_hash_bytes, json, block_hash ? hash : NULL); } +#endif return IN3_EIGNORE; } diff --git a/c/src/verifier/eth1/basic/eth_basic.c b/c/src/verifier/eth1/basic/eth_basic.c index 19f080621..c6ef45320 100644 --- a/c/src/verifier/eth1/basic/eth_basic.c +++ b/c/src/verifier/eth1/basic/eth_basic.c @@ -56,42 +56,58 @@ in3_ret_t in3_verify_eth_basic(in3_vctx_t* vc) { if (in3_req_get_proof(vc->req, vc->index) == PROOF_NONE) return IN3_OK; // do we have a result? if not it is a valid error-response - if (!vc->result) - return IN3_OK; - else if (d_type(vc->result) == T_NULL) { + if (!vc->result) return IN3_OK; + + if (d_type(vc->result) == T_NULL) { // check if there's a proof for non-existence +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETTRANSACTIONBYBLOCKHASHANDINDEX) || defined(RPC_ETH_GETTRANSACTIONBYBLOCKNUMBERANDINDEX) if (VERIFY_RPC("eth_getTransactionByBlockHashAndIndex") || VERIFY_RPC("eth_getTransactionByBlockNumberAndIndex")) return eth_verify_eth_getTransactionByBlock(vc, d_get_at(d_get(vc->request, K_PARAMS), 0), d_get_int_at(d_get(vc->request, K_PARAMS), 1)); +#endif return IN3_OK; } - if (VERIFY_RPC("eth_getTransactionByHash")) - return eth_verify_eth_getTransaction(vc, d_get_bytes_at(d_get(vc->request, K_PARAMS), 0)); - else if (VERIFY_RPC("eth_getTransactionByBlockHashAndIndex") || VERIFY_RPC("eth_getTransactionByBlockNumberAndIndex")) +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETTRANSACTIONBYHASH) + if (VERIFY_RPC("eth_getTransactionByHash")) return eth_verify_eth_getTransaction(vc, d_get_bytes_at(d_get(vc->request, K_PARAMS), 0)); +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETTRANSACTIONBYBLOCKHASHANDINDEX) || defined(RPC_ETH_GETTRANSACTIONBYBLOCKNUMBERANDINDEX) + if (VERIFY_RPC("eth_getTransactionByBlockHashAndIndex") || VERIFY_RPC("eth_getTransactionByBlockNumberAndIndex")) return eth_verify_eth_getTransactionByBlock(vc, d_get_at(d_get(vc->request, K_PARAMS), 0), d_get_int_at(d_get(vc->request, K_PARAMS), 1)); - else if (VERIFY_RPC("eth_getBlockByNumber")) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETBLOCKBYNUMBER) + if (VERIFY_RPC("eth_getBlockByNumber")) return eth_verify_eth_getBlock(vc, NULL, d_get_long_at(d_get(vc->request, K_PARAMS), 0)); - else if (VERIFY_RPC("eth_getBlockTransactionCountByHash")) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETTRANSACTIONCOUNTBYHASH) + if (VERIFY_RPC("eth_getBlockTransactionCountByHash")) return eth_verify_eth_getBlockTransactionCount(vc, d_get_bytes_at(d_get(vc->request, K_PARAMS), 0), 0); - else if (VERIFY_RPC("eth_getBlockTransactionCountByNumber")) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETTRANSACTIONCOUNTBYNUMBER) + if (VERIFY_RPC("eth_getBlockTransactionCountByNumber")) return eth_verify_eth_getBlockTransactionCount(vc, NULL, d_get_long_at(d_get(vc->request, K_PARAMS), 0)); - else if (VERIFY_RPC("eth_getBlockByHash")) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETBLOCKBYHASH) + if (VERIFY_RPC("eth_getBlockByHash")) return eth_verify_eth_getBlock(vc, d_get_bytes_at(d_get(vc->request, K_PARAMS), 0), 0); - else if (VERIFY_RPC("eth_getBalance") || VERIFY_RPC("eth_getCode") || VERIFY_RPC("eth_getStorageAt") || VERIFY_RPC("eth_getTransactionCount")) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETBALANCE) || defined(RPC_ETH_GETCODE) || defined(RPC_ETH_GETSTORAGEAT) || defined(RPC_ETH_GETTRANSACTIONCOUNT) + if (VERIFY_RPC("eth_getBalance") || VERIFY_RPC("eth_getCode") || VERIFY_RPC("eth_getStorageAt") || VERIFY_RPC("eth_getTransactionCount")) return eth_verify_account_proof(vc); - else if (VERIFY_RPC("eth_gasPrice")) - return IN3_OK; - else if (VERIFY_RPC("eth_newFilter") || VERIFY_RPC("eth_newBlockFilter") || VERIFY_RPC("eth_newPendingFilter") || VERIFY_RPC("eth_uninstallFilter") || VERIFY_RPC("eth_getFilterChanges")) +#endif + if (VERIFY_RPC("eth_gasPrice") || VERIFY_RPC("eth_newFilter") || VERIFY_RPC("eth_newBlockFilter") || VERIFY_RPC("eth_newPendingFilter") || VERIFY_RPC("eth_uninstallFilter") || VERIFY_RPC("eth_getFilterChanges")) return IN3_OK; - else if (VERIFY_RPC("eth_getLogs")) // for txReceipt, we need the txhash +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETLOGS) + if (VERIFY_RPC("eth_getLogs")) // for txReceipt, we need the txhash return eth_verify_eth_getLog(vc, d_len(vc->result)); - else if (VERIFY_RPC("eth_sendRawTransaction")) { +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_SENDRAWTRANSACTION) + if (VERIFY_RPC("eth_sendRawTransaction")) { bytes32_t hash; keccak(d_to_bytes(d_get_at(d_get(vc->request, K_PARAMS), 0)), hash); return bytes_cmp(*d_bytes(vc->result), bytes(hash, 32)) ? IN3_OK : vc_err(vc, "the transactionHash of the response does not match the raw transaction!"); } - else - return IN3_EIGNORE; +#endif + return IN3_EIGNORE; } static in3_ret_t eth_send_transaction_and_wait(in3_rpc_handle_ctx_t* ctx) { @@ -178,21 +194,37 @@ static in3_ret_t eth_getFilterChanges(in3_filter_handler_t* filters, in3_rpc_han /** called to see if we can handle the request internally */ static in3_ret_t eth_handle_intern(in3_filter_handler_t* filters, in3_rpc_handle_ctx_t* ctx) { - + UNUSED_VAR(filters); // we only support ETH in this module if (ctx->req->client->chain.type != CHAIN_ETH) return IN3_EIGNORE; - // check method to handle internally + // check method to handle internally +#if !defined(RPC_ONLY) || defined(RPC_ETH_SENDTRANSACTION) TRY_RPC("eth_sendTransaction", handle_eth_sendTransaction(ctx->req, ctx->request)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_SENDTRANSACTIONANDWAIT) TRY_RPC("eth_sendTransactionAndWait", eth_send_transaction_and_wait(ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_NEWFILTER) TRY_RPC("eth_newFilter", eth_newFilter(filters, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_NEWBLOCKFILTER) TRY_RPC("eth_newBlockFilter", eth_newBlockFilter(filters, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_NEWPENDINGTRANSACTIONFILTER) TRY_RPC("eth_newPendingTransactionFilter", req_set_error(ctx->req, "pending filter not supported", IN3_ENOTSUP)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETFILTERCHANGES) TRY_RPC("eth_getFilterChanges", eth_getFilterChanges(filters, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETFILTERLOGS) TRY_RPC("eth_getFilterLogs", eth_getFilterChanges(filters, ctx)) +#endif +#if !defined(RPC_ONLY) || defined(RPC_ETH_UNINSTALLFILTER) TRY_RPC("eth_uninstallFilter", (!ctx->params || d_len(ctx->params) == 0 || d_type(ctx->params + 1) != T_INTEGER) ? req_set_error(ctx->req, "invalid type of params, expected filter-id as integer", IN3_EINVAL) : in3_rpc_handle_with_string(ctx, filter_remove(filters, d_get_long_at(ctx->params, 0)) ? "true" : "false")) +#endif if (strcmp(ctx->method, "eth_chainId") == 0 && ctx->req->client->chain.chain_id != CHAIN_ID_LOCAL) return in3_rpc_handle_with_int(ctx, ctx->req->client->chain.chain_id); diff --git a/c/src/verifier/eth1/full/eth_full.c b/c/src/verifier/eth1/full/eth_full.c index bfebfebf6..c45f25545 100644 --- a/c/src/verifier/eth1/full/eth_full.c +++ b/c/src/verifier/eth1/full/eth_full.c @@ -56,6 +56,7 @@ in3_ret_t in3_verify_eth_full(void* pdata, in3_plugin_act_t action, void* pctx) // do we have a result? if not it is a vaslid error-response if (!vc->result) return IN3_OK; +#if !defined(RPC_ONLY) || defined(RPC_ETH_CALL) if (VERIFY_RPC("eth_call")) { if (eth_verify_account_proof(vc) < 0) return vc_err(vc, "proof could not be validated"); d_token_t* tx = d_get_at(d_get(vc->request, K_PARAMS), 0); @@ -131,8 +132,8 @@ in3_ret_t in3_verify_eth_full(void* pdata, in3_plugin_act_t action, void* pctx) return req_set_error(vc->req, "General Error during execution", (in3_ret_t) ret); } } - else - return IN3_EIGNORE; +#endif + return IN3_EIGNORE; } in3_ret_t in3_register_eth_full(in3_t* c) { diff --git a/c/src/verifier/eth1/nano/eth_nano.c b/c/src/verifier/eth1/nano/eth_nano.c index 4ecf14564..19f882143 100644 --- a/c/src/verifier/eth1/nano/eth_nano.c +++ b/c/src/verifier/eth1/nano/eth_nano.c @@ -62,11 +62,12 @@ in3_ret_t in3_verify_eth_nano(void* p_data, in3_plugin_act_t action, void* pctx) return IN3_OK; } +#if !defined(RPC_ONLY) || defined(RPC_ETH_GETTRANSACTIONRECEIPT) if (VERIFY_RPC("eth_getTransactionReceipt")) // for txReceipt, we need the txhash return eth_verify_eth_getTransactionReceipt(vc, d_get_bytes_at(d_get(vc->request, K_PARAMS), 0)); - else - return IN3_EIGNORE; +#endif + return IN3_EIGNORE; } in3_ret_t in3_register_eth_nano(in3_t* c) { diff --git a/c/src/verifier/ipfs/ipfs.c b/c/src/verifier/ipfs/ipfs.c index 0f267a2d6..dc85655e2 100644 --- a/c/src/verifier/ipfs/ipfs.c +++ b/c/src/verifier/ipfs/ipfs.c @@ -155,16 +155,19 @@ in3_ret_t in3_verify_ipfs(void* pdata, in3_plugin_act_t action, void* pctx) { if (strcmp(vc->method, "in3_nodeList") == 0) return true; - else if (VERIFY_RPC("ipfs_get")) +#if !defined(RPC_ONLY) || defined(RPC_IPFS_GET) + if (VERIFY_RPC("ipfs_get")) return ipfs_verify_hash(d_string(vc->result), d_get_string_at(params, 1) ? d_get_string_at(params, 1) : "base64", d_get_string_at(params, 0)); - else if (VERIFY_RPC("ipfs_put")) +#endif +#if !defined(RPC_ONLY) || defined(RPC_IPFS_PUT) + if (VERIFY_RPC("ipfs_put")) return ipfs_verify_hash(d_get_string_at(params, 0), d_get_string_at(params, 1) ? d_get_string_at(params, 1) : "base64", d_string(vc->result)); - else - return IN3_EIGNORE; +#endif + return IN3_EIGNORE; } in3_ret_t in3_register_ipfs(in3_t* c) { in3_register_eth_nano(c); From 69eb5b10eca5ea1653c7aa9658c526d9c7b3a89a Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 19 Jul 2021 13:16:15 +0200 Subject: [PATCH 086/110] update options --- c/docs/1_install.md | 98 ++++++++++++++++++++++++++++++++++--- c/include/in3/plugin.h | 4 ++ c/src/core/util/used_keys.h | 51 ++++--------------- 3 files changed, 104 insertions(+), 49 deletions(-) diff --git a/c/docs/1_install.md b/c/docs/1_install.md index 5b2195c6b..2ac1a68d0 100644 --- a/c/docs/1_install.md +++ b/c/docs/1_install.md @@ -40,6 +40,13 @@ Default-Value: `-DASSERTIONS=OFF` Default-Value: `-DBTC=ON` +#### BTC_PRE_BPI34 + + Enable BTC-Verfification for blocks before BIP34 was activated + +Default-Value: `-DBTC_PRE_BPI34=ON` + + #### BUILD_DOC generates the documenation with doxygen. @@ -68,11 +75,11 @@ Default-Value: `-DCODE_COVERAGE=OFF` Default-Value: `-DCOLOR=ON` -#### DEV_NO_INTRN_PTR +#### CORE_API - (*dev option*) if true the client will NOT include a void pointer (named internal) for use by devs) + registers a chain independend rpc-methods util-functions -Default-Value: `-DDEV_NO_INTRN_PTR=ON` +Default-Value: `-DCORE_API=ON` #### ESP_IDF @@ -184,7 +191,21 @@ Default-Value: `-DLOGGING=ON` add capapbility to sign with a multig. Currrently only gnosis safe is supported -Default-Value: `-DMULTISIG=OFF` +Default-Value: `-DMULTISIG=ON` + + +#### NODESELECT_DEF + + Enable default nodeselect implementation + +Default-Value: `-DNODESELECT_DEF=ON` + + +#### NODESELECT_DEF_WL + + Enable default nodeselect whitelist implementation + +Default-Value: `-DNODESELECT_DEF_WL=ON` #### PAY_ETH @@ -198,7 +219,21 @@ Default-Value: `-DPAY_ETH=OFF` pkg-config executable -Default-Value: `-DPKG_CONFIG_EXECUTABLE=/opt/local/bin/pkg-config` +Default-Value: `-DPKG_CONFIG_EXECUTABLE=/opt/homebrew/bin/pkg-config` + + +#### PK_SIGNER + + Enable Signing with private keys + +Default-Value: `-DPK_SIGNER=ON` + + +#### PLGN_CLIENT_DATA + + Enable client-data plugin + +Default-Value: `-DPLGN_CLIENT_DATA=OFF` #### POA @@ -208,6 +243,20 @@ Default-Value: `-DPKG_CONFIG_EXECUTABLE=/opt/local/bin/pkg-config` Default-Value: `-DPOA=OFF` +#### RECORDER + + enable recording option for reproduce executions + +Default-Value: `-DRECORDER=ON` + + +#### RPC_ONLY + + specifies a coma-seperqted list of rpc-methods which should be supported. all other rpc-methods will be removed reducing the size of executable a lot. + +Default-Value: `-DRPC_ONLY=OFF` + + #### SEGGER_RTT Use the segger real time transfer terminal as the logging mechanism @@ -215,6 +264,20 @@ Default-Value: `-DPOA=OFF` Default-Value: `-DSEGGER_RTT=OFF` +#### SENTRY + + Enable Sentry + +Default-Value: `-DSENTRY=OFF` + + +#### SWIFT + + swift API for swift bindings + +Default-Value: `-DSWIFT=OFF` + + #### TAG_VERSION the tagged version, which should be used @@ -229,6 +292,13 @@ Default-Value: `-DTAG_VERSION=OFF` Default-Value: `-DTEST=OFF` +#### THREADSAFE + + uses mutex to protect shared nodelist access + +Default-Value: `-DTHREADSAFE=ON` + + #### TRANSPORTS builds transports, which may require extra libraries. @@ -257,6 +327,13 @@ Default-Value: `-DUSE_PRECOMPUTED_EC=ON` Default-Value: `-DUSE_SCRYPT=ON` +#### USE_WINHTTP + + if true the winhttp transport will be built (with a dependency to winhttp) + +Default-Value: `-DUSE_WINHTTP=OFF` + + #### WASM Includes the WASM-Build. In order to build it you need emscripten as toolchain. Usually you also want to turn off other builds in this case. @@ -285,10 +362,17 @@ Default-Value: `-DWASM_EMMALLOC=ON` Default-Value: `-DWASM_SYNC=OFF` +#### ZKCRYPTO_LIB + + Path to the static zkcrypto-lib + +Default-Value: `-DZKCRYPTO_LIB=OFF` + + #### ZKSYNC - add RPC-functioin to handle zksync-payments + add RPC-function to handle zksync-payments -Default-Value: `-DZKSYNC=OFF` +Default-Value: `-DZKSYNC=ON` diff --git a/c/include/in3/plugin.h b/c/include/in3/plugin.h index 1f9033a83..d7b9d01f5 100644 --- a/c/include/in3/plugin.h +++ b/c/include/in3/plugin.h @@ -129,6 +129,10 @@ NONULL in3_ret_t in3_rpc_handle_with_string(in3_rpc_handle_ctx_t* hctx, char* da */ NONULL in3_ret_t in3_rpc_handle_with_int(in3_rpc_handle_ctx_t* hctx, uint64_t value); +/** + * creates a response with bytes but without a leading 0. + */ +NONULL in3_ret_t in3_rpc_handle_with_uint256(in3_rpc_handle_ctx_t* hctx, bytes_t data); // -------------- TRANSPORT ------------- /** diff --git a/c/src/core/util/used_keys.h b/c/src/core/util/used_keys.h index d1ceac0ee..8f0853ac7 100644 --- a/c/src/core/util/used_keys.h +++ b/c/src/core/util/used_keys.h @@ -10,8 +10,6 @@ static char* USED_KEYS[] = { "amount", "approveDepositAmountForERC20", "author", - "autoUpdateList", - "avgBlockTime", "balance", "bits", "block", @@ -19,7 +17,6 @@ static char* USED_KEYS[] = { "blockNumber", "blockhash", "blocktime", - "bootWeights", "bulkSize", "bypassFinality", "c", @@ -27,14 +24,12 @@ static char* USED_KEYS[] = { "cbtx", "cbtxMerkleProof", "chainId", - "chainType", "chainwork", "cipher", "cipherparams", "ciphertext", "code", "codeHash", - "codehash", "coinbase", "commitment", "committed", @@ -42,16 +37,13 @@ static char* USED_KEYS[] = { "contract", "contractAddress", "count", - "create2", - "create_proof_method", - "creator", "crypto", "cumulativeGasUsed", "currentBlock", "data", "dataNodes", - "debug", "decimals", + "deploy_data", "deposit", "depositTo", "difficulty", @@ -60,12 +52,13 @@ static char* USED_KEYS[] = { "error", "ethAddress", "execTime", - "experimental", "extraData", "fee", "final", "finality", "finalityBlocks", + "fn_args", + "fn_sig", "from", "fromBlock", "gas", @@ -79,20 +72,18 @@ static char* USED_KEYS[] = { "id", "in3", "in_active_chain", - "incentive", - "includeCode", "index", "input", "iv", "kdf", "kdfparams", - "keepIn3", "key", "lastBlockNumber", "lastNodeList", "lastValidatorChange", "lastWhiteList", "last_failed", + "level", "list", "locktime", "logIndex", @@ -101,34 +92,21 @@ static char* USED_KEYS[] = { "logsBloom", "mac", "mainContract", - "main_contract", - "maxAttempts", - "maxDAP", - "maxDiff", "maxPrice", - "maxVerifiedHashes", - "max_price", "merkleProof", "merkleroot", "message", "method", - "minDeposit", "miner", "mixHash", "msSigs", + "msg", "msgHash", "msgType", - "musig_pub_keys", - "musig_urls", "n", "nTx", "name", - "needsUpdate", "nextblockhash", - "nodeLimit", - "nodeList", - "nodeProps", - "nodeRegistry", "nodes", "nonce", "number", @@ -138,17 +116,17 @@ static char* USED_KEYS[] = { "parentHash", "pay", "payed", + "pdata", "performance", - "pk", + "pgas", "pre_commitment", - "preselect_nodes", "previousblockhash", "prf", "price", "priceList", "proof", "props", - "provider_url", + "pto", "pubKeyHash", "pub_keys", "publicKey", @@ -160,7 +138,6 @@ static char* USED_KEYS[] = { "registerTime", "registryId", "removed", - "replaceLatestBlock", "requestCount", "result", "root", @@ -170,27 +147,22 @@ static char* USED_KEYS[] = { "running", "s", "salt", - "saltarg", "sealFields", "sequence", "sha3Uncles", "sig", "signature", - "signatureCount", "signatures", "signedError", "signerNodes", - "signer_type", "size", "standardV", "stateRoot", "states", - "stats", "status", "storageHash", "storageProof", "symbol", - "sync_key", "time", "timeout", "timestamp", @@ -214,24 +186,19 @@ static char* USED_KEYS[] = { "type", "uncles", "url", - "useBinary", - "useHttp", "v", "validatorContract", "validatorList", "validators", "value", "verification", - "verifiedHashes", - "verify_proof_method", "version", "versionHex", "vin", "vout", "vsize", "wait", + "wallet", "weight", - "whiteList", - "whiteListContract", "zksync", 0}; From 40a61daeac8bdb0fbc6cc8da6342e5fe5431e966 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 19 Jul 2021 14:02:48 +0200 Subject: [PATCH 087/110] fix unsused functions for wasm --- c/compiler.cmake | 4 ++-- c/src/api/core/core_api.c | 3 ++- c/src/nodeselect/full/nodeselect_def.c | 1 + c/src/signer/pk-signer/signer.c | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/c/compiler.cmake b/c/compiler.cmake index cbab98147..fe8e3d22c 100644 --- a/c/compiler.cmake +++ b/c/compiler.cmake @@ -10,8 +10,8 @@ else(MSVC) endif() endif(MSVC) if (WASM) - set (CMAKE_C_FLAGS "-Wall -funsigned-char -Wextra -std=c99 ") - set (CMAKE_CXX_FLAGS "-Wall -funsigned-char -Wextra -std=c99 -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") + set (CMAKE_C_FLAGS "-Wall -funsigned-char -Wextra -std=c99 -Wno-unused-function") + set (CMAKE_CXX_FLAGS "-Wall -funsigned-char -Wextra -std=c99 -Wno-unused-function -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") if (CMAKE_BUILD_TYPE MATCHES Debug) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined,address -fsanitize-minimal-runtime") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined,address -fsanitize-minimal-runtime") diff --git a/c/src/api/core/core_api.c b/c/src/api/core/core_api.c index e6164c1fb..4a9e0ae35 100644 --- a/c/src/api/core/core_api.c +++ b/c/src/api/core/core_api.c @@ -136,10 +136,11 @@ static in3_ret_t in3_createKey(in3_rpc_handle_ctx_t* ctx) { } static in3_ret_t handle_intern(void* pdata, in3_plugin_act_t action, void* plugin_ctx) { + in3_rpc_handle_ctx_t* ctx = plugin_ctx; UNUSED_VAR(pdata); UNUSED_VAR(action); + UNUSED_VAR(ctx); // in case RPC_ONLY is used - in3_rpc_handle_ctx_t* ctx = plugin_ctx; #if !defined(RPC_ONLY) || defined(RPC_WEB3_SHA3) TRY_RPC("web3_sha3", in3_sha3(ctx)) #endif diff --git a/c/src/nodeselect/full/nodeselect_def.c b/c/src/nodeselect/full/nodeselect_def.c index 362c825d3..beba62299 100644 --- a/c/src/nodeselect/full/nodeselect_def.c +++ b/c/src/nodeselect/full/nodeselect_def.c @@ -58,6 +58,7 @@ static in3_ret_t rpc_verify(in3_nodeselect_def_t* data, in3_vctx_t* vc) { // do we have a result? if not it is a valid error-response if (!vc->result) return IN3_OK; + UNUSED_VAR(data); // no waring in case RPC_ONLY is used #if !defined(RPC_ONLY) || defined(RPC_IN3_NODELIST) if (VERIFY_RPC("in3_nodeList")) { diff --git a/c/src/signer/pk-signer/signer.c b/c/src/signer/pk-signer/signer.c index 9253df68e..0cba988b1 100644 --- a/c/src/signer/pk-signer/signer.c +++ b/c/src/signer/pk-signer/signer.c @@ -225,6 +225,7 @@ static in3_ret_t pk_rpc(void* data, in3_plugin_act_t action, void* action_ctx) { case PLGN_ACT_RPC_HANDLE: { in3_rpc_handle_ctx_t* ctx = action_ctx; + UNUSED_VAR(ctx); // in case RPC_ONLY is used #if !defined(RPC_ONLY) || defined(RPC_IN3_ADDRAWKEY) TRY_RPC("in3_addRawKey", add_raw_key(ctx)) #endif From f823f69d4948c0b90170d97132620629338e06e6 Mon Sep 17 00:00:00 2001 From: Leonardo Souza Date: Tue, 20 Jul 2021 13:04:41 +0200 Subject: [PATCH 088/110] Allow handling of uuid parameters --- c/src/cmd/in3/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/cmd/in3/main.c b/c/src/cmd/in3/main.c index 01afa8d22..48955107d 100644 --- a/c/src/cmd/in3/main.c +++ b/c/src/cmd/in3/main.c @@ -77,7 +77,7 @@ int main(int argc, char* argv[]) { continue; } } - if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && !strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC) + if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC && !strstr(argv[i], "-")) sb_print(args, "\"%s\"", get_wei(argv[i])); else sb_print(args, From a18b75aa8769075f59c3a419d2c29aa3b02e003c Mon Sep 17 00:00:00 2001 From: Leonardo Souza Date: Wed, 21 Jul 2021 18:17:31 +0200 Subject: [PATCH 089/110] Fix handling of escape characters --- c/src/core/util/stringbuilder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/core/util/stringbuilder.c b/c/src/core/util/stringbuilder.c index 8739599d2..6010a61e2 100644 --- a/c/src/core/util/stringbuilder.c +++ b/c/src/core/util/stringbuilder.c @@ -99,7 +99,7 @@ sb_t* sb_add_escaped_chars(sb_t* sb, const char* chars) { if (escapes) { escapes = 0; for (int i = 0; i < l; i++) { - if (chars[i] == '"') { + if (chars[i] == '"' || chars[i] == '\\') { sb->data[sb->len + i + escapes] = '\\'; memcpy(sb->data + sb->len + i + escapes + 1, chars + i, l - i); escapes++; From c52f03626c8350c6211406287877cef1fa190197 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 22 Jul 2021 13:53:19 +0200 Subject: [PATCH 090/110] fixed tokensize --- c/src/pay/zksync/zk_helper.c | 7 +++++-- c/src/pay/zksync/zksync.h | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/c/src/pay/zksync/zk_helper.c b/c/src/pay/zksync/zk_helper.c index 7d4895edf..c5b52060f 100644 --- a/c/src/pay/zksync/zk_helper.c +++ b/c/src/pay/zksync/zk_helper.c @@ -362,8 +362,11 @@ in3_ret_t resolve_tokens(zksync_config_t* conf, in3_req_t* ctx, d_token_t* token conf->tokens[i].id = d_get_int(it.token, K_ID); conf->tokens[i].decimals = d_get_int(it.token, key("decimals")); char* name = d_get_string(it.token, key("symbol")); - if (!name || strlen(name) > 7) return req_set_error(ctx, "invalid token name", IN3_EINVAL); - strcpy(conf->tokens[i].symbol, name); + if (!name) return req_set_error(ctx, "missing token name", IN3_EINVAL); + if (strlen(name) > 9) + strncpy(conf->tokens[i].symbol, name, 9); + else + strcpy(conf->tokens[i].symbol, name); bytes_t* adr = d_get_bytes(it.token, K_ADDRESS); if (!adr || !adr->data || adr->len != 20) return req_set_error(ctx, "invalid token addr", IN3_EINVAL); memcpy(conf->tokens[i].address, adr->data, 20); diff --git a/c/src/pay/zksync/zksync.h b/c/src/pay/zksync/zksync.h index 9adefad46..c5a0b77d4 100644 --- a/c/src/pay/zksync/zksync.h +++ b/c/src/pay/zksync/zksync.h @@ -69,10 +69,10 @@ static const cache_props_t ZKSYNC_CACHED_PROOF = 0xFF00 | CACHE_PROP_INHERIT; /** represents a token supported in zksync. */ typedef struct { - uint16_t id; /**< the id used in messaged */ - char symbol[8]; /**< short symbol */ - uint8_t decimals; /**< decimals for display */ - address_t address; /**< erc20 address (or 0x00 for eth) */ + uint16_t id; /**< the id used in messaged */ + char symbol[10]; /**< short symbol */ + uint8_t decimals; /**< decimals for display */ + address_t address; /**< erc20 address (or 0x00 for eth) */ } zksync_token_t; /** message type. */ From e1ab61d3a5ab84c197b40fa5f8258471b74edb90 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Thu, 22 Jul 2021 18:44:33 +0200 Subject: [PATCH 091/110] fix pk-signer --- c/src/signer/pk-signer/rpc.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c/src/signer/pk-signer/rpc.yml b/c/src/signer/pk-signer/rpc.yml index 162a25c05..e335d75dd 100644 --- a/c/src/signer/pk-signer/rpc.yml +++ b/c/src/signer/pk-signer/rpc.yml @@ -11,7 +11,8 @@ account: cmd: k pk: - type: bytes32|bytes32[] + array: true + type: bytes32 descr: registers raw private keys as signers for transactions. (only availble if build with `-DPK_SIGNER=true` , which is on per default) example: ["0xc9564409cbfca3f486a07996e8015124f30ff8331fc6dcbd610a050f1f983afe"] optional: true From e25dcb7b08a7831e3a16474a280ffe189127a45d Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 23 Jul 2021 10:39:47 +0200 Subject: [PATCH 092/110] update used_keys including sdk-core --- c/src/core/client/keys.h | 4 +++ c/src/core/util/used_keys.h | 66 +++++++++++++++++++++++++++++++++++++ scripts/update_keys.sh | 2 +- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/c/src/core/client/keys.h b/c/src/core/client/keys.h index 1e7ecdb7a..0248a6cc5 100644 --- a/c/src/core/client/keys.h +++ b/c/src/core/client/keys.h @@ -78,6 +78,10 @@ #define K_S key("s") #define K_V key("v") +#define K_MAX_FEE_PER_GAS key("maxFeePerGas") +#define K_MAX_PRIORITY_FEE_PER_GAS key("maxPriorityFeePerGas") +#define K_ACCESS_LIST key("accessList") +#define K_BASE_GAS_FEE key("baseFeePerGas") #define K_NONCE key("nonce") #define K_GAS key("gas") #define K_GAS_PRICE key("gasPrice") diff --git a/c/src/core/util/used_keys.h b/c/src/core/util/used_keys.h index 8f0853ac7..9f0559af5 100644 --- a/c/src/core/util/used_keys.h +++ b/c/src/core/util/used_keys.h @@ -1,16 +1,24 @@ // this is a autogenerated file (scripts/updqate_keys.sh)! Do not edit manually! static char* USED_KEYS[] = { + "accessList", "account", "accountId", "accountProof", "accounts", "action", + "add_module", "address", + "allSignatures", + "allowed_confs", + "allowed_targets", "amount", "approveDepositAmountForERC20", + "args", "author", "balance", + "balances", + "baseFeePerGas", "bits", "block", "blockHash", @@ -25,34 +33,51 @@ static char* USED_KEYS[] = { "cbtxMerkleProof", "chainId", "chainwork", + "check_nonce", "cipher", "cipherparams", "ciphertext", "code", "codeHash", + "codehash", "coinbase", "commitment", "committed", "confirmations", "contract", "contractAddress", + "cosign_rpc", + "cosign_url", "count", + "create_module", + "created_at", + "creator", "crypto", "cumulativeGasUsed", "currentBlock", + "current_period", + "custody", "data", "dataNodes", "decimals", + "default_wallet", + "delegate", + "deploy_block", "deploy_data", "deposit", "depositTo", "difficulty", "dklen", + "domain_sep", "engine", "error", "ethAddress", + "exec", "execTime", + "executed", "extraData", + "failReason", + "fail_reason", "fee", "final", "finality", @@ -73,17 +98,21 @@ static char* USED_KEYS[] = { "in3", "in_active_chain", "index", + "indexed", "input", "iv", "kdf", "kdfparams", "key", + "lang", "lastBlockNumber", "lastNodeList", "lastValidatorChange", "lastWhiteList", "last_failed", "level", + "limit", + "limits", "list", "locktime", "logIndex", @@ -92,25 +121,36 @@ static char* USED_KEYS[] = { "logsBloom", "mac", "mainContract", + "master_copy", + "master_copy_custody", + "mastercopy", + "mastercopy_custody", + "maxFeePerGas", "maxPrice", + "maxPriorityFeePerGas", "merkleProof", "merkleroot", "message", "method", "miner", "mixHash", + "ms", "msSigs", "msg", "msgHash", "msgType", + "multisend", + "musig_pub_keys", "n", "nTx", "name", + "newPkHash", "nextblockhash", "nodes", "nonce", "number", "offer", + "owners", "p", "params", "parentHash", @@ -118,17 +158,20 @@ static char* USED_KEYS[] = { "payed", "pdata", "performance", + "period", "pgas", "pre_commitment", "previousblockhash", "prf", "price", "priceList", + "priority_op", "proof", "props", "pto", "pubKeyHash", "pub_keys", + "pubkey", "publicKey", "r", "raw", @@ -139,30 +182,43 @@ static char* USED_KEYS[] = { "registryId", "removed", "requestCount", + "rest_url", "result", + "roles", "root", "rpc", "rpcCount", "rpcTime", + "rpc_url", "running", "s", + "safetype", "salt", + "saltarg", "sealFields", "sequence", + "service", "sha3Uncles", "sig", "signature", "signatures", + "signed", "signedError", + "signed_2fa", + "signer", "signerNodes", "size", + "spent", "standardV", "stateRoot", "states", "status", "storageHash", "storageProof", + "success", "symbol", + "sync_key", + "threshold", "time", "timeout", "timestamp", @@ -182,16 +238,23 @@ static char* USED_KEYS[] = { "txHash", "txIndex", "txProof", + "tx_analyzer", + "tx_id", "txid", "type", "uncles", + "unsigned", + "unsigned_2fa", "url", "v", "validatorContract", "validatorList", "validators", "value", + "varName", + "vault", "verification", + "verified", "version", "versionHex", "vin", @@ -199,6 +262,9 @@ static char* USED_KEYS[] = { "vsize", "wait", "wallet", + "wallet_deploy", + "wallets", "weight", + "zk_wallet", "zksync", 0}; diff --git a/scripts/update_keys.sh b/scripts/update_keys.sh index c55c90596..14c3f0fd2 100755 --- a/scripts/update_keys.sh +++ b/scripts/update_keys.sh @@ -2,7 +2,7 @@ DST=../c/src/core/util/used_keys.h echo "// this is a autogenerated file (scripts/updqate_keys.sh)! Do not edit manually!\nstatic char* USED_KEYS[] = {" > $DST echo "">tmp -for f in `find ../c/src -name "*.c" -o -name "*.h"` +for f in `find ../c/src ../../src -name "*.c" -o -name "*.h"` do echo "check $f" cat $f | grep "key(\"" | sed 's/.*key("\([^"]*\)").*/ "\1\",/' >> tmp From d0e2d2e81262c4f9497b9a2d5b2c99606627a7ba Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 23 Jul 2021 10:54:16 +0200 Subject: [PATCH 093/110] implement support for EIP 2718, EIP 2930 and EIP 1559 --- c/src/verifier/eth1/basic/eth_getLog.c | 8 +- .../verifier/eth1/basic/eth_getTransaction.c | 73 +++++++++----- c/src/verifier/eth1/basic/rpc.yml | 36 +++++++ c/src/verifier/eth1/nano/rpc.yml | 8 ++ c/src/verifier/eth1/nano/serialize.c | 98 +++++++++++++++---- c/src/verifier/eth1/nano/serialize.h | 1 + 6 files changed, 178 insertions(+), 46 deletions(-) diff --git a/c/src/verifier/eth1/basic/eth_getLog.c b/c/src/verifier/eth1/basic/eth_getLog.c index 1608e9dfe..368c9a8c9 100644 --- a/c/src/verifier/eth1/basic/eth_getLog.c +++ b/c/src/verifier/eth1/basic/eth_getLog.c @@ -294,7 +294,13 @@ in3_ret_t eth_verify_eth_getLog(in3_vctx_t* vc, int l_logs) { } if (!r) return vc_err(vc, "missing proof for log"); d_token_t* topics = d_get(it.token, K_TOPICS); - rlp_decode(&r->data, 0, &tmp); + bytes_t data = r->data; + // EIP 2718 Envelop + if (data.len && data.data[0] < 0x7f) { + data.data++; + data.len--; + } + rlp_decode(&data, 0, &tmp); // decode the list to tmp // verify the log-data if (rlp_decode(&tmp, 3, &logddata) != 2) return vc_err(vc, "invalid log-data"); diff --git a/c/src/verifier/eth1/basic/eth_getTransaction.c b/c/src/verifier/eth1/basic/eth_getTransaction.c index db19e3909..1f1a220dd 100644 --- a/c/src/verifier/eth1/basic/eth_getTransaction.c +++ b/c/src/verifier/eth1/basic/eth_getTransaction.c @@ -47,15 +47,51 @@ static const uint8_t* secp256k1n_2 = (uint8_t*) "\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x5D\x57\x6E\x73\x57\xA4\x50\x1D\xDF\xE9\x2F\x46\x68\x1B\x20\xA0"; +bytes_t create_unsigned_tx(bytes_t raw, uint32_t chain_id) { + bytes_builder_t bb = {0}; + int type = raw.len && raw.data[0] < 0x7f ? raw.data[0] : 0; + int last_item = 5; + bytes_t raw_list = raw; + bytes_t item; + if (type) { + raw_list.data++; + raw_list.len--; + if (type == 1) last_item = 7; + if (type == 2) last_item = 8; + } + rlp_decode(&raw_list, 0, &raw_list); + rlp_decode(&raw_list, last_item, &item); + + bb_write_raw_bytes(&bb, raw_list.data, item.data + item.len - raw_list.data); // add data including last_item to bb + if (chain_id && type == 0) { + uint8_t chain_data[4]; + item = bytes(chain_data, 4); + int_to_bytes(chain_id, chain_data); + b_optimize_len(&item); + rlp_encode_item(&bb, &item); + item.len = 0; + rlp_encode_item(&bb, &item); + rlp_encode_item(&bb, &item); + } + rlp_encode_to_list(&bb); + if (type) { + bb_check_size(&bb, 1); + memmove(bb.b.data + 1, bb.b.data, bb.b.len); + bb.b.len++; + bb.b.data[0] = (uint8_t) type; + } + return bb.b; +} + in3_ret_t eth_verify_tx_values(in3_vctx_t* vc, d_token_t* tx, bytes_t* raw) { d_token_t* t = NULL; uint8_t hash[32], pubkey[65], sdata[64]; bytes_t pubkey_bytes = {.len = 64, .data = ((uint8_t*) &pubkey) + 1}; - - bytes_t* r = d_get_byteskl(tx, K_R, 32); - bytes_t* s = d_get_byteskl(tx, K_S, 32); - uint32_t v = d_get_int(tx, K_V); - uint32_t chain_id = v > 35 ? (v - 35) / 2 : 0; + int type = raw && raw->len && raw->data[0] < 0x7f ? raw->data[0] : 0; + bytes_t* r = d_get_byteskl(tx, K_R, 32); + bytes_t* s = d_get_byteskl(tx, K_S, 32); + uint32_t v = d_get_int(tx, K_V); + uint32_t chain_id = d_get(tx, K_CHAIN_ID) ? (uint32_t) d_get_int(tx, K_CHAIN_ID) : (v > 35 ? (v - 35) / 2 : 0); // check transaction hash if (keccak(raw ? *raw : d_to_bytes(d_get(tx, K_RAW)), hash) == 0 && memcmp(hash, d_get_byteskl(tx, K_HASH, 32)->data, 32)) @@ -86,30 +122,13 @@ in3_ret_t eth_verify_tx_values(in3_vctx_t* vc, d_token_t* tx, bytes_t* raw) { memcpy(sdata + 32 - r->len, r->data, r->len); memcpy(sdata + 64 - s->len, s->data, s->len); - // calculate the messagehash - bytes_builder_t* bb = bb_new(); - bytes_t raw_list, item; - rlp_decode(raw ? raw : d_get_bytes(tx, K_RAW), 0, &raw_list); - rlp_decode(&raw_list, 5, &item); - bb_write_raw_bytes(bb, raw_list.data, item.data + item.len - raw_list.data); - if (chain_id) { - uint8_t chain_data[4]; - uint8_t *pc = chain_data, lc = 4; - int_to_bytes(chain_id, chain_data); - optimize_len(pc, lc); - item.len = lc; - item.data = pc; - rlp_encode_item(bb, &item); - item.len = 0; - rlp_encode_item(bb, &item); - rlp_encode_item(bb, &item); - } - rlp_encode_to_list(bb); - keccak(bb->b, hash); - bb_free(bb); + // calculate the unsigned hash + bytes_t unsigned_tx = create_unsigned_tx(raw ? *raw : d_to_bytes(d_get(tx, K_RAW)), chain_id); + keccak(unsigned_tx, hash); + _free(unsigned_tx.data); // verify signature - if (ecdsa_recover_pub_from_sig(&secp256k1, pubkey, sdata, hash, (chain_id ? v - chain_id * 2 - 8 : v) - 27)) + if (ecdsa_recover_pub_from_sig(&secp256k1, pubkey, sdata, hash, type ? v : ((chain_id ? v - chain_id * 2 - 8 : v) - 27))) return vc_err(vc, "could not recover signature"); if ((t = d_getl(tx, K_PUBLIC_KEY, 64)) && memcmp(pubkey_bytes.data, t->data, t->len) != 0) diff --git a/c/src/verifier/eth1/basic/rpc.yml b/c/src/verifier/eth1/basic/rpc.yml index f4ce0668b..8e9d1c222 100644 --- a/c/src/verifier/eth1/basic/rpc.yml +++ b/c/src/verifier/eth1/basic/rpc.yml @@ -97,6 +97,11 @@ types: descr: Array of uncle hashes. array: true type: bytes32 + baseFeePerGas: + descr: block fees based on EIP 1559 starting with the London hard fork + type: uint64 + optional: true + eth_blockdataWithTxHashes: _extends: eth_blockheader @@ -155,6 +160,37 @@ types: s: descr: y-value of the EC-Point of the signature type: bytes32 + accessList: + optional: true + descr: the list of storage keys accesses as defined in EIP-2930 transactions of type 0x1 or 0x2. Will only be included if the type>0 + array: true + typeName: EthTxAccessList + type: + address: + descr: the address being accessed. + type: address + storageKeys: + array: true + descr: The storage location being accessed. + type: bytes32 + type: + optional: true + descr: the transaction type (0 = legacy tx, 1 = EIP-2930, 2= EIP-1559) + type: int + chainId: + descr: the chainId the transaction is to operate on. + optional: true + type: uint64 + maxFeePerGas: + optional: true + descr: the max Fee gas as defined in EIP-1559 + type: uint64 + maxPriorityFeePerGas: + optional: true + descr: the max priority Fee gas as defined in EIP-1559 + type: uint64 + + eth: diff --git a/c/src/verifier/eth1/nano/rpc.yml b/c/src/verifier/eth1/nano/rpc.yml index da430cf7c..74aa72f6a 100644 --- a/c/src/verifier/eth1/nano/rpc.yml +++ b/c/src/verifier/eth1/nano/rpc.yml @@ -55,6 +55,10 @@ types: gasUsed: descr: gas used by this transaction. type: uint64 + effectiveGasPrice: + descr: the efficte gas price + type: uint256 + optional: true logs: descr: array of events created during execution of the tx array: true @@ -74,6 +78,10 @@ types: from: descr: address of the sender. type: address + type: + optional: true + descr: the transaction type (0 = legacy tx, 1 = EIP-2930, 2= EIP-1559) + type: int to: descr: address of the receiver. null when its a contract creation transaction. type: address diff --git a/c/src/verifier/eth1/nano/serialize.c b/c/src/verifier/eth1/nano/serialize.c index e2ef6fc97..e346a242b 100644 --- a/c/src/verifier/eth1/nano/serialize.c +++ b/c/src/verifier/eth1/nano/serialize.c @@ -100,12 +100,41 @@ int rlp_add(bytes_builder_t* rlp, d_token_t* t, int ml) { return rlp_add_bytes(rlp, b, ml); } +static bytes_t* convert_to_typed_list(bytes_builder_t* rlp, int32_t type) { + rlp_encode_to_list(rlp); + if (type) { + bb_check_size(rlp, 1); + memmove(rlp->b.data + 1, rlp->b.data, rlp->b.len); + rlp->b.len++; + rlp->b.data[0] = (uint8_t) type; + } + return bb_move_to_bytes(rlp); +} + #define UINT 0 #define BYTES -1 #define ADDRESS -20 #define HASH 32 #define BLOOM 256 +static void rlp_add_list(bytes_builder_t* rlp, d_token_t* t) { + bytes_builder_t* bb1 = bb_new(); + bytes_builder_t* bb2 = bb_new(); + bytes_builder_t* bb3 = bb_new(); + for (d_iterator_t adr = d_iter(t); adr.left && d_len(adr.token) == 2 && d_type(adr.token) == T_ARRAY && d_type(d_get_at(adr.token, 1)) == T_ARRAY; d_iter_next(&adr)) { + bb_clear(bb2); + bb_clear(bb3); + rlp_add(bb2, d_get_at(adr.token, 0), ADDRESS); + for (d_iterator_t st = d_iter(d_get_at(adr.token, 1)); st.left && d_type(st.token) == T_BYTES; d_iter_next(&st)) rlp_add(bb3, st.token, HASH); + rlp_encode_list(bb2, &bb3->b); + rlp_encode_list(bb1, &bb2->b); + } + rlp_encode_list(rlp, &bb1->b); + bb_free(bb1); + bb_free(bb2); + bb_free(bb3); +} + bytes_t* serialize_account(d_token_t* a) { bytes_builder_t* rlp = bb_new(); // clang-format off @@ -118,19 +147,51 @@ bytes_t* serialize_account(d_token_t* a) { } bytes_t* serialize_tx(d_token_t* tx) { - bytes_builder_t* rlp = bb_new(); - // clang-format off - rlp_add(rlp, d_get(tx,K_NONCE) , UINT); - rlp_add(rlp, d_get(tx,K_GAS_PRICE) , UINT); - rlp_add(rlp, d_get_or(tx,K_GAS,K_GAS_LIMIT), UINT); - rlp_add(rlp, d_getl(tx,K_TO, 20) , ADDRESS); - rlp_add(rlp, d_get(tx,K_VALUE) , UINT); - rlp_add(rlp, d_get_or(tx,K_INPUT,K_DATA) , BYTES); - rlp_add(rlp, d_get(tx,K_V) , UINT); - rlp_add(rlp, d_getl(tx,K_R, 32) , UINT); - rlp_add(rlp, d_getl(tx,K_S, 32) , UINT); - // clang-format on - return bb_move_to_bytes(rlp_encode_to_list(rlp)); + bytes_builder_t* rlp = bb_new(); + int32_t type = d_get_int(tx, K_TYPE); + switch (type) { + case 0: // legacy tx + rlp_add(rlp, d_get(tx, K_NONCE), UINT); + rlp_add(rlp, d_get(tx, K_GAS_PRICE), UINT); + rlp_add(rlp, d_get_or(tx, K_GAS, K_GAS_LIMIT), UINT); + rlp_add(rlp, d_getl(tx, K_TO, 20), ADDRESS); + rlp_add(rlp, d_get(tx, K_VALUE), UINT); + rlp_add(rlp, d_get_or(tx, K_INPUT, K_DATA), BYTES); + rlp_add(rlp, d_get(tx, K_V), UINT); + rlp_add(rlp, d_getl(tx, K_R, 32), UINT); + rlp_add(rlp, d_getl(tx, K_S, 32), UINT); + break; + + case 1: //EIP 2930 + rlp_add(rlp, d_get(tx, K_CHAIN_ID), UINT); + rlp_add(rlp, d_get(tx, K_NONCE), UINT); + rlp_add(rlp, d_get(tx, K_GAS_PRICE), UINT); + rlp_add(rlp, d_get_or(tx, K_GAS, K_GAS_LIMIT), UINT); + rlp_add(rlp, d_getl(tx, K_TO, 20), ADDRESS); + rlp_add(rlp, d_get(tx, K_VALUE), UINT); + rlp_add(rlp, d_get_or(tx, K_INPUT, K_DATA), BYTES); + rlp_add_list(rlp, d_get(tx, K_ACCESS_LIST)); + rlp_add(rlp, d_get(tx, K_V), UINT); + rlp_add(rlp, d_getl(tx, K_R, 32), UINT); + rlp_add(rlp, d_getl(tx, K_S, 32), UINT); + break; + + case 2: //EIP 1559 + rlp_add(rlp, d_get(tx, K_CHAIN_ID), UINT); + rlp_add(rlp, d_get(tx, K_NONCE), UINT); + rlp_add(rlp, d_get(tx, K_MAX_PRIORITY_FEE_PER_GAS), UINT); + rlp_add(rlp, d_get(tx, K_MAX_FEE_PER_GAS), UINT); + rlp_add(rlp, d_get_or(tx, K_GAS, K_GAS_LIMIT), UINT); + rlp_add(rlp, d_getl(tx, K_TO, 20), ADDRESS); + rlp_add(rlp, d_get(tx, K_VALUE), UINT); + rlp_add(rlp, d_get_or(tx, K_INPUT, K_DATA), BYTES); + rlp_add_list(rlp, d_get(tx, K_ACCESS_LIST)); + rlp_add(rlp, d_get(tx, K_V), UINT); + rlp_add(rlp, d_getl(tx, K_R, 32), UINT); + rlp_add(rlp, d_getl(tx, K_S, 32), UINT); + break; + } + return convert_to_typed_list(rlp, type); } bytes_t* serialize_tx_raw(bytes_t nonce, bytes_t gas_price, bytes_t gas_limit, bytes_t to, bytes_t value, bytes_t data, uint64_t v, bytes_t r, bytes_t s) { @@ -187,8 +248,11 @@ bytes_t* serialize_block_header(d_token_t* block) { } else { // good old proof of work... - rlp_add(rlp, d_getl(block,K_MIX_HASH, 32) , HASH); - rlp_add(rlp, d_get(block,K_NONCE) , BYTES); + rlp_add(rlp, d_getl(block,K_MIX_HASH, 32) , HASH); + rlp_add(rlp, d_get(block,K_NONCE) , BYTES); + // if we have a base gas fee we need to use EIP-1559 + if (d_get_long(block,K_BASE_GAS_FEE)) + rlp_add(rlp, d_get(block,K_BASE_GAS_FEE) , UINT); } // clang-format on return bb_move_to_bytes(rlp_encode_to_list(rlp)); @@ -233,11 +297,9 @@ bytes_t* serialize_tx_receipt(d_token_t* receipt) { // clang-format on rlp_encode_list(rlp, &rlp_loglist->b); - rlp_encode_to_list(rlp); - bb_free(bb); bb_free(rlp_log); bb_free(rlp_topics); bb_free(rlp_loglist); - return bb_move_to_bytes(rlp); + return convert_to_typed_list(rlp, d_get_int(receipt, K_TYPE)); } \ No newline at end of file diff --git a/c/src/verifier/eth1/nano/serialize.h b/c/src/verifier/eth1/nano/serialize.h index ecc5eef57..039fdf102 100644 --- a/c/src/verifier/eth1/nano/serialize.h +++ b/c/src/verifier/eth1/nano/serialize.h @@ -116,4 +116,5 @@ int rlp_add(bytes_builder_t* rlp, d_token_t* t, int ml); #define BLOCKHEADER_SEALED_FIELD1 13 #define BLOCKHEADER_SEALED_FIELD2 14 #define BLOCKHEADER_SEALED_FIELD3 15 +#define BLOCKHEADER_BASE_GAS_FEE 15 From 4d07d91aa11dbe2ef780c603324ce95cfb714e12 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 23 Jul 2021 11:43:36 +0200 Subject: [PATCH 094/110] fixed accessList --- c/src/core/client/keys.h | 1 + c/src/core/util/used_keys.h | 1 + c/src/verifier/eth1/nano/serialize.c | 27 +++++++++++++-------------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/c/src/core/client/keys.h b/c/src/core/client/keys.h index 0248a6cc5..c5fef7550 100644 --- a/c/src/core/client/keys.h +++ b/c/src/core/client/keys.h @@ -153,6 +153,7 @@ #define K_TYPE key("type") #define K_BALANCE key("balance") #define K_STORAGE_HASH key("storageHash") +#define K_STORAGE_KEYS key("storageKeys") #define K_KEY key("key") #define K_STORAGE_PROOF key("storageProof") diff --git a/c/src/core/util/used_keys.h b/c/src/core/util/used_keys.h index 9f0559af5..b2f83d8ab 100644 --- a/c/src/core/util/used_keys.h +++ b/c/src/core/util/used_keys.h @@ -214,6 +214,7 @@ static char* USED_KEYS[] = { "states", "status", "storageHash", + "storageKeys", "storageProof", "success", "symbol", diff --git a/c/src/verifier/eth1/nano/serialize.c b/c/src/verifier/eth1/nano/serialize.c index e346a242b..c7d1874fd 100644 --- a/c/src/verifier/eth1/nano/serialize.c +++ b/c/src/verifier/eth1/nano/serialize.c @@ -118,21 +118,20 @@ static bytes_t* convert_to_typed_list(bytes_builder_t* rlp, int32_t type) { #define BLOOM 256 static void rlp_add_list(bytes_builder_t* rlp, d_token_t* t) { - bytes_builder_t* bb1 = bb_new(); - bytes_builder_t* bb2 = bb_new(); - bytes_builder_t* bb3 = bb_new(); - for (d_iterator_t adr = d_iter(t); adr.left && d_len(adr.token) == 2 && d_type(adr.token) == T_ARRAY && d_type(d_get_at(adr.token, 1)) == T_ARRAY; d_iter_next(&adr)) { - bb_clear(bb2); - bb_clear(bb3); - rlp_add(bb2, d_get_at(adr.token, 0), ADDRESS); - for (d_iterator_t st = d_iter(d_get_at(adr.token, 1)); st.left && d_type(st.token) == T_BYTES; d_iter_next(&st)) rlp_add(bb3, st.token, HASH); - rlp_encode_list(bb2, &bb3->b); - rlp_encode_list(bb1, &bb2->b); + + bytes_builder_t bb1 = {0}, bb2 = {0}, bb3 = {0}; + for (d_iterator_t adr = d_iter(t); adr.left && d_len(adr.token) == 2 && d_type(adr.token) == T_OBJECT; d_iter_next(&adr)) { + bb_clear(&bb2); + bb_clear(&bb3); + rlp_add(&bb2, d_get(adr.token, K_ADDRESS), ADDRESS); + for (d_iterator_t st = d_iter(d_get(adr.token, K_STORAGE_KEYS)); st.left && d_type(st.token) == T_BYTES; d_iter_next(&st)) rlp_add(bb3, st.token, HASH); + rlp_encode_list(&bb2, &bb3.b); + rlp_encode_list(&bb1, &bb2.b); } - rlp_encode_list(rlp, &bb1->b); - bb_free(bb1); - bb_free(bb2); - bb_free(bb3); + rlp_encode_list(rlp, &bb1.b); + _free(bb1.b.data); + _free(bb2.b.data); + _free(bb3.b.data); } bytes_t* serialize_account(d_token_t* a) { From e6f34320266d3e347edbcc663e392dbfeb881843 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Fri, 23 Jul 2021 13:01:48 +0200 Subject: [PATCH 095/110] fixed typo --- c/src/verifier/eth1/nano/serialize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/verifier/eth1/nano/serialize.c b/c/src/verifier/eth1/nano/serialize.c index c7d1874fd..6283d2394 100644 --- a/c/src/verifier/eth1/nano/serialize.c +++ b/c/src/verifier/eth1/nano/serialize.c @@ -124,7 +124,7 @@ static void rlp_add_list(bytes_builder_t* rlp, d_token_t* t) { bb_clear(&bb2); bb_clear(&bb3); rlp_add(&bb2, d_get(adr.token, K_ADDRESS), ADDRESS); - for (d_iterator_t st = d_iter(d_get(adr.token, K_STORAGE_KEYS)); st.left && d_type(st.token) == T_BYTES; d_iter_next(&st)) rlp_add(bb3, st.token, HASH); + for (d_iterator_t st = d_iter(d_get(adr.token, K_STORAGE_KEYS)); st.left && d_type(st.token) == T_BYTES; d_iter_next(&st)) rlp_add(&bb3, st.token, HASH); rlp_encode_list(&bb2, &bb3.b); rlp_encode_list(&bb1, &bb2.b); } From 57cd2b1b5db0e8f659d13acaff4f777a6759d8bf Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Sun, 25 Jul 2021 16:43:17 +0200 Subject: [PATCH 096/110] fix tests --- c/test/testdata/cmd/zksync_deposit_c2.txt | 2 +- c/test/testdata/cmd/zksync_emergencyWithdraw.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/c/test/testdata/cmd/zksync_deposit_c2.txt b/c/test/testdata/cmd/zksync_deposit_c2.txt index 22d2b2890..307dcc903 100644 --- a/c/test/testdata/cmd/zksync_deposit_c2.txt +++ b/c/test/testdata/cmd/zksync_deposit_c2.txt @@ -18,7 +18,7 @@ 18c402514c401950947896338bcb113452593a0a933c3c8c61d042c9480a11a4bd23aae9ff7d99bb :: cache zksync_tokens_69f5 1 -010044414900000000001264e9e65f1cee1fa5071d0075cd211e7b7274a444000300424154000000000012a41da0108ab9875d60169b8a9cd4c8a13b3b2ef20000004554480000000000120000000000000000000000000000000000000000000200774254430000000008cb18f9f65af976000931ca251741068e6aabbd2f0004004d4c545400000000124368e824754a7de8d8a82db5725c48a1e191cbc600 +150045524332302d32310000121f9840a85d5af5bf1d1762f925bdaddc4201f9840011004d4c545400000000000012690f4886c6911d81beb8130db30c825c27281f220003004c494e4b000000000000124da8d0795830f75be471f072a034d42c369b5d0a00140050484e5800000000000012fe1b6abc39e46cec54d275efb4b29b33be176c2a00160045524332302d3232000012e70f71019d3a598bdbbf8f8aa6e85a34556966e3000000455448000000000000001200000000000000000000000000000000000000000008005a52580000000000000012db7f2b9f6a0cb35fe5d236e5ed871d3ad4184290000f004c414d42000000000000129ecec4d48efdd96ae377af3ab868f99de865cff8000500485400000000000000001214700cae8b2943bad34c70bb76ae27ecf5bc50130002005553444300000000000006eb8f08a975ab53e34d8a0330e0d34de942c959260004005455534400000000000012d2255612f9b045e9c81244bb874abb413ca139a300120058454d0000000000000000c3904a7c3a95bc265066bb5bfc4d6664b217477400130044414900000000000000122e055eee18284513b993db7568a592679ab1318800070054524200000000000000122655f3a9eeb7f960be83098457144813ffad07a400010055534454000000000000063b00ef435fa4fcff5c209a37d1f3dcff37c705ad00100074474c4d00000000000012d94e3dc39d4cad1dad634e7eb585a57a19dc7efe000a0052455000000000000000129cac8508b9ff26501439590a24893d80e7e84d210006004f4d4700000000000000122b203de02ad6109521e09985b3af9b8c62541cd6000b0053544f524a0000000000088098165d982765097e4aa17138816e5b95f9fdb5000e004b4e430000000000000012290eba6ec56ecc9ff81c72e8eccc77d2c2bf63eb000d004d434f0000000000000008d93addb2921b8061b697c2ab055979bbefe2b7ac0009004241540000000000000012d2084ea2ae4bbe1424e4fe3cde25b713632fb988000c004e45584f0000000000001202d01f0835b7fdfa5d801a8f5f74c37f2bb1ae6a00 :: request http://localhost:8545 [{"id":4,"jsonrpc":"2.0","method":"eth_chainId","params":[]}] diff --git a/c/test/testdata/cmd/zksync_emergencyWithdraw.txt b/c/test/testdata/cmd/zksync_emergencyWithdraw.txt index a87f8a3e6..974cee5e1 100644 --- a/c/test/testdata/cmd/zksync_emergencyWithdraw.txt +++ b/c/test/testdata/cmd/zksync_emergencyWithdraw.txt @@ -20,7 +20,7 @@ 87cb3690972de082831b108dd12b3a7b8c3416322550dd5db176196f2344215e6492ca196541174c :: cache zksync_tokens_69f5 1 -030042415400000000001233c60fe20938da463650e886551b6203dc46d5d2000100444149000000000012450551f930a5ebf022be21873be531428f99b39b0000004554480000000000120000000000000000000000000000000000000000000200774254430000000008809cfdea09c689bed37399dfd7d08bf75d1036c100 +150045524332302d32310000121f9840a85d5af5bf1d1762f925bdaddc4201f9840011004d4c545400000000000012690f4886c6911d81beb8130db30c825c27281f220003004c494e4b000000000000124da8d0795830f75be471f072a034d42c369b5d0a00140050484e5800000000000012fe1b6abc39e46cec54d275efb4b29b33be176c2a00160045524332302d3232000012e70f71019d3a598bdbbf8f8aa6e85a34556966e3000000455448000000000000001200000000000000000000000000000000000000000008005a52580000000000000012db7f2b9f6a0cb35fe5d236e5ed871d3ad4184290000f004c414d42000000000000129ecec4d48efdd96ae377af3ab868f99de865cff8000500485400000000000000001214700cae8b2943bad34c70bb76ae27ecf5bc50130002005553444300000000000006eb8f08a975ab53e34d8a0330e0d34de942c959260004005455534400000000000012d2255612f9b045e9c81244bb874abb413ca139a300120058454d0000000000000000c3904a7c3a95bc265066bb5bfc4d6664b217477400130044414900000000000000122e055eee18284513b993db7568a592679ab1318800070054524200000000000000122655f3a9eeb7f960be83098457144813ffad07a400010055534454000000000000063b00ef435fa4fcff5c209a37d1f3dcff37c705ad00100074474c4d00000000000012d94e3dc39d4cad1dad634e7eb585a57a19dc7efe000a0052455000000000000000129cac8508b9ff26501439590a24893d80e7e84d210006004f4d4700000000000000122b203de02ad6109521e09985b3af9b8c62541cd6000b0053544f524a0000000000088098165d982765097e4aa17138816e5b95f9fdb5000e004b4e430000000000000012290eba6ec56ecc9ff81c72e8eccc77d2c2bf63eb000d004d434f0000000000000008d93addb2921b8061b697c2ab055979bbefe2b7ac0009004241540000000000000012d2084ea2ae4bbe1424e4fe3cde25b713632fb988000c004e45584f0000000000001202d01f0835b7fdfa5d801a8f5f74c37f2bb1ae6a00 :: cache zksync_ac8a91dc2d28b689474298d91899f0c1baf62cb85b 1 00000001 From d4d188748cffcd08b3b2735d47edbc12cf8aa047 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 26 Jul 2021 16:17:59 +0200 Subject: [PATCH 097/110] add eth_feeHistory --- c/src/verifier/eth1/basic/rpc.yml | 51 +++++++++++++++++++++++++++++ c/src/verifier/eth1/nano/eth_nano.c | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/c/src/verifier/eth1/basic/rpc.yml b/c/src/verifier/eth1/basic/rpc.yml index 8e9d1c222..7940941c6 100644 --- a/c/src/verifier/eth1/basic/rpc.yml +++ b/c/src/verifier/eth1/basic/rpc.yml @@ -194,6 +194,57 @@ types: eth: + eth_gasPrice: + descr: returns the current gasPrice in wei per gas + params: [] + result: + descr: the current gasPrice in wei per gas + type: uint64 + example: + response: '0x0625900800' + + eth_feeHistory: + descr: | + base fee per gas and transaction effective priority fee per gas history for the requested block range if available. + The range between headBlock-4 and headBlock is guaranteed to be available while retrieving data from the pending block and older history are optional to support. + For pre-EIP-1559 blocks the gas prices are returned as rewards and zeroes are returned for the base fee per gas + params: + blockCount: + plainInt: true + descr: Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available. + type: uint64 + newestBlock: + descr: the Highest blockNumber or one of `latest`, `earliest`or `pending` + type: uint64 + internalDefault : latest + optional: true + rewardPercentiles: + descr: A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used. + type: double + array: true + result: + descr: Fee history for the returned block range. This can be a subsection of the requested range if not all blocks are available. + typeName: FeeHistory + type: + oldestBlock: + descr: Lowest number block of the returned range. + type: uint64 + baseFeePerGas: + descr: An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks. + type: uint64 + array: true + gasUsedRatio: + array: true + descr: An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit. + type: double + reward: + array: true + + + + + + eth_blockNumber: descr: | returns the number of the most recent block. diff --git a/c/src/verifier/eth1/nano/eth_nano.c b/c/src/verifier/eth1/nano/eth_nano.c index 19f882143..2e3d8440b 100644 --- a/c/src/verifier/eth1/nano/eth_nano.c +++ b/c/src/verifier/eth1/nano/eth_nano.c @@ -45,7 +45,7 @@ // list of methods allowed withoput proof #define MAX_METHODS 26 -const char* ALLOWED_METHODS[MAX_METHODS] = {"eth_chainId", "in3_stats", "eth_blockNumber", "web3_clientVersion", "web3_sha3", "net_version", "net_peerCount", "net_listening", "eth_protocolVersion", "eth_syncing", "eth_coinbase", "eth_mining", "eth_hashrate", "eth_gasPrice", "eth_accounts", "eth_sign", "eth_sendRawTransaction", "eth_estimateGas", "eth_getCompilers", "eth_compileLLL", "eth_compileSolidity", "eth_compileSerpent", "eth_getWork", "eth_submitWork", "eth_submitHashrate", "eth_getProof"}; +const char* ALLOWED_METHODS[MAX_METHODS] = {"eth_chainId", "in3_stats", "eth_blockNumber", "web3_clientVersion", "web3_sha3", "net_version", "net_peerCount", "net_listening", "eth_protocolVersion", "eth_syncing", "eth_coinbase", "eth_mining", "eth_hashrate", "eth_gasPrice", "eth_feeHistory", "eth_accounts", "eth_sign", "eth_sendRawTransaction", "eth_estimateGas", "eth_getCompilers", "eth_compileLLL", "eth_compileSolidity", "eth_compileSerpent", "eth_getWork", "eth_submitWork", "eth_submitHashrate", "eth_getProof"}; in3_ret_t in3_verify_eth_nano(void* p_data, in3_plugin_act_t action, void* pctx) { UNUSED_VAR(p_data); From 6b93d4d33a99b3ef26e8ee74cbd6a1e1cd1378db Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 26 Jul 2021 16:20:25 +0200 Subject: [PATCH 098/110] fixed warning --- c/src/verifier/eth1/basic/eth_getTransaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/verifier/eth1/basic/eth_getTransaction.c b/c/src/verifier/eth1/basic/eth_getTransaction.c index 1f1a220dd..4be022fae 100644 --- a/c/src/verifier/eth1/basic/eth_getTransaction.c +++ b/c/src/verifier/eth1/basic/eth_getTransaction.c @@ -87,7 +87,7 @@ in3_ret_t eth_verify_tx_values(in3_vctx_t* vc, d_token_t* tx, bytes_t* raw) { d_token_t* t = NULL; uint8_t hash[32], pubkey[65], sdata[64]; bytes_t pubkey_bytes = {.len = 64, .data = ((uint8_t*) &pubkey) + 1}; - int type = raw && raw->len && raw->data[0] < 0x7f ? raw->data[0] : 0; + int type = raw && raw->len && raw->data && raw->data[0] < 0x7f ? raw->data[0] : 0; bytes_t* r = d_get_byteskl(tx, K_R, 32); bytes_t* s = d_get_byteskl(tx, K_S, 32); uint32_t v = d_get_int(tx, K_V); From bbf27dbf9718179f5955332afdf28aaf18ec3db1 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 26 Jul 2021 16:21:07 +0200 Subject: [PATCH 099/110] format-fix --- c/src/nodeselect/full/nodeselect_def.c | 6 +++--- c/src/verifier/eth1/nano/serialize.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/c/src/nodeselect/full/nodeselect_def.c b/c/src/nodeselect/full/nodeselect_def.c index beba62299..8857ffea6 100644 --- a/c/src/nodeselect/full/nodeselect_def.c +++ b/c/src/nodeselect/full/nodeselect_def.c @@ -599,9 +599,9 @@ static void check_autoupdate(const in3_req_t* ctx, in3_nodeselect_def_t* data, d memcpy(data->nodelist_upd8_params->node, n->address, 20); data->nodelist_upd8_params->exp_last_block = d_get_long(response_in3, K_LAST_NODE_LIST); data->nodelist_upd8_params->timestamp = in3_time(NULL) + update_waittime(d_get_long(response_in3, K_LAST_NODE_LIST), - d_get_long(response_in3, K_CURRENT_BLOCK), - ctx->client->replace_latest_block, - data->avg_block_time); + d_get_long(response_in3, K_CURRENT_BLOCK), + ctx->client->replace_latest_block, + data->avg_block_time); } } diff --git a/c/src/verifier/eth1/nano/serialize.c b/c/src/verifier/eth1/nano/serialize.c index 6283d2394..9556d31fb 100644 --- a/c/src/verifier/eth1/nano/serialize.c +++ b/c/src/verifier/eth1/nano/serialize.c @@ -161,7 +161,7 @@ bytes_t* serialize_tx(d_token_t* tx) { rlp_add(rlp, d_getl(tx, K_S, 32), UINT); break; - case 1: //EIP 2930 + case 1: // EIP 2930 rlp_add(rlp, d_get(tx, K_CHAIN_ID), UINT); rlp_add(rlp, d_get(tx, K_NONCE), UINT); rlp_add(rlp, d_get(tx, K_GAS_PRICE), UINT); @@ -175,7 +175,7 @@ bytes_t* serialize_tx(d_token_t* tx) { rlp_add(rlp, d_getl(tx, K_S, 32), UINT); break; - case 2: //EIP 1559 + case 2: // EIP 1559 rlp_add(rlp, d_get(tx, K_CHAIN_ID), UINT); rlp_add(rlp, d_get(tx, K_NONCE), UINT); rlp_add(rlp, d_get(tx, K_MAX_PRIORITY_FEE_PER_GAS), UINT); From 4dc92a7fe5c1b0be680b97828a5474696db775fd Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 26 Jul 2021 17:33:07 +0200 Subject: [PATCH 100/110] better cmd- arg detection --- c/src/cmd/in3/helper.c | 28 ++++++++++++++++++++++++++++ c/src/cmd/in3/helper.h | 4 ++-- c/src/cmd/in3/main.c | 9 +-------- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/c/src/cmd/in3/helper.c b/c/src/cmd/in3/helper.c index bdc879dd0..4705d008f 100644 --- a/c/src/cmd/in3/helper.c +++ b/c/src/cmd/in3/helper.c @@ -401,4 +401,32 @@ void display_result(char* method, char* result) { else recorder_print(0, "%s\n", result); } +} + +static inline bool is_convertable_number(char* c) { + if (!*c) return false; + for (; *c; c++) { + if ((*c < '0' || *c > '9') && *c != '.') return strcmp(c, "eth") == 0; + } + return true; +} + +static inline bool is_json(char* c) { + char* e = parse_json_error(c); + if (e) { + _free(e); + return false; + } + return true; +} +static inline bool needs_hex_number(char* arg, char* method) { + // for eth, zksync (but not for eth_feeHistory) + return (strncmp(method, "eth_", 4) == 0 || strncmp(method, "zk", 2) == 0) && strcmp(method, "eth_feeHistory") && is_convertable_number(arg); +} + +void add_argument(char* arg, sb_t* args, in3_t* c, char* method) { + if (needs_hex_number(arg, method)) + sb_print(args, "\"%s\"", get_wei(arg)); + else + sb_print(args, is_json(arg) ? "%s" : "\"%s\"", strcmp(method, "in3_ens") ? resolve(c, arg) : arg); } \ No newline at end of file diff --git a/c/src/cmd/in3/helper.h b/c/src/cmd/in3/helper.h index ca41f23b1..ce9f18a37 100644 --- a/c/src/cmd/in3/helper.h +++ b/c/src/cmd/in3/helper.h @@ -44,8 +44,8 @@ void read_pk(char* pk_file, char* pwd, in3_t* c, char* method); void print_val(d_token_t* t); -char* get_argument(int argc, char* argv[], char* alias, char* arg, bool has_value); - +char* get_argument(int argc, char* argv[], char* alias, char* arg, bool has_value); +void add_argument(char* arg, sb_t* args, in3_t* c, char* method); uint32_t* get_output_conf(); const char* get_help_args(); typedef enum output { diff --git a/c/src/cmd/in3/main.c b/c/src/cmd/in3/main.c index 48955107d..3229cd532 100644 --- a/c/src/cmd/in3/main.c +++ b/c/src/cmd/in3/main.c @@ -77,14 +77,7 @@ int main(int argc, char* argv[]) { continue; } } - if (*argv[i] >= '0' && *argv[i] <= '9' && *(argv[i] + 1) != 'x' && strcmp(method, "in3_toWei") && c->chain.chain_id != CHAIN_ID_BTC && !strstr(argv[i], "-")) - sb_print(args, "\"%s\"", get_wei(argv[i])); - else - sb_print(args, - (argv[i][0] == '{' || argv[i][0] == '[' || strcmp(argv[i], "true") == 0 || strcmp(argv[i], "false") == 0 || (*argv[i] >= '0' && *argv[i] <= '9' && strlen(argv[i]) < 16 && *(argv[i] + 1) != 'x')) - ? "%s" - : "\"%s\"", - strcmp(method, "in3_ens") ? resolve(c, argv[i]) : argv[i]); + add_argument(argv[i], args, c, method); } } sb_add_char(args, ']'); From ad860ccfde42f68e70ff0679052cd200aed4ea71 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Mon, 26 Jul 2021 17:40:38 +0200 Subject: [PATCH 101/110] fix rpc --- c/src/verifier/eth1/basic/rpc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/c/src/verifier/eth1/basic/rpc.yml b/c/src/verifier/eth1/basic/rpc.yml index 7940941c6..302b79b71 100644 --- a/c/src/verifier/eth1/basic/rpc.yml +++ b/c/src/verifier/eth1/basic/rpc.yml @@ -221,6 +221,8 @@ eth: rewardPercentiles: descr: A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used. type: double + internalDefault : [] + optional: true array: true result: descr: Fee history for the returned block range. This can be a subsection of the requested range if not all blocks are available. From 035672ffef9008b5e009940048ea86b18ddeadea Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Jul 2021 10:57:02 +0200 Subject: [PATCH 102/110] fix len --- c/src/verifier/eth1/nano/eth_nano.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/verifier/eth1/nano/eth_nano.c b/c/src/verifier/eth1/nano/eth_nano.c index 2e3d8440b..027a76913 100644 --- a/c/src/verifier/eth1/nano/eth_nano.c +++ b/c/src/verifier/eth1/nano/eth_nano.c @@ -44,7 +44,7 @@ #include // list of methods allowed withoput proof -#define MAX_METHODS 26 +#define MAX_METHODS 27 const char* ALLOWED_METHODS[MAX_METHODS] = {"eth_chainId", "in3_stats", "eth_blockNumber", "web3_clientVersion", "web3_sha3", "net_version", "net_peerCount", "net_listening", "eth_protocolVersion", "eth_syncing", "eth_coinbase", "eth_mining", "eth_hashrate", "eth_gasPrice", "eth_feeHistory", "eth_accounts", "eth_sign", "eth_sendRawTransaction", "eth_estimateGas", "eth_getCompilers", "eth_compileLLL", "eth_compileSolidity", "eth_compileSerpent", "eth_getWork", "eth_submitWork", "eth_submitHashrate", "eth_getProof"}; in3_ret_t in3_verify_eth_nano(void* p_data, in3_plugin_act_t action, void* pctx) { From f639437fa9422e4c5ada85499a0d434733a2c347 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Jul 2021 17:18:00 +0200 Subject: [PATCH 103/110] fixed blockheader! --- c/src/verifier/eth1/nano/serialize.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/c/src/verifier/eth1/nano/serialize.c b/c/src/verifier/eth1/nano/serialize.c index 9556d31fb..a368117fd 100644 --- a/c/src/verifier/eth1/nano/serialize.c +++ b/c/src/verifier/eth1/nano/serialize.c @@ -250,9 +250,9 @@ bytes_t* serialize_block_header(d_token_t* block) { rlp_add(rlp, d_getl(block,K_MIX_HASH, 32) , HASH); rlp_add(rlp, d_get(block,K_NONCE) , BYTES); // if we have a base gas fee we need to use EIP-1559 - if (d_get_long(block,K_BASE_GAS_FEE)) - rlp_add(rlp, d_get(block,K_BASE_GAS_FEE) , UINT); } + if (d_get_long(block,K_BASE_GAS_FEE)) + rlp_add(rlp, d_get(block,K_BASE_GAS_FEE) , UINT); // clang-format on return bb_move_to_bytes(rlp_encode_to_list(rlp)); } From a785d15a3e2c428e7a49352a06a801e9dc8efa51 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Jul 2021 18:47:38 +0200 Subject: [PATCH 104/110] add parse_tx_url --- c/src/api/eth1/rpc.yml | 18 ++++ c/src/api/eth1/rpc_api.c | 122 +++++++++++++++++++++++++++- c/src/verifier/eth1/basic/sign_tx.c | 4 +- 3 files changed, 141 insertions(+), 3 deletions(-) diff --git a/c/src/api/eth1/rpc.yml b/c/src/api/eth1/rpc.yml index 02214d3ea..4cfbd8cba 100644 --- a/c/src/api/eth1/rpc.yml +++ b/c/src/api/eth1/rpc.yml @@ -121,6 +121,24 @@ utils: - false response: "0x1Fe2E9bf29aa1938859Af64C413361227d04059a" + in3_parse_tx_url: + descr: parse a ethereum-url based on EIP 681 (https://eips.ethereum.org/EIPS/eip-681) + params: + url: + descr: the url with the tx-params + type: string + result: + type: tx_input + example: + request: + - ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7/transfer?address=0x8e23ee67d1332ad560396262c48ffbb01f93d052&uint256=1 + result: + to: '0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7' + fn_sig: transfer(address,uint256) + fn_args: + - '0x8e23ee67d1332ad560396262c48ffbb01f93d052' + - 1 + in3_toWei: sync: true descr: converts the given value into wei. diff --git a/c/src/api/eth1/rpc_api.c b/c/src/api/eth1/rpc_api.c index c5c7a2e79..ba06d9672 100644 --- a/c/src/api/eth1/rpc_api.c +++ b/c/src/api/eth1/rpc_api.c @@ -192,8 +192,12 @@ int string_val_to_bytes(char* val, char* unit, bytes32_t target) { exp = *UNITS[i + 1]; break; } - else if (!UNITS[i + 2]) - return IN3_EINVAL; + else if (!UNITS[i + 2]) { + if (*unit == 'e' && unit[1] >= 0 && unit[1] <= 9) + exp = atoi(unit + 1); + else + return IN3_EINVAL; + } } } if (!exp && l < 20) { @@ -342,6 +346,117 @@ static in3_ret_t in3_pk2address(in3_rpc_handle_ctx_t* ctx) { return in3_rpc_handle_with_bytes(ctx, bytes(public_key + 1, 64)); } +static in3_ret_t parse_tx_param(in3_rpc_handle_ctx_t* ctx, char* params, sb_t* fn_args, sb_t* fn_sig, sb_t* sb) { + while (*params) { + char* eq = strchr(params, '='); + if (!eq || eq == params) return req_set_error(ctx->req, "invalid params, missing =", IN3_EINVAL); + char* n = strchr(params, '&'); + if (n == NULL) n = params + strlen(params); + if (n <= eq) return req_set_error(ctx->req, "invalid params, missing value", IN3_EINVAL); + if ((eq - params) > 30) return req_set_error(ctx->req, "invalid params, name too long", IN3_EINVAL); + char* name = params; + char* value = eq + 1; + *eq = 0; + params = *n ? n + 1 : n; + *n = 0; + if (strcmp(name, "value") == 0) { + bytes32_t tmp = {0}; + string_val_to_bytes(value, NULL, tmp); + bytes_t b = bytes(tmp, 32); + b_optimize_len(&b); + sb_add_bytes(sb, ",\"value\":", &b, 1, false); + } + else if (strcmp(name, "gas") == 0 || strcmp(name, "gasLimit") == 0) { + sb_add_chars(sb, ",\"gas\":"); + sb_print(sb, (value[0] == '0' && value[1] == 'x') ? "\"%s\"" : "%s", value); + } + else if (strcmp(name, "gasPrice") == 0) { + sb_add_chars(sb, ",\"gasPrice\":"); + sb_print(sb, (value[0] == '0' && value[1] == 'x') ? "\"%s\"" : "%s", value); + } + else if (strcmp(name, "data") == 0) { + sb_add_chars(sb, ",\"data\":"); + sb_print(sb, (value[0] == '0' && value[1] == 'x') ? "\"%s\"" : "%s", value); + } + else if (strcmp(name, "from") == 0) { + sb_add_chars(sb, ",\"from\":"); + sb_print(sb, (value[0] == '0' && value[1] == 'x') ? "\"%s\"" : "%s", value); + } + else if (strcmp(name, "nonce") == 0) { + sb_add_chars(sb, ",\"nonce\":"); + sb_print(sb, (value[0] == '0' && value[1] == 'x') ? "\"%s\"" : "%s", value); + } + else if (strcmp(name, "layer") == 0) { + sb_print(sb, ",\"layer\":\"%s\"", value); + } + else { + if (fn_args->len) { + sb_add_char(fn_args, ','); + sb_add_char(fn_sig, ','); + } + sb_add_chars(fn_sig, name); + sb_print(fn_args, *name == 's' || (value[0] == '0' && value[1] == 'x') ? "\"%s\"" : "%s", value); + } + } + + if (fn_sig->data) { + sb_add_chars(sb, ",\"fn_sig\":\""); + sb_add_chars(sb, fn_sig->data); + sb_add_chars(sb, ")\",\"fn_args\":["); + if (fn_args->data) sb_add_chars(sb, fn_args->data); + sb_add_chars(sb, "]"); + } + sb_add_chars(sb, "}"); + + return IN3_OK; +} + +static in3_ret_t parse_tx_url(in3_rpc_handle_ctx_t* ctx) { + char* aurl = NULL; + d_token_t* url_token = d_get_at(ctx->params, 0); + if (d_type(url_token) != T_STRING) return req_set_error(ctx->req, "missing the url as first arg'", IN3_EINVAL); + char* url = d_string(url_token); + if (strncmp(url, "ethereum:", 9)) return req_set_error(ctx->req, "URL must start with 'ethereum:'", IN3_EINVAL); + url += 9; + sb_t sb = {0}; + int l = strlen(url); + char* s1 = strchr(url, '/'); + char* q = strchr(url, '?'); + int to_len = s1 ? s1 - url : (q ? q - url : l); + if (to_len == 42 && url[0] == '0' && url[1] == 'x') { + sb_add_chars(&sb, "{\"to\":\""); + sb_add_range(&sb, url, 0, 42); + sb_add_chars(&sb, "\""); + } + else + return req_set_error(ctx->req, "invalid address in url. Currently ENS names are notsupported yet!", IN3_EINVAL); + url = _strdupn(url + to_len, -1); + q = strchr(url, '?'); + aurl = url; + sb_t fn_args = {0}; + sb_t fn_sig = {0}; + + if (*url == '/') { + l = q > url ? q - url : strlen(url); + if (l) { + sb_add_range(&fn_sig, url, 1, l - 1); + sb_add_char(&fn_sig, '('); + } + url += l + (q ? 1 : 0); + } + in3_ret_t res = IN3_OK; + TRY_GOTO(parse_tx_param(ctx, url, &fn_args, &fn_sig, &sb)) + sb_add_chars(in3_rpc_handle_start(ctx), sb.data); + res = in3_rpc_handle_finish(ctx); + +clean: + _free(sb.data); + _free(fn_args.data); + _free(fn_sig.data); + _free(aurl); + return res; +} + static in3_ret_t in3_calcDeployAddress(in3_rpc_handle_ctx_t* ctx) { bytes_t sender = d_to_bytes(d_get_at(ctx->params, 0)); bytes_t nonce = d_to_bytes(d_get_at(ctx->params, 1)); @@ -632,6 +747,9 @@ static in3_ret_t handle_intern(void* pdata, in3_plugin_act_t action, void* plugi #if !defined(RPC_ONLY) || defined(RPC_IN3_CALCDEPLOYADDRESS) TRY_RPC("in3_calcDeployAddress", in3_calcDeployAddress(ctx)) #endif +#if !defined(RPC_ONLY) || defined(RPC_IN3_PARSE_TX_URL) + TRY_RPC("in3_parse_tx_url", parse_tx_url(ctx)) +#endif return IN3_EIGNORE; } diff --git a/c/src/verifier/eth1/basic/sign_tx.c b/c/src/verifier/eth1/basic/sign_tx.c index fa3880e06..758ad3f5e 100644 --- a/c/src/verifier/eth1/basic/sign_tx.c +++ b/c/src/verifier/eth1/basic/sign_tx.c @@ -263,11 +263,13 @@ in3_ret_t eth_prepare_unsigned_tx(d_token_t* tx, in3_req_t* ctx, bytes_t* dst, s sb_add_rawbytes(meta, "\",\"gas\":\"0x", gas_limit, 0); sb_add_rawbytes(meta, "\",\"gasPrice\":\"0x", gas_price, 0); sb_add_rawbytes(meta, "\",\"nonce\":\"0x", nonce, 0); - sb_add_char(meta, '\"'); + sb_add_chars(meta, "\",\"layer\":\"l1\""); sb_add_json(meta, ",\"fn_sig\":", d_get(tx, key("fn_sig"))); sb_add_json(meta, ",\"fn_args\":", d_get(tx, key("fn_args"))); sb_add_json(meta, ",\"token\":", d_get(tx, key("token"))); sb_add_json(meta, ",\"wallet\":", d_get(tx, key("wallet"))); + sb_add_json(meta, ",\"url\":", d_get(tx, key("url"))); + sb_add_json(meta, ",\"delegate\":", d_get(tx, key("delegate"))); } // do we need to transform the tx before we sign it? From de01d2378a19d3ad2451aa5cb44eb29a05250bbe Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Tue, 27 Jul 2021 18:49:08 +0200 Subject: [PATCH 105/110] fix rpc --- c/src/api/eth1/rpc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/api/eth1/rpc.yml b/c/src/api/eth1/rpc.yml index 4cfbd8cba..c08c33c9d 100644 --- a/c/src/api/eth1/rpc.yml +++ b/c/src/api/eth1/rpc.yml @@ -132,7 +132,7 @@ utils: example: request: - ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7/transfer?address=0x8e23ee67d1332ad560396262c48ffbb01f93d052&uint256=1 - result: + response: to: '0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7' fn_sig: transfer(address,uint256) fn_args: From f224de7b1ff51a0673ada33e3ff51002c60e60c8 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Jul 2021 11:52:45 +0200 Subject: [PATCH 106/110] fixed warning --- c/src/api/eth1/rpc_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/api/eth1/rpc_api.c b/c/src/api/eth1/rpc_api.c index ba06d9672..77533a751 100644 --- a/c/src/api/eth1/rpc_api.c +++ b/c/src/api/eth1/rpc_api.c @@ -437,7 +437,7 @@ static in3_ret_t parse_tx_url(in3_rpc_handle_ctx_t* ctx) { sb_t fn_sig = {0}; if (*url == '/') { - l = q > url ? q - url : strlen(url); + l = q > url ? (int) (q - url) : (int) (strlen(url)); if (l) { sb_add_range(&fn_sig, url, 1, l - 1); sb_add_char(&fn_sig, '('); From c6e8988f35cc1a18ad56bdd8c1832bf208268ea2 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Jul 2021 11:54:27 +0200 Subject: [PATCH 107/110] updated headers --- c/include/in3/zksync.h | 8 ++++---- scripts/_in3.sh | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/c/include/in3/zksync.h b/c/include/in3/zksync.h index 859c8e464..35d990ef7 100644 --- a/c/include/in3/zksync.h +++ b/c/include/in3/zksync.h @@ -69,10 +69,10 @@ static const cache_props_t ZKSYNC_CACHED_PROOF = 0xFF00 | CACHE_PROP_INHERIT; /** represents a token supported in zksync. */ typedef struct { - uint16_t id; /**< the id used in messaged */ - char symbol[8]; /**< short symbol */ - uint8_t decimals; /**< decimals for display */ - address_t address; /**< erc20 address (or 0x00 for eth) */ + uint16_t id; /**< the id used in messaged */ + char symbol[10]; /**< short symbol */ + uint8_t decimals; /**< decimals for display */ + address_t address; /**< erc20 address (or 0x00 for eth) */ } zksync_token_t; /** message type. */ diff --git a/scripts/_in3.sh b/scripts/_in3.sh index 538db7eb1..95ee77374 100755 --- a/scripts/_in3.sh +++ b/scripts/_in3.sh @@ -36,6 +36,8 @@ subcmds=( 'eth_blockNumber: returns the number of the most recent block' 'eth_call: calls a function of a contract (or simply executes the evm opcodes) and returns the result ' 'eth_estimateGas: calculates the gas needed to execute a transaction ' + 'eth_feeHistory: base fee per gas and transaction effective priority fee per gas history for the requested block rang... ' + 'eth_gasPrice: returns the current gasPrice in wei per gas ' 'eth_getBalance: gets the balance of an account for a given block ' 'eth_getBlockByHash: Returns information about a block by hash ' 'eth_getBlockByNumber: returns information about a block by block number ' @@ -65,6 +67,7 @@ subcmds=( 'in3_calcDeployAddress: calculates the address of a contract about to deploy ' 'in3_checksumAddress: Will convert an upper or lowercase Ethereum address to a checksum address
' 'in3_fromWei: converts a given uint (also as hex) with a wei-value into a specified unit ' + 'in3_parse_tx_url: parse a ethereum-url based on EIP 681 (https://eips ' 'in3_toWei: converts the given value into wei ' 'keccak: Returns Keccak-256 (not the standardized SHA3-256) of the given data' 'net_version: Returns the current network id' From 1bc073978ba2c32f558da8ff378bc11ca215946d Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Jul 2021 12:12:35 +0200 Subject: [PATCH 108/110] fix rpc-def --- c/src/verifier/eth1/basic/rpc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/c/src/verifier/eth1/basic/rpc.yml b/c/src/verifier/eth1/basic/rpc.yml index 302b79b71..b699b417c 100644 --- a/c/src/verifier/eth1/basic/rpc.yml +++ b/c/src/verifier/eth1/basic/rpc.yml @@ -240,7 +240,9 @@ eth: descr: An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit. type: double reward: + descr: An array of rewards array: true + type: uint64 From dd312fb722be1f23429203014926ef237324c4f2 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Jul 2021 12:34:25 +0200 Subject: [PATCH 109/110] fix warning --- c/src/api/eth1/rpc_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c/src/api/eth1/rpc_api.c b/c/src/api/eth1/rpc_api.c index 77533a751..255efb736 100644 --- a/c/src/api/eth1/rpc_api.c +++ b/c/src/api/eth1/rpc_api.c @@ -193,7 +193,7 @@ int string_val_to_bytes(char* val, char* unit, bytes32_t target) { break; } else if (!UNITS[i + 2]) { - if (*unit == 'e' && unit[1] >= 0 && unit[1] <= 9) + if (unit[0] == 'e' && unit[1] >= '0' && unit[1] <= '9') exp = atoi(unit + 1); else return IN3_EINVAL; From ae27895453d338262268ee90b31bc69b44420789 Mon Sep 17 00:00:00 2001 From: Simon Jentzsch Date: Wed, 28 Jul 2021 15:47:03 +0200 Subject: [PATCH 110/110] fixed gcc warning --- c/src/cmd/in3/helper.c | 1 + 1 file changed, 1 insertion(+) diff --git a/c/src/cmd/in3/helper.c b/c/src/cmd/in3/helper.c index 4705d008f..4fae1268f 100644 --- a/c/src/cmd/in3/helper.c +++ b/c/src/cmd/in3/helper.c @@ -412,6 +412,7 @@ static inline bool is_convertable_number(char* c) { } static inline bool is_json(char* c) { + if (!c) return false; char* e = parse_json_error(c); if (e) { _free(e);