Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cellframe-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
18
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
cellframe-sdk
Commits
d427c8f3
Commit
d427c8f3
authored
1 year ago
by
Roman Khlopkov
🔜
Browse files
Options
Downloads
Patches
Plain Diff
[*} DAG PoA filtering change from SHA256 to XOR
parent
0b8d2c0e
No related branches found
No related tags found
No related merge requests found
Pipeline
#27243
passed with stage
in 8 minutes and 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dap-sdk
+1
-1
1 addition, 1 deletion
dap-sdk
modules/consensus/dag-poa/dap_chain_cs_dag_poa.c
+25
-10
25 additions, 10 deletions
modules/consensus/dag-poa/dap_chain_cs_dag_poa.c
with
26 additions
and
11 deletions
dap-sdk
@
a70e9212
Compare
e96283dd
...
a70e9212
Subproject commit
e96283ddc24d41a307badd6365d82cf524685f79
Subproject commit
a70e9212ad7f25ec8f1737c87fab6eaabc35c0c7
This diff is collapsed.
Click to expand it.
modules/consensus/dag-poa/dap_chain_cs_dag_poa.c
+
25
−
10
View file @
d427c8f3
...
...
@@ -456,10 +456,26 @@ enum dap_chain_poa_round_filter_stage {
DAP_CHAIN_POA_ROUND_FILTER_STAGE_START
,
DAP_CHAIN_POA_ROUND_FILTER_STAGE_SIGNS
,
DAP_CHAIN_POA_ROUND_FILTER_STAGE_TS
,
DAP_CHAIN_POA_ROUND_FILTER_STAGE_
HASH
,
DAP_CHAIN_POA_ROUND_FILTER_STAGE_
MEM
,
DAP_CHAIN_POA_ROUND_FILTER_STAGE_MAX
};
#define DAP_CHAIN_POA_ROUND_FILTER_MEM_SIZE 1024
static
void
s_event_get_unique_mem_region
(
dap_chain_cs_dag_event_round_item_t
*
a_round_item
,
byte_t
*
a_mem_region
)
{
memset
(
a_mem_region
,
0
,
DAP_CHAIN_POA_ROUND_FILTER_MEM_SIZE
);
dap_chain_cs_dag_event_t
*
l_event
=
(
dap_chain_cs_dag_event_t
*
)
a_round_item
->
event_n_signs
;
for
(
int
n
=
0
;
n
<
l_event
->
header
.
signs_count
;
n
++
)
{
dap_sign_t
*
l_sign
=
dap_chain_cs_dag_event_get_sign
(
l_event
,
a_round_item
->
event_size
,
n
);
size_t
l_sign_size
=
0
;
byte_t
*
l_sign_mem
=
dap_sign_get_sign
(
l_sign
,
&
l_sign_size
);
size_t
l_mem_size
=
MIN
(
l_sign_size
,
DAP_CHAIN_POA_ROUND_FILTER_MEM_SIZE
);
for
(
size_t
i
=
0
;
i
<
l_mem_size
;
i
++
)
a_mem_region
[
i
]
^=
l_sign_mem
[
i
];
}
}
static
dap_chain_cs_dag_event_round_item_t
*
s_round_event_choose_dup
(
dap_list_t
*
a_dups
,
uint16_t
a_max_signs_counts
)
{
dap_chain_cs_dag_event_round_item_t
*
l_round_item
;
...
...
@@ -468,7 +484,8 @@ static dap_chain_cs_dag_event_round_item_t *s_round_event_choose_dup(dap_list_t
return
NULL
;
dap_list_t
*
l_dups
=
dap_list_copy
(
a_dups
);
uint64_t
l_min_ts_update
=
(
uint64_t
)
-
1
;
dap_hash_fast_t
l_event_hash
,
l_winner_hash
=
{};
byte_t
l_event_mem_region
[
DAP_CHAIN_POA_ROUND_FILTER_MEM_SIZE
],
l_winner_mem_region
[
DAP_CHAIN_POA_ROUND_FILTER_MEM_SIZE
]
=
{};
enum
dap_chain_poa_round_filter_stage
l_stage
=
DAP_CHAIN_POA_ROUND_FILTER_STAGE_START
;
while
(
l_stage
++
<
DAP_CHAIN_POA_ROUND_FILTER_STAGE_MAX
)
{
for
(
dap_list_t
*
it
=
l_dups
;
it
;
it
=
it
->
next
)
{
...
...
@@ -485,16 +502,14 @@ static dap_chain_cs_dag_event_round_item_t *s_round_event_choose_dup(dap_list_t
if
(
l_round_item
->
round_info
.
ts_update
!=
l_min_ts_update
)
l_dups
=
dap_list_remove_link
(
l_dups
,
it
);
else
{
dap_chain_cs_dag_event_calc_hash
((
dap_chain_cs_dag_event_t
*
)
l_round_item
->
event_n_signs
,
l_round_item
->
event_size
,
&
l_event_hash
);
if
(
memcmp
(
&
l_winner_hash
,
&
l_event_hash
,
sizeof
(
dap_hash_fast_t
))
<
0
)
l_winner_hash
=
l_event_hash
;
s_event_get_unique_mem_region
(
l_round_item
,
l_event_mem_region
);
if
(
memcmp
(
&
l_winner_mem_region
,
&
l_event_mem_region
,
DAP_CHAIN_POA_ROUND_FILTER_MEM_SIZE
)
>
0
)
memcpy
(
l_winner_mem_region
,
l_event_mem_region
,
DAP_CHAIN_POA_ROUND_FILTER_MEM_SIZE
);
}
break
;
case
DAP_CHAIN_POA_ROUND_FILTER_STAGE_HASH
:
dap_chain_cs_dag_event_calc_hash
((
dap_chain_cs_dag_event_t
*
)
l_round_item
->
event_n_signs
,
l_round_item
->
event_size
,
&
l_event_hash
);
if
(
memcmp
(
&
l_winner_hash
,
&
l_event_hash
,
sizeof
(
dap_hash_fast_t
)))
case
DAP_CHAIN_POA_ROUND_FILTER_STAGE_MEM
:
s_event_get_unique_mem_region
(
l_round_item
,
l_event_mem_region
);
if
(
memcmp
(
&
l_winner_mem_region
,
&
l_event_mem_region
,
DAP_CHAIN_POA_ROUND_FILTER_MEM_SIZE
))
l_dups
=
dap_list_remove_link
(
l_dups
,
it
);
default:
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment