Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Maurer <[email protected]>
  • Loading branch information
maurermi committed Apr 6, 2023
1 parent 77a5338 commit ce7e857
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 50 deletions.
3 changes: 2 additions & 1 deletion src/3pc/agent/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<response> resp) {
assert(resp.has_value());
Expand Down
20 changes: 11 additions & 9 deletions src/3pc/agent/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/3pc/agent/impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/3pc/agent/runners/evm/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
50 changes: 25 additions & 25 deletions src/3pc/agent/runners/evm/host.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,58 +36,58 @@ 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,
const uint8_t* data,
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<evmc::address, std::vector<evm_log>>;
Expand Down
3 changes: 2 additions & 1 deletion src/3pc/agent/runners/evm/http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
5 changes: 3 additions & 2 deletions src/3pc/agent/runners/evm/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/3pc/agent/runners/evm/impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<evmc_message, bool>;

void handle_lock_from_account(
Expand Down
1 change: 0 additions & 1 deletion src/3pc/agent/runners/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions src/3pc/broker/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ticket_number_type, error_code>;
using ticketnum_or_errcode_type
= std::variant<ticket_number_type, error_code>;
/// Callback function type for a begin operation.
using begin_callback_type = std::function<void(ticketnum_or_errcode_type)>;
using begin_callback_type
= std::function<void(ticketnum_or_errcode_type)>;

/// Acquires a new ticket number to begin a transaction.
/// \param result_callback function to call with begin result.
Expand Down

0 comments on commit ce7e857

Please sign in to comment.