This repository has been archived by the owner on Aug 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 574
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 #68 from EOSIO/develop
Merge develop into master
- Loading branch information
Showing
30 changed files
with
2,704 additions
and
137 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 |
---|---|---|
|
@@ -32,3 +32,4 @@ | |
*.app | ||
|
||
build/* | ||
.DS_Store |
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,10 @@ | ||
add_executable(eosio.bios.wasm ${CMAKE_CURRENT_SOURCE_DIR}/src/eosio.bios.cpp) | ||
target_include_directories(eosio.bios.wasm | ||
PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
set_target_properties(eosio.bios.wasm | ||
PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") | ||
|
||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/abi/eosio.bios.abi" "${CMAKE_CURRENT_BINARY_DIR}" 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 |
---|---|---|
@@ -0,0 +1,244 @@ | ||
{ | ||
"version": "eosio::abi/1.0", | ||
"types": [{ | ||
"new_type_name": "account_name", | ||
"type": "name" | ||
},{ | ||
"new_type_name": "permission_name", | ||
"type": "name" | ||
},{ | ||
"new_type_name": "action_name", | ||
"type": "name" | ||
},{ | ||
"new_type_name": "transaction_id_type", | ||
"type": "checksum256" | ||
},{ | ||
"new_type_name": "weight_type", | ||
"type": "uint16" | ||
}], | ||
"structs": [{ | ||
"name": "permission_level", | ||
"base": "", | ||
"fields": [ | ||
{"name":"actor", "type":"account_name"}, | ||
{"name":"permission", "type":"permission_name"} | ||
] | ||
},{ | ||
"name": "key_weight", | ||
"base": "", | ||
"fields": [ | ||
{"name":"key", "type":"public_key"}, | ||
{"name":"weight", "type":"weight_type"} | ||
] | ||
},{ | ||
"name": "permission_level_weight", | ||
"base": "", | ||
"fields": [ | ||
{"name":"permission", "type":"permission_level"}, | ||
{"name":"weight", "type":"weight_type"} | ||
] | ||
},{ | ||
"name": "wait_weight", | ||
"base": "", | ||
"fields": [ | ||
{"name":"wait_sec", "type":"uint32"}, | ||
{"name":"weight", "type":"weight_type"} | ||
] | ||
},{ | ||
"name": "authority", | ||
"base": "", | ||
"fields": [ | ||
{"name":"threshold", "type":"uint32"}, | ||
{"name":"keys", "type":"key_weight[]"}, | ||
{"name":"accounts", "type":"permission_level_weight[]"}, | ||
{"name":"waits", "type":"wait_weight[]"} | ||
] | ||
},{ | ||
"name": "newaccount", | ||
"base": "", | ||
"fields": [ | ||
{"name":"creator", "type":"account_name"}, | ||
{"name":"name", "type":"account_name"}, | ||
{"name":"owner", "type":"authority"}, | ||
{"name":"active", "type":"authority"} | ||
] | ||
},{ | ||
"name": "setcode", | ||
"base": "", | ||
"fields": [ | ||
{"name":"account", "type":"account_name"}, | ||
{"name":"vmtype", "type":"uint8"}, | ||
{"name":"vmversion", "type":"uint8"}, | ||
{"name":"code", "type":"bytes"} | ||
] | ||
},{ | ||
"name": "setabi", | ||
"base": "", | ||
"fields": [ | ||
{"name":"account", "type":"account_name"}, | ||
{"name":"abi", "type":"bytes"} | ||
] | ||
},{ | ||
"name": "abi_hash", | ||
"base": "", | ||
"fields": [ | ||
{"name":"owner", "type":"account_name"}, | ||
{"name":"hash", "type":"checksum256"} | ||
] | ||
},{ | ||
"name": "updateauth", | ||
"base": "", | ||
"fields": [ | ||
{"name":"account", "type":"account_name"}, | ||
{"name":"permission", "type":"permission_name"}, | ||
{"name":"parent", "type":"permission_name"}, | ||
{"name":"auth", "type":"authority"} | ||
] | ||
},{ | ||
"name": "deleteauth", | ||
"base": "", | ||
"fields": [ | ||
{"name":"account", "type":"account_name"}, | ||
{"name":"permission", "type":"permission_name"} | ||
] | ||
},{ | ||
"name": "linkauth", | ||
"base": "", | ||
"fields": [ | ||
{"name":"account", "type":"account_name"}, | ||
{"name":"code", "type":"account_name"}, | ||
{"name":"type", "type":"action_name"}, | ||
{"name":"requirement", "type":"permission_name"} | ||
] | ||
},{ | ||
"name": "unlinkauth", | ||
"base": "", | ||
"fields": [ | ||
{"name":"account", "type":"account_name"}, | ||
{"name":"code", "type":"account_name"}, | ||
{"name":"type", "type":"action_name"} | ||
] | ||
},{ | ||
"name": "canceldelay", | ||
"base": "", | ||
"fields": [ | ||
{"name":"canceling_auth", "type":"permission_level"}, | ||
{"name":"trx_id", "type":"transaction_id_type"} | ||
] | ||
},{ | ||
"name": "onerror", | ||
"base": "", | ||
"fields": [ | ||
{"name":"sender_id", "type":"uint128"}, | ||
{"name":"sent_trx", "type":"bytes"} | ||
] | ||
},{ | ||
"name": "set_account_limits", | ||
"base": "", | ||
"fields": [ | ||
{"name":"account", "type":"account_name"}, | ||
{"name":"ram_bytes", "type":"int64"}, | ||
{"name":"net_weight", "type":"int64"}, | ||
{"name":"cpu_weight", "type":"int64"} | ||
] | ||
},{ | ||
"name": "setpriv", | ||
"base": "", | ||
"fields": [ | ||
{"name":"account", "type":"account_name"}, | ||
{"name":"is_priv", "type":"int8"} | ||
] | ||
},{ | ||
"name": "set_global_limits", | ||
"base": "", | ||
"fields": [ | ||
{"name":"cpu_usec_per_period", "type":"int64"} | ||
] | ||
},{ | ||
"name": "producer_key", | ||
"base": "", | ||
"fields": [ | ||
{"name":"producer_name", "type":"account_name"}, | ||
{"name":"block_signing_key", "type":"public_key"} | ||
] | ||
},{ | ||
"name": "set_producers", | ||
"base": "", | ||
"fields": [ | ||
{"name":"schedule", "type":"producer_key[]"} | ||
] | ||
},{ | ||
"name": "require_auth", | ||
"base": "", | ||
"fields": [ | ||
{"name":"from", "type":"account_name"} | ||
] | ||
}], | ||
"actions": [{ | ||
"name": "newaccount", | ||
"type": "newaccount", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "setcode", | ||
"type": "setcode", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "setabi", | ||
"type": "setabi", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "updateauth", | ||
"type": "updateauth", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "deleteauth", | ||
"type": "deleteauth", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "linkauth", | ||
"type": "linkauth", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "unlinkauth", | ||
"type": "unlinkauth", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "canceldelay", | ||
"type": "canceldelay", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "onerror", | ||
"type": "onerror", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "setalimits", | ||
"type": "set_account_limits", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "setglimits", | ||
"type": "set_global_limits", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "setpriv", | ||
"type": "setpriv", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "setprods", | ||
"type": "set_producers", | ||
"ricardian_contract": "" | ||
},{ | ||
"name": "reqauth", | ||
"type": "require_auth", | ||
"ricardian_contract": "" | ||
} | ||
], | ||
"tables": [{ | ||
"name": "abihash", | ||
"type": "abi_hash", | ||
"index_type": "i64", | ||
"key_names": ["owner"], | ||
"key_types": ["account_name"] | ||
}], | ||
"ricardian_clauses": [], | ||
"abi_extensions": [] | ||
} |
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,70 @@ | ||
#pragma once | ||
#include <eosiolib/crypto.h> | ||
#include <eosiolib/eosio.hpp> | ||
#include <eosiolib/privileged.hpp> | ||
|
||
namespace eosio { | ||
|
||
struct abi_hash { | ||
account_name owner; | ||
checksum256 hash; | ||
auto primary_key()const { return owner; } | ||
|
||
EOSLIB_SERIALIZE( abi_hash, (owner)(hash) ) | ||
}; | ||
|
||
typedef eosio::multi_index< N(abihash), abi_hash> abi_hash_table; | ||
|
||
class bios : public contract { | ||
public: | ||
bios( action_name self ):contract(self){} | ||
|
||
void setpriv( account_name account, uint8_t ispriv ) { | ||
require_auth( _self ); | ||
set_privileged( account, ispriv ); | ||
} | ||
|
||
void setalimits( account_name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight ) { | ||
require_auth( _self ); | ||
set_resource_limits( account, ram_bytes, net_weight, cpu_weight ); | ||
} | ||
|
||
void setglimits( uint64_t ram, uint64_t net, uint64_t cpu ) { | ||
(void)ram; (void)net; (void)cpu; | ||
require_auth( _self ); | ||
} | ||
|
||
void setprods( std::vector<eosio::producer_key> schedule ) { | ||
(void)schedule; // schedule argument just forces the deserialization of the action data into vector<producer_key> (necessary check) | ||
require_auth( _self ); | ||
|
||
constexpr size_t max_stack_buffer_size = 512; | ||
size_t size = action_data_size(); | ||
char* buffer = (char*)( max_stack_buffer_size < size ? malloc(size) : alloca(size) ); | ||
read_action_data( buffer, size ); | ||
set_proposed_producers(buffer, size); | ||
} | ||
|
||
void reqauth( action_name from ) { | ||
require_auth( from ); | ||
} | ||
|
||
void setabi( account_name acnt, const bytes& abi ) { | ||
abi_hash_table table(_self, _self); | ||
auto itr = table.find( acnt ); | ||
if( itr == table.end() ) { | ||
table.emplace( acnt, [&]( auto& row ) { | ||
row.owner = acnt; | ||
sha256( const_cast<char*>(abi.data()), abi.size(), &row.hash ); | ||
}); | ||
} else { | ||
table.modify( itr, 0, [&]( auto& row ) { | ||
sha256( const_cast<char*>(abi.data()), abi.size(), &row.hash ); | ||
}); | ||
} | ||
} | ||
|
||
private: | ||
}; | ||
|
||
} /// namespace eosio |
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,3 @@ | ||
#include <eosio.bios/eosio.bios.hpp> | ||
|
||
EOSIO_ABI( eosio::bios, (setpriv)(setalimits)(setglimits)(setprods)(reqauth)(setabi) ) |
Oops, something went wrong.