diff --git a/src/config/version.hpp b/src/config/version.hpp index 39f381dd7..ea0a46114 100644 --- a/src/config/version.hpp +++ b/src/config/version.hpp @@ -1,6 +1,6 @@ #ifndef ZKEVM_PROVER_VERSION_HPP #define ZKEVM_PROVER_VERSION_HPP -#define ZKEVM_PROVER_VERSION "v6.0.0" +#define ZKEVM_PROVER_VERSION "v6.0.2-hotfix1" #endif diff --git a/src/grpc/gen/executor.pb.cc b/src/grpc/gen/executor.pb.cc index 1f5239189..5f0cd0e31 100644 --- a/src/grpc/gen/executor.pb.cc +++ b/src/grpc/gen/executor.pb.cc @@ -43,6 +43,7 @@ extern PROTOBUF_INTERNAL_EXPORT_executor_2eproto ::PROTOBUF_NAMESPACE_ID::intern extern PROTOBUF_INTERNAL_EXPORT_executor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ProcessBlockResponseV2_executor_2eproto; extern PROTOBUF_INTERNAL_EXPORT_executor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ProcessTransactionResponse_executor_2eproto; extern PROTOBUF_INTERNAL_EXPORT_executor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ProcessTransactionResponseV2_executor_2eproto; +extern PROTOBUF_INTERNAL_EXPORT_executor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ResponseDebug_executor_2eproto; extern PROTOBUF_INTERNAL_EXPORT_executor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_TraceConfig_executor_2eproto; extern PROTOBUF_INTERNAL_EXPORT_executor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_TraceConfigV2_executor_2eproto; extern PROTOBUF_INTERNAL_EXPORT_executor_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_TransactionContext_executor_2eproto; @@ -169,6 +170,10 @@ class ProcessBatchResponseV2DefaultTypeInternal { public: ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; } _ProcessBatchResponseV2_default_instance_; +class ResponseDebugDefaultTypeInternal { + public: + ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; +} _ResponseDebug_default_instance_; class TraceConfigV2DefaultTypeInternal { public: ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed _instance; @@ -656,10 +661,11 @@ static void InitDefaultsscc_info_ProcessBatchResponseV2_executor_2eproto() { ::executor::v1::ProcessBatchResponseV2::InitAsDefaultInstance(); } -::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ProcessBatchResponseV2_executor_2eproto = - {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_ProcessBatchResponseV2_executor_2eproto}, { +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_ProcessBatchResponseV2_executor_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, 0, InitDefaultsscc_info_ProcessBatchResponseV2_executor_2eproto}, { &scc_info_ProcessBlockResponseV2_executor_2eproto.base, - &scc_info_ProcessBatchResponseV2_ReadWriteAddressesEntry_DoNotUse_executor_2eproto.base,}}; + &scc_info_ProcessBatchResponseV2_ReadWriteAddressesEntry_DoNotUse_executor_2eproto.base, + &scc_info_ResponseDebug_executor_2eproto.base,}}; static void InitDefaultsscc_info_ProcessBatchResponseV2_ReadWriteAddressesEntry_DoNotUse_executor_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -738,6 +744,20 @@ ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_ProcessTransactionRespons &scc_info_LogV2_executor_2eproto.base, &scc_info_FullTraceV2_executor_2eproto.base,}}; +static void InitDefaultsscc_info_ResponseDebug_executor_2eproto() { + GOOGLE_PROTOBUF_VERIFY_VERSION; + + { + void* ptr = &::executor::v1::_ResponseDebug_default_instance_; + new (ptr) ::executor::v1::ResponseDebug(); + ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr); + } + ::executor::v1::ResponseDebug::InitAsDefaultInstance(); +} + +::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ResponseDebug_executor_2eproto = + {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ResponseDebug_executor_2eproto}, {}}; + static void InitDefaultsscc_info_TraceConfig_executor_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; @@ -852,7 +872,7 @@ static void InitDefaultsscc_info_TransactionStepV2_StorageEntry_DoNotUse_executo ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_TransactionStepV2_StorageEntry_DoNotUse_executor_2eproto = {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_TransactionStepV2_StorageEntry_DoNotUse_executor_2eproto}, {}}; -static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_executor_2eproto[43]; +static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_executor_2eproto[44]; static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_executor_2eproto[2]; static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_executor_2eproto = nullptr; @@ -1240,6 +1260,13 @@ const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_executor_2eproto::offsets[] PR PROTOBUF_FIELD_OFFSET(::executor::v1::ProcessBatchResponseV2, cnt_reserve_steps_), PROTOBUF_FIELD_OFFSET(::executor::v1::ProcessBatchResponseV2, cnt_reserve_sha256_hashes_), PROTOBUF_FIELD_OFFSET(::executor::v1::ProcessBatchResponseV2, old_state_root_), + PROTOBUF_FIELD_OFFSET(::executor::v1::ProcessBatchResponseV2, debug_), + ~0u, // no _has_bits_ + PROTOBUF_FIELD_OFFSET(::executor::v1::ResponseDebug, _internal_metadata_), + ~0u, // no _extensions_ + ~0u, // no _oneof_case_ + ~0u, // no _weak_field_map_ + PROTOBUF_FIELD_OFFSET(::executor::v1::ResponseDebug, error_log_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::executor::v1::TraceConfigV2, _internal_metadata_), ~0u, // no _extensions_ @@ -1453,20 +1480,21 @@ static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOB { 326, -1, sizeof(::executor::v1::DebugV2)}, { 336, 343, sizeof(::executor::v1::ProcessBatchResponseV2_ReadWriteAddressesEntry_DoNotUse)}, { 345, -1, sizeof(::executor::v1::ProcessBatchResponseV2)}, - { 383, -1, sizeof(::executor::v1::TraceConfigV2)}, - { 393, 400, sizeof(::executor::v1::OverrideAccountV2_StateEntry_DoNotUse)}, - { 402, 409, sizeof(::executor::v1::OverrideAccountV2_StateDiffEntry_DoNotUse)}, - { 411, -1, sizeof(::executor::v1::OverrideAccountV2)}, - { 421, 428, sizeof(::executor::v1::InfoReadWriteV2_ScStorageEntry_DoNotUse)}, - { 430, -1, sizeof(::executor::v1::InfoReadWriteV2)}, - { 440, -1, sizeof(::executor::v1::FullTraceV2)}, - { 447, -1, sizeof(::executor::v1::TransactionContextV2)}, - { 467, 474, sizeof(::executor::v1::TransactionStepV2_StorageEntry_DoNotUse)}, - { 476, -1, sizeof(::executor::v1::TransactionStepV2)}, - { 496, -1, sizeof(::executor::v1::ContractV2)}, - { 507, -1, sizeof(::executor::v1::ProcessBlockResponseV2)}, - { 525, -1, sizeof(::executor::v1::ProcessTransactionResponseV2)}, - { 551, -1, sizeof(::executor::v1::LogV2)}, + { 384, -1, sizeof(::executor::v1::ResponseDebug)}, + { 390, -1, sizeof(::executor::v1::TraceConfigV2)}, + { 400, 407, sizeof(::executor::v1::OverrideAccountV2_StateEntry_DoNotUse)}, + { 409, 416, sizeof(::executor::v1::OverrideAccountV2_StateDiffEntry_DoNotUse)}, + { 418, -1, sizeof(::executor::v1::OverrideAccountV2)}, + { 428, 435, sizeof(::executor::v1::InfoReadWriteV2_ScStorageEntry_DoNotUse)}, + { 437, -1, sizeof(::executor::v1::InfoReadWriteV2)}, + { 447, -1, sizeof(::executor::v1::FullTraceV2)}, + { 454, -1, sizeof(::executor::v1::TransactionContextV2)}, + { 474, 481, sizeof(::executor::v1::TransactionStepV2_StorageEntry_DoNotUse)}, + { 483, -1, sizeof(::executor::v1::TransactionStepV2)}, + { 503, -1, sizeof(::executor::v1::ContractV2)}, + { 514, -1, sizeof(::executor::v1::ProcessBlockResponseV2)}, + { 532, -1, sizeof(::executor::v1::ProcessTransactionResponseV2)}, + { 558, -1, sizeof(::executor::v1::LogV2)}, }; static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = { @@ -1499,6 +1527,7 @@ static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = reinterpret_cast(&::executor::v1::_DebugV2_default_instance_), reinterpret_cast(&::executor::v1::_ProcessBatchResponseV2_ReadWriteAddressesEntry_DoNotUse_default_instance_), reinterpret_cast(&::executor::v1::_ProcessBatchResponseV2_default_instance_), + reinterpret_cast(&::executor::v1::_ResponseDebug_default_instance_), reinterpret_cast(&::executor::v1::_TraceConfigV2_default_instance_), reinterpret_cast(&::executor::v1::_OverrideAccountV2_StateEntry_DoNotUse_default_instance_), reinterpret_cast(&::executor::v1::_OverrideAccountV2_StateDiffEntry_DoNotUse_default_instance_), @@ -1647,7 +1676,7 @@ const char descriptor_table_protodef_executor_2eproto[] PROTOBUF_SECTION_VARIABL "smt_proof\030\004 \003(\014\"\204\001\n\007DebugV2\022\021\n\tgas_limit" "\030\001 \001(\004\022\026\n\016new_state_root\030\002 \001(\014\022\032\n\022new_ac" "c_input_hash\030\003 \001(\014\022\033\n\023new_local_exit_roo" - "t\030\004 \001(\014\022\025\n\rnew_batch_num\030\005 \001(\004\"\327\010\n\026Proce" + "t\030\004 \001(\014\022\025\n\rnew_batch_num\030\005 \001(\004\"\202\t\n\026Proce" "ssBatchResponseV2\022\026\n\016new_state_root\030\001 \001(" "\014\022\032\n\022new_acc_input_hash\030\002 \001(\014\022\033\n\023new_loc" "al_exit_root\030\003 \001(\014\022\025\n\rnew_batch_num\030\004 \001(" @@ -1673,267 +1702,269 @@ const char descriptor_table_protodef_executor_2eproto[] PROTOBUF_SECTION_VARIABL "e_arithmetics\030\035 \001(\r\022\034\n\024cnt_reserve_binar" "ies\030\036 \001(\r\022\031\n\021cnt_reserve_steps\030\037 \001(\r\022!\n\031" "cnt_reserve_sha256_hashes\030 \001(\r\022\026\n\016old_s" - "tate_root\030! \001(\014\032W\n\027ReadWriteAddressesEnt" - "ry\022\013\n\003key\030\001 \001(\t\022+\n\005value\030\002 \001(\0132\034.executo" - "r.v1.InfoReadWriteV2:\0028\001\"\232\001\n\rTraceConfig" - "V2\022\027\n\017disable_storage\030\001 \001(\r\022\025\n\rdisable_s" - "tack\030\002 \001(\r\022\025\n\renable_memory\030\003 \001(\r\022\032\n\022ena" - "ble_return_data\030\004 \001(\r\022&\n\036tx_hash_to_gene" - "rate_full_trace\030\005 \001(\014\"\236\002\n\021OverrideAccoun" - "tV2\022\017\n\007balance\030\001 \001(\014\022\r\n\005nonce\030\002 \001(\004\022\014\n\004c" - "ode\030\003 \001(\014\0228\n\005state\030\004 \003(\0132).executor.v1.O" - "verrideAccountV2.StateEntry\022A\n\nstate_dif" - "f\030\005 \003(\0132-.executor.v1.OverrideAccountV2." - "StateDiffEntry\032,\n\nStateEntry\022\013\n\003key\030\001 \001(" - "\t\022\r\n\005value\030\002 \001(\t:\0028\001\0320\n\016StateDiffEntry\022\013" - "\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\310\001\n\017InfoR" - "eadWriteV2\022\r\n\005nonce\030\001 \001(\t\022\017\n\007balance\030\002 \001" - "(\t\022\017\n\007sc_code\030\003 \001(\t\022\?\n\nsc_storage\030\004 \003(\0132" - "+.executor.v1.InfoReadWriteV2.ScStorageE" - "ntry\022\021\n\tsc_length\030\005 \001(\t\0320\n\016ScStorageEntr" - "y\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"p\n\013Ful" - "lTraceV2\0222\n\007context\030\001 \001(\0132!.executor.v1." - "TransactionContextV2\022-\n\005steps\030\002 \003(\0132\036.ex" - "ecutor.v1.TransactionStepV2\"\224\002\n\024Transact" - "ionContextV2\022\014\n\004type\030\001 \001(\t\022\014\n\004from\030\002 \001(\t" - "\022\n\n\002to\030\003 \001(\t\022\014\n\004data\030\004 \001(\014\022\013\n\003gas\030\005 \001(\004\022" - "\r\n\005value\030\006 \001(\t\022\022\n\nblock_hash\030\007 \001(\014\022\016\n\006ou" - "tput\030\010 \001(\014\022\020\n\010gas_used\030\t \001(\004\022\021\n\tgas_pric" - "e\030\n \001(\t\022\026\n\016execution_time\030\013 \001(\r\022\026\n\016old_s" - "tate_root\030\014 \001(\014\022\r\n\005nonce\030\r \001(\004\022\020\n\010tx_ind" - "ex\030\016 \001(\004\022\020\n\010chain_id\030\017 \001(\004\"\240\003\n\021Transacti" - "onStepV2\022\022\n\nstate_root\030\001 \001(\014\022\r\n\005depth\030\002 " - "\001(\r\022\n\n\002pc\030\003 \001(\004\022\013\n\003gas\030\004 \001(\004\022\020\n\010gas_cost" - "\030\005 \001(\004\022\022\n\ngas_refund\030\006 \001(\004\022\n\n\002op\030\007 \001(\r\022\r" - "\n\005stack\030\010 \003(\t\022\016\n\006memory\030\t \001(\014\022\023\n\013memory_" - "size\030\n \001(\r\022\025\n\rmemory_offset\030\013 \001(\r\022\023\n\013ret" - "urn_data\030\014 \001(\014\022)\n\010contract\030\r \001(\0132\027.execu" - "tor.v1.ContractV2\022$\n\005error\030\016 \001(\0162\025.execu" - "tor.v1.RomError\022<\n\007storage\030\017 \003(\0132+.execu" - "tor.v1.TransactionStepV2.StorageEntry\032.\n" - "\014StorageEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(" - "\t:\0028\001\"e\n\nContractV2\022\017\n\007address\030\001 \001(\t\022\016\n\006" - "caller\030\002 \001(\t\022\r\n\005value\030\003 \001(\t\022\014\n\004data\030\004 \001(" - "\014\022\013\n\003gas\030\005 \001(\004\022\014\n\004type\030\006 \001(\t\"\344\002\n\026Process" - "BlockResponseV2\022\023\n\013parent_hash\030\001 \001(\014\022\020\n\010" - "coinbase\030\002 \001(\t\022\021\n\tgas_limit\030\003 \001(\004\022\024\n\014blo" - "ck_number\030\004 \001(\004\022\021\n\ttimestamp\030\005 \001(\004\022\013\n\003ge" - "r\030\006 \001(\014\022\025\n\rblock_hash_l1\030\007 \001(\014\022\020\n\010gas_us" - "ed\030\010 \001(\004\022\027\n\017block_info_root\030\t \001(\014\022\022\n\nblo" - "ck_hash\030\n \001(\014\022<\n\tresponses\030\013 \003(\0132).execu" - "tor.v1.ProcessTransactionResponseV2\022 \n\004l" - "ogs\030\014 \003(\0132\022.executor.v1.LogV2\022$\n\005error\030\r" - " \001(\0162\025.executor.v1.RomError\"\236\004\n\034ProcessT" - "ransactionResponseV2\022\017\n\007tx_hash\030\001 \001(\014\022\022\n" - "\ntx_hash_l2\030\002 \001(\014\022\016\n\006rlp_tx\030\003 \001(\014\022\022\n\nblo" - "ck_hash\030\004 \001(\014\022\024\n\014block_number\030\005 \001(\004\022\014\n\004t" - "ype\030\006 \001(\r\022\024\n\014return_value\030\007 \001(\014\022\020\n\010gas_l" - "eft\030\010 \001(\004\022\020\n\010gas_used\030\t \001(\004\022\033\n\023cumulativ" - "e_gas_used\030\n \001(\004\022\024\n\014gas_refunded\030\013 \001(\004\022$" - "\n\005error\030\014 \001(\0162\025.executor.v1.RomError\022\026\n\016" - "create_address\030\r \001(\t\022\022\n\nstate_root\030\016 \001(\014" - "\022 \n\004logs\030\017 \003(\0132\022.executor.v1.LogV2\022,\n\nfu" - "ll_trace\030\020 \001(\0132\030.executor.v1.FullTraceV2" - "\022\033\n\023effective_gas_price\030\021 \001(\t\022\034\n\024effecti" - "ve_percentage\030\022 \001(\r\022\033\n\023has_gasprice_opco" - "de\030\023 \001(\r\022\032\n\022has_balance_opcode\030\024 \001(\r\022\016\n\006" - "status\030\025 \001(\r\"\246\001\n\005LogV2\022\017\n\007address\030\001 \001(\t\022" - "\016\n\006topics\030\002 \003(\014\022\014\n\004data\030\003 \001(\014\022\024\n\014block_n" - "umber\030\004 \001(\004\022\017\n\007tx_hash\030\005 \001(\014\022\022\n\ntx_hash_" - "l2\030\006 \001(\014\022\020\n\010tx_index\030\007 \001(\r\022\022\n\nblock_hash" - "\030\010 \001(\014\022\r\n\005index\030\t \001(\r*\347\n\n\010RomError\022\031\n\025RO" - "M_ERROR_UNSPECIFIED\020\000\022\026\n\022ROM_ERROR_NO_ER" - "ROR\020\001\022\030\n\024ROM_ERROR_OUT_OF_GAS\020\002\022\034\n\030ROM_E" - "RROR_STACK_OVERFLOW\020\003\022\035\n\031ROM_ERROR_STACK" - "_UNDERFLOW\020\004\022$\n ROM_ERROR_MAX_CODE_SIZE_" - "EXCEEDED\020\005\022(\n$ROM_ERROR_CONTRACT_ADDRESS" - "_COLLISION\020\006\022 \n\034ROM_ERROR_EXECUTION_REVE" - "RTED\020\007\022\"\n\036ROM_ERROR_OUT_OF_COUNTERS_STEP" - "\020\010\022$\n ROM_ERROR_OUT_OF_COUNTERS_KECCAK\020\t" - "\022$\n ROM_ERROR_OUT_OF_COUNTERS_BINARY\020\n\022!" - "\n\035ROM_ERROR_OUT_OF_COUNTERS_MEM\020\013\022#\n\037ROM" - "_ERROR_OUT_OF_COUNTERS_ARITH\020\014\022%\n!ROM_ER" - "ROR_OUT_OF_COUNTERS_PADDING\020\r\022&\n\"ROM_ERR" - "OR_OUT_OF_COUNTERS_POSEIDON\020\016\022!\n\035ROM_ERR" - "OR_OUT_OF_COUNTERS_SHA\020\017\022\032\n\026ROM_ERROR_IN" - "VALID_JUMP\020\020\022\034\n\030ROM_ERROR_INVALID_OPCODE" - "\020\021\022\034\n\030ROM_ERROR_INVALID_STATIC\020\022\022(\n$ROM_" - "ERROR_INVALID_BYTECODE_STARTS_EF\020\023\022)\n%RO" - "M_ERROR_INTRINSIC_INVALID_SIGNATURE\020\024\022(\n" - "$ROM_ERROR_INTRINSIC_INVALID_CHAIN_ID\020\025\022" - "%\n!ROM_ERROR_INTRINSIC_INVALID_NONCE\020\026\022)" - "\n%ROM_ERROR_INTRINSIC_INVALID_GAS_LIMIT\020" - "\027\022\'\n#ROM_ERROR_INTRINSIC_INVALID_BALANCE" - "\020\030\022/\n+ROM_ERROR_INTRINSIC_INVALID_BATCH_" - "GAS_LIMIT\020\031\022+\n\'ROM_ERROR_INTRINSIC_INVAL" - "ID_SENDER_CODE\020\032\022\'\n#ROM_ERROR_INTRINSIC_" - "TX_GAS_OVERFLOW\020\033\022 \n\034ROM_ERROR_BATCH_DAT" - "A_TOO_BIG\020\034\022!\n\035ROM_ERROR_UNSUPPORTED_FOR" - "K_ID\020\035\022\031\n\025ROM_ERROR_INVALID_RLP\020\036\022,\n(ROM" - "_ERROR_INVALID_DECODE_CHANGE_L2_BLOCK\020\037\022" - "2\n.ROM_ERROR_INVALID_NOT_FIRST_TX_CHANGE" - "_L2_BLOCK\020 \0228\n4ROM_ERROR_INVALID_TX_CHAN" - "GE_L2_BLOCK_LIMIT_TIMESTAMP\020!\0226\n2ROM_ERR" - "OR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMEST" - "AMP\020\"\022(\n$ROM_ERROR_INVALID_L1_INFO_TREE_" - "INDEX\020#*\355+\n\rExecutorError\022\036\n\032EXECUTOR_ER" - "ROR_UNSPECIFIED\020\000\022\033\n\027EXECUTOR_ERROR_NO_E" - "RROR\020\001\022\033\n\027EXECUTOR_ERROR_DB_ERROR\020\002\0222\n.E" - "XECUTOR_ERROR_SM_MAIN_COUNTERS_OVERFLOW_" - "STEPS\020\003\0223\n/EXECUTOR_ERROR_SM_MAIN_COUNTE" - "RS_OVERFLOW_KECCAK\020\004\0223\n/EXECUTOR_ERROR_S" - "M_MAIN_COUNTERS_OVERFLOW_BINARY\020\005\0220\n,EXE" - "CUTOR_ERROR_SM_MAIN_COUNTERS_OVERFLOW_ME" - "M\020\006\0222\n.EXECUTOR_ERROR_SM_MAIN_COUNTERS_O" - "VERFLOW_ARITH\020\007\0224\n0EXECUTOR_ERROR_SM_MAI" - "N_COUNTERS_OVERFLOW_PADDING\020\010\0225\n1EXECUTO" - "R_ERROR_SM_MAIN_COUNTERS_OVERFLOW_POSEID" - "ON\020\t\022&\n\"EXECUTOR_ERROR_UNSUPPORTED_FORK_" - "ID\020\n\022#\n\037EXECUTOR_ERROR_BALANCE_MISMATCH\020" - "\013\022\035\n\031EXECUTOR_ERROR_FEA2SCALAR\020\014\022\030\n\024EXEC" - "UTOR_ERROR_TOS32\020\r\022.\n*EXECUTOR_ERROR_SM_" - "MAIN_INVALID_UNSIGNED_TX\020\016\022.\n*EXECUTOR_E" - "RROR_SM_MAIN_INVALID_NO_COUNTERS\020\017\0229\n5EX" - "ECUTOR_ERROR_SM_MAIN_ARITH_ECRECOVER_DIV" - "IDE_BY_ZERO\020\020\022/\n+EXECUTOR_ERROR_SM_MAIN_" - "ADDRESS_OUT_OF_RANGE\020\021\022+\n\'EXECUTOR_ERROR" - "_SM_MAIN_ADDRESS_NEGATIVE\020\022\022.\n*EXECUTOR_" - "ERROR_SM_MAIN_STORAGE_INVALID_KEY\020\023\022 \n\034E" - "XECUTOR_ERROR_SM_MAIN_HASHK\020\024\0222\n.EXECUTO" - "R_ERROR_SM_MAIN_HASHK_SIZE_OUT_OF_RANGE\020" - "\025\0222\n.EXECUTOR_ERROR_SM_MAIN_HASHK_POSITI" - "ON_NEGATIVE\020\026\022@\n\0222\n.EXECUTOR_E" - "RROR_SM_MAIN_MEMALIGN_WRITE_MISMATCH\020\?\0223" - "\n/EXECUTOR_ERROR_SM_MAIN_MEMALIGN_WRITE8" - "_MISMATCH\020@\0221\n-EXECUTOR_ERROR_SM_MAIN_ME" - "MALIGN_READ_MISMATCH\020A\022,\n(EXECUTOR_ERROR" - "_SM_MAIN_JMPN_OUT_OF_RANGE\020B\0222\n.EXECUTOR" - "_ERROR_SM_MAIN_HASHK_READ_OUT_OF_RANGE\020C" - "\0222\n.EXECUTOR_ERROR_SM_MAIN_HASHP_READ_OU" - "T_OF_RANGE\020D\022)\n%EXECUTOR_ERROR_INVALID_O" - "LD_STATE_ROOT\020E\022-\n)EXECUTOR_ERROR_INVALI" - "D_OLD_ACC_INPUT_HASH\020F\022#\n\037EXECUTOR_ERROR" - "_INVALID_CHAIN_ID\020G\022(\n$EXECUTOR_ERROR_IN" - "VALID_BATCH_L2_DATA\020H\022+\n\'EXECUTOR_ERROR_" - "INVALID_GLOBAL_EXIT_ROOT\020I\022#\n\037EXECUTOR_E" - "RROR_INVALID_COINBASE\020J\022\037\n\033EXECUTOR_ERRO" - "R_INVALID_FROM\020K\022!\n\035EXECUTOR_ERROR_INVAL" - "ID_DB_KEY\020L\022#\n\037EXECUTOR_ERROR_INVALID_DB" - "_VALUE\020M\0221\n-EXECUTOR_ERROR_INVALID_CONTR" - "ACTS_BYTECODE_KEY\020N\0223\n/EXECUTOR_ERROR_IN" - "VALID_CONTRACTS_BYTECODE_VALUE\020O\022\"\n\036EXEC" - "UTOR_ERROR_INVALID_GET_KEY\020P\0223\n/EXECUTOR" - "_ERROR_SM_MAIN_COUNTERS_OVERFLOW_SHA256\020" - "Q\022 \n\034EXECUTOR_ERROR_SM_MAIN_HASHS\020R\0222\n.E" - "XECUTOR_ERROR_SM_MAIN_HASHS_SIZE_OUT_OF_" - "RANGE\020S\0222\n.EXECUTOR_ERROR_SM_MAIN_HASHS_" - "POSITION_NEGATIVE\020T\022@\nZ\0222\n.EXECUTOR_ER" + "ROR_SM_MAIN_MEMALIGN_WRITE_MISMATCH\020\?\0223\n" + "/EXECUTOR_ERROR_SM_MAIN_MEMALIGN_WRITE8_" + "MISMATCH\020@\0221\n-EXECUTOR_ERROR_SM_MAIN_MEM" + "ALIGN_READ_MISMATCH\020A\022,\n(EXECUTOR_ERROR_" + "SM_MAIN_JMPN_OUT_OF_RANGE\020B\0222\n.EXECUTOR_" + "ERROR_SM_MAIN_HASHK_READ_OUT_OF_RANGE\020C\022" + "2\n.EXECUTOR_ERROR_SM_MAIN_HASHP_READ_OUT" + "_OF_RANGE\020D\022)\n%EXECUTOR_ERROR_INVALID_OL" + "D_STATE_ROOT\020E\022-\n)EXECUTOR_ERROR_INVALID" + "_OLD_ACC_INPUT_HASH\020F\022#\n\037EXECUTOR_ERROR_" + "INVALID_CHAIN_ID\020G\022(\n$EXECUTOR_ERROR_INV" + "ALID_BATCH_L2_DATA\020H\022+\n\'EXECUTOR_ERROR_I" + "NVALID_GLOBAL_EXIT_ROOT\020I\022#\n\037EXECUTOR_ER" + "ROR_INVALID_COINBASE\020J\022\037\n\033EXECUTOR_ERROR" + "_INVALID_FROM\020K\022!\n\035EXECUTOR_ERROR_INVALI" + "D_DB_KEY\020L\022#\n\037EXECUTOR_ERROR_INVALID_DB_" + "VALUE\020M\0221\n-EXECUTOR_ERROR_INVALID_CONTRA" + "CTS_BYTECODE_KEY\020N\0223\n/EXECUTOR_ERROR_INV" + "ALID_CONTRACTS_BYTECODE_VALUE\020O\022\"\n\036EXECU" + "TOR_ERROR_INVALID_GET_KEY\020P\0223\n/EXECUTOR_" + "ERROR_SM_MAIN_COUNTERS_OVERFLOW_SHA256\020Q" + "\022 \n\034EXECUTOR_ERROR_SM_MAIN_HASHS\020R\0222\n.EX" + "ECUTOR_ERROR_SM_MAIN_HASHS_SIZE_OUT_OF_R" + "ANGE\020S\0222\n.EXECUTOR_ERROR_SM_MAIN_HASHS_P" + "OSITION_NEGATIVE\020T\022@\nZdebug_ = const_cast< ::executor::v1::ResponseDebug*>( + ::executor::v1::ResponseDebug::internal_default_instance()); } class ProcessBatchResponseV2::_Internal { public: + static const ::executor::v1::ResponseDebug& debug(const ProcessBatchResponseV2* msg); }; +const ::executor::v1::ResponseDebug& +ProcessBatchResponseV2::_Internal::debug(const ProcessBatchResponseV2* msg) { + return *msg->debug_; +} ProcessBatchResponseV2::ProcessBatchResponseV2(::PROTOBUF_NAMESPACE_ID::Arena* arena) : ::PROTOBUF_NAMESPACE_ID::Message(arena), block_responses_(arena), @@ -10402,6 +10441,11 @@ ProcessBatchResponseV2::ProcessBatchResponseV2(const ProcessBatchResponseV2& fro old_state_root_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_old_state_root(), GetArena()); } + if (from._internal_has_debug()) { + debug_ = new ::executor::v1::ResponseDebug(*from.debug_); + } else { + debug_ = nullptr; + } ::memcpy(&new_batch_num_, &from.new_batch_num_, static_cast(reinterpret_cast(&cnt_reserve_sha256_hashes_) - reinterpret_cast(&new_batch_num_)) + sizeof(cnt_reserve_sha256_hashes_)); @@ -10415,9 +10459,9 @@ void ProcessBatchResponseV2::SharedCtor() { new_local_exit_root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); prover_id_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); old_state_root_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); - ::memset(&new_batch_num_, 0, static_cast( + ::memset(&debug_, 0, static_cast( reinterpret_cast(&cnt_reserve_sha256_hashes_) - - reinterpret_cast(&new_batch_num_)) + sizeof(cnt_reserve_sha256_hashes_)); + reinterpret_cast(&debug_)) + sizeof(cnt_reserve_sha256_hashes_)); } ProcessBatchResponseV2::~ProcessBatchResponseV2() { @@ -10433,6 +10477,7 @@ void ProcessBatchResponseV2::SharedDtor() { new_local_exit_root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); prover_id_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); old_state_root_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (this != internal_default_instance()) delete debug_; } void ProcessBatchResponseV2::ArenaDtor(void* object) { @@ -10465,6 +10510,10 @@ void ProcessBatchResponseV2::Clear() { new_local_exit_root_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); prover_id_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); old_state_root_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + if (GetArena() == nullptr && debug_ != nullptr) { + delete debug_; + } + debug_ = nullptr; ::memset(&new_batch_num_, 0, static_cast( reinterpret_cast(&cnt_reserve_sha256_hashes_) - reinterpret_cast(&new_batch_num_)) + sizeof(cnt_reserve_sha256_hashes_)); @@ -10740,6 +10789,13 @@ const char* ProcessBatchResponseV2::_InternalParse(const char* ptr, ::PROTOBUF_N CHK_(ptr); } else goto handle_unusual; continue; + // .executor.v1.ResponseDebug debug = 34; + case 34: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) { + ptr = ctx->ParseMessage(_internal_mutable_debug(), ptr); + CHK_(ptr); + } else goto handle_unusual; + continue; default: { handle_unusual: if ((tag & 7) == 4 || tag == 0) { @@ -11009,6 +11065,14 @@ ::PROTOBUF_NAMESPACE_ID::uint8* ProcessBatchResponseV2::_InternalSerialize( 33, this->_internal_old_state_root(), target); } + // .executor.v1.ResponseDebug debug = 34; + if (this->has_debug()) { + target = stream->EnsureSpace(target); + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite:: + InternalWriteMessage( + 34, _Internal::debug(this), target, stream); + } + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); @@ -11092,6 +11156,13 @@ size_t ProcessBatchResponseV2::ByteSizeLong() const { this->_internal_old_state_root()); } + // .executor.v1.ResponseDebug debug = 34; + if (this->has_debug()) { + total_size += 2 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize( + *debug_); + } + // uint64 new_batch_num = 4; if (this->new_batch_num() != 0) { total_size += 1 + @@ -11308,6 +11379,9 @@ void ProcessBatchResponseV2::MergeFrom(const ProcessBatchResponseV2& from) { if (from.old_state_root().size() > 0) { _internal_set_old_state_root(from._internal_old_state_root()); } + if (from.has_debug()) { + _internal_mutable_debug()->::executor::v1::ResponseDebug::MergeFrom(from._internal_debug()); + } if (from.new_batch_num() != 0) { _internal_set_new_batch_num(from._internal_new_batch_num()); } @@ -11415,9 +11489,9 @@ void ProcessBatchResponseV2::InternalSwap(ProcessBatchResponseV2* other) { ::PROTOBUF_NAMESPACE_ID::internal::memswap< PROTOBUF_FIELD_OFFSET(ProcessBatchResponseV2, cnt_reserve_sha256_hashes_) + sizeof(ProcessBatchResponseV2::cnt_reserve_sha256_hashes_) - - PROTOBUF_FIELD_OFFSET(ProcessBatchResponseV2, new_batch_num_)>( - reinterpret_cast(&new_batch_num_), - reinterpret_cast(&other->new_batch_num_)); + - PROTOBUF_FIELD_OFFSET(ProcessBatchResponseV2, debug_)>( + reinterpret_cast(&debug_), + reinterpret_cast(&other->debug_)); } ::PROTOBUF_NAMESPACE_ID::Metadata ProcessBatchResponseV2::GetMetadata() const { @@ -11425,6 +11499,215 @@ ::PROTOBUF_NAMESPACE_ID::Metadata ProcessBatchResponseV2::GetMetadata() const { } +// =================================================================== + +void ResponseDebug::InitAsDefaultInstance() { +} +class ResponseDebug::_Internal { + public: +}; + +ResponseDebug::ResponseDebug(::PROTOBUF_NAMESPACE_ID::Arena* arena) + : ::PROTOBUF_NAMESPACE_ID::Message(arena) { + SharedCtor(); + RegisterArenaDtor(arena); + // @@protoc_insertion_point(arena_constructor:executor.v1.ResponseDebug) +} +ResponseDebug::ResponseDebug(const ResponseDebug& from) + : ::PROTOBUF_NAMESPACE_ID::Message() { + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + error_log_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); + if (!from._internal_error_log().empty()) { + error_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_error_log(), + GetArena()); + } + // @@protoc_insertion_point(copy_constructor:executor.v1.ResponseDebug) +} + +void ResponseDebug::SharedCtor() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_ResponseDebug_executor_2eproto.base); + error_log_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +ResponseDebug::~ResponseDebug() { + // @@protoc_insertion_point(destructor:executor.v1.ResponseDebug) + SharedDtor(); + _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +void ResponseDebug::SharedDtor() { + GOOGLE_DCHECK(GetArena() == nullptr); + error_log_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited()); +} + +void ResponseDebug::ArenaDtor(void* object) { + ResponseDebug* _this = reinterpret_cast< ResponseDebug* >(object); + (void)_this; +} +void ResponseDebug::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) { +} +void ResponseDebug::SetCachedSize(int size) const { + _cached_size_.Set(size); +} +const ResponseDebug& ResponseDebug::default_instance() { + ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ResponseDebug_executor_2eproto.base); + return *internal_default_instance(); +} + + +void ResponseDebug::Clear() { +// @@protoc_insertion_point(message_clear_start:executor.v1.ResponseDebug) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + error_log_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); + _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); +} + +const char* ResponseDebug::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) { +#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure + ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena; + while (!ctx->Done(&ptr)) { + ::PROTOBUF_NAMESPACE_ID::uint32 tag; + ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag); + CHK_(ptr); + switch (tag >> 3) { + // string error_log = 1; + case 1: + if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) { + auto str = _internal_mutable_error_log(); + ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx); + CHK_(::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "executor.v1.ResponseDebug.error_log")); + CHK_(ptr); + } else goto handle_unusual; + continue; + default: { + handle_unusual: + if ((tag & 7) == 4 || tag == 0) { + ctx->SetLastTag(tag); + goto success; + } + ptr = UnknownFieldParse(tag, + _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(), + ptr, ctx); + CHK_(ptr != nullptr); + continue; + } + } // switch + } // while +success: + return ptr; +failure: + ptr = nullptr; + goto success; +#undef CHK_ +} + +::PROTOBUF_NAMESPACE_ID::uint8* ResponseDebug::_InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const { + // @@protoc_insertion_point(serialize_to_array_start:executor.v1.ResponseDebug) + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + // string error_log = 1; + if (this->error_log().size() > 0) { + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( + this->_internal_error_log().data(), static_cast(this->_internal_error_log().length()), + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, + "executor.v1.ResponseDebug.error_log"); + target = stream->WriteStringMaybeAliased( + 1, this->_internal_error_log(), target); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray( + _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream); + } + // @@protoc_insertion_point(serialize_to_array_end:executor.v1.ResponseDebug) + return target; +} + +size_t ResponseDebug::ByteSizeLong() const { +// @@protoc_insertion_point(message_byte_size_start:executor.v1.ResponseDebug) + size_t total_size = 0; + + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + // Prevent compiler warnings about cached_has_bits being unused + (void) cached_has_bits; + + // string error_log = 1; + if (this->error_log().size() > 0) { + total_size += 1 + + ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( + this->_internal_error_log()); + } + + if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) { + return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize( + _internal_metadata_, total_size, &_cached_size_); + } + int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size); + SetCachedSize(cached_size); + return total_size; +} + +void ResponseDebug::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_merge_from_start:executor.v1.ResponseDebug) + GOOGLE_DCHECK_NE(&from, this); + const ResponseDebug* source = + ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated( + &from); + if (source == nullptr) { + // @@protoc_insertion_point(generalized_merge_from_cast_fail:executor.v1.ResponseDebug) + ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this); + } else { + // @@protoc_insertion_point(generalized_merge_from_cast_success:executor.v1.ResponseDebug) + MergeFrom(*source); + } +} + +void ResponseDebug::MergeFrom(const ResponseDebug& from) { +// @@protoc_insertion_point(class_specific_merge_from_start:executor.v1.ResponseDebug) + GOOGLE_DCHECK_NE(&from, this); + _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); + ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0; + (void) cached_has_bits; + + if (from.error_log().size() > 0) { + _internal_set_error_log(from._internal_error_log()); + } +} + +void ResponseDebug::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) { +// @@protoc_insertion_point(generalized_copy_from_start:executor.v1.ResponseDebug) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void ResponseDebug::CopyFrom(const ResponseDebug& from) { +// @@protoc_insertion_point(class_specific_copy_from_start:executor.v1.ResponseDebug) + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool ResponseDebug::IsInitialized() const { + return true; +} + +void ResponseDebug::InternalSwap(ResponseDebug* other) { + using std::swap; + _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_); + error_log_.Swap(&other->error_log_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} + +::PROTOBUF_NAMESPACE_ID::Metadata ResponseDebug::GetMetadata() const { + return GetMetadataStatic(); +} + + // =================================================================== void TraceConfigV2::InitAsDefaultInstance() { @@ -16428,6 +16711,9 @@ template<> PROTOBUF_NOINLINE ::executor::v1::ProcessBatchResponseV2_ReadWriteAdd template<> PROTOBUF_NOINLINE ::executor::v1::ProcessBatchResponseV2* Arena::CreateMaybeMessage< ::executor::v1::ProcessBatchResponseV2 >(Arena* arena) { return Arena::CreateMessageInternal< ::executor::v1::ProcessBatchResponseV2 >(arena); } +template<> PROTOBUF_NOINLINE ::executor::v1::ResponseDebug* Arena::CreateMaybeMessage< ::executor::v1::ResponseDebug >(Arena* arena) { + return Arena::CreateMessageInternal< ::executor::v1::ResponseDebug >(arena); +} template<> PROTOBUF_NOINLINE ::executor::v1::TraceConfigV2* Arena::CreateMaybeMessage< ::executor::v1::TraceConfigV2 >(Arena* arena) { return Arena::CreateMessageInternal< ::executor::v1::TraceConfigV2 >(arena); } diff --git a/src/grpc/gen/executor.pb.h b/src/grpc/gen/executor.pb.h index cde2146b6..2f91211d1 100644 --- a/src/grpc/gen/executor.pb.h +++ b/src/grpc/gen/executor.pb.h @@ -52,7 +52,7 @@ struct TableStruct_executor_2eproto { PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::AuxillaryParseTableField aux[] PROTOBUF_SECTION_VARIABLE(protodesc_cold); - static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[43] + static const ::PROTOBUF_NAMESPACE_ID::internal::ParseTable schema[44] PROTOBUF_SECTION_VARIABLE(protodesc_cold); static const ::PROTOBUF_NAMESPACE_ID::internal::FieldMetadata field_metadata[]; static const ::PROTOBUF_NAMESPACE_ID::internal::SerializationTable serialization_table[]; @@ -166,6 +166,9 @@ extern ProcessTransactionResponseDefaultTypeInternal _ProcessTransactionResponse class ProcessTransactionResponseV2; class ProcessTransactionResponseV2DefaultTypeInternal; extern ProcessTransactionResponseV2DefaultTypeInternal _ProcessTransactionResponseV2_default_instance_; +class ResponseDebug; +class ResponseDebugDefaultTypeInternal; +extern ResponseDebugDefaultTypeInternal _ResponseDebug_default_instance_; class TraceConfig; class TraceConfigDefaultTypeInternal; extern TraceConfigDefaultTypeInternal _TraceConfig_default_instance_; @@ -228,6 +231,7 @@ template<> ::executor::v1::ProcessBlockResponseV2* Arena::CreateMaybeMessage<::e template<> ::executor::v1::ProcessStatelessBatchRequestV2* Arena::CreateMaybeMessage<::executor::v1::ProcessStatelessBatchRequestV2>(Arena*); template<> ::executor::v1::ProcessTransactionResponse* Arena::CreateMaybeMessage<::executor::v1::ProcessTransactionResponse>(Arena*); template<> ::executor::v1::ProcessTransactionResponseV2* Arena::CreateMaybeMessage<::executor::v1::ProcessTransactionResponseV2>(Arena*); +template<> ::executor::v1::ResponseDebug* Arena::CreateMaybeMessage<::executor::v1::ResponseDebug>(Arena*); template<> ::executor::v1::TraceConfig* Arena::CreateMaybeMessage<::executor::v1::TraceConfig>(Arena*); template<> ::executor::v1::TraceConfigV2* Arena::CreateMaybeMessage<::executor::v1::TraceConfigV2>(Arena*); template<> ::executor::v1::TransactionContext* Arena::CreateMaybeMessage<::executor::v1::TransactionContext>(Arena*); @@ -6011,6 +6015,7 @@ class ProcessBatchResponseV2 PROTOBUF_FINAL : kNewLocalExitRootFieldNumber = 3, kProverIdFieldNumber = 18, kOldStateRootFieldNumber = 33, + kDebugFieldNumber = 34, kNewBatchNumFieldNumber = 4, kCntKeccakHashesFieldNumber = 5, kCntPoseidonHashesFieldNumber = 6, @@ -6244,6 +6249,24 @@ class ProcessBatchResponseV2 PROTOBUF_FINAL : std::string* _internal_mutable_old_state_root(); public: + // .executor.v1.ResponseDebug debug = 34; + bool has_debug() const; + private: + bool _internal_has_debug() const; + public: + void clear_debug(); + const ::executor::v1::ResponseDebug& debug() const; + ::executor::v1::ResponseDebug* release_debug(); + ::executor::v1::ResponseDebug* mutable_debug(); + void set_allocated_debug(::executor::v1::ResponseDebug* debug); + private: + const ::executor::v1::ResponseDebug& _internal_debug() const; + ::executor::v1::ResponseDebug* _internal_mutable_debug(); + public: + void unsafe_arena_set_allocated_debug( + ::executor::v1::ResponseDebug* debug); + ::executor::v1::ResponseDebug* unsafe_arena_release_debug(); + // uint64 new_batch_num = 4; void clear_new_batch_num(); ::PROTOBUF_NAMESPACE_ID::uint64 new_batch_num() const; @@ -6481,6 +6504,7 @@ class ProcessBatchResponseV2 PROTOBUF_FINAL : ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr new_local_exit_root_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr prover_id_; ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr old_state_root_; + ::executor::v1::ResponseDebug* debug_; ::PROTOBUF_NAMESPACE_ID::uint64 new_batch_num_; ::PROTOBUF_NAMESPACE_ID::uint32 cnt_keccak_hashes_; ::PROTOBUF_NAMESPACE_ID::uint32 cnt_poseidon_hashes_; @@ -6510,6 +6534,159 @@ class ProcessBatchResponseV2 PROTOBUF_FINAL : }; // ------------------------------------------------------------------- +class ResponseDebug PROTOBUF_FINAL : + public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:executor.v1.ResponseDebug) */ { + public: + inline ResponseDebug() : ResponseDebug(nullptr) {}; + virtual ~ResponseDebug(); + + ResponseDebug(const ResponseDebug& from); + ResponseDebug(ResponseDebug&& from) noexcept + : ResponseDebug() { + *this = ::std::move(from); + } + + inline ResponseDebug& operator=(const ResponseDebug& from) { + CopyFrom(from); + return *this; + } + inline ResponseDebug& operator=(ResponseDebug&& from) noexcept { + if (GetArena() == from.GetArena()) { + if (this != &from) InternalSwap(&from); + } else { + CopyFrom(from); + } + return *this; + } + + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* descriptor() { + return GetDescriptor(); + } + static const ::PROTOBUF_NAMESPACE_ID::Descriptor* GetDescriptor() { + return GetMetadataStatic().descriptor; + } + static const ::PROTOBUF_NAMESPACE_ID::Reflection* GetReflection() { + return GetMetadataStatic().reflection; + } + static const ResponseDebug& default_instance(); + + static void InitAsDefaultInstance(); // FOR INTERNAL USE ONLY + static inline const ResponseDebug* internal_default_instance() { + return reinterpret_cast( + &_ResponseDebug_default_instance_); + } + static constexpr int kIndexInFileMessages = + 29; + + friend void swap(ResponseDebug& a, ResponseDebug& b) { + a.Swap(&b); + } + inline void Swap(ResponseDebug* other) { + if (other == this) return; + if (GetArena() == other->GetArena()) { + InternalSwap(other); + } else { + ::PROTOBUF_NAMESPACE_ID::internal::GenericSwap(this, other); + } + } + void UnsafeArenaSwap(ResponseDebug* other) { + if (other == this) return; + GOOGLE_DCHECK(GetArena() == other->GetArena()); + InternalSwap(other); + } + + // implements Message ---------------------------------------------- + + inline ResponseDebug* New() const final { + return CreateMaybeMessage(nullptr); + } + + ResponseDebug* New(::PROTOBUF_NAMESPACE_ID::Arena* arena) const final { + return CreateMaybeMessage(arena); + } + void CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) final; + void CopyFrom(const ResponseDebug& from); + void MergeFrom(const ResponseDebug& from); + PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final; + bool IsInitialized() const final; + + size_t ByteSizeLong() const final; + const char* _InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) final; + ::PROTOBUF_NAMESPACE_ID::uint8* _InternalSerialize( + ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const final; + int GetCachedSize() const final { return _cached_size_.Get(); } + + private: + inline void SharedCtor(); + inline void SharedDtor(); + void SetCachedSize(int size) const final; + void InternalSwap(ResponseDebug* other); + friend class ::PROTOBUF_NAMESPACE_ID::internal::AnyMetadata; + static ::PROTOBUF_NAMESPACE_ID::StringPiece FullMessageName() { + return "executor.v1.ResponseDebug"; + } + protected: + explicit ResponseDebug(::PROTOBUF_NAMESPACE_ID::Arena* arena); + private: + static void ArenaDtor(void* object); + inline void RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena* arena); + public: + + ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadata() const final; + private: + static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { + ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_executor_2eproto); + return ::descriptor_table_executor_2eproto.file_level_metadata[kIndexInFileMessages]; + } + + public: + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + enum : int { + kErrorLogFieldNumber = 1, + }; + // string error_log = 1; + void clear_error_log(); + const std::string& error_log() const; + void set_error_log(const std::string& value); + void set_error_log(std::string&& value); + void set_error_log(const char* value); + void set_error_log(const char* value, size_t size); + std::string* mutable_error_log(); + std::string* release_error_log(); + void set_allocated_error_log(std::string* error_log); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + std::string* unsafe_arena_release_error_log(); + GOOGLE_PROTOBUF_RUNTIME_DEPRECATED("The unsafe_arena_ accessors for" + " string fields are deprecated and will be removed in a" + " future release.") + void unsafe_arena_set_allocated_error_log( + std::string* error_log); + private: + const std::string& _internal_error_log() const; + void _internal_set_error_log(const std::string& value); + std::string* _internal_mutable_error_log(); + public: + + // @@protoc_insertion_point(class_scope:executor.v1.ResponseDebug) + private: + class _Internal; + + template friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; + typedef void InternalArenaConstructable_; + typedef void DestructorSkippable_; + ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr error_log_; + mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; + friend struct ::TableStruct_executor_2eproto; +}; +// ------------------------------------------------------------------- + class TraceConfigV2 PROTOBUF_FINAL : public ::PROTOBUF_NAMESPACE_ID::Message /* @@protoc_insertion_point(class_definition:executor.v1.TraceConfigV2) */ { public: @@ -6552,7 +6729,7 @@ class TraceConfigV2 PROTOBUF_FINAL : &_TraceConfigV2_default_instance_); } static constexpr int kIndexInFileMessages = - 29; + 30; friend void swap(TraceConfigV2& a, TraceConfigV2& b) { a.Swap(&b); @@ -6733,7 +6910,7 @@ class OverrideAccountV2_StateEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID::in private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_executor_2eproto); - return ::descriptor_table_executor_2eproto.file_level_metadata[30]; + return ::descriptor_table_executor_2eproto.file_level_metadata[31]; } public: @@ -6767,7 +6944,7 @@ class OverrideAccountV2_StateDiffEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_executor_2eproto); - return ::descriptor_table_executor_2eproto.file_level_metadata[31]; + return ::descriptor_table_executor_2eproto.file_level_metadata[32]; } public: @@ -6817,7 +6994,7 @@ class OverrideAccountV2 PROTOBUF_FINAL : &_OverrideAccountV2_default_instance_); } static constexpr int kIndexInFileMessages = - 32; + 33; friend void swap(OverrideAccountV2& a, OverrideAccountV2& b) { a.Swap(&b); @@ -7041,7 +7218,7 @@ class InfoReadWriteV2_ScStorageEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID:: private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_executor_2eproto); - return ::descriptor_table_executor_2eproto.file_level_metadata[33]; + return ::descriptor_table_executor_2eproto.file_level_metadata[34]; } public: @@ -7091,7 +7268,7 @@ class InfoReadWriteV2 PROTOBUF_FINAL : &_InfoReadWriteV2_default_instance_); } static constexpr int kIndexInFileMessages = - 34; + 35; friend void swap(InfoReadWriteV2& a, InfoReadWriteV2& b) { a.Swap(&b); @@ -7350,7 +7527,7 @@ class FullTraceV2 PROTOBUF_FINAL : &_FullTraceV2_default_instance_); } static constexpr int kIndexInFileMessages = - 35; + 36; friend void swap(FullTraceV2& a, FullTraceV2& b) { a.Swap(&b); @@ -7516,7 +7693,7 @@ class TransactionContextV2 PROTOBUF_FINAL : &_TransactionContextV2_default_instance_); } static constexpr int kIndexInFileMessages = - 36; + 37; friend void swap(TransactionContextV2& a, TransactionContextV2& b) { a.Swap(&b); @@ -7935,7 +8112,7 @@ class TransactionStepV2_StorageEntry_DoNotUse : public ::PROTOBUF_NAMESPACE_ID:: private: static ::PROTOBUF_NAMESPACE_ID::Metadata GetMetadataStatic() { ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&::descriptor_table_executor_2eproto); - return ::descriptor_table_executor_2eproto.file_level_metadata[37]; + return ::descriptor_table_executor_2eproto.file_level_metadata[38]; } public: @@ -7985,7 +8162,7 @@ class TransactionStepV2 PROTOBUF_FINAL : &_TransactionStepV2_default_instance_); } static constexpr int kIndexInFileMessages = - 38; + 39; friend void swap(TransactionStepV2& a, TransactionStepV2& b) { a.Swap(&b); @@ -8362,7 +8539,7 @@ class ContractV2 PROTOBUF_FINAL : &_ContractV2_default_instance_); } static constexpr int kIndexInFileMessages = - 39; + 40; friend void swap(ContractV2& a, ContractV2& b) { a.Swap(&b); @@ -8634,7 +8811,7 @@ class ProcessBlockResponseV2 PROTOBUF_FINAL : &_ProcessBlockResponseV2_default_instance_); } static constexpr int kIndexInFileMessages = - 40; + 41; friend void swap(ProcessBlockResponseV2& a, ProcessBlockResponseV2& b) { a.Swap(&b); @@ -9017,7 +9194,7 @@ class ProcessTransactionResponseV2 PROTOBUF_FINAL : &_ProcessTransactionResponseV2_default_instance_); } static constexpr int kIndexInFileMessages = - 41; + 42; friend void swap(ProcessTransactionResponseV2& a, ProcessTransactionResponseV2& b) { a.Swap(&b); @@ -9520,7 +9697,7 @@ class LogV2 PROTOBUF_FINAL : &_LogV2_default_instance_); } static constexpr int kIndexInFileMessages = - 42; + 43; friend void swap(LogV2& a, LogV2& b) { a.Swap(&b); @@ -18785,6 +18962,172 @@ inline void ProcessBatchResponseV2::unsafe_arena_set_allocated_old_state_root( // @@protoc_insertion_point(field_unsafe_arena_set_allocated:executor.v1.ProcessBatchResponseV2.old_state_root) } +// .executor.v1.ResponseDebug debug = 34; +inline bool ProcessBatchResponseV2::_internal_has_debug() const { + return this != internal_default_instance() && debug_ != nullptr; +} +inline bool ProcessBatchResponseV2::has_debug() const { + return _internal_has_debug(); +} +inline void ProcessBatchResponseV2::clear_debug() { + if (GetArena() == nullptr && debug_ != nullptr) { + delete debug_; + } + debug_ = nullptr; +} +inline const ::executor::v1::ResponseDebug& ProcessBatchResponseV2::_internal_debug() const { + const ::executor::v1::ResponseDebug* p = debug_; + return p != nullptr ? *p : *reinterpret_cast( + &::executor::v1::_ResponseDebug_default_instance_); +} +inline const ::executor::v1::ResponseDebug& ProcessBatchResponseV2::debug() const { + // @@protoc_insertion_point(field_get:executor.v1.ProcessBatchResponseV2.debug) + return _internal_debug(); +} +inline void ProcessBatchResponseV2::unsafe_arena_set_allocated_debug( + ::executor::v1::ResponseDebug* debug) { + if (GetArena() == nullptr) { + delete reinterpret_cast<::PROTOBUF_NAMESPACE_ID::MessageLite*>(debug_); + } + debug_ = debug; + if (debug) { + + } else { + + } + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:executor.v1.ProcessBatchResponseV2.debug) +} +inline ::executor::v1::ResponseDebug* ProcessBatchResponseV2::release_debug() { + auto temp = unsafe_arena_release_debug(); + if (GetArena() != nullptr) { + temp = ::PROTOBUF_NAMESPACE_ID::internal::DuplicateIfNonNull(temp); + } + return temp; +} +inline ::executor::v1::ResponseDebug* ProcessBatchResponseV2::unsafe_arena_release_debug() { + // @@protoc_insertion_point(field_release:executor.v1.ProcessBatchResponseV2.debug) + + ::executor::v1::ResponseDebug* temp = debug_; + debug_ = nullptr; + return temp; +} +inline ::executor::v1::ResponseDebug* ProcessBatchResponseV2::_internal_mutable_debug() { + + if (debug_ == nullptr) { + auto* p = CreateMaybeMessage<::executor::v1::ResponseDebug>(GetArena()); + debug_ = p; + } + return debug_; +} +inline ::executor::v1::ResponseDebug* ProcessBatchResponseV2::mutable_debug() { + // @@protoc_insertion_point(field_mutable:executor.v1.ProcessBatchResponseV2.debug) + return _internal_mutable_debug(); +} +inline void ProcessBatchResponseV2::set_allocated_debug(::executor::v1::ResponseDebug* debug) { + ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArena(); + if (message_arena == nullptr) { + delete debug_; + } + if (debug) { + ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena = + ::PROTOBUF_NAMESPACE_ID::Arena::GetArena(debug); + if (message_arena != submessage_arena) { + debug = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage( + message_arena, debug, submessage_arena); + } + + } else { + + } + debug_ = debug; + // @@protoc_insertion_point(field_set_allocated:executor.v1.ProcessBatchResponseV2.debug) +} + +// ------------------------------------------------------------------- + +// ResponseDebug + +// string error_log = 1; +inline void ResponseDebug::clear_error_log() { + error_log_.ClearToEmpty(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline const std::string& ResponseDebug::error_log() const { + // @@protoc_insertion_point(field_get:executor.v1.ResponseDebug.error_log) + return _internal_error_log(); +} +inline void ResponseDebug::set_error_log(const std::string& value) { + _internal_set_error_log(value); + // @@protoc_insertion_point(field_set:executor.v1.ResponseDebug.error_log) +} +inline std::string* ResponseDebug::mutable_error_log() { + // @@protoc_insertion_point(field_mutable:executor.v1.ResponseDebug.error_log) + return _internal_mutable_error_log(); +} +inline const std::string& ResponseDebug::_internal_error_log() const { + return error_log_.Get(); +} +inline void ResponseDebug::_internal_set_error_log(const std::string& value) { + + error_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), value, GetArena()); +} +inline void ResponseDebug::set_error_log(std::string&& value) { + + error_log_.Set( + &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::move(value), GetArena()); + // @@protoc_insertion_point(field_set_rvalue:executor.v1.ResponseDebug.error_log) +} +inline void ResponseDebug::set_error_log(const char* value) { + GOOGLE_DCHECK(value != nullptr); + + error_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string(value), + GetArena()); + // @@protoc_insertion_point(field_set_char:executor.v1.ResponseDebug.error_log) +} +inline void ResponseDebug::set_error_log(const char* value, + size_t size) { + + error_log_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), ::std::string( + reinterpret_cast(value), size), GetArena()); + // @@protoc_insertion_point(field_set_pointer:executor.v1.ResponseDebug.error_log) +} +inline std::string* ResponseDebug::_internal_mutable_error_log() { + + return error_log_.Mutable(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline std::string* ResponseDebug::release_error_log() { + // @@protoc_insertion_point(field_release:executor.v1.ResponseDebug.error_log) + return error_log_.Release(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena()); +} +inline void ResponseDebug::set_allocated_error_log(std::string* error_log) { + if (error_log != nullptr) { + + } else { + + } + error_log_.SetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), error_log, + GetArena()); + // @@protoc_insertion_point(field_set_allocated:executor.v1.ResponseDebug.error_log) +} +inline std::string* ResponseDebug::unsafe_arena_release_error_log() { + // @@protoc_insertion_point(field_unsafe_arena_release:executor.v1.ResponseDebug.error_log) + GOOGLE_DCHECK(GetArena() != nullptr); + + return error_log_.UnsafeArenaRelease(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + GetArena()); +} +inline void ResponseDebug::unsafe_arena_set_allocated_error_log( + std::string* error_log) { + GOOGLE_DCHECK(GetArena() != nullptr); + if (error_log != nullptr) { + + } else { + + } + error_log_.UnsafeArenaSetAllocated(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), + error_log, GetArena()); + // @@protoc_insertion_point(field_unsafe_arena_set_allocated:executor.v1.ResponseDebug.error_log) +} + // ------------------------------------------------------------------- // TraceConfigV2 @@ -23866,6 +24209,8 @@ inline void LogV2::set_index(::PROTOBUF_NAMESPACE_ID::uint32 value) { // ------------------------------------------------------------------- +// ------------------------------------------------------------------- + // @@protoc_insertion_point(namespace_scope) diff --git a/src/grpc/proto/executor.proto b/src/grpc/proto/executor.proto index 69409b3d6..97d70e367 100644 --- a/src/grpc/proto/executor.proto +++ b/src/grpc/proto/executor.proto @@ -362,6 +362,11 @@ message ProcessBatchResponseV2 { uint32 cnt_reserve_steps = 31; uint32 cnt_reserve_sha256_hashes = 32; bytes old_state_root = 33; + ResponseDebug debug = 34; +} + +message ResponseDebug { + string error_log = 1; } // Trace configuration request params diff --git a/src/hashdb/database.cpp b/src/hashdb/database.cpp index ffe1bcc30..0e5eb1d10 100644 --- a/src/hashdb/database.cpp +++ b/src/hashdb/database.cpp @@ -159,7 +159,7 @@ zkresult Database::read(const string &_key, Goldilocks::Element (&vkey)[4], vect r = ZKR_SUCCESS; } // If get tree is configured, read the tree from the branch (key hash) to the leaf (keys since level) - else if (config.dbGetTree && (keys != NULL)) + else if (useRemoteDB && config.dbGetTree && (keys != NULL)) { // Get the tree uint64_t numberOfFields; diff --git a/src/main_generator/main_generator.cpp b/src/main_generator/main_generator.cpp index 235cff973..2986fe025 100644 --- a/src/main_generator/main_generator.cpp +++ b/src/main_generator/main_generator.cpp @@ -1403,7 +1403,7 @@ code += " #endif\n"; if (bFastMode) { - code += " zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value);\n"; + code += " zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key);\n"; code += " if (zkResult != ZKR_SUCCESS)\n"; code += " {\n"; code += " proverRequest.result = zkResult;\n"; @@ -1646,7 +1646,7 @@ code += " #endif\n"; if (bFastMode) { - code += " zkResult = eval_addReadWriteAddress(ctx, value);\n"; + code += " zkResult = eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key);\n"; code += " if (zkResult != ZKR_SUCCESS)\n"; code += " {\n"; code += " proverRequest.result = zkResult;\n"; @@ -2827,7 +2827,7 @@ code += " #endif\n"; if (bFastMode) { - code += " zkResult = eval_addReadWriteAddress(ctx, value);\n"; + code += " zkResult = eval_addReadWriteAddress(ctx, value, key);\n"; code += " if (zkResult != ZKR_SUCCESS)\n"; code += " {\n"; code += " proverRequest.result = zkResult;\n"; @@ -3015,7 +3015,7 @@ code += " #endif\n"; if (bFastMode) { - code += " zkResult = eval_addReadWriteAddress(ctx, scalarD);\n"; + code += " zkResult = eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key);\n"; code += " if (zkResult != ZKR_SUCCESS)\n"; code += " {\n"; code += " proverRequest.result = zkResult;\n"; diff --git a/src/main_sm/fork_1/main/eval_command.cpp b/src/main_sm/fork_1/main/eval_command.cpp index 15ca18a96..e10c509dc 100644 --- a/src/main_sm/fork_1/main/eval_command.cpp +++ b/src/main_sm/fork_1/main/eval_command.cpp @@ -2063,13 +2063,14 @@ void eval_AddPointEc (Context &ctx, const RomCommand &cmd, bool dbl, RawFec::Ele ctx.fec.sub(y3, aux1, y1); } -void eval_addReadWriteAddress (Context &ctx, const mpz_class value) +void eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 1); ((fork_1::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], - value); + value, + key); } } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_1/main/eval_command.hpp b/src/main_sm/fork_1/main/eval_command.hpp index 4bd9dc947..66c72efa3 100644 --- a/src/main_sm/fork_1/main/eval_command.hpp +++ b/src/main_sm/fork_1/main/eval_command.hpp @@ -120,7 +120,7 @@ void eval_storeLog (Context &ctx, const RomCommand &cmd, CommandResul void eval_memAlignWR_W0 (Context &ctx, const RomCommand &cmd, CommandResult &cr); void eval_memAlignWR_W1 (Context &ctx, const RomCommand &cmd, CommandResult &cr); void eval_memAlignWR8_W0 (Context &ctx, const RomCommand &cmd, CommandResult &cr); -void eval_addReadWriteAddress (Context &ctx, const mpz_class value); +void eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); } // namespace diff --git a/src/main_sm/fork_1/main/full_tracer.cpp b/src/main_sm/fork_1/main/full_tracer.cpp index cdc56dbd4..81a23db2d 100644 --- a/src/main_sm/fork_1/main/full_tracer.cpp +++ b/src/main_sm/fork_1/main/full_tracer.cpp @@ -858,6 +858,9 @@ void FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + fillInReadWriteAddresses(ctx); + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1326,12 +1329,15 @@ void FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7); @@ -1349,11 +1355,19 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1363,11 +1377,19 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1376,4 +1398,48 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons #endif } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2]) || !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_1/main/full_tracer.hpp b/src/main_sm/fork_1/main/full_tracer.hpp index 791049d6d..3e7b576fb 100644 --- a/src/main_sm/fork_1/main/full_tracer.hpp +++ b/src/main_sm/fork_1/main/full_tracer.hpp @@ -63,7 +63,9 @@ class FullTracer: public FullTracerInterface void onOpcode (Context &ctx, const RomCommand &cmd); void addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txCount(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0) { }; ~FullTracer() diff --git a/src/main_sm/fork_1/main/main_executor.cpp b/src/main_sm/fork_1/main/main_executor.cpp index 02bbef069..25e6c2886 100644 --- a/src/main_sm/fork_1/main/main_executor.cpp +++ b/src/main_sm/fork_1/main/main_executor.cpp @@ -1032,11 +1032,11 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - eval_addReadWriteAddress(ctx, smtGetResult.value); + if (bProcessBatch) + { + eval_addReadWriteAddress(ctx, smtGetResult.value, key); + } } scalar2fea(fr, smtGetResult.value, fi0, fi1, fi2, fi3, fi4, fi5, fi6, fi7); @@ -1258,7 +1258,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, } if (bProcessBatch) { - eval_addReadWriteAddress(ctx, value); + eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); } // If we just modified a balance @@ -1965,7 +1965,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - eval_addReadWriteAddress(ctx, smtGetResult.value); + eval_addReadWriteAddress(ctx, smtGetResult.value, key); } #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR @@ -2107,7 +2107,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - eval_addReadWriteAddress(ctx, scalarD); + eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); } // If we just modified a balance diff --git a/src/main_sm/fork_2/main/eval_command.cpp b/src/main_sm/fork_2/main/eval_command.cpp index daca28c2b..b69181db4 100644 --- a/src/main_sm/fork_2/main/eval_command.cpp +++ b/src/main_sm/fork_2/main/eval_command.cpp @@ -2063,13 +2063,14 @@ void eval_AddPointEc (Context &ctx, const RomCommand &cmd, bool dbl, RawFec::Ele ctx.fec.sub(y3, aux1, y1); } -void eval_addReadWriteAddress (Context &ctx, const mpz_class value) +void eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 2); // fork_2 ((fork_2::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], - value); + value, + key); } } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_2/main/eval_command.hpp b/src/main_sm/fork_2/main/eval_command.hpp index 6af3a0e5b..56b511924 100644 --- a/src/main_sm/fork_2/main/eval_command.hpp +++ b/src/main_sm/fork_2/main/eval_command.hpp @@ -120,7 +120,7 @@ void eval_storeLog (Context &ctx, const RomCommand &cmd, CommandResul void eval_memAlignWR_W0 (Context &ctx, const RomCommand &cmd, CommandResult &cr); void eval_memAlignWR_W1 (Context &ctx, const RomCommand &cmd, CommandResult &cr); void eval_memAlignWR8_W0 (Context &ctx, const RomCommand &cmd, CommandResult &cr); -void eval_addReadWriteAddress (Context &ctx, const mpz_class value); +void eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); } // namespace diff --git a/src/main_sm/fork_2/main/full_tracer.cpp b/src/main_sm/fork_2/main/full_tracer.cpp index 6ca4c9c1b..126a6820f 100644 --- a/src/main_sm/fork_2/main/full_tracer.cpp +++ b/src/main_sm/fork_2/main/full_tracer.cpp @@ -862,6 +862,9 @@ void FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + fillInReadWriteAddresses(ctx); + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1330,12 +1333,15 @@ void FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7); @@ -1353,11 +1359,19 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1367,11 +1381,19 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1380,4 +1402,48 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons #endif } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2]) || !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_2/main/full_tracer.hpp b/src/main_sm/fork_2/main/full_tracer.hpp index 7a0421dc8..99ce56bf1 100644 --- a/src/main_sm/fork_2/main/full_tracer.hpp +++ b/src/main_sm/fork_2/main/full_tracer.hpp @@ -63,7 +63,9 @@ class FullTracer: public FullTracerInterface void onOpcode (Context &ctx, const RomCommand &cmd); void addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txCount(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0) { }; ~FullTracer() diff --git a/src/main_sm/fork_2/main/main_executor.cpp b/src/main_sm/fork_2/main/main_executor.cpp index d5d5c42db..92db44bce 100644 --- a/src/main_sm/fork_2/main/main_executor.cpp +++ b/src/main_sm/fork_2/main/main_executor.cpp @@ -1023,11 +1023,11 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - eval_addReadWriteAddress(ctx, smtGetResult.value); + if (bProcessBatch) + { + eval_addReadWriteAddress(ctx, smtGetResult.value, key); + } } #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR @@ -1253,7 +1253,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, } if (bProcessBatch) { - eval_addReadWriteAddress(ctx, value); + eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); } // If we just modified a balance @@ -1960,7 +1960,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - eval_addReadWriteAddress(ctx, smtGetResult.value); + eval_addReadWriteAddress(ctx, smtGetResult.value, key); } #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR @@ -2102,7 +2102,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - eval_addReadWriteAddress(ctx, scalarD); + eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); } // If we just modified a balance diff --git a/src/main_sm/fork_3/main/eval_command.cpp b/src/main_sm/fork_3/main/eval_command.cpp index 41ef5d970..4f51698a1 100644 --- a/src/main_sm/fork_3/main/eval_command.cpp +++ b/src/main_sm/fork_3/main/eval_command.cpp @@ -2063,13 +2063,14 @@ void eval_AddPointEc (Context &ctx, const RomCommand &cmd, bool dbl, RawFec::Ele ctx.fec.sub(y3, aux1, y1); } -void eval_addReadWriteAddress (Context &ctx, const mpz_class value) +void eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 3); // fork_3 ((fork_3::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], - value); + value, + key); } } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_3/main/eval_command.hpp b/src/main_sm/fork_3/main/eval_command.hpp index 6dcaf4a3a..9d6d74006 100644 --- a/src/main_sm/fork_3/main/eval_command.hpp +++ b/src/main_sm/fork_3/main/eval_command.hpp @@ -120,7 +120,7 @@ void eval_storeLog (Context &ctx, const RomCommand &cmd, CommandResul void eval_memAlignWR_W0 (Context &ctx, const RomCommand &cmd, CommandResult &cr); void eval_memAlignWR_W1 (Context &ctx, const RomCommand &cmd, CommandResult &cr); void eval_memAlignWR8_W0 (Context &ctx, const RomCommand &cmd, CommandResult &cr); -void eval_addReadWriteAddress (Context &ctx, const mpz_class value); +void eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); } // namespace diff --git a/src/main_sm/fork_3/main/full_tracer.cpp b/src/main_sm/fork_3/main/full_tracer.cpp index 1a2d658ab..635956b1d 100644 --- a/src/main_sm/fork_3/main/full_tracer.cpp +++ b/src/main_sm/fork_3/main/full_tracer.cpp @@ -862,6 +862,9 @@ void FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + fillInReadWriteAddresses(ctx); + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1330,12 +1333,15 @@ void FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7); @@ -1353,11 +1359,19 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1367,11 +1381,19 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1380,4 +1402,48 @@ void FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, cons #endif } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2]) || !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_3/main/full_tracer.hpp b/src/main_sm/fork_3/main/full_tracer.hpp index 14cfbd765..d1223ecb7 100644 --- a/src/main_sm/fork_3/main/full_tracer.hpp +++ b/src/main_sm/fork_3/main/full_tracer.hpp @@ -63,7 +63,9 @@ class FullTracer: public FullTracerInterface void onOpcode (Context &ctx, const RomCommand &cmd); void addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txCount(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0) { }; ~FullTracer() diff --git a/src/main_sm/fork_3/main/main_executor.cpp b/src/main_sm/fork_3/main/main_executor.cpp index 6e4f3ffed..58f2201e4 100644 --- a/src/main_sm/fork_3/main/main_executor.cpp +++ b/src/main_sm/fork_3/main/main_executor.cpp @@ -1023,11 +1023,11 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - eval_addReadWriteAddress(ctx, smtGetResult.value); + if (bProcessBatch) + { + eval_addReadWriteAddress(ctx, smtGetResult.value, key); + } } scalar2fea(fr, smtGetResult.value, fi0, fi1, fi2, fi3, fi4, fi5, fi6, fi7); @@ -1249,7 +1249,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, } if (bProcessBatch) { - eval_addReadWriteAddress(ctx, value); + eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); } // If we just modified a balance @@ -1956,7 +1956,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - eval_addReadWriteAddress(ctx, smtGetResult.value); + eval_addReadWriteAddress(ctx, smtGetResult.value, key); } #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR @@ -2098,7 +2098,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - eval_addReadWriteAddress(ctx, scalarD); + eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); } // If we just modified a balance diff --git a/src/main_sm/fork_4/main/eval_command.cpp b/src/main_sm/fork_4/main/eval_command.cpp index 7b1611fb5..f5261c807 100644 --- a/src/main_sm/fork_4/main/eval_command.cpp +++ b/src/main_sm/fork_4/main/eval_command.cpp @@ -2413,13 +2413,14 @@ zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const Ra return ZKR_SUCCESS; } -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value) +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 4); // fork_4 return ((fork_4::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], - value); + value, + key); } } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_4/main/eval_command.hpp b/src/main_sm/fork_4/main/eval_command.hpp index 538e693c7..db32edffc 100644 --- a/src/main_sm/fork_4/main/eval_command.hpp +++ b/src/main_sm/fork_4/main/eval_command.hpp @@ -124,7 +124,7 @@ void eval_memAlignWR8_W0 (Context &ctx, const RomCommand &cmd, CommandResul zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const RawFec::Element &y1, const RawFec::Element &x2, const RawFec::Element &y2, RawFec::Element &x3, RawFec::Element &y3); -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value); +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); mpz_class sqrtTonelliShanks ( const mpz_class &n, const mpz_class &p ); diff --git a/src/main_sm/fork_4/main/full_tracer.cpp b/src/main_sm/fork_4/main/full_tracer.cpp index d51a94f4a..e7538c01a 100644 --- a/src/main_sm/fork_4/main/full_tracer.cpp +++ b/src/main_sm/fork_4/main/full_tracer.cpp @@ -1026,6 +1026,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1648,12 +1656,15 @@ zkresult FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -1679,11 +1690,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1693,11 +1712,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1708,4 +1735,48 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, return ZKR_SUCCESS; } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2])|| !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_4/main/full_tracer.hpp b/src/main_sm/fork_4/main/full_tracer.hpp index 5ee64e9f5..d0cabdbc9 100644 --- a/src/main_sm/fork_4/main/full_tracer.hpp +++ b/src/main_sm/fork_4/main/full_tracer.hpp @@ -63,7 +63,9 @@ class FullTracer: public FullTracerInterface zkresult onOpcode (Context &ctx, const RomCommand &cmd); zkresult addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txCount(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0) { }; ~FullTracer() diff --git a/src/main_sm/fork_4/main/main_executor.cpp b/src/main_sm/fork_4/main/main_executor.cpp index 9d4c7097d..a0efcbae7 100644 --- a/src/main_sm/fork_4/main/main_executor.cpp +++ b/src/main_sm/fork_4/main/main_executor.cpp @@ -1057,17 +1057,17 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); - if (zkResult != ZKR_SUCCESS) + if (bProcessBatch) { - proverRequest.result = zkResult; - logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); - pHashDB->cancelBatch(proverRequest.uuid); - return; + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); + if (zkResult != ZKR_SUCCESS) + { + proverRequest.result = zkResult; + logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); + pHashDB->cancelBatch(proverRequest.uuid); + return; + } } } @@ -1290,7 +1290,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, } if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, value); + zkResult = eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2116,7 +2116,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2276,7 +2276,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, scalarD); + zkResult = eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; diff --git a/src/main_sm/fork_5/main/eval_command.cpp b/src/main_sm/fork_5/main/eval_command.cpp index ea3786e62..7cb78852a 100644 --- a/src/main_sm/fork_5/main/eval_command.cpp +++ b/src/main_sm/fork_5/main/eval_command.cpp @@ -2413,13 +2413,14 @@ zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const Ra return ZKR_SUCCESS; } -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value) +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 5); // fork_5 return ((fork_5::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], - value); + value, + key); } } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_5/main/eval_command.hpp b/src/main_sm/fork_5/main/eval_command.hpp index 8dd542925..c7f7fcdb8 100644 --- a/src/main_sm/fork_5/main/eval_command.hpp +++ b/src/main_sm/fork_5/main/eval_command.hpp @@ -124,7 +124,7 @@ void eval_memAlignWR8_W0 (Context &ctx, const RomCommand &cmd, CommandResul zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const RawFec::Element &y1, const RawFec::Element &x2, const RawFec::Element &y2, RawFec::Element &x3, RawFec::Element &y3); -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value); +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); mpz_class sqrtTonelliShanks ( const mpz_class &n, const mpz_class &p ); diff --git a/src/main_sm/fork_5/main/full_tracer.cpp b/src/main_sm/fork_5/main/full_tracer.cpp index 7cdac656c..5c80e5f60 100644 --- a/src/main_sm/fork_5/main/full_tracer.cpp +++ b/src/main_sm/fork_5/main/full_tracer.cpp @@ -1065,6 +1065,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1711,12 +1719,15 @@ zkresult FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -1742,11 +1753,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1756,11 +1775,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1771,4 +1798,48 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, return ZKR_SUCCESS; } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2]) || !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_5/main/full_tracer.hpp b/src/main_sm/fork_5/main/full_tracer.hpp index f72404d23..012178481 100644 --- a/src/main_sm/fork_5/main/full_tracer.hpp +++ b/src/main_sm/fork_5/main/full_tracer.hpp @@ -66,7 +66,9 @@ class FullTracer: public FullTracerInterface zkresult onOpcode (Context &ctx, const RomCommand &cmd); zkresult addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txCount(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0), hasGaspriceOpcode(false), hasBalanceOpcode(false) { }; ~FullTracer() diff --git a/src/main_sm/fork_5/main/main_executor.cpp b/src/main_sm/fork_5/main/main_executor.cpp index b227679ba..fc64e998d 100644 --- a/src/main_sm/fork_5/main/main_executor.cpp +++ b/src/main_sm/fork_5/main/main_executor.cpp @@ -1050,17 +1050,17 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); - if (zkResult != ZKR_SUCCESS) + if (bProcessBatch) { - proverRequest.result = zkResult; - logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); - pHashDB->cancelBatch(proverRequest.uuid); - return; + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); + if (zkResult != ZKR_SUCCESS) + { + proverRequest.result = zkResult; + logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); + pHashDB->cancelBatch(proverRequest.uuid); + return; + } } } @@ -1289,7 +1289,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, value); + zkResult = eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2125,7 +2125,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2291,7 +2291,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, scalarD); + zkResult = eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; diff --git a/src/main_sm/fork_6/main/eval_command.cpp b/src/main_sm/fork_6/main/eval_command.cpp index 7c459cdb8..dbb35bfbc 100644 --- a/src/main_sm/fork_6/main/eval_command.cpp +++ b/src/main_sm/fork_6/main/eval_command.cpp @@ -2478,13 +2478,14 @@ zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const Ra return ZKR_SUCCESS; } -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value) +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 6); // fork_6 return ((fork_6::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], - value); + value, + key); } } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_6/main/eval_command.hpp b/src/main_sm/fork_6/main/eval_command.hpp index 8c349fe3f..1ad3644c4 100644 --- a/src/main_sm/fork_6/main/eval_command.hpp +++ b/src/main_sm/fork_6/main/eval_command.hpp @@ -125,7 +125,7 @@ void eval_memAlignWR8_W0 (Context &ctx, const RomCommand &cmd, CommandResul zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const RawFec::Element &y1, const RawFec::Element &x2, const RawFec::Element &y2, RawFec::Element &x3, RawFec::Element &y3); -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value); +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); mpz_class sqrtTonelliShanks ( const mpz_class &n, const mpz_class &p ); diff --git a/src/main_sm/fork_6/main/full_tracer.cpp b/src/main_sm/fork_6/main/full_tracer.cpp index 519bce9ca..daeabe36d 100644 --- a/src/main_sm/fork_6/main/full_tracer.cpp +++ b/src/main_sm/fork_6/main/full_tracer.cpp @@ -1065,6 +1065,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -1711,12 +1719,15 @@ zkresult FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -1742,11 +1753,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -1756,11 +1775,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -1771,4 +1798,48 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, return ZKR_SUCCESS; } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2]) || !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_6/main/full_tracer.hpp b/src/main_sm/fork_6/main/full_tracer.hpp index 09b7b9e87..2917751c5 100644 --- a/src/main_sm/fork_6/main/full_tracer.hpp +++ b/src/main_sm/fork_6/main/full_tracer.hpp @@ -66,7 +66,9 @@ class FullTracer: public FullTracerInterface zkresult onOpcode (Context &ctx, const RomCommand &cmd); zkresult addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txCount(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0), hasGaspriceOpcode(false), hasBalanceOpcode(false) { }; ~FullTracer() diff --git a/src/main_sm/fork_6/main/main_executor.cpp b/src/main_sm/fork_6/main/main_executor.cpp index d6ee1e728..13775415d 100644 --- a/src/main_sm/fork_6/main/main_executor.cpp +++ b/src/main_sm/fork_6/main/main_executor.cpp @@ -1050,17 +1050,17 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); - if (zkResult != ZKR_SUCCESS) + if (bProcessBatch) { - proverRequest.result = zkResult; - logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); - pHashDB->cancelBatch(proverRequest.uuid); - return; + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); + if (zkResult != ZKR_SUCCESS) + { + proverRequest.result = zkResult; + logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); + pHashDB->cancelBatch(proverRequest.uuid); + return; + } } } @@ -1288,7 +1288,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, } if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, value); + zkResult = eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2125,7 +2125,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2291,7 +2291,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, scalarD); + zkResult = eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; diff --git a/src/main_sm/fork_7/main/context.cpp b/src/main_sm/fork_7/main/context.cpp index 50b12411f..18073f733 100644 --- a/src/main_sm/fork_7/main/context.cpp +++ b/src/main_sm/fork_7/main/context.cpp @@ -4,28 +4,59 @@ namespace fork_7 { -void Context::printRegs() +void Context::printRegs(string &log) { - zklog.info("Registers:"); if (pStep == NULL) { zklog.error("Context::printRegs() called with pStep==NULL"); return; } - printReg("A", pols.A0[*pStep], pols.A1[*pStep], pols.A2[*pStep], pols.A3[*pStep], pols.A4[*pStep], pols.A5[*pStep], pols.A6[*pStep], pols.A7[*pStep]); - printReg("B", pols.B0[*pStep], pols.B1[*pStep], pols.B2[*pStep], pols.B3[*pStep], pols.B4[*pStep], pols.B5[*pStep], pols.B6[*pStep], pols.B7[*pStep]); - printReg("C", pols.C0[*pStep], pols.C1[*pStep], pols.C2[*pStep], pols.C3[*pStep], pols.C4[*pStep], pols.C5[*pStep], pols.C6[*pStep], pols.C7[*pStep]); - printReg("D", pols.D0[*pStep], pols.D1[*pStep], pols.D2[*pStep], pols.D3[*pStep], pols.D4[*pStep], pols.D5[*pStep], pols.D6[*pStep], pols.D7[*pStep]); - printReg("E", pols.E0[*pStep], pols.E1[*pStep], pols.E2[*pStep], pols.E3[*pStep], pols.E4[*pStep], pols.E5[*pStep], pols.E6[*pStep], pols.E7[*pStep]); - printReg("SR", pols.SR0[*pStep], pols.SR1[*pStep], pols.SR2[*pStep], pols.SR3[*pStep], pols.SR4[*pStep], pols.SR5[*pStep], pols.SR6[*pStep], pols.SR7[*pStep]); - printReg("CTX", pols.CTX[*pStep]); - printReg("SP", pols.SP[*pStep]); - printReg("PC", pols.PC[*pStep]); - printReg("GAS", pols.GAS[*pStep]); - printReg("zkPC", pols.zkPC[*pStep]); + + log.clear(); + + log = + "Registers: SR=" + reg2string(pols.SR0[*pStep], pols.SR1[*pStep], pols.SR2[*pStep], pols.SR3[*pStep], pols.SR4[*pStep], pols.SR5[*pStep], pols.SR6[*pStep], pols.SR7[*pStep]) + + " CONST=" + reg2string(pols.CONST0[*pStep], pols.CONST1[*pStep], pols.CONST2[*pStep], pols.CONST3[*pStep], pols.CONST4[*pStep], pols.CONST5[*pStep], pols.CONST6[*pStep], pols.CONST7[*pStep]) + + " FREE=" + reg2string(pols.FREE0[*pStep], pols.FREE1[*pStep], pols.FREE2[*pStep], pols.FREE3[*pStep], pols.FREE4[*pStep], pols.FREE5[*pStep], pols.FREE6[*pStep], pols.FREE7[*pStep]); + zklog.error(log); + + string aux; + aux = + "A=" + reg2string(pols.A0[*pStep], pols.A1[*pStep], pols.A2[*pStep], pols.A3[*pStep], pols.A4[*pStep], pols.A5[*pStep], pols.A6[*pStep], pols.A7[*pStep]) + + " B=" + reg2string(pols.B0[*pStep], pols.B1[*pStep], pols.B2[*pStep], pols.B3[*pStep], pols.B4[*pStep], pols.B5[*pStep], pols.B6[*pStep], pols.B7[*pStep]) + + " C=" + reg2string(pols.C0[*pStep], pols.C1[*pStep], pols.C2[*pStep], pols.C3[*pStep], pols.C4[*pStep], pols.C5[*pStep], pols.C6[*pStep], pols.C7[*pStep]) + + " D=" + reg2string(pols.D0[*pStep], pols.D1[*pStep], pols.D2[*pStep], pols.D3[*pStep], pols.D4[*pStep], pols.D5[*pStep], pols.D6[*pStep], pols.D7[*pStep]) + + " E=" + reg2string(pols.E0[*pStep], pols.E1[*pStep], pols.E2[*pStep], pols.E3[*pStep], pols.E4[*pStep], pols.E5[*pStep], pols.E6[*pStep], pols.E7[*pStep]); + zklog.error(aux); + log += " " + aux; + Goldilocks::Element step; step = fr.fromU64(*pStep); - printReg("STEP", step); + + aux = + "CTX=" + reg2string(pols.CTX[*pStep]) + + " SP=" + reg2string(pols.SP[*pStep]) + + " PC=" + reg2string(pols.PC[*pStep]) + + " GAS=" + reg2string(pols.GAS[*pStep]) + + " zkPC=" + reg2string(pols.zkPC[*pStep]) + + " STEP=" + reg2string(step) + + " RR=" + reg2string(pols.RR[*pStep]) + + " HASHPOS=" + reg2string(pols.HASHPOS[*pStep]) + + " RCX=" + reg2string(pols.RCX[*pStep]); + zklog.error(aux); + log += " " + aux; + + aux = + "cntArith=" + reg2string(pols.cntArith[*pStep]) + + " cntBinary=" + reg2string(pols.cntBinary[*pStep]) + + " cntMemAlign=" + reg2string(pols.cntMemAlign[*pStep]) + + " cntKeccakF=" + reg2string(pols.cntKeccakF[*pStep]) + + " cntSha256F=" + reg2string(pols.cntSha256F[*pStep]) + + " cntPoseidonG=" + reg2string(pols.cntPoseidonG[*pStep]) + + " cntPaddingPG=" + reg2string(pols.cntPaddingPG[*pStep]); + zklog.error(aux); + log += " " + aux; + #ifdef LOG_FILENAME zklog.info("File: " + fileName + " Line: " + to_string(line)); #endif @@ -70,12 +101,21 @@ void Context::printReg(string name, Goldilocks::Element &fe) { zklog.info(" Register " + name + " = " + fr.toString(fe, 16)); } +string Context::reg2string(Goldilocks::Element &fe) +{ + return fr.toString(fe, 16); +} void Context::printReg(string name, Goldilocks::Element &fe0, Goldilocks::Element &fe1, Goldilocks::Element &fe2, Goldilocks::Element &fe3, Goldilocks::Element &fe4, Goldilocks::Element &fe5, Goldilocks::Element &fe6, Goldilocks::Element &fe7) { zklog.info(" Register " + name + " = " + fr.toString(fe7, 16) + ":" + fr.toString(fe6, 16) + ":" + fr.toString(fe5, 16) + ":" + fr.toString(fe4, 16) + ":" + fr.toString(fe3, 16) + ":" + fr.toString(fe2, 16) + ":" + fr.toString(fe1, 16) + ":" + fr.toString(fe0, 16)); } +string Context::reg2string(Goldilocks::Element &fe0, Goldilocks::Element &fe1, Goldilocks::Element &fe2, Goldilocks::Element &fe3, Goldilocks::Element &fe4, Goldilocks::Element &fe5, Goldilocks::Element &fe6, Goldilocks::Element &fe7) +{ + return fr.toString(fe7, 16) + ":" + fr.toString(fe6, 16) + ":" + fr.toString(fe5, 16) + ":" + fr.toString(fe4, 16) + ":" + fr.toString(fe3, 16) + ":" + fr.toString(fe2, 16) + ":" + fr.toString(fe1, 16) + ":" + fr.toString(fe0, 16); +} + void Context::printU64(string name, uint64_t v) { zklog.info(" U64: " + name + ":" + to_string(v)); diff --git a/src/main_sm/fork_7/main/context.hpp b/src/main_sm/fork_7/main/context.hpp index 3a7567aba..e50aa5a7e 100644 --- a/src/main_sm/fork_7/main/context.hpp +++ b/src/main_sm/fork_7/main/context.hpp @@ -217,11 +217,13 @@ class Context vector quotient; // Print functions - void printRegs(); + void printRegs(string &log); void printVars(); void printMem(); void printReg(string name, Goldilocks::Element &fe); + string reg2string(Goldilocks::Element &fe); void printReg(string name, Goldilocks::Element &fe0, Goldilocks::Element &fe1, Goldilocks::Element &fe2, Goldilocks::Element &fe3, Goldilocks::Element &fe4, Goldilocks::Element &fe5, Goldilocks::Element &fe6, Goldilocks::Element &fe7); + string reg2string(Goldilocks::Element &fe0, Goldilocks::Element &fe1, Goldilocks::Element &fe2, Goldilocks::Element &fe3, Goldilocks::Element &fe4, Goldilocks::Element &fe5, Goldilocks::Element &fe6, Goldilocks::Element &fe7); void printU64(string name, uint64_t v); void printU32(string name, uint32_t v); void printU16(string name, uint16_t v); diff --git a/src/main_sm/fork_7/main/eval_command.cpp b/src/main_sm/fork_7/main/eval_command.cpp index 42ad39cd6..911c9e7d0 100644 --- a/src/main_sm/fork_7/main/eval_command.cpp +++ b/src/main_sm/fork_7/main/eval_command.cpp @@ -2509,13 +2509,14 @@ zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const Ra return ZKR_SUCCESS; } -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value) +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 7); // fork_7 return ((fork_7::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], - value); + value, + key); } void eval_getL1InfoRoot (Context &ctx, const RomCommand &cmd, CommandResult &cr) diff --git a/src/main_sm/fork_7/main/eval_command.hpp b/src/main_sm/fork_7/main/eval_command.hpp index 496b042b4..8b068a828 100644 --- a/src/main_sm/fork_7/main/eval_command.hpp +++ b/src/main_sm/fork_7/main/eval_command.hpp @@ -151,7 +151,7 @@ void eval_fpBN254inv (Context &ctx, const RomCommand &cmd, Comm zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const RawFec::Element &y1, const RawFec::Element &x2, const RawFec::Element &y2, RawFec::Element &x3, RawFec::Element &y3); -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value); +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); mpz_class sqrtTonelliShanks ( const mpz_class &n, const mpz_class &p ); diff --git a/src/main_sm/fork_7/main/full_tracer.cpp b/src/main_sm/fork_7/main/full_tracer.cpp index 5fe71bf17..04d80e2fe 100644 --- a/src/main_sm/fork_7/main/full_tracer.cpp +++ b/src/main_sm/fork_7/main/full_tracer.cpp @@ -1427,6 +1427,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -2073,12 +2081,15 @@ zkresult FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -2104,11 +2115,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -2118,11 +2137,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } @@ -2133,4 +2160,48 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, return ZKR_SUCCESS; } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2]) || !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_7/main/full_tracer.hpp b/src/main_sm/fork_7/main/full_tracer.hpp index c072fff8f..30a2a6723 100644 --- a/src/main_sm/fork_7/main/full_tracer.hpp +++ b/src/main_sm/fork_7/main/full_tracer.hpp @@ -70,7 +70,9 @@ class FullTracer: public FullTracerInterface zkresult onOpcode (Context &ctx, const RomCommand &cmd); zkresult addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0), hasGaspriceOpcode(false), hasBalanceOpcode(false), txIndex(0), isForced(false) { }; ~FullTracer() diff --git a/src/main_sm/fork_7/main/main_executor.cpp b/src/main_sm/fork_7/main/main_executor.cpp index 70077a9ee..2752e94c6 100644 --- a/src/main_sm/fork_7/main/main_executor.cpp +++ b/src/main_sm/fork_7/main/main_executor.cpp @@ -276,7 +276,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkr != ZKR_SUCCESS) { proverRequest.result = zkr; - logError(ctx, string("Copying timestamp from state to memory, failed calling pHashDB->get() result=") + zkresult2string(zkr)); + logError(ctx, string("Copying timestamp from state to memory, failed calling pHashDB->get() result=") + zkresult2string(zkr) + " key=" + fea2string(fr, keyToRead)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1140,7 +1140,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1159,17 +1159,17 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); - if (zkResult != ZKR_SUCCESS) + if (bProcessBatch) { - proverRequest.result = zkResult; - logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); - pHashDB->cancelBatch(proverRequest.uuid); - return; + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); + if (zkResult != ZKR_SUCCESS) + { + proverRequest.result = zkResult; + logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); + pHashDB->cancelBatch(proverRequest.uuid); + return; + } } } @@ -1379,7 +1379,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, ctx.lastSWrite.key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1400,7 +1400,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, } if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, value); + zkResult = eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2375,7 +2375,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -2384,7 +2384,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2542,7 +2542,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, ctx.lastSWrite.key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -2551,7 +2551,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, scalarD); + zkResult = eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -3132,7 +3132,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->setProgram() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->setProgram() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, result)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -3187,7 +3187,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->getProgram() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->getProgram() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, aux)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -5829,9 +5829,12 @@ void MainExecutor::assertOutputs(Context &ctx) void MainExecutor::logError (Context &ctx, const string &message) { // Log the message, if provided + string log0 = "MainExecutor::logError()"; + string log1; if (message.size() > 0) { - zklog.error("MainExecutor::logError() " + message); + log1 = message; + zklog.error(log0 + " " + log1); } // Log details @@ -5840,21 +5843,24 @@ void MainExecutor::logError (Context &ctx, const string &message) uint64_t evaluation = (ctx.pEvaluation != NULL) ? *ctx.pEvaluation : INVALID_LOG_ERROR_VALUE; uint64_t zkpc = (ctx.pZKPC != NULL) ? *ctx.pZKPC : INVALID_LOG_ERROR_VALUE; string romLine = (ctx.pZKPC != NULL) ? rom.line[*ctx.pZKPC].toString(fr) : "INVALID_ZKPC"; - zklog.error(string("MainExecutor::logError() proverRequest.result=") + zkresult2string(ctx.proverRequest.result) + + string log2 = string("proverRequest.result=") + zkresult2string(ctx.proverRequest.result) + " step=" + to_string(step) + " eval=" + to_string(evaluation) + " zkPC=" + to_string(zkpc) + " rom.line={" + romLine + - "} uuid=" + ctx.proverRequest.uuid, - &ctx.proverRequest.tags); + "} uuid=" + ctx.proverRequest.uuid; + zklog.error(log0 + " " + log2, &ctx.proverRequest.tags); // Log registers - ctx.printRegs(); + string log3; + ctx.printRegs(log3); // Log the input file content json inputJson; ctx.proverRequest.input.save(inputJson); zklog.error("Input=" + inputJson.dump()); + + ctx.proverRequest.errorLog = log0 + " " + log1 + " " + log2 + " " + log3; } void MainExecutor::linearPoseidon (Context &ctx, const vector &data, Goldilocks::Element (&result)[4]) diff --git a/src/main_sm/fork_8/main/context.cpp b/src/main_sm/fork_8/main/context.cpp index 8ce43ccef..37dfca95d 100644 --- a/src/main_sm/fork_8/main/context.cpp +++ b/src/main_sm/fork_8/main/context.cpp @@ -4,7 +4,7 @@ namespace fork_8 { -void Context::printRegs() +void Context::printRegs(string &log) { if (pStep == NULL) { @@ -12,23 +12,29 @@ void Context::printRegs() return; } - zklog.error( + log.clear(); + + log = "Registers: SR=" + reg2string(pols.SR0[*pStep], pols.SR1[*pStep], pols.SR2[*pStep], pols.SR3[*pStep], pols.SR4[*pStep], pols.SR5[*pStep], pols.SR6[*pStep], pols.SR7[*pStep]) + " CONST=" + reg2string(pols.CONST0[*pStep], pols.CONST1[*pStep], pols.CONST2[*pStep], pols.CONST3[*pStep], pols.CONST4[*pStep], pols.CONST5[*pStep], pols.CONST6[*pStep], pols.CONST7[*pStep]) + - " FREE=" + reg2string(pols.FREE0[*pStep], pols.FREE1[*pStep], pols.FREE2[*pStep], pols.FREE3[*pStep], pols.FREE4[*pStep], pols.FREE5[*pStep], pols.FREE6[*pStep], pols.FREE7[*pStep]) ); + " FREE=" + reg2string(pols.FREE0[*pStep], pols.FREE1[*pStep], pols.FREE2[*pStep], pols.FREE3[*pStep], pols.FREE4[*pStep], pols.FREE5[*pStep], pols.FREE6[*pStep], pols.FREE7[*pStep]); + zklog.error(log); - zklog.error( + string aux; + aux = "A=" + reg2string(pols.A0[*pStep], pols.A1[*pStep], pols.A2[*pStep], pols.A3[*pStep], pols.A4[*pStep], pols.A5[*pStep], pols.A6[*pStep], pols.A7[*pStep]) + " B=" + reg2string(pols.B0[*pStep], pols.B1[*pStep], pols.B2[*pStep], pols.B3[*pStep], pols.B4[*pStep], pols.B5[*pStep], pols.B6[*pStep], pols.B7[*pStep]) + " C=" + reg2string(pols.C0[*pStep], pols.C1[*pStep], pols.C2[*pStep], pols.C3[*pStep], pols.C4[*pStep], pols.C5[*pStep], pols.C6[*pStep], pols.C7[*pStep]) + " D=" + reg2string(pols.D0[*pStep], pols.D1[*pStep], pols.D2[*pStep], pols.D3[*pStep], pols.D4[*pStep], pols.D5[*pStep], pols.D6[*pStep], pols.D7[*pStep]) + - " E=" + reg2string(pols.E0[*pStep], pols.E1[*pStep], pols.E2[*pStep], pols.E3[*pStep], pols.E4[*pStep], pols.E5[*pStep], pols.E6[*pStep], pols.E7[*pStep]) ); + " E=" + reg2string(pols.E0[*pStep], pols.E1[*pStep], pols.E2[*pStep], pols.E3[*pStep], pols.E4[*pStep], pols.E5[*pStep], pols.E6[*pStep], pols.E7[*pStep]); + zklog.error(aux); + log += " " + aux; Goldilocks::Element step; step = fr.fromU64(*pStep); - zklog.error( - "CTX=" + reg2string(pols.CTX[*pStep]) + + aux = + "CTX=" + reg2string(pols.CTX[*pStep]) + " SP=" + reg2string(pols.SP[*pStep]) + " PC=" + reg2string(pols.PC[*pStep]) + " GAS=" + reg2string(pols.GAS[*pStep]) + @@ -36,16 +42,20 @@ void Context::printRegs() " STEP=" + reg2string(step) + " RR=" + reg2string(pols.RR[*pStep]) + " HASHPOS=" + reg2string(pols.HASHPOS[*pStep]) + - " RCX=" + reg2string(pols.RCX[*pStep]) ); + " RCX=" + reg2string(pols.RCX[*pStep]); + zklog.error(aux); + log += " " + aux; - zklog.error( + aux = "cntArith=" + reg2string(pols.cntArith[*pStep]) + " cntBinary=" + reg2string(pols.cntBinary[*pStep]) + " cntMemAlign=" + reg2string(pols.cntMemAlign[*pStep]) + " cntKeccakF=" + reg2string(pols.cntKeccakF[*pStep]) + " cntSha256F=" + reg2string(pols.cntSha256F[*pStep]) + " cntPoseidonG=" + reg2string(pols.cntPoseidonG[*pStep]) + - " cntPaddingPG=" + reg2string(pols.cntPaddingPG[*pStep]) ); + " cntPaddingPG=" + reg2string(pols.cntPaddingPG[*pStep]); + zklog.error(aux); + log += " " + aux; #ifdef LOG_FILENAME zklog.info("File: " + fileName + " Line: " + to_string(line)); diff --git a/src/main_sm/fork_8/main/context.hpp b/src/main_sm/fork_8/main/context.hpp index 310fa9159..14db01ec4 100644 --- a/src/main_sm/fork_8/main/context.hpp +++ b/src/main_sm/fork_8/main/context.hpp @@ -217,7 +217,7 @@ class Context vector quotient; // Print functions - void printRegs(); + void printRegs(string &log); void printVars(); void printMem(); void printReg(string name, Goldilocks::Element &fe); diff --git a/src/main_sm/fork_8/main/eval_command.cpp b/src/main_sm/fork_8/main/eval_command.cpp index fb83062eb..962d58a58 100644 --- a/src/main_sm/fork_8/main/eval_command.cpp +++ b/src/main_sm/fork_8/main/eval_command.cpp @@ -2510,14 +2510,15 @@ zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const Ra return ZKR_SUCCESS; } -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value) +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 8); // fork_8 return ((fork_8::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], ctx.pols.C0[0], ctx.pols.C1[0], ctx.pols.C2[0], ctx.pols.C3[0], ctx.pols.C4[0], ctx.pols.C5[0], ctx.pols.C6[0], ctx.pols.C7[0], - value); + value, + key); } void eval_getL1InfoRoot (Context &ctx, const RomCommand &cmd, CommandResult &cr) diff --git a/src/main_sm/fork_8/main/eval_command.hpp b/src/main_sm/fork_8/main/eval_command.hpp index b41162d19..64d3b3b50 100644 --- a/src/main_sm/fork_8/main/eval_command.hpp +++ b/src/main_sm/fork_8/main/eval_command.hpp @@ -152,7 +152,7 @@ void eval_fpBN254inv (Context &ctx, const RomCommand &cmd, Comm zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const RawFec::Element &y1, const RawFec::Element &x2, const RawFec::Element &y2, RawFec::Element &x3, RawFec::Element &y3); -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value); +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); mpz_class sqrtTonelliShanks ( const mpz_class &n, const mpz_class &p ); diff --git a/src/main_sm/fork_8/main/full_tracer.cpp b/src/main_sm/fork_8/main/full_tracer.cpp index 611817074..52e31c323 100644 --- a/src/main_sm/fork_8/main/full_tracer.cpp +++ b/src/main_sm/fork_8/main/full_tracer.cpp @@ -624,11 +624,7 @@ zkresult FullTracer::onStoreLog (Context &ctx, const RomCommand &cmd) uint64_t size = zkmin(cScalar.get_ui(), 32); // Convert data to hex string and append zeros, left zeros are stored in logs, for example if data = 0x01c8 and size=32, data is 0x00000000000000000000000000000000000000000000000000000000000001c8 - string dataString = data.get_str(16); - if ((size * 2) > dataString.size()) - { - dataString = PrependZeros(dataString, size*2); - } + string dataString = PrependZeros(data.get_str(16), 64); // Get only left size length from bytes, example if size=1 and data= 0xaa00000000000000000000000000000000000000000000000000000000000000, we get 0xaa dataString = dataString.substr(0, size * 2); @@ -1989,6 +1985,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -2764,12 +2768,15 @@ zkresult FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, const Goldilocks::Element &storageKey0, const Goldilocks::Element &storageKey1, const Goldilocks::Element &storageKey2, const Goldilocks::Element &storageKey3, const Goldilocks::Element &storageKey4, const Goldilocks::Element &storageKey5, const Goldilocks::Element &storageKey6, const Goldilocks::Element &storageKey7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -2795,11 +2802,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -2809,11 +2824,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } else if (keyType == SMT_KEY_SC_CODE) @@ -2874,4 +2897,48 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, return ZKR_SUCCESS; } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2]) || !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_8/main/full_tracer.hpp b/src/main_sm/fork_8/main/full_tracer.hpp index 09a679ab7..35de80319 100644 --- a/src/main_sm/fork_8/main/full_tracer.hpp +++ b/src/main_sm/fork_8/main/full_tracer.hpp @@ -79,7 +79,9 @@ class FullTracer: public FullTracerInterface zkresult addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, const Goldilocks::Element &storageKey0, const Goldilocks::Element &storageKey1, const Goldilocks::Element &storageKey2, const Goldilocks::Element &storageKey3, const Goldilocks::Element &storageKey4, const Goldilocks::Element &storageKey5, const Goldilocks::Element &storageKey6, const Goldilocks::Element &storageKey7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0), hasGaspriceOpcode(false), hasBalanceOpcode(false), txIndex(0), isForced(false) { }; ~FullTracer() diff --git a/src/main_sm/fork_8/main/main_executor.cpp b/src/main_sm/fork_8/main/main_executor.cpp index 276f12397..8ae716c18 100644 --- a/src/main_sm/fork_8/main/main_executor.cpp +++ b/src/main_sm/fork_8/main/main_executor.cpp @@ -283,7 +283,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkr != ZKR_SUCCESS) { proverRequest.result = zkr; - logError(ctx, string("Copying timestamp from state to memory, failed calling pHashDB->get() result=") + zkresult2string(zkr)); + logError(ctx, string("Copying timestamp from state to memory, failed calling pHashDB->get() result=") + zkresult2string(zkr) + " key=" + fea2string(fr, keyToRead)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1147,7 +1147,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1166,17 +1166,17 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); - if (zkResult != ZKR_SUCCESS) + if (bProcessBatch) { - proverRequest.result = zkResult; - logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); - pHashDB->cancelBatch(proverRequest.uuid); - return; + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); + if (zkResult != ZKR_SUCCESS) + { + proverRequest.result = zkResult; + logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); + pHashDB->cancelBatch(proverRequest.uuid); + return; + } } } @@ -1386,7 +1386,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, ctx.lastSWrite.key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1407,7 +1407,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, } if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, value); + zkResult = eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2382,7 +2382,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -2391,7 +2391,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2549,7 +2549,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, ctx.lastSWrite.key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -2558,7 +2558,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, scalarD); + zkResult = eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -3139,7 +3139,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->setProgram() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->setProgram() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, result)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -3194,7 +3194,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->getProgram() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->getProgram() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, aux)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -5911,9 +5911,12 @@ void MainExecutor::assertOutputs(Context &ctx) void MainExecutor::logError (Context &ctx, const string &message) { // Log the message, if provided + string log0 = "MainExecutor::logError()"; + string log1; if (message.size() > 0) { - zklog.error("MainExecutor::logError() " + message); + log1 = message; + zklog.error(log0 + " " + log1); } // Log details @@ -5922,21 +5925,24 @@ void MainExecutor::logError (Context &ctx, const string &message) uint64_t evaluation = (ctx.pEvaluation != NULL) ? *ctx.pEvaluation : INVALID_LOG_ERROR_VALUE; uint64_t zkpc = (ctx.pZKPC != NULL) ? *ctx.pZKPC : INVALID_LOG_ERROR_VALUE; string romLine = (ctx.pZKPC != NULL) ? rom.line[*ctx.pZKPC].toString(fr) : "INVALID_ZKPC"; - zklog.error(string("MainExecutor::logError() proverRequest.result=") + zkresult2string(ctx.proverRequest.result) + + string log2 = string("proverRequest.result=") + zkresult2string(ctx.proverRequest.result) + " step=" + to_string(step) + " eval=" + to_string(evaluation) + " zkPC=" + to_string(zkpc) + " rom.line={" + romLine + - "} uuid=" + ctx.proverRequest.uuid, - &ctx.proverRequest.tags); + "} uuid=" + ctx.proverRequest.uuid; + zklog.error(log0 + " " + log2, &ctx.proverRequest.tags); // Log registers - ctx.printRegs(); + string log3; + ctx.printRegs(log3); // Log the input file content json inputJson; ctx.proverRequest.input.save(inputJson); zklog.error("Input=" + inputJson.dump()); + + ctx.proverRequest.errorLog = log0 + " " + log1 + " " + log2 + " " + log3; } void MainExecutor::linearPoseidon (Context &ctx, const vector &data, Goldilocks::Element (&result)[4]) diff --git a/src/main_sm/fork_9/main/context.cpp b/src/main_sm/fork_9/main/context.cpp index 73cf37f86..80a28d9b0 100644 --- a/src/main_sm/fork_9/main/context.cpp +++ b/src/main_sm/fork_9/main/context.cpp @@ -4,7 +4,7 @@ namespace fork_9 { -void Context::printRegs() +void Context::printRegs(string &log) { if (pStep == NULL) { @@ -12,23 +12,29 @@ void Context::printRegs() return; } - zklog.error( + log.clear(); + + log = "Registers: SR=" + reg2string(pols.SR0[*pStep], pols.SR1[*pStep], pols.SR2[*pStep], pols.SR3[*pStep], pols.SR4[*pStep], pols.SR5[*pStep], pols.SR6[*pStep], pols.SR7[*pStep]) + " CONST=" + reg2string(pols.CONST0[*pStep], pols.CONST1[*pStep], pols.CONST2[*pStep], pols.CONST3[*pStep], pols.CONST4[*pStep], pols.CONST5[*pStep], pols.CONST6[*pStep], pols.CONST7[*pStep]) + - " FREE=" + reg2string(pols.FREE0[*pStep], pols.FREE1[*pStep], pols.FREE2[*pStep], pols.FREE3[*pStep], pols.FREE4[*pStep], pols.FREE5[*pStep], pols.FREE6[*pStep], pols.FREE7[*pStep]) ); + " FREE=" + reg2string(pols.FREE0[*pStep], pols.FREE1[*pStep], pols.FREE2[*pStep], pols.FREE3[*pStep], pols.FREE4[*pStep], pols.FREE5[*pStep], pols.FREE6[*pStep], pols.FREE7[*pStep]); + zklog.error(log); - zklog.error( + string aux; + aux = "A=" + reg2string(pols.A0[*pStep], pols.A1[*pStep], pols.A2[*pStep], pols.A3[*pStep], pols.A4[*pStep], pols.A5[*pStep], pols.A6[*pStep], pols.A7[*pStep]) + " B=" + reg2string(pols.B0[*pStep], pols.B1[*pStep], pols.B2[*pStep], pols.B3[*pStep], pols.B4[*pStep], pols.B5[*pStep], pols.B6[*pStep], pols.B7[*pStep]) + " C=" + reg2string(pols.C0[*pStep], pols.C1[*pStep], pols.C2[*pStep], pols.C3[*pStep], pols.C4[*pStep], pols.C5[*pStep], pols.C6[*pStep], pols.C7[*pStep]) + " D=" + reg2string(pols.D0[*pStep], pols.D1[*pStep], pols.D2[*pStep], pols.D3[*pStep], pols.D4[*pStep], pols.D5[*pStep], pols.D6[*pStep], pols.D7[*pStep]) + - " E=" + reg2string(pols.E0[*pStep], pols.E1[*pStep], pols.E2[*pStep], pols.E3[*pStep], pols.E4[*pStep], pols.E5[*pStep], pols.E6[*pStep], pols.E7[*pStep]) ); + " E=" + reg2string(pols.E0[*pStep], pols.E1[*pStep], pols.E2[*pStep], pols.E3[*pStep], pols.E4[*pStep], pols.E5[*pStep], pols.E6[*pStep], pols.E7[*pStep]); + zklog.error(aux); + log += " " + aux; Goldilocks::Element step; step = fr.fromU64(*pStep); - zklog.error( - "CTX=" + reg2string(pols.CTX[*pStep]) + + aux = + "CTX=" + reg2string(pols.CTX[*pStep]) + " SP=" + reg2string(pols.SP[*pStep]) + " PC=" + reg2string(pols.PC[*pStep]) + " GAS=" + reg2string(pols.GAS[*pStep]) + @@ -36,16 +42,20 @@ void Context::printRegs() " STEP=" + reg2string(step) + " RR=" + reg2string(pols.RR[*pStep]) + " HASHPOS=" + reg2string(pols.HASHPOS[*pStep]) + - " RCX=" + reg2string(pols.RCX[*pStep]) ); + " RCX=" + reg2string(pols.RCX[*pStep]); + zklog.error(aux); + log += " " + aux; - zklog.error( + aux = "cntArith=" + reg2string(pols.cntArith[*pStep]) + " cntBinary=" + reg2string(pols.cntBinary[*pStep]) + " cntMemAlign=" + reg2string(pols.cntMemAlign[*pStep]) + " cntKeccakF=" + reg2string(pols.cntKeccakF[*pStep]) + " cntSha256F=" + reg2string(pols.cntSha256F[*pStep]) + " cntPoseidonG=" + reg2string(pols.cntPoseidonG[*pStep]) + - " cntPaddingPG=" + reg2string(pols.cntPaddingPG[*pStep]) ); + " cntPaddingPG=" + reg2string(pols.cntPaddingPG[*pStep]); + zklog.error(aux); + log += " " + aux; #ifdef LOG_FILENAME zklog.info("File: " + fileName + " Line: " + to_string(line)); diff --git a/src/main_sm/fork_9/main/context.hpp b/src/main_sm/fork_9/main/context.hpp index 62b2f157e..a5478c8a2 100644 --- a/src/main_sm/fork_9/main/context.hpp +++ b/src/main_sm/fork_9/main/context.hpp @@ -217,7 +217,7 @@ class Context vector quotient; // Print functions - void printRegs(); + void printRegs(string &log); void printVars(); void printMem(); void printReg(string name, Goldilocks::Element &fe); diff --git a/src/main_sm/fork_9/main/eval_command.cpp b/src/main_sm/fork_9/main/eval_command.cpp index be6f10bd1..ea2d6c511 100644 --- a/src/main_sm/fork_9/main/eval_command.cpp +++ b/src/main_sm/fork_9/main/eval_command.cpp @@ -2510,14 +2510,15 @@ zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const Ra return ZKR_SUCCESS; } -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value) +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]) { zkassert(ctx.proverRequest.input.publicInputsExtended.publicInputs.forkID == 9); // fork_9 return ((fork_9::FullTracer *)ctx.proverRequest.pFullTracer)->addReadWriteAddress( ctx.pols.A0[0], ctx.pols.A1[0], ctx.pols.A2[0], ctx.pols.A3[0], ctx.pols.A4[0], ctx.pols.A5[0], ctx.pols.A6[0], ctx.pols.A7[0], ctx.pols.B0[0], ctx.pols.B1[0], ctx.pols.B2[0], ctx.pols.B3[0], ctx.pols.B4[0], ctx.pols.B5[0], ctx.pols.B6[0], ctx.pols.B7[0], ctx.pols.C0[0], ctx.pols.C1[0], ctx.pols.C2[0], ctx.pols.C3[0], ctx.pols.C4[0], ctx.pols.C5[0], ctx.pols.C6[0], ctx.pols.C7[0], - value); + value, + key); } void eval_getL1InfoRoot (Context &ctx, const RomCommand &cmd, CommandResult &cr) diff --git a/src/main_sm/fork_9/main/eval_command.hpp b/src/main_sm/fork_9/main/eval_command.hpp index 3a57d9922..d6ee5a3d2 100644 --- a/src/main_sm/fork_9/main/eval_command.hpp +++ b/src/main_sm/fork_9/main/eval_command.hpp @@ -152,7 +152,7 @@ void eval_fpBN254inv (Context &ctx, const RomCommand &cmd, Comm zkresult AddPointEc (Context &ctx, bool dbl, const RawFec::Element &x1, const RawFec::Element &y1, const RawFec::Element &x2, const RawFec::Element &y2, RawFec::Element &x3, RawFec::Element &y3); -zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value); +zkresult eval_addReadWriteAddress (Context &ctx, const mpz_class value, const Goldilocks::Element (&key)[4]); mpz_class sqrtTonelliShanks ( const mpz_class &n, const mpz_class &p ); diff --git a/src/main_sm/fork_9/main/full_tracer.cpp b/src/main_sm/fork_9/main/full_tracer.cpp index d24f01d48..fa04f306b 100644 --- a/src/main_sm/fork_9/main/full_tracer.cpp +++ b/src/main_sm/fork_9/main/full_tracer.cpp @@ -563,11 +563,7 @@ zkresult FullTracer::onStoreLog (Context &ctx, const RomCommand &cmd) uint64_t size = zkmin(cScalar.get_ui(), 32); // Convert data to hex string and append zeros, left zeros are stored in logs, for example if data = 0x01c8 and size=32, data is 0x00000000000000000000000000000000000000000000000000000000000001c8 - string dataString = data.get_str(16); - if ((size * 2) > dataString.size()) - { - dataString = PrependZeros(dataString, size*2); - } + string dataString = PrependZeros(data.get_str(16), 64); // Get only left size length from bytes, example if size=1 and data= 0xaa00000000000000000000000000000000000000000000000000000000000000, we get 0xaa dataString = dataString.substr(0, size * 2); @@ -1455,6 +1451,14 @@ zkresult FullTracer::onFinishBatch(Context &ctx, const RomCommand &cmd) // getVarFromCtx(ctx, true, "newNumBatch", auxScalar); // finalTrace.new_batch_num = auxScalar.get_ui(); + // Call fillInReadWriteAddresses + zkr = fillInReadWriteAddresses(ctx); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::onFinishBatch() failed calling fillInReadWriteAddresses()"); + return zkr; + } + #ifdef LOG_FULL_TRACER zklog.info("FullTracer::onFinishBatch() new_state_root=" + finalTrace.new_state_root); #endif @@ -2171,12 +2175,15 @@ zkresult FullTracer::onOpcode(Context &ctx, const RomCommand &cmd) zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &address3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, const Goldilocks::Element &storageKey0, const Goldilocks::Element &storageKey1, const Goldilocks::Element &storageKey2, const Goldilocks::Element &storageKey3, const Goldilocks::Element &storageKey4, const Goldilocks::Element &storageKey5, const Goldilocks::Element &storageKey6, const Goldilocks::Element &storageKey7, - const mpz_class &value ) + const mpz_class &value, + const Goldilocks::Element (&key)[4] ) { #ifdef LOG_TIME_STATISTICS gettimeofday(&t, NULL); #endif + zkassert(!fr.isZero(key[0]) || !fr.isZero(key[1]) || !fr.isZero(key[2]) || !fr.isZero(key[3])); + // Get address mpz_class address; if (!fea2scalar(fr, address, address0, address1, address2, address3, address4, address5, address6, address7)) @@ -2202,11 +2209,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.balance = value.get_str(); + infoReadWrite.balanceKey[0]= key[0]; + infoReadWrite.balanceKey[1]= key[1]; + infoReadWrite.balanceKey[2]= key[2]; + infoReadWrite.balanceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.balance = value.get_str(); + it->second.balanceKey[0]= key[0]; + it->second.balanceKey[1]= key[1]; + it->second.balanceKey[2]= key[2]; + it->second.balanceKey[3]= key[3]; } } else if (keyType == SMT_KEY_NONCE) @@ -2216,11 +2231,19 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, { InfoReadWrite infoReadWrite; infoReadWrite.nonce = value.get_str(); + infoReadWrite.nonceKey[0]= key[0]; + infoReadWrite.nonceKey[1]= key[1]; + infoReadWrite.nonceKey[2]= key[2]; + infoReadWrite.nonceKey[3]= key[3]; read_write_addresses[addressHex] = infoReadWrite; } else { it->second.nonce = value.get_str(); + it->second.nonceKey[0]= key[0]; + it->second.nonceKey[1]= key[1]; + it->second.nonceKey[2]= key[2]; + it->second.nonceKey[3]= key[3]; } } else if (keyType == SMT_KEY_SC_CODE) @@ -2281,4 +2304,48 @@ zkresult FullTracer::addReadWriteAddress ( const Goldilocks::Element &address0, return ZKR_SUCCESS; } +zkresult FullTracer::fillInReadWriteAddresses (Context &ctx) +{ + zkresult zkr; + + // Get new state root fea + Goldilocks::Element newStateRoot[4]; + string2fea(fr, NormalizeToNFormat(finalTrace.new_state_root, 64), newStateRoot); + + // For all entries in read_write_addresses + unordered_map::iterator it; + for (it = read_write_addresses.begin(); it != read_write_addresses.end(); it++) + { + // Re-read balance for this state root + if (!it->second.balance.empty()) + { + zkassert(!fr.isZero(it->second.balanceKey[0]) || !fr.isZero(it->second.balanceKey[1]) || !fr.isZero(it->second.balanceKey[2]) || !fr.isZero(it->second.balanceKey[3])); + mpz_class balance; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.balanceKey, balance, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(balance) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.balance = balance.get_str(); + } + + // Re-read nonce for this state root + if (!it->second.nonce.empty()) + { + zkassert(!fr.isZero(it->second.nonceKey[0]) || !fr.isZero(it->second.nonceKey[1]) || !fr.isZero(it->second.nonceKey[2]) || !fr.isZero(it->second.nonceKey[3])); + mpz_class nonce; + zkr = ctx.pHashDB->get(ctx.proverRequest.uuid, newStateRoot, it->second.nonceKey, nonce, NULL, NULL); + if (zkr != ZKR_SUCCESS) + { + zklog.error("FullTracer::fillInReadWriteAddresses() failed calling ctx.pHashDB->get(nonce) result=" + zkresult2string(zkr)); + return zkr; + } + it->second.nonce = nonce.get_str(); + } + } + + return ZKR_SUCCESS; +} + } // namespace \ No newline at end of file diff --git a/src/main_sm/fork_9/main/full_tracer.hpp b/src/main_sm/fork_9/main/full_tracer.hpp index 78bde4ce5..f58893c8c 100644 --- a/src/main_sm/fork_9/main/full_tracer.hpp +++ b/src/main_sm/fork_9/main/full_tracer.hpp @@ -71,7 +71,9 @@ class FullTracer: public FullTracerInterface zkresult addReadWriteAddress ( const Goldilocks::Element &address0, const Goldilocks::Element &address1, const Goldilocks::Element &address2, const Goldilocks::Element &faddress3, const Goldilocks::Element &address4, const Goldilocks::Element &address5, const Goldilocks::Element &address6, const Goldilocks::Element &address7, const Goldilocks::Element &keyType0, const Goldilocks::Element &keyType1, const Goldilocks::Element &keyType2, const Goldilocks::Element &keyType3, const Goldilocks::Element &keyType4, const Goldilocks::Element &keyType5, const Goldilocks::Element &keyType6, const Goldilocks::Element &keyType7, const Goldilocks::Element &storageKey0, const Goldilocks::Element &storageKey1, const Goldilocks::Element &storageKey2, const Goldilocks::Element &storageKey3, const Goldilocks::Element &storageKey4, const Goldilocks::Element &storageKey5, const Goldilocks::Element &storageKey6, const Goldilocks::Element &storageKey7, - const mpz_class &value ); + const mpz_class &value, + const Goldilocks::Element (&key)[4] ); + zkresult fillInReadWriteAddresses (Context &ctx); FullTracer(Goldilocks &fr) : fr(fr), depth(1), prevCTX(0), initGas(0), txTime(0), accBatchGas(0), numberOfOpcodesInThisTx(0), lastErrorOpcode(0), hasGaspriceOpcode(false), hasBalanceOpcode(false), txIndex(0), isForced(false) { }; ~FullTracer() diff --git a/src/main_sm/fork_9/main/main_executor.cpp b/src/main_sm/fork_9/main/main_executor.cpp index a11d6c22e..5cedf1580 100644 --- a/src/main_sm/fork_9/main/main_executor.cpp +++ b/src/main_sm/fork_9/main/main_executor.cpp @@ -283,7 +283,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkr != ZKR_SUCCESS) { proverRequest.result = zkr; - logError(ctx, string("Copying timestamp from state to memory, failed calling pHashDB->get() result=") + zkresult2string(zkr)); + logError(ctx, string("Copying timestamp from state to memory, failed calling pHashDB->get() result=") + zkresult2string(zkr) + " key=" + fea2string(fr, keyToRead)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1147,7 +1147,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1166,17 +1166,17 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, #ifdef LOG_TIME_STATISTICS_MAIN_EXECUTOR mainMetrics.add("SMT Get", TimeDiff(t)); #endif - } - if (bProcessBatch) - { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); - if (zkResult != ZKR_SUCCESS) + if (bProcessBatch) { - proverRequest.result = zkResult; - logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); - pHashDB->cancelBatch(proverRequest.uuid); - return; + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); + if (zkResult != ZKR_SUCCESS) + { + proverRequest.result = zkResult; + logError(ctx, string("Failed calling eval_addReadWriteAddress() 1 result=") + zkresult2string(zkResult)); + pHashDB->cancelBatch(proverRequest.uuid); + return; + } } } @@ -1386,7 +1386,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, ctx.lastSWrite.key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -1407,7 +1407,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, } if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, value); + zkResult = eval_addReadWriteAddress(ctx, value, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2382,7 +2382,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->get() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -2391,7 +2391,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value); + zkResult = eval_addReadWriteAddress(ctx, smtGetResult.value, key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -2549,7 +2549,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->set() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, ctx.lastSWrite.key)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -2558,7 +2558,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (bProcessBatch) { - zkResult = eval_addReadWriteAddress(ctx, scalarD); + zkResult = eval_addReadWriteAddress(ctx, scalarD, ctx.lastSWrite.key); if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; @@ -3139,7 +3139,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->setProgram() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->setProgram() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, result)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -3194,7 +3194,7 @@ void MainExecutor::execute (ProverRequest &proverRequest, MainCommitPols &pols, if (zkResult != ZKR_SUCCESS) { proverRequest.result = zkResult; - logError(ctx, string("Failed calling pHashDB->getProgram() result=") + zkresult2string(zkResult)); + logError(ctx, string("Failed calling pHashDB->getProgram() result=") + zkresult2string(zkResult) + " key=" + fea2string(fr, aux)); pHashDB->cancelBatch(proverRequest.uuid); return; } @@ -5911,9 +5911,12 @@ void MainExecutor::assertOutputs(Context &ctx) void MainExecutor::logError (Context &ctx, const string &message) { // Log the message, if provided + string log0 = "MainExecutor::logError()"; + string log1; if (message.size() > 0) { - zklog.error("MainExecutor::logError() " + message); + log1 = message; + zklog.error(log0 + " " + log1); } // Log details @@ -5922,21 +5925,24 @@ void MainExecutor::logError (Context &ctx, const string &message) uint64_t evaluation = (ctx.pEvaluation != NULL) ? *ctx.pEvaluation : INVALID_LOG_ERROR_VALUE; uint64_t zkpc = (ctx.pZKPC != NULL) ? *ctx.pZKPC : INVALID_LOG_ERROR_VALUE; string romLine = (ctx.pZKPC != NULL) ? rom.line[*ctx.pZKPC].toString(fr) : "INVALID_ZKPC"; - zklog.error(string("MainExecutor::logError() proverRequest.result=") + zkresult2string(ctx.proverRequest.result) + + string log2 = string("proverRequest.result=") + zkresult2string(ctx.proverRequest.result) + " step=" + to_string(step) + " eval=" + to_string(evaluation) + " zkPC=" + to_string(zkpc) + " rom.line={" + romLine + - "} uuid=" + ctx.proverRequest.uuid, - &ctx.proverRequest.tags); + "} uuid=" + ctx.proverRequest.uuid; + zklog.error(log0 + " " + log2, &ctx.proverRequest.tags); // Log registers - ctx.printRegs(); + string log3; + ctx.printRegs(log3); // Log the input file content json inputJson; ctx.proverRequest.input.save(inputJson); zklog.error("Input=" + inputJson.dump()); + + ctx.proverRequest.errorLog = log0 + " " + log1 + " " + log2 + " " + log3; } void MainExecutor::linearPoseidon (Context &ctx, const vector &data, Goldilocks::Element (&result)[4]) diff --git a/src/prover/cbor.hpp b/src/prover/cbor.hpp index 53bb1edba..8975ae183 100644 --- a/src/prover/cbor.hpp +++ b/src/prover/cbor.hpp @@ -25,6 +25,7 @@ class CborResult vector array; uint64_t tagCount; vector tag; + CborResult() : result(ZKR_UNSPECIFIED), type(UNDEFINED), u64(0), tagCount(0) {}; }; string cborType2string (CborResult::ResultType type); diff --git a/src/prover/full_tracer_interface.hpp b/src/prover/full_tracer_interface.hpp index 1e97ec706..f4fbab865 100644 --- a/src/prover/full_tracer_interface.hpp +++ b/src/prover/full_tracer_interface.hpp @@ -3,6 +3,7 @@ #include #include +#include "zkglobals.hpp" using namespace std; @@ -240,10 +241,26 @@ class InfoReadWrite { public: string nonce; + Goldilocks::Element nonceKey[4]; string balance; + Goldilocks::Element balanceKey[4]; string sc_code; unordered_map sc_storage; string sc_length; + InfoReadWrite() + { + // Reset nonce key + nonceKey[0] = fr.zero(); + nonceKey[1] = fr.zero(); + nonceKey[2] = fr.zero(); + nonceKey[3] = fr.zero(); + + // Reset balance key + balanceKey[0] = fr.zero(); + balanceKey[1] = fr.zero(); + balanceKey[2] = fr.zero(); + balanceKey[3] = fr.zero(); + } }; class TxGAS diff --git a/src/prover/prover_request.hpp b/src/prover/prover_request.hpp index ce3526326..6a487623b 100644 --- a/src/prover/prover_request.hpp +++ b/src/prover/prover_request.hpp @@ -78,6 +78,9 @@ class ProverRequest unordered_set nodesKeys; unordered_set programKeys; + /* Debug info */ + string errorLog; + /* Constructor */ ProverRequest (Goldilocks &fr, const Config &config, tProverRequestType type); ~ProverRequest(); diff --git a/src/prover/witness.cpp b/src/prover/witness.cpp index 24cfd8086..a2c97e6ed 100644 --- a/src/prover/witness.cpp +++ b/src/prover/witness.cpp @@ -425,15 +425,6 @@ zkresult calculateWitnessHash (WitnessContext &ctx, Goldilocks::Element (&hash)[ // Convert to field elements scalar2fea(fr, hashScalar, hash); // TODO: return error if hashScalar is invalid, instead of killing the process - // Store the hash-value pair into db - vector valueData; - valueData.reserve(12); - for (uint64_t i=0; i<12; i++) - { - valueData.emplace_back(fr.zero()); - } - ctx.db[fea2string(fr, hash)] = valueData; - break; } case 0x04: // CODE -> ( 0x04 CBOR(code)... ) @@ -510,6 +501,9 @@ zkresult calculateWitnessHash (WitnessContext &ctx, Goldilocks::Element (&hash)[ zkresult witness2db (const string &witness, DatabaseMap::MTMap &db, DatabaseMap::ProgramMap &programs, mpz_class &stateRoot) { + db.clear(); + programs.clear(); + zkresult zkr; // Check witness is not empty @@ -531,9 +525,8 @@ zkresult witness2db (const string &witness, DatabaseMap::MTMap &db, DatabaseMap: } ctx.p++; - // Calculate witness hash + // Calculate witness hash Goldilocks::Element hash[4]; - vector bits; zkr = calculateWitnessHash(ctx, hash); if (zkr != ZKR_SUCCESS) { diff --git a/src/service/aggregator/aggregator_client.cpp b/src/service/aggregator/aggregator_client.cpp index 71c4fe4b6..5b35e5d67 100644 --- a/src/service/aggregator/aggregator_client.cpp +++ b/src/service/aggregator/aggregator_client.cpp @@ -460,7 +460,13 @@ bool AggregatorClient::GenStatelessBatchProof (const aggregator::v1::GenStateles ba2scalar(pProverRequest->input.publicInputsExtended.publicInputs.oldAccInputHash, genStatelessBatchProofRequest.input().public_inputs().old_acc_input_hash()); // Get oldBatchNum - pProverRequest->input.publicInputsExtended.publicInputs.oldBatchNum = batch.batchNumber; + if (batch.batchNumber == 0) + { + zklog.error("AggregatorClient::GenStatelessBatchProof() called dataStream2batch() but got batch.batchNumber=0", &pProverRequest->tags); + genBatchProofResponse.set_result(aggregator::v1::Result::RESULT_ERROR); + return false; + } + pProverRequest->input.publicInputsExtended.publicInputs.oldBatchNum = batch.batchNumber - 1; // Get chain ID pProverRequest->input.publicInputsExtended.publicInputs.chainID = batch.chainId; @@ -887,10 +893,12 @@ void* aggregatorClientThread(void* arg) break; case aggregator::v1::AggregatorMessage::RequestCase::kGetStatusRequest: case aggregator::v1::AggregatorMessage::RequestCase::kGenBatchProofRequest: - case aggregator::v1::AggregatorMessage::RequestCase::kGenStatelessBatchProofRequest: case aggregator::v1::AggregatorMessage::RequestCase::kCancelRequest: zklog.info("aggregatorClientThread() got: " + aggregatorMessage.ShortDebugString()); break; + case aggregator::v1::AggregatorMessage::RequestCase::kGenStatelessBatchProofRequest: + zklog.info("aggregatorClientThread() got genStatelessBatchProof() request"); + break; case aggregator::v1::AggregatorMessage::RequestCase::kGenAggregatedProofRequest: zklog.info("aggregatorClientThread() got genAggregatedProof() request"); break; diff --git a/src/service/executor/executor_service.cpp b/src/service/executor/executor_service.cpp index 976c44537..a1990f614 100644 --- a/src/service/executor/executor_service.cpp +++ b/src/service/executor/executor_service.cpp @@ -1543,6 +1543,15 @@ ::grpc::Status ExecutorServiceImpl::ProcessBatchV2 (::grpc::ServerContext* conte } } + // Debug + if (!proverRequest.errorLog.empty()) + { + executor::v1::ResponseDebug *pResponseDebug = new executor::v1::ResponseDebug; + zkassertpermanent(pResponseDebug != NULL); + pResponseDebug->set_error_log(proverRequest.errorLog); + response->set_allocated_debug(pResponseDebug); + } + #ifdef LOG_SERVICE_EXECUTOR_OUTPUT { string s = "ExecutorServiceImpl::ProcessBatchV2() returns result=" + to_string(response->error()) + @@ -2227,6 +2236,15 @@ ::grpc::Status ExecutorServiceImpl::ProcessStatelessBatchV2 (::grpc::ServerConte } } + // Debug + if (!proverRequest.errorLog.empty()) + { + executor::v1::ResponseDebug *pResponseDebug = new executor::v1::ResponseDebug; + zkassertpermanent(pResponseDebug != NULL); + pResponseDebug->set_error_log(proverRequest.errorLog); + response->set_allocated_debug(pResponseDebug); + } + #ifdef LOG_SERVICE_EXECUTOR_OUTPUT { string s = "ExecutorServiceImpl::ProcessStatelessBatchV2() returns result=" + to_string(response->error()) + diff --git a/test/service/executor/executor_client.cpp b/test/service/executor/executor_client.cpp index c49ff7a79..783e172ff 100644 --- a/test/service/executor/executor_client.cpp +++ b/test/service/executor/executor_client.cpp @@ -419,6 +419,7 @@ bool ExecutorClient::ProcessBatch (const string &inputFile) return false; } newStateRoot = ba2string(processBatchResponse.new_state_root()); + zklog.info("ExecutorClient::ProcessBatch() newStateRoot=" + newStateRoot); #ifdef LOG_SERVICE cout << "ExecutorClient::ProcessBatch() got:\n" << response.DebugString() << endl; diff --git a/tools/download_archive.sh b/tools/download_archive.sh index c41987050..dac138928 100755 --- a/tools/download_archive.sh +++ b/tools/download_archive.sh @@ -5,7 +5,7 @@ echo "Please ensure that you run this script from the root of the zkevm-prover r echo "Press Enter to continue..." read -ARCHIVE_NAME="v3.0.0-RC3-fork.6" +ARCHIVE_NAME="v6.0.0-rc.1-fork.9" ARCHIVE_EXTENSION=".tgz" ARCHIVE_URL="https://storage.googleapis.com/zkevm/zkproverc/${ARCHIVE_NAME}${ARCHIVE_EXTENSION}"