Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
a4b1d0d0
Y
YTBP
项目概览
YottaChain
/
YTBP
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
YTBP
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a4b1d0d0
编写于
4月 18, 2018
作者:
D
Daniel Larimer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup contract abi
上级
b5387e3a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
343 addition
and
330 deletion
+343
-330
libraries/chain/CMakeLists.txt
libraries/chain/CMakeLists.txt
+1
-0
libraries/chain/apply_context.cpp
libraries/chain/apply_context.cpp
+29
-10
libraries/chain/controller.cpp
libraries/chain/controller.cpp
+1
-296
libraries/chain/eosio_contract.cpp
libraries/chain/eosio_contract.cpp
+9
-10
libraries/chain/eosio_contract_abi.cpp
libraries/chain/eosio_contract_abi.cpp
+285
-0
libraries/chain/include/eosio/chain/apply_context.hpp
libraries/chain/include/eosio/chain/apply_context.hpp
+13
-9
libraries/chain/include/eosio/chain/controller.hpp
libraries/chain/include/eosio/chain/controller.hpp
+0
-3
libraries/chain/include/eosio/chain/eosio_contract.hpp
libraries/chain/include/eosio/chain/eosio_contract.hpp
+3
-0
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+2
-2
未找到文件。
libraries/chain/CMakeLists.txt
浏览文件 @
a4b1d0d0
...
...
@@ -15,6 +15,7 @@ add_library( eosio_chain
genesis_state.cpp
transaction_context.cpp
eosio_contract.cpp
eosio_contract_abi.cpp
# chain_config.cpp
# block_trace.cpp
...
...
libraries/chain/apply_context.cpp
浏览文件 @
a4b1d0d0
...
...
@@ -7,6 +7,7 @@
#include <eosio/chain/resource_limits.hpp>
#include <eosio/chain/scope_sequence_object.hpp>
#include <eosio/chain/account_object.hpp>
#include <eosio/chain/global_property_object.hpp>
#include <boost/container/flat_set.hpp>
using
boost
::
container
::
flat_set
;
...
...
@@ -36,11 +37,11 @@ action_trace apply_context::exec_one()
action_receipt
r
;
r
.
receiver
=
receiver
;
r
.
act_digest
=
digest_type
::
hash
(
act
);
r
.
global_sequence
=
control
.
next_global_sequence
();
r
.
recv_sequence
=
control
.
next_recv_sequence
(
receiver
);
r
.
global_sequence
=
next_global_sequence
();
r
.
recv_sequence
=
next_recv_sequence
(
receiver
);
for
(
const
auto
&
auth
:
act
.
authorization
)
{
r
.
auth_sequence
[
auth
.
actor
]
=
control
.
next_auth_sequence
(
auth
.
actor
);
r
.
auth_sequence
[
auth
.
actor
]
=
next_auth_sequence
(
auth
.
actor
);
}
action_trace
t
(
r
);
...
...
@@ -313,7 +314,7 @@ const table_id_object& apply_context::find_or_create_table( name code, name scop
update_db_usage
(
payer
,
config
::
billable_size_v
<
table_id_object
>
);
return
mutable_
db
.
create
<
table_id_object
>
([
&
](
table_id_object
&
t_id
){
return
db
.
create
<
table_id_object
>
([
&
](
table_id_object
&
t_id
){
t_id
.
code
=
code
;
t_id
.
scope
=
scope
;
t_id
.
table
=
table
;
...
...
@@ -323,7 +324,7 @@ const table_id_object& apply_context::find_or_create_table( name code, name scop
void
apply_context
::
remove_table
(
const
table_id_object
&
tid
)
{
update_db_usage
(
tid
.
payer
,
-
config
::
billable_size_v
<
table_id_object
>
);
mutable_
db
.
remove
(
tid
);
db
.
remove
(
tid
);
}
vector
<
account_name
>
apply_context
::
get_active_producers
()
const
{
...
...
@@ -431,7 +432,7 @@ int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table,
FC_ASSERT
(
payer
!=
account_name
(),
"must specify a valid account to pay for new record"
);
const
auto
&
obj
=
mutable_
db
.
create
<
key_value_object
>
(
[
&
](
auto
&
o
)
{
const
auto
&
obj
=
db
.
create
<
key_value_object
>
(
[
&
](
auto
&
o
)
{
o
.
t_id
=
tableid
;
o
.
primary_key
=
id
;
o
.
value
.
resize
(
buffer_size
);
...
...
@@ -439,7 +440,7 @@ int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table,
memcpy
(
o
.
value
.
data
(),
buffer
,
buffer_size
);
});
mutable_
db
.
modify
(
tab
,
[
&
](
auto
&
t
)
{
db
.
modify
(
tab
,
[
&
](
auto
&
t
)
{
++
t
.
count
;
});
...
...
@@ -474,7 +475,7 @@ void apply_context::db_update_i64( int iterator, account_name payer, const char*
update_db_usage
(
obj
.
payer
,
new_size
-
old_size
);
}
mutable_
db
.
modify
(
obj
,
[
&
](
auto
&
o
)
{
db
.
modify
(
obj
,
[
&
](
auto
&
o
)
{
o
.
value
.
resize
(
buffer_size
);
memcpy
(
o
.
value
.
data
(),
buffer
,
buffer_size
);
o
.
payer
=
payer
;
...
...
@@ -491,10 +492,10 @@ void apply_context::db_remove_i64( int iterator ) {
update_db_usage
(
obj
.
payer
,
-
(
obj
.
value
.
size
()
+
config
::
billable_size_v
<
key_value_object
>
)
);
mutable_
db
.
modify
(
table_obj
,
[
&
](
auto
&
t
)
{
db
.
modify
(
table_obj
,
[
&
](
auto
&
t
)
{
--
t
.
count
;
});
mutable_
db
.
remove
(
obj
);
db
.
remove
(
obj
);
if
(
table_obj
.
count
==
0
)
{
remove_table
(
table_obj
);
...
...
@@ -611,4 +612,22 @@ int apply_context::db_end_i64( uint64_t code, uint64_t scope, uint64_t table ) {
return
keyval_cache
.
cache_table
(
*
tab
);
}
uint64_t
apply_context
::
next_global_sequence
()
{
const
auto
&
p
=
control
.
get_dynamic_global_properties
();
db
.
modify
(
p
,
[
&
](
auto
&
dgp
)
{
++
dgp
.
global_action_sequence
;
});
return
p
.
global_action_sequence
;
}
uint64_t
apply_context
::
next_recv_sequence
(
account_name
receiver
)
{
return
0
;
}
uint64_t
apply_context
::
next_auth_sequence
(
account_name
actor
)
{
return
0
;
}
}
}
/// eosio::chain
libraries/chain/controller.cpp
浏览文件 @
a4b1d0d0
...
...
@@ -25,7 +25,6 @@ namespace eosio { namespace chain {
using
resource_limits
::
resource_limits_manager
;
abi_def
eos_contract_abi
(
const
abi_def
&
eosio_system_abi
);
struct
pending_state
{
pending_state
(
database
::
session
&&
s
)
...
...
@@ -217,7 +216,7 @@ struct controller_impl {
a
.
privileged
=
true
;
if
(
name
==
config
::
system_account_name
)
{
a
.
set_abi
(
eos_contract_abi
(
abi_def
()));
a
.
set_abi
(
eos
io
_contract_abi
(
abi_def
()));
}
});
const
auto
&
owner
=
db
.
create
<
permission_object
>
([
&
](
permission_object
&
p
)
{
...
...
@@ -776,20 +775,6 @@ time_point controller::head_block_time()const {
return
my
->
head
->
header
.
timestamp
;
}
uint64_t
controller
::
next_global_sequence
()
{
const
auto
&
p
=
get_dynamic_global_properties
();
my
->
db
.
modify
(
p
,
[
&
](
auto
&
dgp
)
{
++
dgp
.
global_action_sequence
;
});
return
p
.
global_action_sequence
;
}
uint64_t
controller
::
next_recv_sequence
(
account_name
receiver
)
{
return
0
;
}
uint64_t
controller
::
next_auth_sequence
(
account_name
actor
)
{
return
0
;
}
void
controller
::
record_transaction
(
const
transaction_metadata_ptr
&
trx
)
{
my
->
record_transaction
(
trx
);
}
...
...
@@ -853,286 +838,6 @@ void controller::pop_block() {
}
abi_def
eos_contract_abi
(
const
abi_def
&
eosio_system_abi
)
{
abi_def
eos_abi
(
eosio_system_abi
);
eos_abi
.
types
.
push_back
(
type_def
{
"account_name"
,
"name"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"table_name"
,
"name"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"share_type"
,
"int64"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"onerror"
,
"bytes"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"context_free_type"
,
"bytes"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"weight_type"
,
"uint16"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"fields"
,
"field[]"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"time_point_sec"
,
"time"
}
);
// TODO add ricardian contracts
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"setcode"
),
"setcode"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"setabi"
),
"setabi"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"linkauth"
),
"linkauth"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"unlinkauth"
),
"unlinkauth"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"updateauth"
),
"updateauth"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"deleteauth"
),
"deleteauth"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"newaccount"
),
"newaccount"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"postrecovery"
),
"postrecovery"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"passrecovery"
),
"passrecovery"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"vetorecovery"
),
"vetorecovery"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"onerror"
),
"onerror"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"onblock"
),
"onblock"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"canceldelay"
),
"canceldelay"
,
""
}
);
// TODO add any ricardian_clauses
//
// ACTION PAYLOADS
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"setcode"
,
""
,
{
{
"account"
,
"account_name"
},
{
"vmtype"
,
"uint8"
},
{
"vmversion"
,
"uint8"
},
{
"code"
,
"bytes"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"setabi"
,
""
,
{
{
"account"
,
"account_name"
},
{
"abi"
,
"abi_def"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"updateauth"
,
""
,
{
{
"account"
,
"account_name"
},
{
"permission"
,
"permission_name"
},
{
"parent"
,
"permission_name"
},
{
"data"
,
"authority"
},
{
"delay"
,
"uint32"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"linkauth"
,
""
,
{
{
"account"
,
"account_name"
},
{
"code"
,
"account_name"
},
{
"type"
,
"action_name"
},
{
"requirement"
,
"permission_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"unlinkauth"
,
""
,
{
{
"account"
,
"account_name"
},
{
"code"
,
"account_name"
},
{
"type"
,
"action_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"deleteauth"
,
""
,
{
{
"account"
,
"account_name"
},
{
"permission"
,
"permission_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"newaccount"
,
""
,
{
{
"creator"
,
"account_name"
},
{
"name"
,
"account_name"
},
{
"owner"
,
"authority"
},
{
"active"
,
"authority"
},
{
"recovery"
,
"authority"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"postrecovery"
,
""
,
{
{
"account"
,
"account_name"
},
{
"data"
,
"authority"
},
{
"memo"
,
"string"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"passrecovery"
,
""
,
{
{
"account"
,
"account_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"vetorecovery"
,
""
,
{
{
"account"
,
"account_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"canceldelay"
,
""
,
{
{
"trx_id"
,
"transaction_id_type"
},
}
});
// DATABASE RECORDS
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"pending_recovery"
,
""
,
{
{
"account"
,
"name"
},
{
"request_id"
,
"uint128"
},
{
"update"
,
"updateauth"
},
{
"memo"
,
"string"
}
}
});
eos_abi
.
tables
.
emplace_back
(
table_def
{
"recovery"
,
"i64"
,
{
"account"
,
},
{
"name"
},
"pending_recovery"
});
// abi_def fields
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"field"
,
""
,
{
{
"name"
,
"field_name"
},
{
"type"
,
"type_name"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"struct_def"
,
""
,
{
{
"name"
,
"type_name"
},
{
"base"
,
"type_name"
},
{
"fields"
,
"fields"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"permission_level"
,
""
,
{
{
"actor"
,
"account_name"
},
{
"permission"
,
"permission_name"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"action"
,
""
,
{
{
"account"
,
"account_name"
},
{
"name"
,
"action_name"
},
{
"authorization"
,
"permission_level[]"
},
{
"data"
,
"bytes"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"permission_level_weight"
,
""
,
{
{
"permission"
,
"permission_level"
},
{
"weight"
,
"weight_type"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"transaction_header"
,
""
,
{
{
"expiration"
,
"time_point_sec"
},
{
"region"
,
"uint16"
},
{
"ref_block_num"
,
"uint16"
},
{
"ref_block_prefix"
,
"uint32"
},
{
"max_net_usage_words"
,
"varuint32"
},
{
"max_kcpu_usage"
,
"varuint32"
},
{
"delay_sec"
,
"varuint32"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"transaction"
,
"transaction_header"
,
{
{
"context_free_actions"
,
"action[]"
},
{
"actions"
,
"action[]"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"signed_transaction"
,
"transaction"
,
{
{
"signatures"
,
"signature[]"
},
{
"context_free_data"
,
"bytes[]"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"key_weight"
,
""
,
{
{
"key"
,
"public_key"
},
{
"weight"
,
"weight_type"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"authority"
,
""
,
{
{
"threshold"
,
"uint32"
},
{
"keys"
,
"key_weight[]"
},
{
"accounts"
,
"permission_level_weight[]"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"clause_pair"
,
""
,
{
{
"id"
,
"string"
},
{
"body"
,
"string"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"type_def"
,
""
,
{
{
"new_type_name"
,
"type_name"
},
{
"type"
,
"type_name"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"action_def"
,
""
,
{
{
"name"
,
"action_name"
},
{
"type"
,
"type_name"
},
{
"ricardian_contract"
,
"string"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"table_def"
,
""
,
{
{
"name"
,
"table_name"
},
{
"index_type"
,
"type_name"
},
{
"key_names"
,
"field_name[]"
},
{
"key_types"
,
"type_name[]"
},
{
"type"
,
"type_name"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"abi_def"
,
""
,
{
{
"types"
,
"type_def[]"
},
{
"structs"
,
"struct_def[]"
},
{
"actions"
,
"action_def[]"
},
{
"tables"
,
"table_def[]"
},
{
"ricardian_clauses"
,
"clause_pair[]"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"block_header"
,
""
,
{
{
"previous"
,
"checksum256"
},
{
"timestamp"
,
"uint32"
},
{
"transaction_mroot"
,
"checksum256"
},
{
"action_mroot"
,
"checksum256"
},
{
"block_mroot"
,
"checksum256"
},
{
"producer"
,
"account_name"
},
{
"schedule_version"
,
"uint32"
},
{
"new_producers"
,
"producer_schedule?"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"onblock"
,
""
,
{
{
"header"
,
"block_header"
}
}
});
return
eos_abi
;
}
/**
* @param actions - the actions to check authorization across
* @param provided_keys - the set of public keys which have authorized the transaction
...
...
libraries/chain/eosio_contract.cpp
浏览文件 @
a4b1d0d0
...
...
@@ -26,7 +26,6 @@
namespace
eosio
{
namespace
chain
{
abi_def
eos_contract_abi
(
const
abi_def
&
eosio_system_abi
);
uint128_t
transaction_id_to_sender_id
(
const
transaction_id_type
&
tid
)
{
fc
::
uint128_t
_id
(
tid
.
_hash
[
3
],
tid
.
_hash
[
2
]);
...
...
@@ -54,7 +53,7 @@ void apply_eosio_newaccount(apply_context& context) {
EOS_ASSERT
(
validate
(
create
.
active
),
action_validate_exception
,
"Invalid active authority"
);
EOS_ASSERT
(
validate
(
create
.
recovery
),
action_validate_exception
,
"Invalid recovery authority"
);
auto
&
db
=
context
.
mutable_
db
;
auto
&
db
=
context
.
db
;
auto
name_str
=
name
(
create
.
name
).
to_string
();
...
...
@@ -111,7 +110,7 @@ void apply_eosio_newaccount(apply_context& context) {
}
FC_CAPTURE_AND_RETHROW
(
(
create
)
)
}
void
apply_eosio_setcode
(
apply_context
&
context
)
{
auto
&
db
=
context
.
mutable_
db
;
auto
&
db
=
context
.
db
;
auto
&
resources
=
context
.
mutable_controller
.
get_mutable_resource_limits_manager
();
auto
act
=
context
.
act
.
data_as
<
setcode
>
();
context
.
require_authorization
(
act
.
account
);
...
...
@@ -154,7 +153,7 @@ void apply_eosio_setcode(apply_context& context) {
}
void
apply_eosio_setabi
(
apply_context
&
context
)
{
auto
&
db
=
context
.
mutable_
db
;
auto
&
db
=
context
.
db
;
auto
&
resources
=
context
.
mutable_controller
.
get_mutable_resource_limits_manager
();
auto
act
=
context
.
act
.
data_as
<
setabi
>
();
...
...
@@ -162,7 +161,7 @@ void apply_eosio_setabi(apply_context& context) {
// if system account append native abi
if
(
act
.
account
==
eosio
::
chain
::
config
::
system_account_name
)
{
act
.
abi
=
eos_contract_abi
(
act
.
abi
);
act
.
abi
=
eos
io
_contract_abi
(
act
.
abi
);
}
/// if an ABI is specified make sure it is well formed and doesn't
/// reference any undefined types
...
...
@@ -190,7 +189,7 @@ void apply_eosio_updateauth(apply_context& context) {
auto
&
resources
=
context
.
mutable_controller
.
get_mutable_resource_limits_manager
();
// context.require_write_lock( config::eosio_auth_scope );
auto
&
db
=
context
.
mutable_
db
;
auto
&
db
=
context
.
db
;
auto
update
=
context
.
act
.
data_as
<
updateauth
>
();
EOS_ASSERT
(
!
update
.
permission
.
empty
(),
action_validate_exception
,
"Cannot create authority with empty name"
);
...
...
@@ -294,7 +293,7 @@ void apply_eosio_deleteauth(apply_context& context) {
EOS_ASSERT
(
remove
.
permission
!=
config
::
active_name
,
action_validate_exception
,
"Cannot delete active authority"
);
EOS_ASSERT
(
remove
.
permission
!=
config
::
owner_name
,
action_validate_exception
,
"Cannot delete owner authority"
);
auto
&
db
=
context
.
mutable_
db
;
auto
&
db
=
context
.
db
;
context
.
require_authorization
(
remove
.
account
);
// TODO/QUESTION:
// Inconsistency between permissions that can be satisfied to create/modify (via updateauth) a permission and the
...
...
@@ -331,7 +330,7 @@ void apply_eosio_linkauth(apply_context& context) {
context
.
require_authorization
(
requirement
.
account
);
auto
&
db
=
context
.
mutable_
db
;
auto
&
db
=
context
.
db
;
const
auto
*
account
=
db
.
find
<
account_object
,
by_name
>
(
requirement
.
account
);
EOS_ASSERT
(
account
!=
nullptr
,
account_query_exception
,
"Failed to retrieve account: ${account}"
,
(
"account"
,
requirement
.
account
));
// Redundant?
...
...
@@ -371,7 +370,7 @@ void apply_eosio_linkauth(apply_context& context) {
void
apply_eosio_unlinkauth
(
apply_context
&
context
)
{
auto
&
resources
=
context
.
mutable_controller
.
get_mutable_resource_limits_manager
();
auto
&
db
=
context
.
mutable_
db
;
auto
&
db
=
context
.
db
;
auto
unlink
=
context
.
act
.
data_as
<
unlinkauth
>
();
context
.
require_authorization
(
unlink
.
account
);
...
...
@@ -396,7 +395,7 @@ void apply_eosio_onerror(apply_context& context) {
static
const
abi_serializer
&
get_abi_serializer
()
{
static
optional
<
abi_serializer
>
_abi_serializer
;
if
(
!
_abi_serializer
)
{
_abi_serializer
.
emplace
(
eos_contract_abi
(
abi_def
()));
_abi_serializer
.
emplace
(
eos
io
_contract_abi
(
abi_def
()));
}
return
*
_abi_serializer
;
...
...
libraries/chain/eosio_contract_abi.cpp
0 → 100644
浏览文件 @
a4b1d0d0
#include <eosio/chain/eosio_contract.hpp>
namespace
eosio
{
namespace
chain
{
abi_def
eosio_contract_abi
(
const
abi_def
&
eosio_system_abi
)
{
abi_def
eos_abi
(
eosio_system_abi
);
eos_abi
.
types
.
push_back
(
type_def
{
"account_name"
,
"name"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"table_name"
,
"name"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"share_type"
,
"int64"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"onerror"
,
"bytes"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"context_free_type"
,
"bytes"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"weight_type"
,
"uint16"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"fields"
,
"field[]"
}
);
eos_abi
.
types
.
push_back
(
type_def
{
"time_point_sec"
,
"time"
}
);
// TODO add ricardian contracts
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"setcode"
),
"setcode"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"setabi"
),
"setabi"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"linkauth"
),
"linkauth"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"unlinkauth"
),
"unlinkauth"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"updateauth"
),
"updateauth"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"deleteauth"
),
"deleteauth"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"newaccount"
),
"newaccount"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"postrecovery"
),
"postrecovery"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"passrecovery"
),
"passrecovery"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"vetorecovery"
),
"vetorecovery"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"onerror"
),
"onerror"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"onblock"
),
"onblock"
,
""
}
);
eos_abi
.
actions
.
push_back
(
action_def
{
name
(
"canceldelay"
),
"canceldelay"
,
""
}
);
// TODO add any ricardian_clauses
//
// ACTION PAYLOADS
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"setcode"
,
""
,
{
{
"account"
,
"account_name"
},
{
"vmtype"
,
"uint8"
},
{
"vmversion"
,
"uint8"
},
{
"code"
,
"bytes"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"setabi"
,
""
,
{
{
"account"
,
"account_name"
},
{
"abi"
,
"abi_def"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"updateauth"
,
""
,
{
{
"account"
,
"account_name"
},
{
"permission"
,
"permission_name"
},
{
"parent"
,
"permission_name"
},
{
"data"
,
"authority"
},
{
"delay"
,
"uint32"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"linkauth"
,
""
,
{
{
"account"
,
"account_name"
},
{
"code"
,
"account_name"
},
{
"type"
,
"action_name"
},
{
"requirement"
,
"permission_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"unlinkauth"
,
""
,
{
{
"account"
,
"account_name"
},
{
"code"
,
"account_name"
},
{
"type"
,
"action_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"deleteauth"
,
""
,
{
{
"account"
,
"account_name"
},
{
"permission"
,
"permission_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"newaccount"
,
""
,
{
{
"creator"
,
"account_name"
},
{
"name"
,
"account_name"
},
{
"owner"
,
"authority"
},
{
"active"
,
"authority"
},
{
"recovery"
,
"authority"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"postrecovery"
,
""
,
{
{
"account"
,
"account_name"
},
{
"data"
,
"authority"
},
{
"memo"
,
"string"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"passrecovery"
,
""
,
{
{
"account"
,
"account_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"vetorecovery"
,
""
,
{
{
"account"
,
"account_name"
},
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"canceldelay"
,
""
,
{
{
"trx_id"
,
"transaction_id_type"
},
}
});
// DATABASE RECORDS
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"pending_recovery"
,
""
,
{
{
"account"
,
"name"
},
{
"request_id"
,
"uint128"
},
{
"update"
,
"updateauth"
},
{
"memo"
,
"string"
}
}
});
eos_abi
.
tables
.
emplace_back
(
table_def
{
"recovery"
,
"i64"
,
{
"account"
,
},
{
"name"
},
"pending_recovery"
});
// abi_def fields
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"field"
,
""
,
{
{
"name"
,
"field_name"
},
{
"type"
,
"type_name"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"struct_def"
,
""
,
{
{
"name"
,
"type_name"
},
{
"base"
,
"type_name"
},
{
"fields"
,
"fields"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"permission_level"
,
""
,
{
{
"actor"
,
"account_name"
},
{
"permission"
,
"permission_name"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"action"
,
""
,
{
{
"account"
,
"account_name"
},
{
"name"
,
"action_name"
},
{
"authorization"
,
"permission_level[]"
},
{
"data"
,
"bytes"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"permission_level_weight"
,
""
,
{
{
"permission"
,
"permission_level"
},
{
"weight"
,
"weight_type"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"transaction_header"
,
""
,
{
{
"expiration"
,
"time_point_sec"
},
{
"region"
,
"uint16"
},
{
"ref_block_num"
,
"uint16"
},
{
"ref_block_prefix"
,
"uint32"
},
{
"max_net_usage_words"
,
"varuint32"
},
{
"max_kcpu_usage"
,
"varuint32"
},
{
"delay_sec"
,
"varuint32"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"transaction"
,
"transaction_header"
,
{
{
"context_free_actions"
,
"action[]"
},
{
"actions"
,
"action[]"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"signed_transaction"
,
"transaction"
,
{
{
"signatures"
,
"signature[]"
},
{
"context_free_data"
,
"bytes[]"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"key_weight"
,
""
,
{
{
"key"
,
"public_key"
},
{
"weight"
,
"weight_type"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"authority"
,
""
,
{
{
"threshold"
,
"uint32"
},
{
"keys"
,
"key_weight[]"
},
{
"accounts"
,
"permission_level_weight[]"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"clause_pair"
,
""
,
{
{
"id"
,
"string"
},
{
"body"
,
"string"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"type_def"
,
""
,
{
{
"new_type_name"
,
"type_name"
},
{
"type"
,
"type_name"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"action_def"
,
""
,
{
{
"name"
,
"action_name"
},
{
"type"
,
"type_name"
},
{
"ricardian_contract"
,
"string"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"table_def"
,
""
,
{
{
"name"
,
"table_name"
},
{
"index_type"
,
"type_name"
},
{
"key_names"
,
"field_name[]"
},
{
"key_types"
,
"type_name[]"
},
{
"type"
,
"type_name"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"abi_def"
,
""
,
{
{
"types"
,
"type_def[]"
},
{
"structs"
,
"struct_def[]"
},
{
"actions"
,
"action_def[]"
},
{
"tables"
,
"table_def[]"
},
{
"ricardian_clauses"
,
"clause_pair[]"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"block_header"
,
""
,
{
{
"previous"
,
"checksum256"
},
{
"timestamp"
,
"uint32"
},
{
"transaction_mroot"
,
"checksum256"
},
{
"action_mroot"
,
"checksum256"
},
{
"block_mroot"
,
"checksum256"
},
{
"producer"
,
"account_name"
},
{
"schedule_version"
,
"uint32"
},
{
"new_producers"
,
"producer_schedule?"
}
}
});
eos_abi
.
structs
.
emplace_back
(
struct_def
{
"onblock"
,
""
,
{
{
"header"
,
"block_header"
}
}
});
return
eos_abi
;
}
}
}
/// eosio::chain
libraries/chain/include/eosio/chain/apply_context.hpp
浏览文件 @
a4b1d0d0
...
...
@@ -185,14 +185,14 @@ class apply_context {
const
auto
&
tab
=
context
.
find_or_create_table
(
context
.
receiver
,
scope
,
table
,
payer
);
const
auto
&
obj
=
context
.
mutable_
db
.
create
<
ObjectType
>
(
[
&
](
auto
&
o
){
const
auto
&
obj
=
context
.
db
.
create
<
ObjectType
>
(
[
&
](
auto
&
o
){
o
.
t_id
=
tab
.
id
;
o
.
primary_key
=
id
;
secondary_key_helper_t
::
set
(
o
.
secondary_key
,
value
);
o
.
payer
=
payer
;
});
context
.
mutable_
db
.
modify
(
tab
,
[
&
](
auto
&
t
)
{
context
.
db
.
modify
(
tab
,
[
&
](
auto
&
t
)
{
++
t
.
count
;
});
...
...
@@ -211,10 +211,10 @@ class apply_context {
// context.require_write_lock( table_obj.scope );
context
.
mutable_
db
.
modify
(
table_obj
,
[
&
](
auto
&
t
)
{
context
.
db
.
modify
(
table_obj
,
[
&
](
auto
&
t
)
{
--
t
.
count
;
});
context
.
mutable_
db
.
remove
(
obj
);
context
.
db
.
remove
(
obj
);
if
(
table_obj
.
count
==
0
)
{
context
.
remove_table
(
table_obj
);
...
...
@@ -240,7 +240,7 @@ class apply_context {
context
.
update_db_usage
(
payer
,
+
(
billing_size
)
);
}
context
.
mutable_
db
.
modify
(
obj
,
[
&
](
auto
&
o
)
{
context
.
db
.
modify
(
obj
,
[
&
](
auto
&
o
)
{
secondary_key_helper_t
::
set
(
o
.
secondary_key
,
secondary
);
o
.
payer
=
payer
;
});
...
...
@@ -457,7 +457,6 @@ class apply_context {
db
(
con
.
db
()),
act
(
a
),
mutable_controller
(
con
),
mutable_db
(
con
.
db
()),
used_authorizations
(
act
.
authorization
.
size
(),
false
),
trx_meta
(
trx_meta
),
idx64
(
*
this
),
...
...
@@ -512,8 +511,8 @@ class apply_context {
const
bytes
&
get_packed_transaction
();
controller
&
control
;
c
onst
chainbase
::
database
&
db
;
///< database where state is stored
controller
&
control
;
c
hainbase
::
database
&
db
;
///< database where state is stored
const
action
&
act
;
///< message being applied
account_name
receiver
;
///< the code that is currently running
bool
privileged
=
false
;
...
...
@@ -521,7 +520,6 @@ class apply_context {
bool
used_context_free_api
=
false
;
controller
&
mutable_controller
;
chainbase
::
database
&
mutable_db
;
///< Parallel to act.authorization; tracks which permissions have been used while processing the message
...
...
@@ -588,6 +586,12 @@ class apply_context {
uint64_t
cpu_usage
;
uint64_t
total_cpu_usage
;
uint64_t
next_global_sequence
();
uint64_t
next_recv_sequence
(
account_name
receiver
);
uint64_t
next_auth_sequence
(
account_name
actor
);
private:
iterator_cache
<
key_value_object
>
keyval_cache
;
...
...
libraries/chain/include/eosio/chain/controller.hpp
浏览文件 @
a4b1d0d0
...
...
@@ -90,9 +90,6 @@ namespace eosio { namespace chain {
block_state_ptr
head_block_state
()
const
;
block_state_ptr
pending_block_state
()
const
;
uint64_t
next_global_sequence
();
uint64_t
next_recv_sequence
(
account_name
receiver
);
uint64_t
next_auth_sequence
(
account_name
actor
);
void
record_transaction
(
const
transaction_metadata_ptr
&
trx
);
const
account_object
&
get_account
(
account_name
n
)
const
;
...
...
libraries/chain/include/eosio/chain/eosio_contract.hpp
浏览文件 @
a4b1d0d0
...
...
@@ -5,6 +5,7 @@
#pragma once
#include <eosio/chain/types.hpp>
#include <eosio/chain/contract_types.hpp>
namespace
eosio
{
namespace
chain
{
...
...
@@ -31,5 +32,7 @@ namespace eosio { namespace chain {
void
apply_eosio_canceldelay
(
apply_context
&
);
///@} end action handlers
abi_def
eosio_contract_abi
(
const
abi_def
&
eosio_system_abi
);
}
}
/// namespace eosio::chain
libraries/chain/wasm_interface.cpp
浏览文件 @
a4b1d0d0
...
...
@@ -167,7 +167,7 @@ class privileged_api : public context_aware_api {
datastream
<
const
char
*>
ds
(
packed_blockchain_parameters
,
datalen
);
chain
::
chain_config
cfg
;
fc
::
raw
::
unpack
(
ds
,
cfg
);
context
.
mutable_
db
.
modify
(
context
.
control
.
get_global_properties
(),
context
.
db
.
modify
(
context
.
control
.
get_global_properties
(),
[
&
](
auto
&
gprops
)
{
gprops
.
configuration
=
cfg
;
});
...
...
@@ -179,7 +179,7 @@ class privileged_api : public context_aware_api {
void
set_privileged
(
account_name
n
,
bool
is_priv
)
{
const
auto
&
a
=
context
.
db
.
get
<
account_object
,
by_name
>
(
n
);
context
.
mutable_
db
.
modify
(
a
,
[
&
](
auto
&
ma
){
context
.
db
.
modify
(
a
,
[
&
](
auto
&
ma
){
ma
.
privileged
=
is_priv
;
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录