-
Notifications
You must be signed in to change notification settings - Fork 25
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 #676 from gofractally/main
EdenOS Release 0.3
- Loading branch information
Showing
181 changed files
with
4,306 additions
and
15,268 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
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
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
add_executable(bios src/bios.cpp) | ||
target_include_directories(bios PUBLIC include) | ||
target_link_libraries(bios eosio-contract-simple-malloc) | ||
set_target_properties(bios PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ROOT_BINARY_DIR}) | ||
set_target_properties(bios PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ROOT_BINARY_DIR}/clsdk/contracts) | ||
|
||
add_executable(bios-abigen src/bios.cpp) | ||
target_include_directories(bios-abigen PUBLIC include) | ||
target_link_libraries(bios-abigen eosio-contract-abigen) | ||
add_custom_command(TARGET bios-abigen POST_BUILD | ||
COMMAND mkdir -p ${ROOT_BINARY_DIR}/clsdk/contracts | ||
COMMAND ${ROOT_BINARY_DIR}/cltester bios-abigen.wasm >${ROOT_BINARY_DIR}/clsdk/contracts/bios.abi | ||
) | ||
|
||
configure_file(include/bios/bios.hpp ${ROOT_BINARY_DIR}/clsdk/contracts/bios/include/bios/bios.hpp COPYONLY) | ||
configure_file(src/bios.cpp ${ROOT_BINARY_DIR}/clsdk/contracts/bios/src/bios.cpp COPYONLY) |
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 |
---|---|---|
@@ -1,32 +1,149 @@ | ||
#pragma once | ||
|
||
#include <eosio/bytes.hpp> | ||
#include <eosio/contract.hpp> | ||
#include <eosio/dispatcher.hpp> | ||
#include <eosio/multi_index.hpp> | ||
#include <eosio/privileged.hpp> | ||
|
||
#if defined(COMPILING_TESTS) | ||
#include <eosio/tester.hpp> | ||
#endif | ||
|
||
namespace bios | ||
{ | ||
struct abi_hash | ||
{ | ||
eosio::name owner; | ||
eosio::checksum256 hash; | ||
|
||
uint64_t primary_key() const { return owner.value; } | ||
}; | ||
EOSIO_REFLECT(abi_hash, owner, hash) | ||
|
||
typedef eosio::multi_index<"abihash"_n, abi_hash> abi_hash_table; | ||
|
||
class bios_contract : public eosio::contract | ||
{ | ||
public: | ||
using eosio::contract::contract; | ||
void newaccount() {} | ||
void updateauth() {} | ||
void deleteauth() {} | ||
void linkauth() {} | ||
void setcode() {} | ||
void setabi() {} | ||
void canceldelay() {} | ||
void setpriv(eosio::name account, bool is_priv) { eosio::set_privileged(account, is_priv); } | ||
|
||
void onblock() {} | ||
|
||
void newaccount(eosio::ignore<eosio::name> creator, | ||
eosio::ignore<eosio::name> name, | ||
eosio::ignore<eosio::authority> owner, | ||
eosio::ignore<eosio::authority> active) | ||
{ | ||
} | ||
|
||
void updateauth(eosio::ignore<eosio::name> account, | ||
eosio::ignore<eosio::name> permission, | ||
eosio::ignore<eosio::name> parent, | ||
eosio::ignore<eosio::authority> auth) | ||
{ | ||
} | ||
|
||
void deleteauth(eosio::ignore<eosio::name> account, eosio::ignore<eosio::name> permission) {} | ||
|
||
void linkauth(eosio::ignore<eosio::name> account, | ||
eosio::ignore<eosio::name> code, | ||
eosio::ignore<eosio::name> type, | ||
eosio::ignore<eosio::name> requirement) | ||
{ | ||
} | ||
|
||
void unlinkauth(eosio::ignore<eosio::name> account, | ||
eosio::ignore<eosio::name> code, | ||
eosio::ignore<eosio::name> type) | ||
{ | ||
} | ||
|
||
void canceldelay(eosio::ignore<eosio::permission_level> canceling_auth, | ||
eosio::ignore<eosio::checksum256> trx_id) | ||
{ | ||
} | ||
|
||
void setcode(eosio::ignore<eosio::name> account, | ||
eosio::ignore<uint8_t> vmtype, | ||
eosio::ignore<uint8_t> vmversion, | ||
eosio::ignore<eosio::bytes> code) | ||
{ | ||
} | ||
|
||
void setabi(eosio::name account, const eosio::bytes& abi); | ||
|
||
/** | ||
* Set privilege status for an account | ||
*/ | ||
void setpriv(eosio::name account, bool is_priv); | ||
|
||
/** | ||
* Set the resource limits of an account | ||
* | ||
* @param account - eosio::name of the account whose resource limit to be set | ||
* @param ram_bytes - ram limit in absolute bytes | ||
* @param net_weight - fractionally proportionate net limit of available resources based on (weight / total_weight_of_all_accounts) | ||
* @param cpu_weight - fractionally proportionate cpu limit of available resources based on (weight / total_weight_of_all_accounts) | ||
*/ | ||
void setalimits(eosio::name account, | ||
int64_t ram_bytes, | ||
int64_t net_weight, | ||
int64_t cpu_weight); | ||
|
||
/** | ||
* Set the blockchain parameters. | ||
*/ | ||
void setparams(const eosio::blockchain_parameters& params); | ||
|
||
/** | ||
* Check if the account eosio::name `from` passed in as param has authorization to access | ||
* current action, that is, if it is listed in the action’s allowed permissions vector. | ||
* | ||
* @param from - the account eosio::name to authorize | ||
*/ | ||
void reqauth(eosio::name from); | ||
|
||
/** | ||
* Activate a protocol feature | ||
* | ||
* @param feature_digest - hash of the protocol feature to activate. | ||
*/ | ||
void activate(const eosio::checksum256& feature_digest); | ||
|
||
/** | ||
* Assert that a protocol feature has been activated | ||
* | ||
* @param feature_digest - hash of the protocol feature to check for activation. | ||
*/ | ||
void reqactivated(const eosio::checksum256& feature_digest); | ||
}; | ||
EOSIO_ACTIONS(bios_contract, | ||
"eosio"_n, | ||
newaccount, | ||
updateauth, | ||
deleteauth, | ||
linkauth, | ||
setcode, | ||
setabi, | ||
canceldelay, | ||
setpriv) | ||
action(onblock), | ||
action(newaccount, creator, name, owner, active), | ||
action(updateauth, account, permission, parent, auth), | ||
action(deleteauth, account, permission), | ||
action(linkauth, account, code, type, requirement), | ||
action(unlinkauth, account, code, type), | ||
action(canceldelay, canceling_auth, trx_id), | ||
action(setcode, account, vmtype, vmversion, code), | ||
action(setabi, account, abi), | ||
action(setpriv, account, is_priv), | ||
action(setalimits, account, ram_bytes, net_weight, cpu_weight), | ||
action(setparams, params), | ||
action(reqauth, from), | ||
action(activate, feature_digest), | ||
action(reqactivated, feature_digest)) | ||
|
||
#if defined(COMPILING_TESTS) | ||
void activate(eosio::test_chain& chain, const std::vector<eosio::checksum256>& features) | ||
{ | ||
for (auto& feature : features) | ||
chain.as("eosio"_n).act<actions::activate>(feature); | ||
chain.finish_block(); | ||
chain.finish_block(); | ||
} | ||
#endif | ||
|
||
} // namespace bios |
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 |
---|---|---|
@@ -1,3 +1,62 @@ | ||
#include <bios/bios.hpp> | ||
#include <eosio/abi_generator.hpp> | ||
|
||
namespace bios | ||
{ | ||
void bios_contract::setabi(eosio::name account, const eosio::bytes& abi) | ||
{ | ||
abi_hash_table table(get_self(), get_self().value); | ||
auto itr = table.find(account.value); | ||
if (itr == table.end()) | ||
{ | ||
table.emplace(account, [&](auto& row) { | ||
row.owner = account; | ||
row.hash = eosio::sha256(const_cast<char*>(abi.data.data()), abi.data.size()); | ||
}); | ||
} | ||
else | ||
{ | ||
table.modify(itr, eosio::same_payer, [&](auto& row) { | ||
row.hash = eosio::sha256(const_cast<char*>(abi.data.data()), abi.data.size()); | ||
}); | ||
} | ||
} | ||
|
||
void bios_contract::setpriv(eosio::name account, bool is_priv) | ||
{ | ||
require_auth(get_self()); | ||
set_privileged(account, is_priv); | ||
} | ||
|
||
void bios_contract::setalimits(eosio::name account, | ||
int64_t ram_bytes, | ||
int64_t net_weight, | ||
int64_t cpu_weight) | ||
{ | ||
require_auth(get_self()); | ||
set_resource_limits(account, ram_bytes, net_weight, cpu_weight); | ||
} | ||
|
||
void bios_contract::setparams(const eosio::blockchain_parameters& params) | ||
{ | ||
require_auth(get_self()); | ||
set_blockchain_parameters(params); | ||
} | ||
|
||
void bios_contract::reqauth(eosio::name from) { require_auth(from); } | ||
|
||
void bios_contract::activate(const eosio::checksum256& feature_digest) | ||
{ | ||
require_auth(get_self()); | ||
preactivate_feature(feature_digest); | ||
} | ||
|
||
void bios_contract::reqactivated(const eosio::checksum256& feature_digest) | ||
{ | ||
eosio::check(eosio::is_feature_activated(feature_digest), | ||
"protocol feature is not activated"); | ||
} | ||
} // namespace bios | ||
|
||
EOSIO_ACTION_DISPATCHER(bios::actions) | ||
EOSIO_ABIGEN(actions(bios::actions), table("abihash"_n, bios::abi_hash)) |
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,15 @@ | ||
add_executable(bios2 src/bios2.cpp) | ||
target_include_directories(bios2 PUBLIC include) | ||
target_link_libraries(bios2 eosio-contract-simple-malloc) | ||
set_target_properties(bios2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ROOT_BINARY_DIR}/clsdk/contracts) | ||
|
||
add_executable(bios2-abigen src/bios2.cpp) | ||
target_include_directories(bios2-abigen PUBLIC include) | ||
target_link_libraries(bios2-abigen eosio-contract-abigen) | ||
add_custom_command(TARGET bios2-abigen POST_BUILD | ||
COMMAND mkdir -p ${ROOT_BINARY_DIR}/clsdk/contracts | ||
COMMAND ${ROOT_BINARY_DIR}/cltester bios2-abigen.wasm >${ROOT_BINARY_DIR}/clsdk/contracts/bios2.abi | ||
) | ||
|
||
configure_file(include/bios2/bios2.hpp ${ROOT_BINARY_DIR}/clsdk/contracts/bios2/include/bios2/bios2.hpp COPYONLY) | ||
configure_file(src/bios2.cpp ${ROOT_BINARY_DIR}/clsdk/contracts/bios2/src/bios2.cpp COPYONLY) |
Oops, something went wrong.