Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tinman
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
hive
tinman
Commits
5d481e6d
Unverified
Commit
5d481e6d
authored
6 years ago
by
Anthony Martin
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #168 from steemit/100-txgen-chain-defaults
conf + constants #100
parents
db49c8dd
2431aadf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/txgen_test.py
+14
-7
14 additions, 7 deletions
test/txgen_test.py
tinman/txgen.py
+35
-24
35 additions, 24 deletions
tinman/txgen.py
txgen.conf.example
+6
-0
6 additions, 0 deletions
txgen.conf.example
with
55 additions
and
31 deletions
test/txgen_test.py
+
14
−
7
View file @
5d481e6d
...
...
@@ -6,6 +6,12 @@ from tinman import txgen
FULL_CONF
=
{
"
transactions_per_block
"
:
40
,
"
steem_block_interval
"
:
3
,
"
num_blocks_to_clear_witness_round
"
:
21
,
"
transaction_witness_setup_pad
"
:
100
,
"
steem_max_authority_membership
"
:
10
,
"
steem_address_prefix
"
:
"
TST
"
,
"
steem_init_miner_name
"
:
'
initminer
'
,
"
snapshot_file
"
:
"
/tmp/test-snapshot.json
"
,
"
backfill_file
"
:
"
/tmp/test-backfill.actions
"
,
"
min_vesting_per_account
"
:
{
"
amount
"
:
"
1
"
,
"
precision
"
:
3
,
"
nai
"
:
"
@@000000021
"
},
...
...
@@ -219,13 +225,14 @@ class TxgenTest(unittest.TestCase):
cmd
,
args
=
action
if
cmd
==
"
metadata
"
:
self
.
assertEqual
(
args
[
"
txgen:semver
"
],
"
0.2
"
)
self
.
assertEqual
(
args
[
"
txgen:transactions_per_block
"
],
40
)
self
.
assertIsNotNone
(
args
[
"
epoch:created
"
])
self
.
assertEqual
(
args
[
"
actions:count
"
],
73
)
self
.
assertGreater
(
args
[
"
recommend:miss_blocks
"
],
28631339
)
self
.
assertEqual
(
args
[
"
snapshot:semver
"
],
"
0.2
"
)
self
.
assertEqual
(
args
[
"
snapshot:origin_api
"
],
"
http://calculon.local
"
)
if
not
args
.
get
(
"
post_backfill
"
):
self
.
assertEqual
(
args
[
"
txgen:semver
"
],
"
0.2
"
)
self
.
assertEqual
(
args
[
"
txgen:transactions_per_block
"
],
40
)
self
.
assertIsNotNone
(
args
[
"
epoch:created
"
])
self
.
assertEqual
(
args
[
"
actions:count
"
],
73
)
self
.
assertGreater
(
args
[
"
recommend:miss_blocks
"
],
28631339
)
self
.
assertEqual
(
args
[
"
snapshot:semver
"
],
"
0.2
"
)
self
.
assertEqual
(
args
[
"
snapshot:origin_api
"
],
"
http://calculon.local
"
)
elif
cmd
==
"
wait_blocks
"
:
self
.
assertGreater
(
args
[
"
count
"
],
0
)
elif
cmd
==
"
submit_transaction
"
:
...
...
This diff is collapsed.
Click to expand it.
tinman/txgen.py
+
35
−
24
View file @
5d481e6d
...
...
@@ -31,8 +31,11 @@ TRANSACTION_WITNESS_SETUP_PAD = 100
STEEM_MAX_AUTHORITY_MEMBERSHIP
=
10
DENOM
=
10
**
12
# we need stupidly high precision because VESTS
STEEM_BLOCKS_PER_DAY
=
28800
STEEM_ADDRESS_PREFIX
=
"
TST
"
STEEM_INIT_MINER_NAME
=
"
initminer
"
def
create_system_accounts
(
conf
,
keydb
,
name
):
steem_init_miner_name
=
conf
.
get
(
"
steem_init_miner_name
"
,
STEEM_INIT_MINER_NAME
)
desc
=
conf
[
"
accounts
"
][
name
]
for
index
in
range
(
desc
.
get
(
"
count
"
,
1
)):
name
=
desc
[
"
name
"
].
format
(
index
=
index
)
...
...
@@ -46,7 +49,7 @@ def create_system_accounts(conf, keydb, name):
"
memo_key
"
:
keydb
.
get_pubkey
(
name
,
"
memo
"
),
"
json_metadata
"
:
""
,
}},
{
"
type
"
:
"
transfer_to_vesting_operation
"
,
"
value
"
:
{
"
from
"
:
"
initminer
"
,
"
from
"
:
steem_
init
_
miner
_name
,
"
to
"
:
name
,
"
amount
"
:
desc
[
"
vesting
"
],
}}],
...
...
@@ -107,26 +110,28 @@ def build_setup_transactions(account_stats, conf, keydb, silent=True):
yield
from
port_snapshot
(
account_stats
,
conf
,
keydb
,
silent
)
def
build_initminer_tx
(
conf
,
keydb
):
steem_init_miner_name
=
conf
.
get
(
"
steem_init_miner_name
"
,
STEEM_INIT_MINER_NAME
)
return
{
"
operations
"
:
[
{
"
type
"
:
"
account_update_operation
"
,
"
value
"
:
{
"
account
"
:
"
initminer
"
,
"
owner
"
:
keydb
.
get_authority
(
"
initminer
"
,
"
owner
"
),
"
active
"
:
keydb
.
get_authority
(
"
initminer
"
,
"
active
"
),
"
posting
"
:
keydb
.
get_authority
(
"
initminer
"
,
"
posting
"
),
"
memo_key
"
:
keydb
.
get_pubkey
(
"
initminer
"
,
"
memo
"
),
"
account
"
:
steem_
init
_
miner
_name
,
"
owner
"
:
keydb
.
get_authority
(
steem_
init
_
miner
_name
,
"
owner
"
),
"
active
"
:
keydb
.
get_authority
(
steem_
init
_
miner
_name
,
"
active
"
),
"
posting
"
:
keydb
.
get_authority
(
steem_
init
_
miner
_name
,
"
posting
"
),
"
memo_key
"
:
keydb
.
get_pubkey
(
steem_
init
_
miner
_name
,
"
memo
"
),
"
json_metadata
"
:
""
,
}},
{
"
type
"
:
"
transfer_to_vesting_operation
"
,
"
value
"
:
{
"
from
"
:
"
initminer
"
,
"
to
"
:
"
initminer
"
,
"
amount
"
:
conf
[
"
accounts
"
][
"
initminer
"
][
"
vesting
"
],
"
from
"
:
steem_
init
_
miner
_name
,
"
to
"
:
steem_
init
_
miner
_name
,
"
amount
"
:
conf
[
"
accounts
"
][
steem_
init
_
miner
_name
][
"
vesting
"
],
}},
{
"
type
"
:
"
account_witness_vote_operation
"
,
"
value
"
:
{
"
account
"
:
"
initminer
"
,
"
witness
"
:
"
initminer
"
,
"
account
"
:
steem_
init
_
miner
_name
,
"
witness
"
:
steem_
init
_
miner
_name
,
"
approve
"
:
True
,
}},
],
...
...
@@ -221,6 +226,7 @@ def get_proportions(account_stats, conf, silent=True):
}
def
create_accounts
(
account_stats
,
conf
,
keydb
,
silent
=
True
):
steem_address_prefix
=
conf
.
get
(
"
steem_address_prefix
"
,
STEEM_ADDRESS_PREFIX
)
system_account_names
=
set
(
get_system_account_names
(
conf
))
proportions
=
get_proportions
(
account_stats
,
conf
,
silent
)
min_vesting_per_account
=
proportions
[
"
min_vesting_per_account
"
]
...
...
@@ -250,7 +256,7 @@ def create_accounts(account_stats, conf, keydb, silent=True):
"
owner
"
:
create_auth
,
"
active
"
:
create_auth
,
"
posting
"
:
create_auth
,
"
memo_key
"
:
"
TST
"
+
a
[
"
memo_key
"
][
3
:],
"
memo_key
"
:
steem_address_prefix
+
a
[
"
memo_key
"
][
3
:],
"
json_metadata
"
:
""
,
}},
{
"
type
"
:
"
transfer_to_vesting_operation
"
,
"
value
"
:
{
"
from
"
:
porter
,
...
...
@@ -278,6 +284,8 @@ def create_accounts(account_stats, conf, keydb, silent=True):
print
(
"
\t
100.00%% complete
"
)
def
update_accounts
(
account_stats
,
conf
,
keydb
,
silent
=
True
):
steem_max_authority_membership
=
conf
.
get
(
"
steem_max_authority_membership
"
,
STEEM_MAX_AUTHORITY_MEMBERSHIP
)
steem_address_prefix
=
conf
.
get
(
"
steem_address_prefix
"
,
STEEM_ADDRESS_PREFIX
)
system_account_names
=
set
(
get_system_account_names
(
conf
))
account_names
=
account_stats
[
"
account_names
"
]
num_accounts
=
len
(
account_names
)
...
...
@@ -298,13 +306,13 @@ def update_accounts(account_stats, conf, keydb, silent=True):
new_posting_auth
=
cur_posting_auth
.
copy
()
# filter to only include existing accounts
for
aw
in
cur_owner_auth
[
"
account_auths
"
][:(
STEEM_MAX_AUTHORITY_MEMBERSHIP
-
1
)]:
for
aw
in
cur_owner_auth
[
"
account_auths
"
][:(
steem_max_authority_membership
-
1
)]:
if
(
aw
[
0
]
not
in
account_names
)
or
(
aw
[
0
]
in
system_account_names
):
new_owner_auth
[
"
account_auths
"
].
remove
(
aw
)
for
aw
in
cur_active_auth
[
"
account_auths
"
][:(
STEEM_MAX_AUTHORITY_MEMBERSHIP
-
1
)]:
for
aw
in
cur_active_auth
[
"
account_auths
"
][:(
steem_max_authority_membership
-
1
)]:
if
(
aw
[
0
]
not
in
account_names
)
or
(
aw
[
0
]
in
system_account_names
):
new_active_auth
[
"
account_auths
"
].
remove
(
aw
)
for
aw
in
cur_posting_auth
[
"
account_auths
"
][:(
STEEM_MAX_AUTHORITY_MEMBERSHIP
-
1
)]:
for
aw
in
cur_posting_auth
[
"
account_auths
"
][:(
steem_max_authority_membership
-
1
)]:
if
(
aw
[
0
]
not
in
account_names
)
or
(
aw
[
0
]
in
system_account_names
):
new_posting_auth
[
"
account_auths
"
].
remove
(
aw
)
...
...
@@ -314,9 +322,9 @@ def update_accounts(account_stats, conf, keydb, silent=True):
new_posting_auth
[
"
account_auths
"
].
append
([
tnman
,
cur_posting_auth
[
"
weight_threshold
"
]])
# substitute prefix for key_auths
new_owner_auth
[
"
key_auths
"
]
=
[[
"
TST
"
+
k
[
3
:],
w
]
for
k
,
w
in
new_owner_auth
[
"
key_auths
"
][:
STEEM_MAX_AUTHORITY_MEMBERSHIP
]]
new_active_auth
[
"
key_auths
"
]
=
[[
"
TST
"
+
k
[
3
:],
w
]
for
k
,
w
in
new_active_auth
[
"
key_auths
"
][:
STEEM_MAX_AUTHORITY_MEMBERSHIP
]]
new_posting_auth
[
"
key_auths
"
]
=
[[
"
TST
"
+
k
[
3
:],
w
]
for
k
,
w
in
new_posting_auth
[
"
key_auths
"
][:
STEEM_MAX_AUTHORITY_MEMBERSHIP
]]
new_owner_auth
[
"
key_auths
"
]
=
[[
steem_address_prefix
+
k
[
3
:],
w
]
for
k
,
w
in
new_owner_auth
[
"
key_auths
"
][:
steem_max_authority_membership
]]
new_active_auth
[
"
key_auths
"
]
=
[[
steem_address_prefix
+
k
[
3
:],
w
]
for
k
,
w
in
new_active_auth
[
"
key_auths
"
][:
steem_max_authority_membership
]]
new_posting_auth
[
"
key_auths
"
]
=
[[
steem_address_prefix
+
k
[
3
:],
w
]
for
k
,
w
in
new_posting_auth
[
"
key_auths
"
][:
steem_max_authority_membership
]]
ops
=
[{
"
type
"
:
"
account_update_operation
"
,
"
value
"
:
{
"
account
"
:
a
[
"
name
"
],
...
...
@@ -340,16 +348,17 @@ def update_accounts(account_stats, conf, keydb, silent=True):
print
(
"
\t
100.00%% complete
"
)
def
port_snapshot
(
account_stats
,
conf
,
keydb
,
silent
=
True
):
steem_init_miner_name
=
conf
.
get
(
"
steem_init_miner_name
"
,
STEEM_INIT_MINER_NAME
)
porter
=
conf
[
"
accounts
"
][
"
porter
"
][
"
name
"
]
yield
{
"
operations
"
:
[
{
"
type
"
:
"
transfer_operation
"
,
"
value
"
:
{
"
from
"
:
"
initminer
"
,
"
value
"
:
{
"
from
"
:
steem_
init
_
miner
_name
,
"
to
"
:
porter
,
"
amount
"
:
conf
[
"
total_port_balance
"
],
"
memo
"
:
"
Fund porting balances
"
,
}}],
"
wif_sigs
"
:
[
keydb
.
get_privkey
(
"
initminer
"
)]}
"
wif_sigs
"
:
[
keydb
.
get_privkey
(
steem_
init
_
miner
_name
)]}
yield
from
create_accounts
(
account_stats
,
conf
,
keydb
,
silent
)
yield
from
update_accounts
(
account_stats
,
conf
,
keydb
,
silent
)
...
...
@@ -364,6 +373,8 @@ def build_actions(conf, silent=True):
account_names
=
account_stats
[
"
account_names
"
]
num_accounts
=
len
(
account_names
)
transactions_per_block
=
conf
[
"
transactions_per_block
"
]
steem_block_interval
=
conf
.
get
(
"
steem_block_interval
"
,
STEEM_BLOCK_INTERVAL
)
transaction_witness_setup_pad
=
conf
.
get
(
"
transaction_witness_setup_pad
"
,
TRANSACTION_WITNESS_SETUP_PAD
)
genesis_time
=
datetime
.
datetime
.
utcfromtimestamp
(
STEEM_GENESIS_TIMESTAMP
)
...
...
@@ -379,11 +390,11 @@ def build_actions(conf, silent=True):
# Pad for update witnesses, vote witnesses, clear rounds, and transaction
# setup processing time
predicted_block_count
+=
TRANSACTION_WITNESS_SETUP_PAD
+
(
predicted_transaction_setup_seconds
//
STEEM_BLOCK_INTERVAL
)
predicted_block_count
+=
transaction_witness_setup_pad
+
(
predicted_transaction_setup_seconds
//
steem_block_interval
)
now
=
datetime
.
datetime
.
utcnow
()
start_time
=
now
-
datetime
.
timedelta
(
seconds
=
predicted_block_count
*
STEEM_BLOCK_INTERVAL
)
miss_blocks
=
int
((
start_time
-
genesis_time
).
total_seconds
())
//
STEEM_BLOCK_INTERVAL
start_time
=
now
-
datetime
.
timedelta
(
seconds
=
predicted_block_count
*
steem_block_interval
)
miss_blocks
=
int
((
start_time
-
genesis_time
).
total_seconds
())
//
steem_block_interval
miss_blocks
=
max
(
miss_blocks
-
1
,
0
)
origin_api
=
None
snapshot_head_block_num
=
None
...
...
@@ -455,7 +466,7 @@ def build_actions(conf, silent=True):
for
tx
in
vote_accounts
(
conf
,
keydb
,
"
elector
"
,
"
init
"
):
yield
[
"
submit_transaction
"
,
{
"
tx
"
:
tx
}]
yield
[
"
wait_blocks
"
,
{
"
count
"
:
NUM_BLOCKS_TO_CLEAR_WITNESS_ROUND
}]
yield
[
"
wait_blocks
"
,
{
"
count
"
:
conf
.
get
(
"
num_blocks_to_clear_witness_round
"
,
NUM_BLOCKS_TO_CLEAR_WITNESS_ROUND
)
}]
return
def
main
(
argv
):
...
...
This diff is collapsed.
Click to expand it.
txgen.conf.example
+
6
−
0
View file @
5d481e6d
{
"transactions_per_block" : 40,
"steem_block_interval" : 3,
"num_blocks_to_clear_witness_round" : 21,
"transaction_witness_setup_pad" : 100,
"steem_max_authority_membership" : 10,
"steem_address_prefix" : "TST",
"steem_init_miner_name" : "initminer",
"snapshot_file" : "snapshot.json",
"backfill_file" : "backfill.actions",
...
...
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