zilliqa 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +27 -0
- data/Gemfile.lock +20 -10
- data/lib/zilliqa/util/difficulty.rb +46 -0
- data/lib/zilliqa/util/validator.rb +0 -10
- data/lib/zilliqa/version.rb +1 -1
- data/lib/zilliqa.rb +1 -0
- data/zilliqa.gemspec +5 -1
- metadata +19 -4
- data/.circleci/config.yml +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5b31a541e002ddbb8e7d6f6565737886e4f7b4cf9c72aef65398a73a4fd6256
|
4
|
+
data.tar.gz: b582db1c358c34dc3cf99c2d224cf1d21fd32c096a0a31af2984de742a9f992b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56b59fb6910ef59f005f49baf2d1d14f523f8615408c874b87bb5d5a35dac9b6adf14279e45b7de58c3cfde8a14d96624f82e91cfa40f45e0460c66e133574dc
|
7
|
+
data.tar.gz: d58305528951a8435575ec6a6ebbb180eb849d2b6acfa87132fb6aec26082c1f7be35f8b655932c0387539fdfc537fbeb4c0987d548b354110c114ee27c1ffa4
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
types: [opened, labeled, reopened, synchronize]
|
6
|
+
push:
|
7
|
+
branches: [master]
|
8
|
+
|
9
|
+
defaults:
|
10
|
+
run:
|
11
|
+
shell: bash
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
name: test
|
17
|
+
steps:
|
18
|
+
- name: Setup Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: 2.7.3
|
22
|
+
rubygems: latest
|
23
|
+
bundler-cache: true
|
24
|
+
- uses: actions/checkout@v3
|
25
|
+
- run: sudo apt-get update -y && sudo apt-get install -y libsecp256k1-dev
|
26
|
+
- run: bundle install
|
27
|
+
- run: bundle exec rake test
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zilliqa (0.1.
|
4
|
+
zilliqa (0.1.6)
|
5
5
|
bitcoin-ruby
|
6
|
+
bundler (>= 2.2.33)
|
6
7
|
google-protobuf
|
7
8
|
jsonrpc-client
|
8
9
|
pbkdf2-ruby
|
@@ -16,22 +17,31 @@ GEM
|
|
16
17
|
eventmachine
|
17
18
|
ffi
|
18
19
|
scrypt
|
20
|
+
byebug (11.1.3)
|
21
|
+
coderay (1.1.3)
|
19
22
|
eventmachine (1.2.7)
|
20
|
-
faraday (2.
|
21
|
-
faraday-net_http (
|
23
|
+
faraday (2.7.10)
|
24
|
+
faraday-net_http (>= 2.0, < 3.1)
|
22
25
|
ruby2_keywords (>= 0.0.4)
|
23
|
-
faraday-net_http (
|
26
|
+
faraday-net_http (3.0.2)
|
24
27
|
ffi (1.15.5)
|
25
28
|
ffi-compiler (1.0.1)
|
26
29
|
ffi (>= 1.0.0)
|
27
30
|
rake
|
28
|
-
google-protobuf (3.
|
29
|
-
jsonrpc-client (0.1.
|
31
|
+
google-protobuf (3.24.0)
|
32
|
+
jsonrpc-client (0.1.4)
|
30
33
|
faraday
|
31
34
|
multi_json (>= 1.1.0)
|
32
|
-
|
35
|
+
method_source (1.0.0)
|
36
|
+
minitest (5.15.0)
|
33
37
|
multi_json (1.15.0)
|
34
38
|
pbkdf2-ruby (0.2.1)
|
39
|
+
pry (0.14.2)
|
40
|
+
coderay (~> 1.1)
|
41
|
+
method_source (~> 1.0)
|
42
|
+
pry-byebug (3.10.1)
|
43
|
+
byebug (~> 11.0)
|
44
|
+
pry (>= 0.13, < 0.15)
|
35
45
|
rake (13.0.6)
|
36
46
|
ruby-bitcoin-secp256k1 (0.5.2)
|
37
47
|
ffi (>= 1.9.25)
|
@@ -43,10 +53,10 @@ PLATFORMS
|
|
43
53
|
ruby
|
44
54
|
|
45
55
|
DEPENDENCIES
|
46
|
-
|
47
|
-
|
56
|
+
minitest (= 5.15)
|
57
|
+
pry-byebug (~> 3.10)
|
48
58
|
rake (~> 13.0)
|
49
59
|
zilliqa!
|
50
60
|
|
51
61
|
BUNDLED WITH
|
52
|
-
|
62
|
+
2.2.33
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Zilliqa
|
2
|
+
module Util
|
3
|
+
class Difficulty
|
4
|
+
ZERO_MASK = [0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01]
|
5
|
+
DIVIDEND = 'ffff000000000000000000000000000000000000000000000000000000000000'
|
6
|
+
|
7
|
+
def self.to_boundary_divided(difficulty)
|
8
|
+
n_divided = 8
|
9
|
+
n_divided_start = 32
|
10
|
+
|
11
|
+
return to_boundary(difficulty) if difficulty < n_divided_start
|
12
|
+
|
13
|
+
n_level = (difficulty - n_divided_start) / n_divided
|
14
|
+
m_sub_level = (difficulty - n_divided_start) % n_divided
|
15
|
+
difficulty_level = n_divided_start + n_level
|
16
|
+
|
17
|
+
int_boundary = to_boundary(difficulty_level)
|
18
|
+
|
19
|
+
boundary_change_step = (int_boundary >> 1).div(n_divided)
|
20
|
+
|
21
|
+
int_boundary - (boundary_change_step * m_sub_level)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.to_boundary(difficulty)
|
25
|
+
boundary = ['ff'*32].pack('H*').bytes
|
26
|
+
|
27
|
+
n_bytes_to_zero = difficulty / 8
|
28
|
+
n_bits_to_zero = difficulty % 8
|
29
|
+
|
30
|
+
(0..n_bytes_to_zero).each { |i| boundary[i] = 0 }
|
31
|
+
|
32
|
+
boundary[n_bytes_to_zero] = ZERO_MASK[n_bits_to_zero]
|
33
|
+
|
34
|
+
boundary.pack('C*').unpack('H*').first.to_i(16)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def self.to_hashpower_divided(difficulty)
|
39
|
+
boundary = to_boundary_divided(difficulty)
|
40
|
+
|
41
|
+
int_dividend = DIVIDEND.to_i(16)
|
42
|
+
int_dividend / boundary
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -22,16 +22,6 @@ module Zilliqa
|
|
22
22
|
m != nil
|
23
23
|
end
|
24
24
|
|
25
|
-
# checksum_address?
|
26
|
-
#
|
27
|
-
# takes hex-encoded string and returns boolean if address is checksumed
|
28
|
-
#
|
29
|
-
# @param {string} address
|
30
|
-
# @returns {boolean}
|
31
|
-
def self.checksum_address?(address)
|
32
|
-
self.address?(address) && Zilliqa::Account::Wallet::to_checksum_address(address) == address
|
33
|
-
end
|
34
|
-
|
35
25
|
def self.bech32?(address)
|
36
26
|
m = /^zil1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{38}/ =~ address
|
37
27
|
m != nil
|
data/lib/zilliqa/version.rb
CHANGED
data/lib/zilliqa.rb
CHANGED
data/zilliqa.gemspec
CHANGED
@@ -36,7 +36,11 @@ Gem::Specification.new do |spec|
|
|
36
36
|
|
37
37
|
spec.add_dependency "bundler", ">= 2.2.33"
|
38
38
|
spec.add_development_dependency "rake", "~> 13.0"
|
39
|
-
|
39
|
+
# FIXME starting with 5.16 minitest supports kwargs in mocks,
|
40
|
+
# and that breaks our tests, e.g in contract/contract_factory_test.rb:186,
|
41
|
+
# where we expect hash as mock argument, but minitest treat this hash as kwargs
|
42
|
+
spec.add_development_dependency "minitest", "5.15"
|
43
|
+
spec.add_development_dependency "pry-byebug", "~> 3.10"
|
40
44
|
spec.add_dependency "ruby-bitcoin-secp256k1"
|
41
45
|
spec.add_dependency "scrypt"
|
42
46
|
spec.add_dependency "pbkdf2-ruby"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zilliqa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- snuff
|
@@ -41,18 +41,32 @@ dependencies:
|
|
41
41
|
version: '13.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: minitest
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '5.15'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '5.15'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: pry-byebug
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
60
|
- - "~>"
|
47
61
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
62
|
+
version: '3.10'
|
49
63
|
type: :development
|
50
64
|
prerelease: false
|
51
65
|
version_requirements: !ruby/object:Gem::Requirement
|
52
66
|
requirements:
|
53
67
|
- - "~>"
|
54
68
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
69
|
+
version: '3.10'
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: ruby-bitcoin-secp256k1
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +159,7 @@ executables: []
|
|
145
159
|
extensions: []
|
146
160
|
extra_rdoc_files: []
|
147
161
|
files:
|
148
|
-
- ".
|
162
|
+
- ".github/workflows/ci.yml"
|
149
163
|
- ".gitignore"
|
150
164
|
- ".travis.yml"
|
151
165
|
- Gemfile
|
@@ -169,6 +183,7 @@ files:
|
|
169
183
|
- lib/zilliqa/proto/message.proto
|
170
184
|
- lib/zilliqa/proto/message_pb.rb
|
171
185
|
- lib/zilliqa/util/bech32.rb
|
186
|
+
- lib/zilliqa/util/difficulty.rb
|
172
187
|
- lib/zilliqa/util/unit.rb
|
173
188
|
- lib/zilliqa/util/util.rb
|
174
189
|
- lib/zilliqa/util/validator.rb
|
data/.circleci/config.yml
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
version: 2.1
|
2
|
-
jobs:
|
3
|
-
build:
|
4
|
-
docker:
|
5
|
-
- image: circleci/ruby:2.6.1
|
6
|
-
environment:
|
7
|
-
RAILS_ENV: test
|
8
|
-
steps:
|
9
|
-
- checkout
|
10
|
-
- run:
|
11
|
-
name: Which bundler?
|
12
|
-
command: bundle -v
|
13
|
-
|
14
|
-
- restore_cache:
|
15
|
-
keys:
|
16
|
-
- zilliqa{{ checksum "Gemfile.lock" }}
|
17
|
-
- zilliqa
|
18
|
-
|
19
|
-
- run:
|
20
|
-
name: Install libsecp256k1-dev dependency
|
21
|
-
command: sudo apt-get update -y && sudo apt-get install -y libsecp256k1-dev
|
22
|
-
|
23
|
-
- run:
|
24
|
-
name: Bundle Install
|
25
|
-
command: bundle install
|
26
|
-
- save_cache:
|
27
|
-
key: zilliqa{{ checksum "Gemfile.lock" }}
|
28
|
-
paths:
|
29
|
-
- vendor/bundle
|
30
|
-
- run: bundle exec rake test
|