Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jamtis changes #26

Open
wants to merge 36 commits into
base: seraphis_lib
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
92a8c35
add key exchange round booster to multisig_account
UkoeHB Mar 3, 2022
e583c0b
seraphis mega squash commit [initial commit - 05/15/2023]; see seraph…
UkoeHB Sep 3, 2021
ca6d109
async: explicit task constructors
UkoeHB May 15, 2023
fc3fa5f
rebase fixes
UkoeHB May 16, 2023
e86d813
make JamtisDestinationV1 serializable (#11)
DangerousFreedom1984 Jun 8, 2023
5c28da7
compile fix
UkoeHB Jul 14, 2023
6a74e16
clarify SpBasicEnoteRecordV1 docs; add async unit test for custom joins
UkoeHB Aug 31, 2023
a32b787
remove broken perf tests
UkoeHB Sep 10, 2023
7a9b7d6
add operator== to JamtisPaymentProposals (#18)
DangerousFreedom1984 Oct 18, 2023
a8041ed
make JamtisPaymentProposal serializable (#21)
DangerousFreedom1984 Oct 23, 2023
0ade045
util to convert legacy outputs to seraphis lib compatible enotes (#22)
j-berman Oct 24, 2023
48ae432
container_helpers: is_sorted_and_unique 3x fewer comparison ops (#19)
Oct 24, 2023
e68cd54
modify construct_tx_for_mock_ledger_v1 so it outputs the JamtisPaymen…
DangerousFreedom1984 Oct 29, 2023
7e6e8aa
rebase fixes
UkoeHB Feb 8, 2024
42f3730
fix unbound issue
UkoeHB Feb 9, 2024
de30f2a
missing header
UkoeHB Feb 9, 2024
084d16e
c++17
UkoeHB Feb 9, 2024
b495fad
c++17
UkoeHB Feb 9, 2024
ce93774
split variant into variant and optional (#28)
Feb 16, 2024
36610a3
unit_tests: variant: fix for optional_variant (#30)
Feb 21, 2024
99288f0
derive view_balance from master key (#29)
DangerousFreedom1984 Feb 22, 2024
8d14b42
fix typo in header
UkoeHB Feb 23, 2024
111e58a
free function serialization DSL (#32)
Mar 5, 2024
60f0ea9
blake2b whitespace fixes
UkoeHB Mar 21, 2024
d0b049b
SpTxCoinbaseV1: remove block_reward field (#38)
Mar 22, 2024
7c80674
seraphis_crypto: split BulletproofPlus2 into proof-only and complete …
Mar 22, 2024
b7d8632
Remaining tx ridigity issues (#34)
Mar 25, 2024
f0eac25
cleanup
UkoeHB Apr 23, 2024
6674edc
cleanup
UkoeHB Apr 24, 2024
c742260
Direct & compact tx serialization (#39)
May 2, 2024
60c5d7e
Async wallet scanner (#23)
j-berman May 7, 2024
38b0fc2
serialization: serialize tools::variant (#49)
May 20, 2024
e45a5ac
async: default threadpool cannot be inlined
UkoeHB May 20, 2024
111fe51
Identify non-standard received legacy enotes (#43)
SNeedlewoods May 22, 2024
ace9228
Legacy Indexing Overhaul (#42)
May 23, 2024
537ba29
jamtis changes
jeffro256 Sep 3, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@
path = external/supercop
url = https://github.com/monero-project/supercop
branch = monero
[submodule "external/mx25519"]
path = external/mx25519
url = https://github.com/tevador/mx25519
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ if(NOT MANUAL_SUBMODULES)
check_submodule(external/trezor-common)
check_submodule(external/randomx)
check_submodule(external/supercop)
check_submodule(external/mx25519)
endif()
endif()

Expand Down Expand Up @@ -458,7 +459,7 @@ elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
set(BSDI TRUE)
endif()

include_directories(external/rapidjson/include external/easylogging++ src contrib/epee/include external external/supercop/include)
include_directories(external/rapidjson/include external/easylogging++ src contrib/epee/include external external/supercop/include external/mx25519/include)

if(APPLE)
cmake_policy(SET CMP0042 NEW)
Expand Down
1 change: 1 addition & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ add_subdirectory(db_drivers)
add_subdirectory(easylogging++)
add_subdirectory(qrcodegen)
add_subdirectory(randomx EXCLUDE_FROM_ALL)
add_subdirectory(mx25519)
1 change: 1 addition & 0 deletions external/mx25519
Submodule mx25519 added at 84ca12
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ endfunction ()
include(Version)
monero_add_library(version SOURCES ${CMAKE_BINARY_DIR}/version.cpp DEPENDS genversion)

add_subdirectory(async)
add_subdirectory(common)
add_subdirectory(crypto)
add_subdirectory(ringct)
Expand All @@ -96,7 +97,11 @@ add_subdirectory(hardforks)
add_subdirectory(blockchain_db)
add_subdirectory(mnemonics)
add_subdirectory(rpc)
add_subdirectory(seraphis_core)
add_subdirectory(seraphis_crypto)
add_subdirectory(seraphis_impl)
add_subdirectory(seraphis_main)
add_subdirectory(seraphis_mocks)
if(NOT IOS)
add_subdirectory(serialization)
endif()
Expand Down
52 changes: 52 additions & 0 deletions src/async/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (c) 2021, The Monero Project
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

set(async_sources
sleepy_task_queue.cpp
task_types.cpp
threadpool.cpp
waiter_manager.cpp)

monero_find_all_headers(async_headers, "${CMAKE_CURRENT_SOURCE_DIR}")

monero_add_library(async
${async_sources}
${async_headers})

target_link_libraries(async
PUBLIC
common
epee
PRIVATE
${EXTRA_LIBRARIES})

target_include_directories(async
PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
PRIVATE
${Boost_INCLUDE_DIRS})
87 changes: 87 additions & 0 deletions src/async/misc_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Copyright (c) 2023, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// Miscellaneous async utils.

#pragma once

//local headers
#include "common/expect.h"

//third-party headers

//standard headers
#include <chrono>
#include <future>

//forward declarations


namespace async
{
//-------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------
template <typename T>
bool future_is_ready(const std::future<T> &future)
{
try
{
if (!future.valid())
return false;
if (future.wait_for(std::chrono::seconds(0)) != std::future_status::ready)
return false;
} catch (...) { return false; }
return true;
}
//-------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------
template <typename T>
bool future_is_ready(const std::shared_future<T> &future)
{
try
{
if (!future.valid())
return false;
if (future.wait_for(std::chrono::seconds(0)) != std::future_status::ready)
return false;
} catch (...) { return false; }
return true;
}
//-------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------
template <typename R>
expect<R> unwrap_future(std::future<R> &future)
{
if (!future_is_ready(future)) { return std::error_code{}; }
try { return std::move(future.get()); }
catch (std::error_code e) { return e; }
catch (...) { return std::error_code{}; }
}
//-------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------
} //namespace async
96 changes: 96 additions & 0 deletions src/async/mutex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (c) 2024, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/// mutex

#pragma once

//local headers
#include "misc_language.h"
#include "misc_log_ex.h"

//third-party headers

//standard headers
#include <atomic>
#include <mutex>
#include <string>
#include <thread>

//forward declarations


// Lock the mutex and then unlock it at the end of the local scope
// - if it fails to unlock (either it's already unlocked or owned by a different thread), the exception is ignored
#define SCOPE_LOCK_MUTEX(mutex) \
mutex.lock(); \
auto scope_exit_handler_##mutex = epee::misc_utils::create_scope_leave_handler([this](){ \
CHECK_AND_ASSERT_THROW_MES(mutex.unlock(), "failed to unlock " + std::string(#mutex)); \
})

namespace async
{

/// mutex
class Mutex final
{
public:
/// disable copy/move
Mutex& operator=(Mutex&&) = delete;

//member functions
/// Lock the mutex and claim ownership
void lock()
{
m_mutex.lock();
m_mutex_owner.store(std::this_thread::get_id(), std::memory_order_relaxed);
}

/// Release ownership and unlock the mutex. If this thread does not own the lock already, returns false.
bool unlock()
{
if (!thread_owns_lock())
return false;
m_mutex_owner.store(std::thread::id{}, std::memory_order_relaxed);
m_mutex.unlock();
return true;
}

/// Check if the given thread owns the mutex
bool thread_owns_lock(const std::thread::id thread_id = std::this_thread::get_id()) const
{
return thread_id == m_mutex_owner.load(std::memory_order_relaxed);
}

private:
//member variables
std::mutex m_mutex;
std::atomic<std::thread::id> m_mutex_owner{std::thread::id{}};
};

} //namespace async
Loading
Loading