-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #677 from eosnetworkfoundation/elmato/support-for-…
…eosevm-version Add support for EOSEVM version
- Loading branch information
Showing
19 changed files
with
1,089 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#pragma once | ||
#include <eosio/eosio.hpp> | ||
#include <eosio/asset.hpp> | ||
#include <eosio/time.hpp> | ||
#include <eosio/singleton.hpp> | ||
#include <evm_runtime/tables.hpp> | ||
namespace evm_runtime { | ||
|
||
struct fee_parameters; | ||
struct config_wrapper { | ||
|
||
config_wrapper(eosio::name self); | ||
~config_wrapper(); | ||
|
||
void flush(); | ||
bool exists(); | ||
|
||
eosio::unsigned_int get_version()const; | ||
void set_version(const eosio::unsigned_int version); | ||
|
||
uint64_t get_chainid()const; | ||
void set_chainid(uint64_t chainid); | ||
|
||
const eosio::time_point_sec& get_genesis_time()const; | ||
void set_genesis_time(eosio::time_point_sec genesis_time); | ||
|
||
const eosio::asset& get_ingress_bridge_fee()const; | ||
void set_ingress_bridge_fee(const eosio::asset& ingress_bridge_fee); | ||
|
||
uint64_t get_gas_price()const; | ||
void set_gas_price(uint64_t gas_price); | ||
|
||
uint32_t get_miner_cut()const; | ||
void set_miner_cut(uint32_t miner_cut); | ||
|
||
uint32_t get_status()const; | ||
void set_status(uint32_t status); | ||
|
||
uint64_t get_evm_version()const; | ||
uint64_t get_evm_version_and_maybe_promote(); | ||
void set_evm_version(uint64_t new_version); | ||
|
||
void set_fee_parameters(const fee_parameters& fee_params, | ||
bool allow_any_to_be_unspecified); | ||
|
||
private: | ||
bool is_dirty()const; | ||
void set_dirty(); | ||
void clear_dirty(); | ||
|
||
eosio::time_point get_current_time()const; | ||
|
||
bool _dirty = false; | ||
bool _exists = false; | ||
config _cached_config; | ||
|
||
eosio::name _self; | ||
eosio::singleton<"config"_n, config> _config; | ||
mutable std::optional<eosio::time_point> current_time_point; | ||
}; | ||
|
||
} //namespace evm_runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
namespace evm_runtime { | ||
|
||
struct runtime_config { | ||
bool allow_special_signature = false; | ||
bool abort_on_failure = false; | ||
bool enforce_chain_id = true; | ||
bool allow_non_self_miner = true; | ||
}; | ||
|
||
} //namespace evm_runtime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <optional> | ||
#include <eosio/eosio.hpp> | ||
#include <evm_runtime/types.hpp> | ||
#include <silkworm/core/rlp/encode.hpp> | ||
#include <silkworm/core/types/transaction.hpp> | ||
|
||
namespace evm_runtime { | ||
|
||
using silkworm::Bytes; | ||
using silkworm::ByteView; | ||
|
||
struct transaction { | ||
|
||
transaction() = delete; | ||
explicit transaction(bytes rlptx) : rlptx_(std::move(rlptx)) {} | ||
explicit transaction(silkworm::Transaction tx) : tx_(std::move(tx)) {} | ||
|
||
const bytes& get_rlptx()const { | ||
if(!rlptx_) { | ||
eosio::check(tx_.has_value(), "no tx"); | ||
Bytes rlp; | ||
silkworm::rlp::encode(rlp, tx_.value()); | ||
rlptx_.emplace(bytes{rlp.begin(), rlp.end()}); | ||
} | ||
return rlptx_.value(); | ||
} | ||
|
||
const silkworm::Transaction& get_tx()const { | ||
if(!tx_) { | ||
eosio::check(rlptx_.has_value(), "no rlptx"); | ||
ByteView bv{(const uint8_t*)rlptx_->data(), rlptx_->size()}; | ||
silkworm::Transaction tmp; | ||
eosio::check(silkworm::rlp::decode(bv, tmp) && bv.empty(), "unable to decode transaction"); | ||
tx_.emplace(tmp); | ||
} | ||
return tx_.value(); | ||
} | ||
|
||
void recover_sender()const { | ||
eosio::check(tx_.has_value(), "no tx"); | ||
auto& tx = tx_.value(); | ||
tx.from.reset(); | ||
tx.recover_sender(); | ||
} | ||
|
||
private: | ||
mutable std::optional<bytes> rlptx_; | ||
mutable std::optional<silkworm::Transaction> tx_; | ||
}; | ||
|
||
} //namespace evm_runtime |
Oops, something went wrong.