diff --git a/src/3pc/agent/client.cpp b/src/3pc/agent/client.cpp index 9b5e26c32..ec4e5767f 100644 --- a/src/3pc/agent/client.cpp +++ b/src/3pc/agent/client.cpp @@ -22,7 +22,8 @@ namespace cbdc::threepc::agent::rpc { bool is_readonly_run, const interface::exec_callback_type& result_callback) -> bool { - auto req = request{std::move(function), std::move(param), is_readonly_run}; + auto req + = request{std::move(function), std::move(param), is_readonly_run}; return m_client->call(std::move(req), [result_callback](std::optional resp) { assert(resp.has_value()); diff --git a/src/3pc/agent/impl.cpp b/src/3pc/agent/impl.cpp index 14a69b2ca..07be078d9 100644 --- a/src/3pc/agent/impl.cpp +++ b/src/3pc/agent/impl.cpp @@ -30,7 +30,7 @@ namespace cbdc::threepc::agent { m_runner_factory(std::move(runner_factory)), m_broker(std::move(broker)), m_initial_lock_type(is_readonly_run ? broker::lock_type::read - : initial_lock_type), + : initial_lock_type), m_is_readonly_run(is_readonly_run), m_secp(std::move(secp)), m_threads(std::move(t_pool)) {} @@ -140,7 +140,7 @@ namespace cbdc::threepc::agent { m_state = state::function_get_sent; if(m_is_readonly_run && get_function().size() == 0) { - // If this is a dry-run and the function key is empty, the + // If this is a read-only run and the function key is empty, the // runner will handle retrieving any keys directly. handle_function(broker::value_type()); } else if(get_function().size() == 1) { @@ -191,10 +191,11 @@ namespace cbdc::threepc::agent { res_cb(std::move(res)); } - auto impl::do_try_lock_request( - broker::key_type key, - broker::lock_type locktype, - broker::interface::try_lock_callback_type res_cb) -> bool { + auto + impl::do_try_lock_request(broker::key_type key, + broker::lock_type locktype, + broker::interface::try_lock_callback_type res_cb) + -> bool { // TODO: permissions for keys std::unique_lock l(m_mut); assert(m_ticket_number.has_value()); @@ -227,7 +228,8 @@ namespace cbdc::threepc::agent { return true; } - auto actual_lock_type = m_is_readonly_run ? broker::lock_type::read : locktype; + auto actual_lock_type + = m_is_readonly_run ? broker::lock_type::read : locktype; return m_broker->try_lock( m_ticket_number.value(), std::move(key), @@ -336,8 +338,8 @@ namespace cbdc::threepc::agent { broker::lock_type locktype, broker::interface::try_lock_callback_type res_cb) -> bool { return do_try_lock_request(std::move(key), - locktype, - std::move(res_cb)); + locktype, + std::move(res_cb)); }, m_secp, m_restarted ? nullptr : m_threads, diff --git a/src/3pc/agent/impl.hpp b/src/3pc/agent/impl.hpp index 13ee08672..fe602be99 100644 --- a/src/3pc/agent/impl.hpp +++ b/src/3pc/agent/impl.hpp @@ -145,10 +145,11 @@ namespace cbdc::threepc::agent { void do_commit(); - [[nodiscard]] auto do_try_lock_request( - broker::key_type key, - broker::lock_type locktype, - broker::interface::try_lock_callback_type res_cb) -> bool; + [[nodiscard]] auto + do_try_lock_request(broker::key_type key, + broker::lock_type locktype, + broker::interface::try_lock_callback_type res_cb) + -> bool; void handle_rollback(broker::interface::rollback_return_type rollback_res); diff --git a/src/3pc/agent/runners/evm/host.cpp b/src/3pc/agent/runners/evm/host.cpp index f0871378e..f756d66a5 100644 --- a/src/3pc/agent/runners/evm/host.cpp +++ b/src/3pc/agent/runners/evm/host.cpp @@ -122,7 +122,8 @@ namespace cbdc::threepc::agent::runner { } auto& acc = maybe_acc.value(); - auto maybe_storage = get_account_storage(addr, key, !m_is_readonly_run); + auto maybe_storage + = get_account_storage(addr, key, !m_is_readonly_run); auto prev_value = maybe_storage.value_or(evmc::bytes32{}); auto modified = acc.m_modified.find(key) != acc.m_modified.end(); diff --git a/src/3pc/agent/runners/evm/host.hpp b/src/3pc/agent/runners/evm/host.hpp index a407387b0..58cd29f00 100644 --- a/src/3pc/agent/runners/evm/host.hpp +++ b/src/3pc/agent/runners/evm/host.hpp @@ -36,43 +36,43 @@ namespace cbdc::threepc::agent::runner { bool is_readonly_run, interface::ticket_number_type ticket_number); - [[nodiscard]] bool - account_exists(const evmc::address& addr) const noexcept override; + [[nodiscard]] auto + account_exists(const evmc::address& addr) const noexcept -> bool override; - [[nodiscard]] evmc::bytes32 + [[nodiscard]] auto get_storage(const evmc::address& addr, - const evmc::bytes32& key) const noexcept override final; + const evmc::bytes32& key) const noexcept -> evmc::bytes32 final; - evmc_storage_status + auto set_storage(const evmc::address& addr, const evmc::bytes32& key, - const evmc::bytes32& value) noexcept override final; + const evmc::bytes32& value) noexcept -> evmc_storage_status final; - [[nodiscard]] evmc::uint256be - get_balance(const evmc::address& addr) const noexcept override final; + [[nodiscard]] auto + get_balance(const evmc::address& addr) const noexcept -> evmc::uint256be final; - [[nodiscard]] size_t - get_code_size(const evmc::address& addr) const noexcept override final; + [[nodiscard]] auto + get_code_size(const evmc::address& addr) const noexcept -> size_t final; - [[nodiscard]] evmc::bytes32 - get_code_hash(const evmc::address& addr) const noexcept override final; + [[nodiscard]] auto + get_code_hash(const evmc::address& addr) const noexcept -> evmc::bytes32 final; - size_t copy_code(const evmc::address& addr, + auto copy_code(const evmc::address& addr, size_t code_offset, uint8_t* buffer_data, - size_t buffer_size) const noexcept override final; + size_t buffer_size) const noexcept -> size_t final; void selfdestruct(const evmc::address& addr, - const evmc::address& beneficiary) noexcept override final; + const evmc::address& beneficiary) noexcept final; - evmc::result call(const evmc_message& msg) noexcept override final; + auto call(const evmc_message& msg) noexcept -> evmc::result final; - [[nodiscard]] evmc_tx_context - get_tx_context() const noexcept override final; + [[nodiscard]] auto + get_tx_context() const noexcept -> evmc_tx_context final; - [[nodiscard]] evmc::bytes32 - get_block_hash(int64_t number) const noexcept override final; + [[nodiscard]] auto + get_block_hash(int64_t number) const noexcept -> evmc::bytes32 final; void emit_log( const evmc::address& addr, @@ -80,14 +80,14 @@ namespace cbdc::threepc::agent::runner { size_t data_size, // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays) const evmc::bytes32 topics[], - size_t topics_count) noexcept override final; + size_t topics_count) noexcept final; - evmc_access_status - access_account(const evmc::address& addr) noexcept override final; + auto + access_account(const evmc::address& addr) noexcept -> evmc_access_status final; - evmc_access_status + auto access_storage(const evmc::address& addr, - const evmc::bytes32& key) noexcept override final; + const evmc::bytes32& key) noexcept -> evmc_access_status final; using indexed_logs_type = std::unordered_map>; diff --git a/src/3pc/agent/runners/evm/http_server.cpp b/src/3pc/agent/runners/evm/http_server.cpp index 1a0468785..f389e476c 100644 --- a/src/3pc/agent/runners/evm/http_server.cpp +++ b/src/3pc/agent/runners/evm/http_server.cpp @@ -48,7 +48,8 @@ namespace cbdc::threepc::agent::rpc { const std::string& method, const Json::Value& params, const server_type::result_callback_type& callback) -> bool { - m_log->trace("http_server::request_handler() received request", method); + m_log->trace("http_server::request_handler() received request", + method); auto maybe_handled = handle_supported(method, params, callback); if(maybe_handled.has_value()) { diff --git a/src/3pc/agent/runners/evm/impl.cpp b/src/3pc/agent/runners/evm/impl.cpp index c4db6813b..f70232223 100644 --- a/src/3pc/agent/runners/evm/impl.cpp +++ b/src/3pc/agent/runners/evm/impl.cpp @@ -453,8 +453,9 @@ namespace cbdc::threepc::agent::runner { min_gas = min_gas + creation_gas; } - return std::make_pair(min_gas, - !(evmtx.m_gas_limit < min_gas && !is_readonly_run)); + return std::make_pair( + min_gas, + !(evmtx.m_gas_limit < min_gas && !is_readonly_run)); } auto evm_runner::make_message(const evmc::address& from, diff --git a/src/3pc/agent/runners/evm/impl.hpp b/src/3pc/agent/runners/evm/impl.hpp index af03d2398..3341c94c0 100644 --- a/src/3pc/agent/runners/evm/impl.hpp +++ b/src/3pc/agent/runners/evm/impl.hpp @@ -88,8 +88,8 @@ namespace cbdc::threepc::agent::runner { auto run_get_account_code() -> bool; auto run_get_transaction() -> bool; auto run_get_transaction_receipt() -> bool; - auto run_execute_transaction(const evmc::address& from, bool is_readonly_run) - -> bool; + auto run_execute_transaction(const evmc::address& from, + bool is_readonly_run) -> bool; auto run_get_account() -> bool; auto run_get_block() -> bool; auto run_get_logs() -> bool; @@ -101,8 +101,9 @@ namespace cbdc::threepc::agent::runner { const evm_tx& tx, bool is_readonly_run) -> evmc_tx_context; - static auto - make_message(const evmc::address& from, const evm_tx& tx, bool is_readonly_run) + static auto make_message(const evmc::address& from, + const evm_tx& tx, + bool is_readonly_run) -> std::pair; void handle_lock_from_account( diff --git a/src/3pc/agent/runners/interface.hpp b/src/3pc/agent/runners/interface.hpp index 48f5ca893..90bf3c8f6 100644 --- a/src/3pc/agent/runners/interface.hpp +++ b/src/3pc/agent/runners/interface.hpp @@ -19,7 +19,6 @@ namespace cbdc::threepc::agent::runner { // type alias for function bytecode using bytecode_type = cbdc::buffer; - /// Interface for a contract runner. Subclasses should implement /// application logic to enforce specific transaction semantics. class interface { diff --git a/src/3pc/broker/interface.hpp b/src/3pc/broker/interface.hpp index 4ad90fe5c..4dfc8058a 100644 --- a/src/3pc/broker/interface.hpp +++ b/src/3pc/broker/interface.hpp @@ -81,9 +81,11 @@ namespace cbdc::threepc::broker { /// Return type from a begin operation. Either a new ticket number or /// an error code. - using ticketnum_or_errcode_type = std::variant; + using ticketnum_or_errcode_type + = std::variant; /// Callback function type for a begin operation. - using begin_callback_type = std::function; + using begin_callback_type + = std::function; /// Acquires a new ticket number to begin a transaction. /// \param result_callback function to call with begin result.