thenewboston-blockchain / thenewboston-node

Node for thenewboston digital currency network.
https://thenewboston.com
MIT License
26 stars 10 forks source link

Fix signing algorithm to account for null and repeating fields values removal before signing #441

Closed dmugtasimov closed 2 years ago

dmugtasimov commented 2 years ago

also hash calculation

TODO:

dmugtasimov commented 2 years ago

Probably, blockchain sync after python -m thenewboston_node.manage ensure_node_declared does not work because of it:

(thenewboston-node-BkWiXaKK-py3.9) dmugtasimov@dmugtasimov-Latitude-E5550 ~/gitrep/thenewboston/thenewboston-node $ python -m thenewboston_node.manage sync_blockchain
2021-10-01 16:06:03,326 INFO Calling FileBlockchain.copy_from(...)
2021-10-01 16:06:03,328 INFO Returned from FileBlockchain.copy_from(...) in 1.829ms
2021-10-01 16:06:05,493 WARNING Block message block_identifier value is invalid: Block message block_identifier must be equal to 49a3fc83cba30ace6afc7817c66786131a0edef8984f056d75770f137996228d
2021-10-01 16:06:05,494 WARNING Block identifier is invalid: Block message block_identifier must be equal to 49a3fc83cba30ace6afc7817c66786131a0edef8984f056d75770f137996228d
2021-10-01 16:06:05,494 WARNING Block message is invalid: Block message block_identifier must be equal to 49a3fc83cba30ace6afc7817c66786131a0edef8984f056d75770f137996228d
2021-10-01 16:06:05,494 WARNING Block number 0 (identifier: 6eeec4da32987d0073216b482e691e3656d3cef960f271daca27ed099c53ddb8) is invalid: Block message block_identifier must be equal to 49a3fc83cba30ace6afc7817c66786131a0edef8984f056d75770f137996228d
2021-10-01 16:06:05,494 WARNING Block is invalid: Block message block_identifier must be equal to 49a3fc83cba30ace6afc7817c66786131a0edef8984f056d75770f137996228d
2021-10-01 16:06:05,494 ERROR Exception in FileBlockchain.add_block(...) after 12.794ms
Traceback (most recent call last):
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/logging.py", line 71, in wrapper
    rv = callable_(*args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/blockchain/base/blocks.py", line 67, in add_block
    block.validate(self)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/logging.py", line 149, in wrapper
    rv = callable_(*args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/models/block.py", line 135, in validate
    self.message.validate(blockchain)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/logging.py", line 149, in wrapper
    rv = callable_(*args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/models/block_message.py", line 141, in validate
    self.validate_block_identifier(blockchain)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/logging.py", line 149, in wrapper
    rv = callable_(*args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/models/block_message.py", line 204, in validate_block_identifier
    validate_exact_value(f'{self.humanized_class_name} block_identifier', block_identifier, expected_identifier)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/validators.py", line 93, in validate_exact_value
    raise ValidationError(upper_first(f'{subject} must be equal to {expected_value}'))
thenewboston_node.business_logic.exceptions.ValidationError: Block message block_identifier must be equal to 49a3fc83cba30ace6afc7817c66786131a0edef8984f056d75770f137996228d
2021-10-01 16:06:05,495 WARNING Could not synchronize blockchain with b8591396e291372070db2c3e57c66e8c28401856e8adf2e53c707f7c9c325dac at http://3.143.205.184:8555/
Traceback (most recent call last):
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/management/commands/sync_blockchain.py", line 37, in handle
    sync_minimal_to_file_blockchain(source, blockchain)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/utils/blockchain.py", line 191, in sync_minimal_to_file_blockchain
    sync_minimal(source, temporary_file_blockchain)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/utils/blockchain.py", line 178, in sync_minimal
    target_blockchain.add_block(block)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/utils/file_lock.py", line 20, in wrap
    rv = f(self, *args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/blockchain/file_blockchain/block_chunk/base.py", line 100, in add_block
    rv = super().add_block(block, validate)  # type: ignore
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/logging.py", line 71, in wrapper
    rv = callable_(*args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/blockchain/base/blocks.py", line 67, in add_block
    block.validate(self)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/logging.py", line 149, in wrapper
    rv = callable_(*args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/models/block.py", line 135, in validate
    self.message.validate(blockchain)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/logging.py", line 149, in wrapper
    rv = callable_(*args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/models/block_message.py", line 141, in validate
    self.validate_block_identifier(blockchain)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/core/logging.py", line 149, in wrapper
    rv = callable_(*args, **kwargs)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/models/block_message.py", line 204, in validate_block_identifier
    validate_exact_value(f'{self.humanized_class_name} block_identifier', block_identifier, expected_identifier)
  File "/home/dmugtasimov/gitrep/thenewboston/thenewboston-node/thenewboston_node/business_logic/validators.py", line 93, in validate_exact_value
    raise ValidationError(upper_first(f'{subject} must be equal to {expected_value}'))
thenewboston_node.business_logic.exceptions.ValidationError: Block message block_identifier must be equal to 49a3fc83cba30ace6afc7817c66786131a0edef8984f056d75770f137996228d
2021-10-01 16:06:05,495 ERROR Could not synchronize blockchain with the network
dmugtasimov commented 2 years ago

https://github.com/thenewboston-developers/thenewboston-node/pull/443

dmugtasimov commented 2 years ago

https://github.com/thenewboston-developers/thenewboston-node/pull/444

dmugtasimov commented 2 years ago

https://github.com/thenewboston-developers/thenewboston-node/pull/446

dmugtasimov commented 2 years ago

The reason for the issue was different. Further implementation of the task should be postponed.