Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
YottaChain
YTBP
提交
a94c1b7d
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,发现更多精彩内容 >>
提交
a94c1b7d
编写于
2月 07, 2018
作者:
A
Anton Perkov
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into clang-stl
上级
ebdfe870
6ea416b9
变更
18
展开全部
隐藏空白更改
内联
并排
Showing
18 changed file
with
1341 addition
and
982 deletion
+1341
-982
.travis.yml
.travis.yml
+1
-1
contracts/eosiolib/singleton.hpp
contracts/eosiolib/singleton.hpp
+19
-12
contracts/eosiolib/table.hpp
contracts/eosiolib/table.hpp
+17
-7
contracts/identity/identity.abi
contracts/identity/identity.abi
+3
-9
contracts/identity/identity.hpp
contracts/identity/identity.hpp
+40
-23
contracts/proxy/proxy.cpp
contracts/proxy/proxy.cpp
+14
-0
contracts/proxy/proxy.hpp
contracts/proxy/proxy.hpp
+0
-3
libraries/chain/include/eosio/chain/apply_context.hpp
libraries/chain/include/eosio/chain/apply_context.hpp
+12
-87
libraries/chain/include/eosio/chain/contracts/types.hpp
libraries/chain/include/eosio/chain/contracts/types.hpp
+0
-16
libraries/chain/wasm_interface.cpp
libraries/chain/wasm_interface.cpp
+5
-5
libraries/fc/include/fc/exception/exception.hpp
libraries/fc/include/fc/exception/exception.hpp
+5
-0
libraries/fc/src/exception.cpp
libraries/fc/src/exception.cpp
+15
-0
libraries/testing/include/eosio/testing/tester.hpp
libraries/testing/include/eosio/testing/tester.hpp
+17
-0
libraries/testing/tester.cpp
libraries/testing/tester.cpp
+47
-0
plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
.../chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
+4
-4
plugins/net_plugin/net_plugin.cpp
plugins/net_plugin/net_plugin.cpp
+801
-677
tests/CMakeLists.txt
tests/CMakeLists.txt
+17
-16
tests/wasm_tests/identity_tests.cpp
tests/wasm_tests/identity_tests.cpp
+324
-122
未找到文件。
.travis.yml
浏览文件 @
a94c1b7d
...
...
@@ -78,7 +78,7 @@ script:
-
mkdir build && cd build
-
${CMAKE_DIR}cmake -G Ninja -DWASM_LLVM_CONFIG=$TRAVIS_BUILD_DIR/ext/wasm-compiler/bin/llvm-config -DSecp256k1_ROOT_DIR=$TRAVIS_BUILD_DIR/ext -DBINARYEN_ROOT=$TRAVIS_BUILD_DIR/ext/wasm-compiler -DCMAKE_PREFIX_PATH=$TRAVIS_BUILD_DIR/ext -DCMAKE_BUILD_TYPE=Release -DBUILD_MONGO_DB_PLUGIN=true $EOS_CMAKE_OPTIONS ..
-
ninja -j4
-
'
[
"$TRAVIS_OS_NAME"
==
"osx"
]
||
ctest
--output-on-failure
'
-
'
[
"$TRAVIS_OS_NAME"
==
"osx"
]
||
(export
EOSLIB=$TRAVIS_BUILD_DIR/contracts;
ctest
--output-on-failure)
'
-
cpack
deploy
:
...
...
contracts/eosiolib/singleton.hpp
浏览文件 @
a94c1b7d
...
...
@@ -19,20 +19,26 @@ namespace eosio {
static
bool
exists
(
scope_name
scope
=
Code
)
{
uint64_t
key
=
SingletonName
;
auto
read
=
load_i64
(
scope
,
Cod
e
,
key
,
(
char
*
)
&
key
,
sizeof
(
key
)
);
auto
read
=
load_i64
(
Code
,
scop
e
,
key
,
(
char
*
)
&
key
,
sizeof
(
key
)
);
return
read
>
0
;
}
static
T
get
(
scope_name
scope
=
Code
)
{
char
temp
[
1024
+
8
];
*
reinterpret_cast
<
uint64_t
*>
(
temp
)
=
SingletonName
;
auto
read
=
load_i64
(
scope
,
Cod
e
,
SingletonName
,
temp
,
sizeof
(
temp
)
);
auto
read
=
load_i64
(
Code
,
scop
e
,
SingletonName
,
temp
,
sizeof
(
temp
)
);
eos_assert
(
read
>
0
,
"singleton does not exist"
);
datastream
<
const
char
*>
ds
(
temp
+
sizeof
(
SingletonName
),
read
);
return
unpack
<
T
>
(
temp
+
sizeof
(
SingletonName
),
read
);
}
T
result
;
unpack
(
ds
,
result
);
return
result
;
static
T
get_or_default
(
scope_name
scope
=
Code
,
const
T
&
def
=
T
()
)
{
char
temp
[
1024
+
8
];
*
reinterpret_cast
<
uint64_t
*>
(
temp
)
=
SingletonName
;
auto
read
=
load_i64
(
Code
,
scope
,
SingletonName
,
temp
,
sizeof
(
temp
)
);
if
(
read
<
0
)
{
return
def
;
}
return
unpack
<
T
>
(
temp
+
sizeof
(
SingletonName
),
read
);
}
static
T
get_or_create
(
scope_name
scope
=
Code
,
const
T
&
def
=
T
()
)
{
...
...
@@ -40,16 +46,12 @@ namespace eosio {
*
reinterpret_cast
<
uint64_t
*>
(
temp
)
=
SingletonName
;
auto
read
=
load_i64
(
scope
,
Cod
e
,
SingletonName
,
temp
,
sizeof
(
temp
)
);
auto
read
=
load_i64
(
Code
,
scop
e
,
SingletonName
,
temp
,
sizeof
(
temp
)
);
if
(
read
<
0
)
{
set
(
def
,
scope
);
return
def
;
}
datastream
<
const
char
*>
ds
(
temp
+
sizeof
(
SingletonName
),
read
);
T
result
;
ds
>>
result
;
return
result
;
return
unpack
<
T
>
(
temp
+
sizeof
(
SingletonName
),
read
);
}
static
void
set
(
const
T
&
value
=
T
(),
scope_name
scope
=
Code
,
account_name
b
=
BillToAccount
)
{
...
...
@@ -64,6 +66,11 @@ namespace eosio {
store_i64
(
scope
,
SingletonName
,
b
,
buf
,
sizeof
(
buf
)
);
}
static
void
remove
(
scope_name
scope
=
Code
)
{
uint64_t
key
=
SingletonName
;
remove_i64
(
scope
,
SingletonName
,
&
key
);
}
};
}
/// namespace eosio
contracts/eosiolib/table.hpp
浏览文件 @
a94c1b7d
...
...
@@ -93,7 +93,7 @@ namespace eosio {
temp
[
1
]
=
secondary
;
temp
[
2
]
=
tertiary
;
auto
read
=
lower_bound_primary_i64i64i64
(
Code
,
_scope
,
TableName
,
auto
read
=
lower_bound_primary_i64i64i64
(
Code
,
_scope
,
TableName
,
(
char
*
)
temp
,
sizeof
(
temp
)
);
if
(
read
<=
0
)
{
return
false
;
...
...
@@ -104,21 +104,31 @@ namespace eosio {
return
true
;
}
bool
next_primary
(
T
&
result
,
const
T
&
current
)
{
bool
primary_upper_bound
(
T
&
result
,
uint64_t
primary
=
0
,
uint64_t
secondary
=
0
,
uint64_t
tertiary
=
0
)
{
uint64_t
temp
[
1024
/
8
];
memcpy
(
temp
,
(
const
char
*
)
&
current
,
3
*
sizeof
(
uint64_t
)
);
auto
read
=
next_primary_i64i64i64
(
Code
,
_scope
,
TableName
,
temp
[
0
]
=
primary
;
temp
[
1
]
=
secondary
;
temp
[
2
]
=
tertiary
;
auto
read
=
upper_bound_primary_i64i64i64
(
Code
,
_scope
,
TableName
,
(
char
*
)
temp
,
sizeof
(
temp
)
);
if
(
read
<=
0
)
{
return
false
;
}
datastream
<
const
char
*>
ds
(
(
char
*
)
temp
,
sizeof
(
temp
)
);
ds
>>
result
;
result
=
unpack
<
T
>
(
(
char
*
)
temp
,
sizeof
(
temp
)
);
return
true
;
}
bool
next_primary
(
T
&
result
,
const
T
&
current
)
{
const
uint64_t
*
keys
=
reinterpret_cast
<
const
uint64_t
*>
(
&
current
);
return
primary_upper_bound
(
result
,
keys
[
0
],
keys
[
1
],
keys
[
2
]);
}
void
store
(
const
T
&
value
,
account_name
bill_to
=
BillToAccount
)
{
char
temp
[
1024
];
datastream
<
char
*>
ds
(
temp
,
sizeof
(
temp
)
);
...
...
contracts/identity/identity.abi
浏览文件 @
a94c1b7d
...
...
@@ -62,18 +62,12 @@
{"name":"identity", "type":"uint64"},
{"name":"creator", "type":"account_name"}
]
},{
"name": "trustrow",
"base": "",
"fields": [
{"name":"account", "type":"account_name"},
{"name":"trusted", "type":"uint8"}
]
},{
"name": "accountrow",
"base": "",
"fields": [
{"name":"account", "type":"account_name"}
{"name":"singleton_name", "type":"uint64"},
{"name":"identity", "type":"uint64"}
]
}
],
...
...
@@ -110,7 +104,7 @@
"key_types": [ "uint64" ]
},{
"name": "trust",
"type": "
trustrow
",
"type": "
account_name
",
"index_type": "i64",
"key_names" : [ "account" ],
"key_types": [ "account_name" ]
...
...
contracts/identity/identity.hpp
浏览文件 @
a94c1b7d
...
...
@@ -2,6 +2,7 @@
#include <eosiolib/chain.h>
#include <eosiolib/dispatcher.hpp>
#include <eosiolib/singleton.hpp>
#include <eosiolib/table.hpp>
#include <eosiolib/vector.hpp>
#include <eosiolib/string.hpp>
...
...
@@ -10,6 +11,7 @@ namespace identity {
using
eosio
::
action_meta
;
using
eosio
::
table_i64i64i64
;
using
eosio
::
table64
;
using
eosio
::
singleton
;
using
eosio
::
string
;
using
eosio
::
vector
;
...
...
@@ -195,8 +197,8 @@ namespace identity {
typedef
table_i64i64i64
<
code
,
N
(
certs
),
code
,
certrow
>
certs_table
;
typedef
table64
<
code
,
N
(
ident
),
code
,
identrow
>
idents_table
;
typedef
table64
<
code
,
N
(
account
),
code
,
identity_name
>
accounts_table
;
typedef
table64
<
code
,
N
(
trust
),
code
,
trustrow
>
trust_table
;
typedef
singleton
<
code
,
N
(
account
),
code
,
identity_name
>
accounts_table
;
typedef
table64
<
code
,
N
(
trust
),
code
,
account_name
>
trust_table
;
static
identity_name
get_claimed_identity
(
account_name
acnt
)
{
return
accounts_table
::
get_or_default
(
acnt
,
0
);
...
...
@@ -209,13 +211,19 @@ namespace identity {
certs_table
certs
(
ident
);
certrow
row
;
bool
ok
=
certs
.
primary_lower_bound
(
row
,
N
(
owner
),
1
,
0
);
account_name
owner
=
0
;
while
(
ok
&&
row
.
property
==
N
(
owner
)
&&
row
.
trusted
)
{
if
(
sizeof
(
account_name
)
==
row
.
data
.
size
())
{
account_name
account
=
*
reinterpret_cast
<
account_name
*>
(
row
.
data
.
data
());
if
(
ident
==
get_claimed_identity
(
account
))
{
if
(
is_trusted
(
row
.
certifier
)
)
{
// the certifier is still trusted
return
account
;
if
(
!
owner
||
owner
==
account
)
{
owner
=
account
;
}
else
{
//contradiction found: different owners certified for the same identity
return
0
;
}
}
else
if
(
DeployToAccount
==
current_receiver
()){
//the certifier is no longer trusted, need to unset the flag
row
.
trusted
=
0
;
...
...
@@ -227,8 +235,13 @@ namespace identity {
}
else
{
// bad row - skip it
}
//ok = certs.primary_upper_bound(row, row.property, row.trusted, row.certifier);
ok
=
certs
.
next_primary
(
row
,
row
);
}
if
(
owner
)
{
//owner found, no contradictions among certifications flaged as trusted
return
owner
;
}
// trusted certification not found
// let's see if some of untrusted certifications became trusted
ok
=
certs
.
primary_lower_bound
(
row
,
N
(
owner
),
0
,
0
);
...
...
@@ -236,18 +249,25 @@ namespace identity {
if
(
sizeof
(
account_name
)
==
row
.
data
.
size
())
{
account_name
account
=
*
reinterpret_cast
<
account_name
*>
(
row
.
data
.
data
());
if
(
ident
==
get_claimed_identity
(
account
)
&&
is_trusted
(
row
.
certifier
))
{
// the certifier became trusted, need to set the flag
row
.
trusted
=
1
;
certs
.
store
(
row
,
0
);
//assuming 0 means bill to the same account
return
*
reinterpret_cast
<
account_name
*>
(
row
.
data
.
data
());
if
(
DeployToAccount
==
current_receiver
())
{
// the certifier became trusted and we have permissions to update the flag
row
.
trusted
=
1
;
certs
.
store
(
row
,
0
);
//assuming 0 means bill to the same account
}
if
(
!
owner
||
owner
==
account
)
{
owner
=
account
;
}
else
{
//contradiction found: different owners certified for the same identity
return
0
;
}
}
}
else
{
// bad row - skip it
}
//ok = certs.primary_upper_bound(row, row.property, row.trusted, row.certifier);
ok
=
certs
.
next_primary
(
row
,
row
);
}
return
0
;
return
owner
;
}
static
identity_name
get_identity_for_account
(
account_name
acnt
)
{
...
...
@@ -258,10 +278,7 @@ namespace identity {
}
static
bool
is_trusted_by
(
account_name
trusted
,
account_name
by
)
{
trustrow
def
;
def
.
trusted
=
0
;
trustrow
row
=
trust_table
::
get_or_default
(
trusted
,
by
,
def
);
return
def
.
trusted
;
return
trust_table
::
exists
(
trusted
,
by
);
}
static
bool
is_trusted
(
account_name
acnt
)
{
...
...
@@ -283,13 +300,9 @@ namespace identity {
require_recipient
(
t
.
trusting
);
if
(
t
.
trust
!=
0
)
{
trustrow
row
{
.
account
=
t
.
trusting
,
.
trusted
=
t
.
trust
};
trust_table
::
set
(
row
,
t
.
trustor
);
trust_table
::
set
(
t
.
trusting
,
t
.
trustor
);
}
else
{
trustrow
row
{
.
account
=
t
.
trusting
,
.
trusted
=
t
.
trust
};
trust_table
::
remove
(
row
.
account
,
t
.
trustor
);
trust_table
::
remove
(
t
.
trusting
,
t
.
trustor
);
}
}
...
...
@@ -318,7 +331,7 @@ namespace identity {
row
.
trusted
=
is_trusted
(
cert
.
certifier
);
row
.
certifier
=
cert
.
certifier
;
row
.
confidence
=
value
.
confidence
;
eos_assert
(
value
.
type
.
get_size
()
<=
32
,
"certrow::type should
n't be
longer than 32 bytes"
);
eos_assert
(
value
.
type
.
get_size
()
<=
32
,
"certrow::type should
be not
longer than 32 bytes"
);
row
.
type
=
value
.
type
;
row
.
data
=
value
.
data
;
...
...
@@ -330,17 +343,21 @@ namespace identity {
if
(
value
.
property
==
N
(
owner
))
{
eos_assert
(
sizeof
(
account_name
)
==
value
.
data
.
size
(),
"data size doesn't match account_name size"
);
account_name
acnt
=
*
reinterpret_cast
<
const
account_name
*>
(
value
.
data
.
data
());
accounts_table
::
set
(
acnt
,
cert
.
identity
);
if
(
cert
.
certifier
==
acnt
)
{
//only self-certitication affects accounts_table
accounts_table
::
set
(
cert
.
identity
,
acnt
);
}
}
}
else
{
//remove both tursted and untrusted because we cannot now if it was trusted back at creation time
//remove both tursted and untrusted because we cannot
k
now if it was trusted back at creation time
certs
.
remove
(
value
.
property
,
0
,
cert
.
certifier
);
certs
.
remove
(
value
.
property
,
1
,
cert
.
certifier
);
//special handling for owner
if
(
value
.
property
==
N
(
owner
))
{
eos_assert
(
sizeof
(
account_name
)
==
value
.
data
.
size
(),
"data size doesn't match account_name size"
);
account_name
acnt
=
*
reinterpret_cast
<
const
account_name
*>
(
value
.
data
.
data
());
accounts_table
::
remove
(
acnt
,
cert
.
identity
);
if
(
cert
.
certifier
==
acnt
)
{
//only self-certitication affects accounts_table
accounts_table
::
remove
(
acnt
);
}
}
}
}
...
...
contracts/proxy/proxy.cpp
浏览文件 @
a94c1b7d
...
...
@@ -9,6 +9,20 @@
namespace
proxy
{
using
namespace
eosio
;
namespace
configs
{
bool
get
(
config
&
out
,
const
account_name
&
self
)
{
auto
read
=
load_i64
(
self
,
self
,
N
(
config
),
(
char
*
)
&
out
,
sizeof
(
config
));
if
(
read
<
0
)
{
return
false
;
}
return
true
;
}
void
store
(
const
config
&
in
,
const
account_name
&
self
)
{
store_i64
(
self
,
N
(
config
),
self
,
(
const
char
*
)
&
in
,
sizeof
(
config
));
}
};
template
<
typename
T
>
void
apply_transfer
(
account_name
code
,
const
T
&
transfer
)
{
config
code_config
;
...
...
contracts/proxy/proxy.hpp
浏览文件 @
a94c1b7d
...
...
@@ -3,7 +3,6 @@
* @copyright defined in eos/LICENSE.txt
*/
#include <eosiolib/eosio.hpp>
#include <eosiolib/db.hpp>
namespace
proxy
{
...
...
@@ -22,6 +21,4 @@ namespace proxy {
uint32_t
next_id
=
0
;
};
using
configs
=
eosio
::
table
<
N
(
proxy
),
N
(
proxy
),
N
(
configs
),
N
(
proxy
),
config
,
uint64_t
>
;
}
/// namespace proxy
libraries/chain/include/eosio/chain/apply_context.hpp
浏览文件 @
a94c1b7d
...
...
@@ -655,57 +655,25 @@ using apply_handler = std::function<void(apply_context&)>;
template
<
typename
ObjectType
>
using
key_helper
=
key_helper_impl
<
ObjectType
,
ObjectType
::
number_of_keys
-
1
>
;
/// find_tuple helper
template
<
typename
KeyType
,
int
KeyIndex
,
typename
...
Args
>
struct
exact_tuple_impl
{
static
auto
get
(
const
contracts
::
table_id_object
&
tid
,
const
KeyType
*
keys
,
Args
...
args
)
{
return
exact_tuple_impl
<
KeyType
,
KeyIndex
-
1
,
const
KeyType
&
,
Args
...
>::
get
(
tid
,
keys
,
raw_key_value
(
keys
,
KeyIndex
),
args
...);
}
};
template
<
typename
KeyType
,
typename
...
Args
>
struct
exact_tuple_impl
<
KeyType
,
-
1
,
Args
...
>
{
static
auto
get
(
const
contracts
::
table_id_object
&
tid
,
const
KeyType
*
,
Args
...
args
)
{
return
boost
::
make_tuple
(
tid
.
id
,
args
...);
}
};
template
<
typename
ObjectType
>
using
exact_tuple
=
exact_tuple_impl
<
typename
ObjectType
::
key_type
,
ObjectType
::
number_of_keys
-
1
>
;
template
<
typename
KeyType
,
int
NullKeyCount
,
typename
Scope
,
typename
...
Args
>
struct
lower_bound_tuple_impl
{
template
<
typename
KeyType
,
int
KeyIndex
,
size_t
Offset
,
typename
...
Args
>
struct
partial_tuple_impl
{
static
auto
get
(
const
contracts
::
table_id_object
&
tid
,
const
KeyType
*
keys
,
Args
...
args
)
{
return
lower_bound_tuple_impl
<
KeyType
,
NullKeyCount
-
1
,
Scope
,
KeyType
,
Args
...
>::
get
(
tid
,
keys
,
KeyType
(
0
),
args
...);
return
partial_tuple_impl
<
KeyType
,
KeyIndex
-
1
,
Offset
,
KeyType
,
Args
...
>::
get
(
tid
,
keys
,
raw_key_value
(
keys
,
Offset
+
KeyIndex
),
args
...);
}
};
template
<
typename
KeyType
,
typename
Scope
,
typename
...
Args
>
struct
lower_bound_tuple_impl
<
KeyType
,
0
,
Scope
,
Args
...
>
{
template
<
typename
KeyType
,
size_t
Offset
,
typename
...
Args
>
struct
partial_tuple_impl
<
KeyType
,
0
,
Offset
,
Args
...
>
{
static
auto
get
(
const
contracts
::
table_id_object
&
tid
,
const
KeyType
*
keys
,
Args
...
args
)
{
return
boost
::
make_tuple
(
tid
.
id
,
raw_key_value
(
keys
,
scope_to_key_index_v
<
Scope
>
),
args
...);
return
boost
::
make_tuple
(
tid
.
id
,
raw_key_value
(
keys
,
Offset
),
args
...);
}
};
template
<
typename
IndexType
,
typename
Scope
>
using
lower_bound_tuple
=
lower_bound_tuple_impl
<
typename
IndexType
::
value_type
::
key_type
,
IndexType
::
value_type
::
number_of_keys
-
scope_to_key_index_v
<
Scope
>
-
1
,
Scope
>
;
using
partial_tuple
=
partial_tuple_impl
<
typename
IndexType
::
value_type
::
key_type
,
IndexType
::
value_type
::
number_of_keys
-
impl
::
scope_to_key_index_v
<
Scope
>
-
1
,
impl
::
scope_to_key_index_v
<
Scope
>
>
;
template
<
typename
KeyType
,
int
NullKeyCount
,
typename
Scope
,
typename
...
Args
>
struct
upper_bound_tuple_impl
{
static
auto
get
(
const
contracts
::
table_id_object
&
tid
,
const
KeyType
*
keys
,
Args
...
args
)
{
return
upper_bound_tuple_impl
<
KeyType
,
NullKeyCount
-
1
,
Scope
,
KeyType
,
Args
...
>::
get
(
tid
,
keys
,
KeyType
(
-
1
),
args
...);
}
};
template
<
typename
KeyType
,
typename
Scope
,
typename
...
Args
>
struct
upper_bound_tuple_impl
<
KeyType
,
0
,
Scope
,
Args
...
>
{
static
auto
get
(
const
contracts
::
table_id_object
&
tid
,
const
KeyType
*
keys
,
Args
...
args
)
{
return
boost
::
make_tuple
(
tid
.
id
,
raw_key_value
(
keys
,
scope_to_key_index_v
<
Scope
>
),
args
...);
}
};
template
<
typename
IndexType
,
typename
Scope
>
using
upper_bound_tuple
=
upper_bound_tuple_impl
<
typename
IndexType
::
value_type
::
key_type
,
IndexType
::
value_type
::
number_of_keys
-
scope_to_key_index_v
<
Scope
>
-
1
,
Scope
>
;
template
<
typename
ObjectType
>
using
exact_tuple
=
partial_tuple_impl
<
typename
ObjectType
::
key_type
,
ObjectType
::
number_of_keys
-
1
,
0
>
;
template
<
typename
IndexType
,
typename
Scope
>
struct
record_scope_compare
{
...
...
@@ -790,7 +758,7 @@ using apply_handler = std::function<void(apply_context&)>;
require_read_lock
(
t_id
.
code
,
t_id
.
scope
);
const
auto
&
idx
=
db
.
get_index
<
IndexType
,
Scope
>
();
auto
tuple
=
impl
::
lower_bound
_tuple
<
IndexType
,
Scope
>::
get
(
t_id
,
keys
);
auto
tuple
=
impl
::
partial
_tuple
<
IndexType
,
Scope
>::
get
(
t_id
,
keys
);
auto
itr
=
idx
.
lower_bound
(
tuple
);
if
(
itr
==
idx
.
end
()
||
...
...
@@ -862,49 +830,6 @@ using apply_handler = std::function<void(apply_context&)>;
}
}
template
<
typename
IndexType
,
typename
Scope
>
int32_t
apply_context
::
next_record
(
const
table_id_object
&
t_id
,
typename
IndexType
::
value_type
::
key_type
*
keys
,
char
*
value
,
size_t
valuelen
)
{
require_read_lock
(
t_id
.
code
,
t_id
.
scope
);
const
auto
&
pidx
=
db
.
get_index
<
IndexType
,
contracts
::
by_scope_primary
>
();
auto
tuple
=
impl
::
exact_tuple
<
typename
IndexType
::
value_type
>::
get
(
t_id
,
keys
);
auto
pitr
=
pidx
.
find
(
tuple
);
if
(
pitr
==
pidx
.
end
())
return
-
1
;
const
auto
&
fidx
=
db
.
get_index
<
IndexType
>
();
auto
itr
=
fidx
.
indicies
().
template
project
<
Scope
>(
pitr
);
const
auto
&
idx
=
db
.
get_index
<
IndexType
,
Scope
>
();
if
(
itr
==
idx
.
end
()
||
itr
->
t_id
!=
t_id
.
id
||
!
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
compare
(
*
itr
,
keys
)
)
{
return
-
1
;
}
++
itr
;
if
(
itr
==
idx
.
end
()
||
itr
->
t_id
!=
t_id
.
id
)
{
return
-
1
;
}
impl
::
key_helper
<
typename
IndexType
::
value_type
>::
get
(
keys
,
*
itr
);
if
(
valuelen
)
{
auto
copylen
=
std
::
min
<
size_t
>
(
itr
->
value
.
size
(),
valuelen
);
if
(
copylen
)
{
itr
->
value
.
copy
(
value
,
copylen
);
}
return
copylen
;
}
else
{
return
itr
->
value
.
size
();
}
}
template
<
typename
IndexType
,
typename
Scope
>
int32_t
apply_context
::
previous_record
(
const
table_id_object
&
t_id
,
typename
IndexType
::
value_type
::
key_type
*
keys
,
char
*
value
,
size_t
valuelen
)
{
require_read_lock
(
t_id
.
code
,
t_id
.
scope
);
...
...
@@ -949,7 +874,7 @@ using apply_handler = std::function<void(apply_context&)>;
require_read_lock
(
t_id
.
code
,
t_id
.
scope
);
const
auto
&
idx
=
db
.
get_index
<
IndexType
,
Scope
>
();
auto
tuple
=
impl
::
lower_bound
_tuple
<
IndexType
,
Scope
>::
get
(
t_id
,
keys
);
auto
tuple
=
impl
::
partial
_tuple
<
IndexType
,
Scope
>::
get
(
t_id
,
keys
);
auto
itr
=
idx
.
lower_bound
(
tuple
);
if
(
itr
==
idx
.
end
()
||
...
...
@@ -973,7 +898,7 @@ using apply_handler = std::function<void(apply_context&)>;
require_read_lock
(
t_id
.
code
,
t_id
.
scope
);
const
auto
&
idx
=
db
.
get_index
<
IndexType
,
Scope
>
();
auto
tuple
=
impl
::
upper_bound
_tuple
<
IndexType
,
Scope
>::
get
(
t_id
,
keys
);
auto
tuple
=
impl
::
partial
_tuple
<
IndexType
,
Scope
>::
get
(
t_id
,
keys
);
auto
itr
=
idx
.
upper_bound
(
tuple
);
if
(
itr
==
idx
.
end
()
||
...
...
libraries/chain/include/eosio/chain/contracts/types.hpp
浏览文件 @
a94c1b7d
...
...
@@ -103,22 +103,6 @@ struct abi_def {
vector
<
table_def
>
tables
;
};
struct
transfer
{
account_name
from
;
account_name
to
;
uint64
amount
;
string
memo
;
static
account_name
get_account
()
{
return
config
::
system_account_name
;
}
static
name
get_name
()
{
return
N
(
transfer
);
}
};
struct
newaccount
{
account_name
creator
;
account_name
name
;
...
...
libraries/chain/wasm_interface.cpp
浏览文件 @
a94c1b7d
...
...
@@ -527,9 +527,10 @@ class producer_api : public context_aware_api {
int
get_active_producers
(
array_ptr
<
chain
::
account_name
>
producers
,
size_t
datalen
)
{
auto
active_producers
=
context
.
get_active_producers
();
size_t
len
=
std
::
min
(
datalen
/
sizeof
(
chain
::
account_name
),
active_producers
.
size
());
memcpy
(
producers
,
active_producers
.
data
(),
len
);
return
active_producers
.
size
()
*
sizeof
(
chain
::
account_name
);
size_t
len
=
active_producers
.
size
()
*
sizeof
(
chain
::
account_name
);
size_t
cpy_len
=
std
::
min
(
datalen
,
len
);
memcpy
(
producers
,
active_producers
.
data
(),
cpy_len
);
return
len
;
}
};
...
...
@@ -784,7 +785,7 @@ class db_index_api : public context_aware_api {
int
call
(
ContextMethodType
method
,
const
account_name
&
code
,
const
scope_name
&
scope
,
const
name
&
table
,
array_ptr
<
char
>
data
,
size_t
data_len
)
{
auto
maybe_t_id
=
context
.
find_table
(
co
ntext
.
receiver
,
scope
,
table
);
auto
maybe_t_id
=
context
.
find_table
(
co
de
,
scope
,
table
);
if
(
maybe_t_id
==
nullptr
)
{
return
-
1
;
}
...
...
@@ -1058,7 +1059,6 @@ REGISTER_INTRINSICS(memory_api,
(load, int32_t(int64_t, int64_t, int64_t, int, int), "load_"#SUFFIX )\
(front, int32_t(int64_t, int64_t, int64_t, int, int), "front_"#SUFFIX )\
(back, int32_t(int64_t, int64_t, int64_t, int, int), "back_"#SUFFIX )\
(next, int32_t(int64_t, int64_t, int64_t, int, int), "next_"#SUFFIX )\
(previous, int32_t(int64_t, int64_t, int64_t, int, int), "previous_"#SUFFIX )\
(lower_bound, int32_t(int64_t, int64_t, int64_t, int, int), "lower_bound_"#SUFFIX )\
(upper_bound, int32_t(int64_t, int64_t, int64_t, int, int), "upper_bound_"#SUFFIX )\
...
...
libraries/fc/include/fc/exception/exception.hpp
浏览文件 @
a94c1b7d
...
...
@@ -102,6 +102,11 @@ namespace fc
*/
std
::
string
to_string
(
log_level
ll
=
log_level
::
info
)
const
;
/**
* Generates a user-friendly error report.
*/
std
::
string
top_message
(
)
const
;
/**
* Throw this exception as its most derived type.
*
...
...
libraries/fc/src/exception.cpp
浏览文件 @
a94c1b7d
...
...
@@ -185,6 +185,21 @@ namespace fc
return
ss
.
str
();
}
/**
* Generates a user-friendly error report.
*/
string
exception
::
top_message
(
)
const
{
for
(
auto
itr
=
my
->
_elog
.
begin
();
itr
!=
my
->
_elog
.
end
();
++
itr
)
{
auto
s
=
fc
::
format_string
(
itr
->
get_format
(),
itr
->
get_data
()
);
if
(
!
s
.
empty
())
{
return
s
;
}
}
return
string
();
}
void
NO_RETURN
exception_factory
::
rethrow
(
const
exception
&
e
)
const
{
auto
itr
=
_registered_exceptions
.
find
(
e
.
code
()
);
...
...
libraries/testing/include/eosio/testing/tester.hpp
浏览文件 @
a94c1b7d
...
...
@@ -2,6 +2,7 @@
#include <eosio/chain/chain_controller.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <iostream>
namespace
eosio
{
namespace
testing
{
...
...
@@ -14,6 +15,8 @@ namespace eosio { namespace testing {
*/
class
tester
{
public:
typedef
string
action_result
;
tester
(
bool
process_genesis
=
true
);
void
close
();
...
...
@@ -25,6 +28,7 @@ namespace eosio { namespace testing {
transaction_trace
push_transaction
(
packed_transaction
&
trx
);
transaction_trace
push_transaction
(
signed_transaction
&
trx
);
action_result
push_action
(
action
&&
cert_act
,
uint64_t
authorizer
);
void
set_tapos
(
signed_transaction
&
trx
)
const
;
void
create_accounts
(
vector
<
account_name
>
names
,
asset
init_bal
,
bool
multisig
=
false
)
{
...
...
@@ -65,6 +69,18 @@ namespace eosio { namespace testing {
const
symbol
&
asset_symbol
,
const
account_name
&
account
)
const
;
static
vector
<
uint8_t
>
to_uint8_vector
(
const
string
&
s
);
static
vector
<
uint8_t
>
to_uint8_vector
(
uint64_t
x
);
static
uint64_t
to_uint64
(
fc
::
variant
x
);
static
string
to_string
(
fc
::
variant
x
);
static
action_result
success
()
{
return
string
();
}
static
action_result
error
(
const
string
&
msg
)
{
return
msg
;
}
private:
fc
::
temp_directory
tempdir
;
chain_controller
::
controller_config
cfg
;
...
...
@@ -88,4 +104,5 @@ namespace eosio { namespace testing {
string
expected
;
};
}
}
/// eosio::testing
libraries/testing/tester.cpp
浏览文件 @
a94c1b7d
#include <boost/test/unit_test.hpp>
#include <eosio/testing/tester.hpp>
#include <eosio/chain/asset.hpp>
#include <eosio/chain/contracts/types.hpp>
...
...
@@ -157,6 +158,26 @@ namespace eosio { namespace testing {
return
push_transaction
(
ptrx
);
}
tester
::
action_result
tester
::
push_action
(
action
&&
cert_act
,
uint64_t
authorizer
)
{
signed_transaction
trx
;
if
(
authorizer
)
{
cert_act
.
authorization
=
vector
<
permission_level
>
{{
authorizer
,
config
::
active_name
}};
}
trx
.
actions
.
emplace_back
(
std
::
move
(
cert_act
));
set_tapos
(
trx
);
if
(
authorizer
)
{
trx
.
sign
(
get_private_key
(
authorizer
,
"active"
),
chain_id_type
());
}
try
{
push_transaction
(
trx
);
}
catch
(
const
fc
::
exception
&
ex
)
{
return
error
(
ex
.
top_message
());
}
produce_block
();
BOOST_REQUIRE_EQUAL
(
true
,
chain_has_transaction
(
trx
.
id
()));
return
success
();
}
void
tester
::
create_account
(
account_name
a
,
string
initial_balance
,
account_name
creator
,
bool
multisig
)
{
create_account
(
a
,
asset
::
from_string
(
initial_balance
),
creator
,
multisig
);
}
...
...
@@ -357,5 +378,31 @@ namespace eosio { namespace testing {
return
asset
(
result
,
asset_symbol
);
}
vector
<
uint8_t
>
tester
::
to_uint8_vector
(
const
string
&
s
)
{
vector
<
uint8_t
>
v
(
s
.
size
());
copy
(
s
.
begin
(),
s
.
end
(),
v
.
begin
());
return
v
;
};
vector
<
uint8_t
>
tester
::
to_uint8_vector
(
uint64_t
x
)
{
vector
<
uint8_t
>
v
(
sizeof
(
x
));
*
reinterpret_cast
<
uint64_t
*>
(
v
.
data
())
=
x
;
return
v
;
};
uint64_t
tester
::
to_uint64
(
fc
::
variant
x
)
{
vector
<
uint8_t
>
blob
;
fc
::
from_variant
<
uint8_t
>
(
x
,
blob
);
FC_ASSERT
(
8
==
blob
.
size
());
return
*
reinterpret_cast
<
uint64_t
*>
(
blob
.
data
());
}
string
tester
::
to_string
(
fc
::
variant
x
)
{
vector
<
uint8_t
>
v
;
fc
::
from_variant
<
uint8_t
>
(
x
,
v
);
string
s
(
v
.
size
(),
0
);
copy
(
v
.
begin
(),
v
.
end
(),
s
.
begin
());
return
s
;
}
}
}
/// eosio::test
plugins/chain_plugin/include/eosio/chain_plugin/chain_plugin.hpp
浏览文件 @
a94c1b7d
...
...
@@ -196,13 +196,13 @@ public:
fc
::
variant
get_currency_stats
(
const
get_currency_stats_params
&
params
)
const
;
void
copy_row
(
const
chain
::
contracts
::
key_value_object
&
obj
,
vector
<
char
>&
data
)
const
{
static
void
copy_row
(
const
chain
::
contracts
::
key_value_object
&
obj
,
vector
<
char
>&
data
)
{
data
.
resize
(
sizeof
(
uint64_t
)
+
obj
.
value
.
size
()
);
memcpy
(
data
.
data
(),
&
obj
.
primary_key
,
sizeof
(
uint64_t
)
);
memcpy
(
data
.
data
()
+
sizeof
(
uint64_t
),
obj
.
value
.
data
(),
obj
.
value
.
size
()
);
}
void
copy_row
(
const
chain
::
contracts
::
keystr_value_object
&
obj
,
vector
<
char
>&
data
)
const
{
static
void
copy_row
(
const
chain
::
contracts
::
keystr_value_object
&
obj
,
vector
<
char
>&
data
)
{
data
.
resize
(
obj
.
primary_key
.
size
()
+
obj
.
value
.
size
()
+
8
);
fc
::
datastream
<
char
*>
ds
(
data
.
data
(),
data
.
size
());
fc
::
raw
::
pack
(
ds
,
obj
.
primary_key
);
...
...
@@ -210,14 +210,14 @@ public:
data
.
resize
(
ds
.
tellp
());
}
void
copy_row
(
const
chain
::
contracts
::
key128x128_value_object
&
obj
,
vector
<
char
>&
data
)
const
{
static
void
copy_row
(
const
chain
::
contracts
::
key128x128_value_object
&
obj
,
vector
<
char
>&
data
)
{
data
.
resize
(
2
*
sizeof
(
uint128_t
)
+
obj
.
value
.
size
()
);
memcpy
(
data
.
data
(),
&
obj
.
primary_key
,
sizeof
(
uint128_t
)
);
memcpy
(
data
.
data
()
+
sizeof
(
uint128_t
),
&
obj
.
secondary_key
,
sizeof
(
uint128_t
)
);
memcpy
(
data
.
data
()
+
2
*
sizeof
(
uint128_t
),
obj
.
value
.
data
(),
obj
.
value
.
size
()
);
}
void
copy_row
(
const
chain
::
contracts
::
key64x64x64_value_object
&
obj
,
vector
<
char
>&
data
)
const
{
static
void
copy_row
(
const
chain
::
contracts
::
key64x64x64_value_object
&
obj
,
vector
<
char
>&
data
)
{
data
.
resize
(
3
*
sizeof
(
uint64_t
)
+
obj
.
value
.
size
()
);
memcpy
(
data
.
data
(),
&
obj
.
primary_key
,
sizeof
(
uint64_t
)
);
memcpy
(
data
.
data
()
+
sizeof
(
uint64_t
),
&
obj
.
secondary_key
,
sizeof
(
uint64_t
)
);
...
...
plugins/net_plugin/net_plugin.cpp
浏览文件 @
a94c1b7d
此差异已折叠。
点击以展开。
tests/CMakeLists.txt
浏览文件 @
a94c1b7d
...
...
@@ -38,7 +38,7 @@ target_link_libraries( chain_test eosio_testing eosio_chain chainbase eos_utilit
if
(
WASM_TOOLCHAIN
)
target_include_directories
(
chain_test PUBLIC
${
CMAKE_BINARY_DIR
}
/contracts
${
CMAKE_CURRENT_BINARY_DIR
}
/tests/contracts
)
target_include_directories
(
chain_test PUBLIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/wasm_tests
)
add_dependencies
(
chain_test asserter test_api currency proxy stltest
)
add_dependencies
(
chain_test asserter test_api currency proxy
identity
stltest
)
endif
()
...
...
@@ -70,21 +70,22 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/testUtils.py ${CMAKE_CURRENT_BINARY_D
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/eosiod_run_test.py
${
CMAKE_CURRENT_BINARY_DIR
}
/eosiod_run_test.py COPYONLY
)
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/eosiod_run_remote_test.py
${
CMAKE_CURRENT_BINARY_DIR
}
/eosiod_run_remote_test.py COPYONLY
)
add_test
(
NAME eosiod_run_test COMMAND tests/eosiod_run_test.py --dump-error-detail WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME p2p_sync_test COMMAND tests/p2p_tests/sync/test.sh WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME p2p_sync_test_p2_d10 COMMAND tests/p2p_tests/sync/test.sh -p 2 -d 10 WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME message_storm COMMAND tests/p2p_tests/sync/test.sh -m -p 21 -n 21 -d 5 -l WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME p2p_dawn515_test COMMAND tests/p2p_tests/dawn_515/test.sh WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME eosiod_run_remote_test COMMAND tests/eosiod_run_remote_test.py --dump-error-detail WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
if
(
BUILD_MONGO_DB_PLUGIN
)
add_test
(
NAME eosiod_run_test-mongodb COMMAND tests/eosiod_run_test.py --mongodb --exit-early --dump-error-detail WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
endif
()
add_test
(
chain_test chain_test
)
add_test
(
NAME trans_sync_across_mixed_cluster_test COMMAND tests/trans_sync_across_mixed_cluster_test.sh -p 1 -n 2 WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME distributed-transactions-test COMMAND tests/distributed-transactions-test.py -p 1 -n 4 --dump-error-detail WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py --dump-error-detail WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME restart-scenarios-test_resync COMMAND tests/restart-scenarios-test.py -c resync -p3 --dumpErrorDetails WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
NAME restart-scenarios-test_replay COMMAND tests/restart-scenarios-test.py -c replay -p3 --dumpErrorDetails WORKING_DIRECTORY
${
CMAKE_BINARY_DIR
}
)
add_test
(
chain_test chain_test --report_level=detailed
)
# TODO: Tests removed until working again on master.
# TODO: add_test(NAME eosiod_run_test COMMAND tests/eosiod_run_test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME p2p_sync_test COMMAND tests/p2p_tests/sync/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME p2p_sync_test_p2_d10 COMMAND tests/p2p_tests/sync/test.sh -p 2 -d 10 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME message_storm COMMAND tests/p2p_tests/sync/test.sh -m -p 21 -n 21 -d 5 -l WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME p2p_dawn515_test COMMAND tests/p2p_tests/dawn_515/test.sh WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME eosiod_run_remote_test COMMAND tests/eosiod_run_remote_test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: if(BUILD_MONGO_DB_PLUGIN)
# TODO: add_test(NAME eosiod_run_test-mongodb COMMAND tests/eosiod_run_test.py --mongodb --exit-early --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: endif()
# TODO: add_test(NAME trans_sync_across_mixed_cluster_test COMMAND tests/trans_sync_across_mixed_cluster_test.sh -p 1 -n 2 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME distributed-transactions-test COMMAND tests/distributed-transactions-test.py -p 1 -n 4 --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME distributed-transactions-remote-test COMMAND tests/distributed-transactions-remote-test.py --dump-error-detail WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME restart-scenarios-test_resync COMMAND tests/restart-scenarios-test.py -c resync -p3 --dumpErrorDetails WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
# TODO: add_test(NAME restart-scenarios-test_replay COMMAND tests/restart-scenarios-test.py -c replay -p3 --dumpErrorDetails WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
if
(
ENABLE_COVERAGE_TESTING
)
...
...
tests/wasm_tests/identity_tests.cpp
浏览文件 @
a94c1b7d
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录