From 609d666171b3701d394bed1a3a145e489633484d Mon Sep 17 00:00:00 2001 From: Igor Sikachyna Date: Wed, 13 Nov 2024 06:53:37 -0500 Subject: [PATCH] BLOCK-2575 - Sponsor account balance for uos.pool to avoid requiring its signature --- include/evm_runtime/evm_contract.hpp | 3 ++- src/actions.cpp | 8 ++++---- ultratests/eosevm.spec.ts | 6 ------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/evm_runtime/evm_contract.hpp b/include/evm_runtime/evm_contract.hpp index 35064bbe..79255071 100644 --- a/include/evm_runtime/evm_contract.hpp +++ b/include/evm_runtime/evm_contract.hpp @@ -128,7 +128,8 @@ class [[eosio::contract]] evm_contract : public contract #endif private: - void open_internal_balance(eosio::name owner); + /*ultra-igor-sikachyna---BLOCK-2575 review evm contract --- allow evm contract to sponsor ram for uos.pool account balance*/ + void open_internal_balance(eosio::name owner, bool ram_sponsored = false); std::shared_ptr _config; enum class status_flags : uint32_t diff --git a/src/actions.cpp b/src/actions.cpp index 080269e7..a2aebbc4 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -81,7 +81,7 @@ void evm_contract::init(const uint64_t chainid, const fee_parameters& fee_params }); open_internal_balance(get_self()); - open_internal_balance(uos_pool_account); + open_internal_balance(uos_pool_account, true); } void evm_contract::setfeeparams(const fee_parameters& fee_params) @@ -594,17 +594,17 @@ void evm_contract::open(eosio::name owner) { open_internal_balance(owner); } -void evm_contract::open_internal_balance(eosio::name owner) { +void evm_contract::open_internal_balance(eosio::name owner, bool ram_sponsored) { balances balance_table(get_self(), get_self().value); if(balance_table.find(owner.value) == balance_table.end()) - balance_table.emplace(owner, [&](balance& a) { + balance_table.emplace(ram_sponsored ? get_self() : owner, [&](balance& a) { a.owner = owner; a.balance.balance = eosio::asset(0, _config->get_token_symbol()); }); nextnonces nextnonce_table(get_self(), get_self().value); if(nextnonce_table.find(owner.value) == nextnonce_table.end()) - nextnonce_table.emplace(owner, [&](nextnonce& a) { + nextnonce_table.emplace(ram_sponsored ? get_self() : owner, [&](nextnonce& a) { a.owner = owner; }); } diff --git a/ultratests/eosevm.spec.ts b/ultratests/eosevm.spec.ts index 204578a6..dbc3d617 100644 --- a/ultratests/eosevm.spec.ts +++ b/ultratests/eosevm.spec.ts @@ -185,11 +185,6 @@ export default class Test extends UltraTest { super(); } - // handled by genesis plugin - // requiredProducers() { - // return 1; - // } - async onChainStart(ultra: UltraTestAPI) { ultra.addPlugins([genesis(ultra), system(ultra), ultraContracts(ultra), await ultraStartup(ultra)]); } @@ -205,7 +200,6 @@ export default class Test extends UltraTest { return [{ account: EVM_CONTRACT, contract: "../build/evm_runtime", - isPrivileged: true }] }