ciri 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +0 -1
- data/Gemfile.lock +11 -7
- data/LICENSE.txt +201 -21
- data/README.md +78 -25
- data/Rakefile +45 -17
- data/bin/bundle +105 -0
- data/bin/htmldiff +29 -0
- data/bin/ldiff +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/ciri-crypto/.gitignore +11 -0
- data/ciri-crypto/.rspec +3 -0
- data/ciri-crypto/.travis.yml +5 -0
- data/ciri-crypto/CODE_OF_CONDUCT.md +74 -0
- data/ciri-crypto/Gemfile +6 -0
- data/ciri-crypto/Gemfile.lock +43 -0
- data/ciri-crypto/LICENSE.txt +201 -0
- data/ciri-crypto/README.md +58 -0
- data/ciri-crypto/Rakefile +6 -0
- data/ciri-crypto/bin/console +14 -0
- data/ciri-crypto/bin/setup +8 -0
- data/ciri-crypto/ciri-crypto.gemspec +40 -0
- data/ciri-crypto/lib/ciri/crypto/errors.rb +29 -0
- data/ciri-crypto/lib/ciri/crypto/signature.rb +71 -0
- data/ciri-crypto/lib/ciri/crypto/version.rb +5 -0
- data/{lib → ciri-crypto/lib}/ciri/crypto.rb +16 -69
- data/ciri-crypto/spec/ciri/crypto_spec.rb +56 -0
- data/ciri-crypto/spec/spec_helper.rb +14 -0
- data/ciri-rlp/Gemfile.lock +5 -5
- data/ciri-rlp/LICENSE.txt +201 -21
- data/ciri-rlp/README.md +1 -1
- data/ciri-rlp/ciri-rlp.gemspec +3 -3
- data/ciri-rlp/lib/ciri/rlp/decode.rb +10 -16
- data/ciri-rlp/lib/ciri/rlp/encode.rb +10 -16
- data/ciri-rlp/lib/ciri/rlp/serializable.rb +10 -16
- data/ciri-rlp/lib/ciri/rlp.rb +10 -16
- data/ciri-rlp/spec/ciri/fixture_spec.rb +10 -16
- data/ciri-rlp/spec/ciri/rlp/serializable_spec.rb +10 -16
- data/ciri-utils/Gemfile.lock +4 -4
- data/ciri-utils/LICENSE.txt +201 -21
- data/ciri-utils/README.md +1 -1
- data/ciri-utils/ciri-utils.gemspec +2 -2
- data/ciri-utils/lib/ciri/utils/logger.rb +10 -16
- data/ciri-utils/lib/ciri/utils/number.rb +10 -16
- data/ciri-utils/lib/ciri/utils/version.rb +1 -1
- data/ciri-utils/lib/ciri/utils.rb +3 -3
- data/ciri.gemspec +4 -3
- data/docker/{Base → Dockerfile} +9 -3
- data/lib/ciri/actor.rb +10 -16
- data/lib/ciri/bloom_filter.rb +11 -17
- data/lib/ciri/chain/block.rb +10 -16
- data/lib/ciri/chain/header.rb +12 -18
- data/lib/ciri/chain/header_chain.rb +8 -22
- data/lib/ciri/chain/transaction.rb +38 -33
- data/lib/ciri/chain.rb +27 -26
- data/lib/ciri/core_ext.rb +61 -0
- data/lib/ciri/db/account_db.rb +25 -21
- data/lib/ciri/db/backend/memory.rb +10 -16
- data/lib/ciri/db/backend/rocks.rb +10 -16
- data/lib/ciri/db/backend/rocks_db.rb +10 -16
- data/lib/ciri/devp2p/peer.rb +10 -16
- data/lib/ciri/devp2p/protocol.rb +10 -16
- data/lib/ciri/devp2p/protocol_io.rb +10 -16
- data/lib/ciri/devp2p/rlpx/connection.rb +10 -16
- data/lib/ciri/devp2p/rlpx/encryption_handshake.rb +13 -19
- data/lib/ciri/devp2p/rlpx/error.rb +10 -16
- data/lib/ciri/devp2p/rlpx/frame_io.rb +10 -16
- data/lib/ciri/devp2p/rlpx/message.rb +10 -16
- data/lib/ciri/devp2p/rlpx/node.rb +10 -16
- data/lib/ciri/devp2p/rlpx/protocol_handshake.rb +10 -16
- data/lib/ciri/devp2p/rlpx/protocol_messages.rb +10 -16
- data/lib/ciri/devp2p/rlpx/secrets.rb +10 -16
- data/lib/ciri/devp2p/rlpx.rb +10 -16
- data/lib/ciri/devp2p/server.rb +10 -16
- data/lib/ciri/eth/peer.rb +10 -16
- data/lib/ciri/eth/protocol_manage.rb +10 -16
- data/lib/ciri/eth/protocol_messages.rb +10 -16
- data/lib/ciri/eth/synchronizer.rb +10 -16
- data/lib/ciri/eth.rb +10 -16
- data/lib/ciri/ethash.rb +10 -16
- data/lib/ciri/evm/block_info.rb +25 -17
- data/lib/ciri/evm/errors.rb +13 -16
- data/lib/ciri/evm/execution_context.rb +136 -0
- data/lib/ciri/evm/instruction.rb +17 -24
- data/lib/ciri/evm/log_entry.rb +12 -18
- data/lib/ciri/evm/machine_state.rb +28 -33
- data/lib/ciri/evm/op.rb +52 -89
- data/lib/ciri/evm/op_call.rb +114 -0
- data/lib/ciri/evm/precompile_contract.rb +102 -0
- data/lib/ciri/evm/state.rb +28 -21
- data/lib/ciri/evm/sub_state.rb +18 -24
- data/lib/ciri/evm/vm.rb +128 -190
- data/lib/ciri/evm.rb +77 -85
- data/lib/ciri/forks/base.rb +28 -16
- data/lib/ciri/forks/byzantium.rb +43 -0
- data/lib/ciri/forks/config.rb +36 -0
- data/lib/ciri/forks/frontier/cost.rb +42 -33
- data/lib/ciri/forks/frontier.rb +47 -18
- data/lib/ciri/forks/homestead/cost.rb +195 -0
- data/lib/ciri/forks/homestead.rb +46 -0
- data/lib/ciri/forks.rb +12 -22
- data/lib/ciri/key.rb +14 -3
- data/lib/ciri/pow.rb +11 -17
- data/lib/ciri/rlp/decode.rb +10 -16
- data/lib/ciri/rlp/encode.rb +10 -16
- data/lib/ciri/rlp/serializable.rb +10 -16
- data/lib/ciri/serialize.rb +14 -17
- data/lib/ciri/trie/nibbles.rb +10 -16
- data/lib/ciri/trie/nodes.rb +12 -17
- data/lib/ciri/trie.rb +12 -18
- data/lib/ciri/types/account.rb +15 -17
- data/lib/ciri/types/address.rb +11 -17
- data/lib/ciri/types/errors.rb +10 -16
- data/lib/ciri/types/receipt.rb +12 -18
- data/lib/ciri/types/uint.rb +79 -0
- data/lib/ciri/version.rb +1 -1
- data/lib/ciri.rb +10 -16
- metadata +54 -10
- data/lib/ciri/types/number.rb +0 -73
data/lib/ciri/trie.rb
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright
|
|
3
|
+
# Copyright 2018 Jiang Jinyang <https://justjjy.com>
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
11
8
|
#
|
|
12
|
-
#
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
10
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
# THE SOFTWARE.
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
22
16
|
|
|
23
17
|
|
|
24
18
|
require 'ciri/utils'
|
|
@@ -261,7 +255,7 @@ module Ciri
|
|
|
261
255
|
@root_hash = BLANK_NODE_HASH
|
|
262
256
|
else
|
|
263
257
|
encoded_root_node = RLP.encode_simple(root_node)
|
|
264
|
-
new_root_hash = Utils.
|
|
258
|
+
new_root_hash = Utils.keccak(encoded_root_node)
|
|
265
259
|
@db[new_root_hash] = encoded_root_node
|
|
266
260
|
@root_hash = new_root_hash
|
|
267
261
|
end
|
|
@@ -271,7 +265,7 @@ module Ciri
|
|
|
271
265
|
return [node, nil] if node.null?
|
|
272
266
|
encoded_node = RLP.encode_simple(node)
|
|
273
267
|
return [node, nil] if encoded_node.size < 32
|
|
274
|
-
encoded_node_hash = Utils.
|
|
268
|
+
encoded_node_hash = Utils.keccak(encoded_node)
|
|
275
269
|
[encoded_node_hash, encoded_node]
|
|
276
270
|
end
|
|
277
271
|
|
data/lib/ciri/types/account.rb
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright
|
|
3
|
+
# Copyright 2018 Jiang Jinyang <https://justjjy.com>
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
11
8
|
#
|
|
12
|
-
#
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
10
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
# THE SOFTWARE.
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
22
16
|
|
|
23
17
|
|
|
24
18
|
require 'ciri/utils'
|
|
@@ -42,7 +36,11 @@ module Ciri
|
|
|
42
36
|
|
|
43
37
|
# EMPTY(σ,a) ≡ σ[a]c =KEC()∧σ[a]n =0∧σ[a]b =0
|
|
44
38
|
def empty?
|
|
45
|
-
|
|
39
|
+
!has_code? && nonce == 0 && balance == 0
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def has_code?
|
|
43
|
+
code_hash != Utils::BLANK_SHA3
|
|
46
44
|
end
|
|
47
45
|
|
|
48
46
|
class << self
|
data/lib/ciri/types/address.rb
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright
|
|
3
|
+
# Copyright 2018 Jiang Jinyang <https://justjjy.com>
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
11
8
|
#
|
|
12
|
-
#
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
10
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
# THE SOFTWARE.
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
22
16
|
|
|
23
17
|
|
|
24
18
|
require_relative 'errors'
|
|
@@ -61,7 +55,7 @@ module Ciri
|
|
|
61
55
|
end
|
|
62
56
|
|
|
63
57
|
def empty?
|
|
64
|
-
@address.empty?
|
|
58
|
+
@address.empty?
|
|
65
59
|
end
|
|
66
60
|
|
|
67
61
|
def validate
|
data/lib/ciri/types/errors.rb
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright
|
|
3
|
+
# Copyright 2018 Jiang Jinyang <https://justjjy.com>
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
11
8
|
#
|
|
12
|
-
#
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
10
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
# THE SOFTWARE.
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
22
16
|
|
|
23
17
|
|
|
24
18
|
module Ciri
|
data/lib/ciri/types/receipt.rb
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright
|
|
3
|
+
# Copyright 2018 Jiang Jinyang <https://justjjy.com>
|
|
4
4
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
11
8
|
#
|
|
12
|
-
#
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
10
|
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
# THE SOFTWARE.
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
22
16
|
|
|
23
17
|
|
|
24
18
|
require 'ciri/rlp'
|
|
25
19
|
require 'ciri/bloom_filter'
|
|
26
|
-
require 'ciri/types/
|
|
20
|
+
require 'ciri/types/uint'
|
|
27
21
|
|
|
28
22
|
module Ciri
|
|
29
23
|
module Types
|
|
@@ -35,7 +29,7 @@ module Ciri
|
|
|
35
29
|
schema [
|
|
36
30
|
:state_root,
|
|
37
31
|
{gas_used: Integer},
|
|
38
|
-
{bloom: Types::
|
|
32
|
+
{bloom: Types::UInt256},
|
|
39
33
|
:logs,
|
|
40
34
|
]
|
|
41
35
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2018 Jiang Jinyang <https://justjjy.com>
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
require 'ciri/utils'
|
|
18
|
+
require 'ciri/rlp'
|
|
19
|
+
|
|
20
|
+
module Ciri
|
|
21
|
+
module Types
|
|
22
|
+
|
|
23
|
+
class UInt
|
|
24
|
+
class << self
|
|
25
|
+
attr_reader :size
|
|
26
|
+
|
|
27
|
+
def rlp_encode(item)
|
|
28
|
+
RLP.encode new(item).to_bytes
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def rlp_decode(encoded)
|
|
32
|
+
Utils.big_endian_decode(RLP.decode(encoded))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def max
|
|
36
|
+
@max ||= 2 ** size - 1
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def min
|
|
40
|
+
0
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def valid?(n)
|
|
44
|
+
n >= 0 && n <= max
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
@size = 0
|
|
49
|
+
|
|
50
|
+
def initialize(value)
|
|
51
|
+
raise "can't initialize size #{self.class.size} number" if self.class.size <= 0
|
|
52
|
+
@value = value
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def serialized
|
|
56
|
+
Utils.big_endian_encode(@value, size: bytes_size)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
alias to_bytes serialized
|
|
60
|
+
|
|
61
|
+
def bytes_size
|
|
62
|
+
self.class.size
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def to_i
|
|
66
|
+
@value
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class UInt32 < UInt
|
|
71
|
+
@size = 32
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class UInt256 < UInt
|
|
75
|
+
@size = 256
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
data/lib/ciri/version.rb
CHANGED
data/lib/ciri.rb
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
# Copyright
|
|
1
|
+
# Copyright 2018 Jiang Jinyang <https://justjjy.com>
|
|
2
2
|
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
# furnished to do so, subject to the following conditions:
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
9
6
|
#
|
|
10
|
-
#
|
|
11
|
-
# all copies or substantial portions of the Software.
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
8
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
# THE SOFTWARE.
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
20
14
|
|
|
21
15
|
|
|
22
16
|
require "ciri/version"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ciri
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jiang Jinyang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-08-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ciri-utils
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.2.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: 0.2.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: ciri-rlp
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: 0.1.1
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: ciri-crypto
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.1.1
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.1.1
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: ffi
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -128,14 +142,14 @@ dependencies:
|
|
|
128
142
|
requirements:
|
|
129
143
|
- - "~>"
|
|
130
144
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '
|
|
145
|
+
version: '12.0'
|
|
132
146
|
type: :development
|
|
133
147
|
prerelease: false
|
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
149
|
requirements:
|
|
136
150
|
- - "~>"
|
|
137
151
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '
|
|
152
|
+
version: '12.0'
|
|
139
153
|
- !ruby/object:Gem::Dependency
|
|
140
154
|
name: rspec
|
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -168,8 +182,31 @@ files:
|
|
|
168
182
|
- LICENSE.txt
|
|
169
183
|
- README.md
|
|
170
184
|
- Rakefile
|
|
185
|
+
- bin/bundle
|
|
171
186
|
- bin/console
|
|
187
|
+
- bin/htmldiff
|
|
188
|
+
- bin/ldiff
|
|
189
|
+
- bin/rake
|
|
190
|
+
- bin/rspec
|
|
172
191
|
- bin/setup
|
|
192
|
+
- ciri-crypto/.gitignore
|
|
193
|
+
- ciri-crypto/.rspec
|
|
194
|
+
- ciri-crypto/.travis.yml
|
|
195
|
+
- ciri-crypto/CODE_OF_CONDUCT.md
|
|
196
|
+
- ciri-crypto/Gemfile
|
|
197
|
+
- ciri-crypto/Gemfile.lock
|
|
198
|
+
- ciri-crypto/LICENSE.txt
|
|
199
|
+
- ciri-crypto/README.md
|
|
200
|
+
- ciri-crypto/Rakefile
|
|
201
|
+
- ciri-crypto/bin/console
|
|
202
|
+
- ciri-crypto/bin/setup
|
|
203
|
+
- ciri-crypto/ciri-crypto.gemspec
|
|
204
|
+
- ciri-crypto/lib/ciri/crypto.rb
|
|
205
|
+
- ciri-crypto/lib/ciri/crypto/errors.rb
|
|
206
|
+
- ciri-crypto/lib/ciri/crypto/signature.rb
|
|
207
|
+
- ciri-crypto/lib/ciri/crypto/version.rb
|
|
208
|
+
- ciri-crypto/spec/ciri/crypto_spec.rb
|
|
209
|
+
- ciri-crypto/spec/spec_helper.rb
|
|
173
210
|
- ciri-rlp/.gitignore
|
|
174
211
|
- ciri-rlp/.rspec
|
|
175
212
|
- ciri-rlp/.travis.yml
|
|
@@ -212,7 +249,7 @@ files:
|
|
|
212
249
|
- ciri-utils/spec/ciri/utils_spec.rb
|
|
213
250
|
- ciri-utils/spec/spec_helper.rb
|
|
214
251
|
- ciri.gemspec
|
|
215
|
-
- docker/
|
|
252
|
+
- docker/Dockerfile
|
|
216
253
|
- lib/ciri.rb
|
|
217
254
|
- lib/ciri/actor.rb
|
|
218
255
|
- lib/ciri/bloom_filter.rb
|
|
@@ -221,7 +258,7 @@ files:
|
|
|
221
258
|
- lib/ciri/chain/header.rb
|
|
222
259
|
- lib/ciri/chain/header_chain.rb
|
|
223
260
|
- lib/ciri/chain/transaction.rb
|
|
224
|
-
- lib/ciri/
|
|
261
|
+
- lib/ciri/core_ext.rb
|
|
225
262
|
- lib/ciri/db/account_db.rb
|
|
226
263
|
- lib/ciri/db/backend/memory.rb
|
|
227
264
|
- lib/ciri/db/backend/rocks.rb
|
|
@@ -249,17 +286,24 @@ files:
|
|
|
249
286
|
- lib/ciri/evm.rb
|
|
250
287
|
- lib/ciri/evm/block_info.rb
|
|
251
288
|
- lib/ciri/evm/errors.rb
|
|
289
|
+
- lib/ciri/evm/execution_context.rb
|
|
252
290
|
- lib/ciri/evm/instruction.rb
|
|
253
291
|
- lib/ciri/evm/log_entry.rb
|
|
254
292
|
- lib/ciri/evm/machine_state.rb
|
|
255
293
|
- lib/ciri/evm/op.rb
|
|
294
|
+
- lib/ciri/evm/op_call.rb
|
|
295
|
+
- lib/ciri/evm/precompile_contract.rb
|
|
256
296
|
- lib/ciri/evm/state.rb
|
|
257
297
|
- lib/ciri/evm/sub_state.rb
|
|
258
298
|
- lib/ciri/evm/vm.rb
|
|
259
299
|
- lib/ciri/forks.rb
|
|
260
300
|
- lib/ciri/forks/base.rb
|
|
301
|
+
- lib/ciri/forks/byzantium.rb
|
|
302
|
+
- lib/ciri/forks/config.rb
|
|
261
303
|
- lib/ciri/forks/frontier.rb
|
|
262
304
|
- lib/ciri/forks/frontier/cost.rb
|
|
305
|
+
- lib/ciri/forks/homestead.rb
|
|
306
|
+
- lib/ciri/forks/homestead/cost.rb
|
|
263
307
|
- lib/ciri/key.rb
|
|
264
308
|
- lib/ciri/pow.rb
|
|
265
309
|
- lib/ciri/rlp/decode.rb
|
|
@@ -272,12 +316,12 @@ files:
|
|
|
272
316
|
- lib/ciri/types/account.rb
|
|
273
317
|
- lib/ciri/types/address.rb
|
|
274
318
|
- lib/ciri/types/errors.rb
|
|
275
|
-
- lib/ciri/types/number.rb
|
|
276
319
|
- lib/ciri/types/receipt.rb
|
|
320
|
+
- lib/ciri/types/uint.rb
|
|
277
321
|
- lib/ciri/version.rb
|
|
278
322
|
homepage: https://github.com/ciri-ethereum/ciri
|
|
279
323
|
licenses:
|
|
280
|
-
-
|
|
324
|
+
- Apache 2.0
|
|
281
325
|
metadata: {}
|
|
282
326
|
post_install_message:
|
|
283
327
|
rdoc_options: []
|
data/lib/ciri/types/number.rb
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2018, by Jiang Jinyang. <https://justjjy.com>
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
|
13
|
-
# all copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
# THE SOFTWARE.
|
|
22
|
-
|
|
23
|
-
require 'ciri/utils'
|
|
24
|
-
require 'ciri/rlp'
|
|
25
|
-
|
|
26
|
-
module Ciri
|
|
27
|
-
module Types
|
|
28
|
-
|
|
29
|
-
class Number
|
|
30
|
-
class << self
|
|
31
|
-
attr_reader :size
|
|
32
|
-
|
|
33
|
-
def rlp_encode(item)
|
|
34
|
-
RLP.encode new(item).to_bytes
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def rlp_decode(encoded)
|
|
38
|
-
Utils.big_endian_decode(RLP.decode(encoded))
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
@size = 0
|
|
43
|
-
|
|
44
|
-
def initialize(value)
|
|
45
|
-
raise "can't initialize size #{self.class.size} number" if self.class.size <= 0
|
|
46
|
-
@value = value
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def serialized
|
|
50
|
-
Utils.big_endian_encode(@value, size: bytes_size)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
alias to_bytes serialized
|
|
54
|
-
|
|
55
|
-
def bytes_size
|
|
56
|
-
self.class.size
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def to_i
|
|
60
|
-
@value
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
class Int32 < Number
|
|
65
|
-
@size = 32
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
class Int256 < Number
|
|
69
|
-
@size = 256
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
end
|