Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
blockchain
nucleo
Commits
9614599b
Commit
9614599b
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://gitlab.bfa.ar/blockchain/nucleo
into distillery
parents
a873c1b0
4588e46e
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Distillery
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+2
-0
2 additions, 0 deletions
README.md
bin/installbfa.sh
+1
-1
1 addition, 1 deletion
bin/installbfa.sh
bin/libbfa.pm
+108
-0
108 additions, 0 deletions
bin/libbfa.pm
bin/walker.pl
+72
-71
72 additions, 71 deletions
bin/walker.pl
with
183 additions
and
72 deletions
README.md
+
2
−
0
View file @
9614599b
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
## Website: https://www.bfa.ar/
## Website: https://www.bfa.ar/
## Repo: https://gitlab.bfa.ar/blockchain/nucleo.git
## Repo: https://gitlab.bfa.ar/blockchain/nucleo.git
This guide should work on Debian derived systems. Tested on
*Debian*
and
*Ubuntu Server*
with no GUI to be installed in either.
1.
Install
`git`
1.
Install
`git`
-
as root:
`apt install git`
-
as root:
`apt install git`
2.
Clone the official BFA repository
2.
Clone the official BFA repository
...
...
This diff is collapsed.
Click to expand it.
bin/installbfa.sh
+
1
−
1
View file @
9614599b
...
@@ -158,7 +158,7 @@ function usersetup
...
@@ -158,7 +158,7 @@ function usersetup
git pull
git pull
#
#
cd
~bfa
cd
~bfa
if
expand
< .bashrc |
grep
-E
vq
'source .*bfa/bin/env'
if
[
$(
expand
< .bashrc |
grep
-E
'source .*bfa/bin/env'
|
wc
-l
)
-eq
0
]
then
then
info Adding to automatically
source
\~
bfa/bfa/bin/env via .bashrc
info Adding to automatically
source
\~
bfa/bfa/bin/env via .bashrc
echo
'source ~/bfa/bin/env'
>>
.bashrc
echo
'source ~/bfa/bin/env'
>>
.bashrc
...
...
This diff is collapsed.
Click to expand it.
bin/libbfa.pm
0 → 100644
+
108
−
0
View file @
9614599b
# 20180927 Robert Martin-Legene <robert@nic.ar>
package
libbfa
;
use
Math::
BigInt
;
use
IO::
File
;
use
LWP
;
use
JSON
;
use
Carp
;
$
Carp::
Verbose
=
1
;
sub
_cat
{
my
$filename
=
shift
;
my
$fh
=
IO::
File
->
new
(
$filename
);
return
if
not
defined
$fh
;
local
$_
=
join
(
'',
$fh
->
getlines
);
$fh
->
close
;
return
if
not
defined
$_
;
s|^\s+||
;
s|\s+$||
;
return
if
$_
eq
'';
return
$_
;
}
sub
_filecontents_or_default
{
my
(
$self
,
$filename
,
$default
)
=
@_
;
local
$_
=
$self
->
_cat
(
$filename
);
return
$default
if
not
defined
$_
;
return
$_
;
}
sub
new
{
my
(
$class
)
=
@_
;
my
$self
=
bless
{},
ref
$class
||
$class
;
# BFAHOME
die
'
$BFAHOME not set. Did you source bfa/bin/env ?\n
'
if
not
exists
$ENV
{'
BFAHOME
'};
$self
->
{'
home
'}
=
$ENV
{'
BFAHOME
'};
# BFANETWORKID
$self
->
{'
networkid
'}
=
$ENV
{'
BFANETWORKID
'}
=
exists
$ENV
{'
BFANETWORKID
'}
?
$ENV
{'
BFANETWORKID
'}
:
47525974938
;
# BFANETWORKDIR
$self
->
{'
networkdir
'}
=
$ENV
{'
BFANETWORKDIR
'}
=
exists
$ENV
{'
BFANETWORKDIR
'}
?
$ENV
{'
BFANETWORKDIR
'}
:
$self
->
{'
home
'}
.
'
/network
';
# BFANODEDIR
$self
->
{'
nodedir
'}
=
$ENV
{'
BFANODEDIR
'}
=
exists
$ENV
{'
BFANODEDIR
'}
?
$ENV
{'
BFANODEDIR
'}
:
$self
->
{'
networkdir
'}
.
'
/node
';
# ACCOUNT
if
(
not
exists
$ENV
{'
BFAACCOUNT
'}
)
{
my
$dir
=
$self
->
{'
nodedir
'};
my
@files
=
sort
<
$
{
dir
}
/*--*>
;
# found none?
if
(
scalar
(
@files
)
>
0
)
{
my
$file
=
$files
[
0
];
$file
=~
s/^.*--//
;
$self
->
{'
account
'}
=
$ENV
{'
BFAACCOUNT
'}
=
'
0x
'
.
$file
;
}
}
#
$self
->
{'
netport
'}
=
$self
->
_filecontents_or_default
(
$self
->
{'
nodedir
'}
.
'
/netport
',
30303
);
$self
->
{'
rpcport
'}
=
$self
->
_filecontents_or_default
(
$self
->
{'
nodedir
'}
.
'
/netport
',
8545
);
$self
->
{'
ua
'}
=
LWP::
UserAgent
->
new
;
return
$self
;
}
sub
contract
{
my
$self
=
shift
;
my
$contract
=
{};
my
$contname
=
shift
;
my
$contdir
=
join
('
/
',
[
$self
->
{'
networkdir
'},
'
contracts
',
$contname
]
);
my
$contaddr
=
readlink
$contdir
;
return
if
not
defined
$contaddr
;
$contaddr
=~
s|^.*/||
;
$contract
->
{'
address
'}
=
#contaddr;
my
$abistr
=
$self
->
_cat
(
$contdir
.
'
/abi
'
);
die
"
Can not find abi file, stopped
"
if
not
defined
$abistr
;
eval
{
my
$contract
->
{'
abi
'}
=
decode_json
(
$abistr
)
};
die
"
Can not decode json, stopped
"
if
not
defined
$contract
->
{'
abi
'};
return
$contract
;
}
sub
rpcreq
{
my
(
$self
,
$opname
,
@params
)
=
@_
;
my
$req
=
HTTP::
Request
->
new
(
POST
=>
"
http://127.0.0.1:
"
.
$self
->
{'
rpcport
'}
);
$req
->
content_type
('
application/json
');
my
$extra
=
scalar
@params
?
sprintf
(
qq(,\"params\":[%s])
,
join
('
,
',
@params
))
:
'';
$req
->
content
(
qq({"jsonrpc":"2.0","method":"${opname}"${extra},"id":1})
);
my
$res
=
$self
->
{'
ua
'}
->
request
(
$req
);
die
$res
->
status_line
unless
$res
->
is_success
;
return
$res
->
content
;
}
1
;
This diff is collapsed.
Click to expand it.
bin/walker.pl
+
72
−
71
View file @
9614599b
...
@@ -6,13 +6,17 @@ use IO::File;
...
@@ -6,13 +6,17 @@ use IO::File;
use
Math::
BigInt
;
use
Math::
BigInt
;
use
Carp
;
use
Carp
;
$
Carp::
Verbose
=
1
;
$
Carp::
Verbose
=
1
;
BEGIN
{
die
"
\$
BFAHOME not set. Did you source bfa/bin/env ?
\n
"
die
"
\$
BFAHOME not set. Did you source bfa/bin/env ?
\n
"
unless
exists
$ENV
{
BFAHOME
};
unless
exists
$ENV
{
BFAHOME
};
chdir
"
$ENV
{BFAHOME}
"
or
die
$!
;
}
use
lib
$ENV
{'
BFAHOME
'}
.
'
/bin
';
use
libbfa
;
use
Data::
Dumper
;
my
$libbfa
;
package
tools
;
package
tools
;
my
$rpcport
;
use
Data::
Dumper
;
my
$ua
=
LWP::
UserAgent
->
new
;
my
$ua
=
LWP::
UserAgent
->
new
;
our
$CSI
=
"
\x1b
[
";
our
$CSI
=
"
\x1b
[
";
our
$clearEOS
=
"
${CSI}
J
";
our
$clearEOS
=
"
${CSI}
J
";
...
@@ -22,8 +26,10 @@ our $normal = "${CSI}m";
...
@@ -22,8 +26,10 @@ our $normal = "${CSI}m";
sub
new
sub
new
{
{
my
$class
=
shift
;
my
(
$class
,
$libbfa
)
=
@_
;
return
bless
{
@
_
},
ref
$class
||
$class
;
my
$self
=
bless
{},
ref
$class
||
$class
;
$self
->
{'
libbfa
'}
=
$libbfa
;
return
$self
;
}
}
sub
wait
sub
wait
...
@@ -68,11 +74,7 @@ sub hex2string($)
...
@@ -68,11 +74,7 @@ sub hex2string($)
sub
rpcreq
sub
rpcreq
{
{
my
(
$opname
,
@params
)
=
@_
;
my
(
$opname
,
@params
)
=
@_
;
if
(
not
defined
$rpcport
)
my
$req
=
HTTP::
Request
->
new
(
POST
=>
'
http://127.0.0.1:
'
.
$libbfa
->
{'
rpcport
'}
);
{
$rpcport
=
tools::
cat
"
$ENV
{BFAHOME}/network5445/node1/rpcport
"
or
die
;
}
my
$req
=
HTTP::
Request
->
new
(
POST
=>
"
http://127.0.0.1:
$rpcport
"
);
$req
->
content_type
('
application/json
');
$req
->
content_type
('
application/json
');
my
$extra
=
scalar
@params
my
$extra
=
scalar
@params
?
sprintf
(
qq(,\"params\":[%s])
,
join
('
,
',
@params
))
?
sprintf
(
qq(,\"params\":[%s])
,
join
('
,
',
@params
))
...
@@ -86,11 +88,13 @@ sub rpcreq
...
@@ -86,11 +88,13 @@ sub rpcreq
package
balance
;
package
balance
;
use
JSON
;
use
JSON
;
use
Data::
Dumper
;
sub
new
sub
new
{
{
my
(
$class
,
$acct
,
$at
)
=
@_
;
my
(
$class
,
$libbfa
,
$acct
,
$at
)
=
@_
;
my
$self
=
bless
{},
ref
$class
||
$class
;
my
$self
=
bless
{},
ref
$class
||
$class
;
$self
->
{'
libbfa
'}
=
$libbfa
;
$self
->
get
(
$acct
,
$at
)
if
defined
$acct
;
$self
->
get
(
$acct
,
$at
)
if
defined
$acct
;
return
$self
;
return
$self
;
}
}
...
@@ -118,10 +122,11 @@ sub at
...
@@ -118,10 +122,11 @@ sub at
sub
get
sub
get
{
{
my
(
$self
,
$acct
,
$at
)
=
@_
;
my
(
$self
,
$acct
,
$at
)
=
@_
;
my
$libbfa
=
$self
->
{'
libbfa
'};
$self
->
acct
(
$acct
)
if
defined
$acct
;
$self
->
acct
(
$acct
)
if
defined
$acct
;
$self
->
at
(
$at
)
if
defined
$at
;
$self
->
at
(
$at
)
if
defined
$at
;
my
@params
=
(
sprintf
(
qq("%s","%s")
,
$self
->
acct
,
$self
->
at
)
);
my
@params
=
(
sprintf
(
qq("%s","%s")
,
$self
->
acct
,
$self
->
at
)
);
my
$content
=
tools::
rpcreq
(
'
eth_getBalance
',
@params
);
my
$content
=
$libbfa
->
rpcreq
(
'
eth_getBalance
',
@params
);
my
$json
;
my
$json
;
eval
{
$json
=
decode_json
(
$content
)
};
eval
{
$json
=
decode_json
(
$content
)
};
my
$error
=
error
->
new
(
$content
);
my
$error
=
error
->
new
(
$content
);
...
@@ -139,6 +144,7 @@ sub get
...
@@ -139,6 +144,7 @@ sub get
package
error
;
package
error
;
use
JSON
;
use
JSON
;
use
Data::
Dumper
;
sub
new
sub
new
{
{
...
@@ -173,15 +179,24 @@ sub message
...
@@ -173,15 +179,24 @@ sub message
package
block
;
package
block
;
use
LWP
;
use
LWP
;
use
JSON
;
use
JSON
;
use
Data::
Dumper
;
sub
new
sub
new
{
{
my
(
$class
,
$json_raw
)
=
@_
;
my
(
$class
,
$libbfa
)
=
@_
;
my
$self
=
bless
{},
ref
$class
||
$class
;
$self
->
{'
libbfa
'}
=
$libbfa
;
return
$self
;
}
sub
parse
{
my
(
$self
,
$json_raw
)
=
@_
;
$self
->
{'
libbfa
'}
=
$libbfa
;
return
unless
defined
$json_raw
;
return
unless
defined
$json_raw
;
return
if
$json_raw
eq
'';
return
if
$json_raw
eq
'';
my
$self
=
bless
{},
ref
$class
||
$class
;
$self
->
{'
json_raw
'}
=
$json_raw
;
$self
->
{'
json_raw
'}
=
$json_raw
;
eval
{
$self
->
{'
json
'}
=
decode_json
(
$json_raw
)
};
eval
{
$self
->
{'
json
'}
=
decode_json
(
$json_raw
)
};
return
if
$@
;
return
if
$@
;
$self
->
error
(
error
->
new
(
$json_raw
)
);
$self
->
error
(
error
->
new
(
$json_raw
)
);
return
$self
;
return
$self
;
...
@@ -292,59 +307,38 @@ sub clear
...
@@ -292,59 +307,38 @@ sub clear
return
$t
;
return
$t
;
}
}
sub
signature
sub
get
{
{
my
(
$self
)
=
@_
;
my
(
$self
,
$number
)
=
@_
;
my
$t
=
$self
->
extradata
;
my
$cachefile
;
return
unless
defined
$t
;
if
(
$number
=~
/^[0-9]+$/
)
return
substr
(
$t
,
-
130
);
{
my
$res
=
$self
->
result
;
$number
=
sprintf
('
0x%x
',
$number
);
die
unless
defined
$res
;
$cachefile
=
"
cache/block.
$number
";
use
Data::
Dumper
;
}
die
Dumper
(
$res
)
.
my
$libbfa
=
$self
->
{'
libbfa
'};
clear
(
$res
->
{'
parentHash
'})
.
my
$block
=
block
->
new
(
$libbfa
);
clear
(
$res
->
{'
sha3Uncles
'})
.
if
(
defined
$cachefile
and
-
r
$cachefile
)
clear
(
$res
->
{'
miner
'})
.
clear
(
$res
->
{'
stateRoot
'})
.
clear
(
$res
->
{'
transactionsRoot
'})
.
clear
(
$res
->
{'
receiptsRoot
'})
.
clear
(
$res
->
{'
logsBloom
'})
.
clear
(
$res
->
{'
difficulty
'})
.
clear
(
$res
->
{'
number
'})
.
clear
(
$res
->
{'
gasLimit
'})
.
clear
(
$res
->
{'
gasUsed
'})
.
clear
(
$res
->
{'
timestamp
'})
.
substr
(
clear
(
$res
->
{'
extraData
'}),
0
,
-
130
)
.
('
0
'
x
130
)
.
clear
(
$res
->
{'
mixHash
'})
.
clear
(
$self
->
{'
nonce
'});
}
sub
get
($
;
$
)
{
my
(
$number
)
=
@_
;
$number
=
sprintf
('
0x%x
',
$number
)
if
$number
ne
'
earliest
';
my
$cachefile
=
"
cache/block.
$number
";
my
$block
;
if
(
-
r
$cachefile
)
{
{
$block
=
block
->
new
(
tools::
cat
$cachefile
);
$block
=
$
block
->
parse
(
tools::
cat
$cachefile
);
return
$block
return
$block
if
defined
$block
and
not
$block
->
error
;
if
defined
$block
and
not
$block
->
error
;
# We delete the cache file if we couldn't use the data in it.
# We delete the cache file if we couldn't use the data in it.
unlink
$cachefile
;
unlink
$cachefile
;
# and then we continue to fetch it
# and then we continue to fetch it
}
}
my
$content
=
tools::
rpcreq
(
'
eth_getBlockByNumber
',
qq("$number")
,
"
false
");
my
$content
=
tools::
rpcreq
(
'
eth_getBlockByNumber
',
qq("$number")
,
"
false
");
$block
=
block
->
new
(
$content
);
$block
=
$
block
->
parse
(
$content
);
return
if
not
defined
$block
;
return
if
not
defined
$block
;
return
if
not
exists
$block
->
{'
json
'};
return
if
not
exists
$block
->
{'
json
'};
die
$block
->
error
->
message
die
$block
->
error
->
message
if
$block
->
error
;
if
$block
->
error
;
return
if
not
$block
->
result
;
return
if
not
$block
->
result
;
my
$fh
=
IO::
File
->
new
(
$cachefile
,
'
w
'
)
if
(
defined
$cachefile
)
or
die
$!
;
{
$fh
->
print
(
$block
->
{'
json_raw
'}
);
my
$fh
=
IO::
File
->
new
(
$cachefile
,
'
w
'
)
or
die
$!
;
$fh
->
close
;
$fh
->
print
(
$block
->
{'
json_raw
'}
);
$fh
->
close
;
}
return
$block
;
return
$block
;
}
}
...
@@ -379,12 +373,12 @@ sub sprint
...
@@ -379,12 +373,12 @@ sub sprint
$txt
.=
sprintf
$txt
.=
sprintf
"
Confirming signer at epoch: 0x%s with an ETH balance of %s
\n
",
"
Confirming signer at epoch: 0x%s with an ETH balance of %s
\n
",
$sealer
,
$sealer
,
balance
->
new
->
get
(
$sealer
,
$self
->
number
);
balance
->
new
->
get
(
$libbfa
,
$sealer
,
$self
->
number
);
$lines
++
;
$lines
++
;
}
}
}
}
$txt
.=
sprintf
$txt
.=
sprintf
'
%s block:%s gaslimit:%s td:%d Vanity:
%s
',
'
%s block:%s gaslimit:%s td:%d Vanity:%s
',
tools::
gmt
(
$self
->
timestamp
),
tools::
gmt
(
$self
->
timestamp
),
$self
->
number
,
$self
->
number
,
$self
->
gasLimit
,
$self
->
gasLimit
,
...
@@ -401,33 +395,40 @@ sub sprint
...
@@ -401,33 +395,40 @@ sub sprint
}
}
package
main
;
package
main
;
use
Data::
Dumper
;
$|
=
1
;
$|
=
1
;
chdir
"
$ENV
{BFAHOME}
"
or
die
$!
;
mkdir
'
cache
';
mkdir
'
cache
';
my
$number
=
shift
||
tools::
cat
'
walker.block.last
'
||
'
earli
est
';
my
$number
=
shift
||
'
lat
est
';
my
$tools
=
tools
->
new
;
my
$tools
=
tools
->
new
;
my
@blks
;
my
$parent
;
my
$parent
;
$libbfa
=
libbfa
->
new
();
while
(
1
)
while
(
1
)
{
{
my
$block
=
block
::
get
(
$number
);
my
$block
=
block
->
new
->
get
(
$number
);
if
(
not
defined
$block
)
if
(
not
defined
$block
)
{
{
$tools
->
wait
();
$tools
->
wait
();
next
;
next
;
}
}
$parent
=
block::
get
(
$block
->
number
-
1
)
if
not
defined
$parent
and
$block
->
number
>
1
;
#print Dumper(['block'=>$block]);
if
(
defined
$parent
and
$parent
->
hash
ne
$block
->
parentHash
)
$number
=
$block
->
number
;
if
(
not
defined
$parent
and
$block
->
number
>
1
)
{
$parent
=
$block
->
get
(
$block
->
number
-
1
);
}
if
(
defined
$parent
and
$parent
->
hash
ne
$block
->
parentHash
)
{
{
printf
"
\r
${tools
::
red}
%s
${tools
::
normal}
\n
",
scalar
(
$parent
->
sprint
);
printf
"
\r
${tools
::
red}
%s
${tools
::
normal}
\n
",
scalar
(
$parent
->
sprint
);
(
$parent
,
$block
,
$number
)
=
(
undef
,
$parent
,
$number
-
1
);
(
$parent
,
$block
,
$number
)
=
(
undef
,
$parent
,
$number
-
1
);
$block
->
delete_cache
;
$block
->
delete_cache
;
next
;
next
;
}
}
shift
@blks
while
scalar
@blks
>
32
;
push
@blks
,
$block
;
$block
->
print
;
$block
->
print
;
$number
=
$block
->
number
+
1
;
$number
=
$block
->
number
+
1
;
$parent
=
$block
;
$parent
=
$block
;
}
}
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