Skip to content

Unified BlockchainInterface API; Transaction Handling#1089

Merged
KPrasch merged 29 commits intonucypher:alhambra-verdefrom
KPrasch:circumflex
Jun 21, 2019
Merged

Unified BlockchainInterface API; Transaction Handling#1089
KPrasch merged 29 commits intonucypher:alhambra-verdefrom
KPrasch:circumflex

Conversation

@KPrasch
Copy link
Member

@KPrasch KPrasch commented Jun 17, 2019

Co-Author @vepkenez

Note: Calls to BlockchainPower or TransactingPower can be considered concept-code, for that, see PR #1092

Follow-up for: #1058
Reverts: #1067
Fixes: #1086
Anticipating: #1092

  • Combines Blockchain and BlockchainInterface, removing chains.py
  • Provides a single method for all Agent and Deployer transactions on BlockchainInterface.send_transaction.
  • Handle all transactions using the w3.etn.sendRawTransaction API
  • Implements local ethereum key signing for EthereumTesterClient(Web3Client)
  • BlockchainInterface requires a TransactingPower or else it is a READ_ONLY_INTERFACE
  • Routes all calls to w3 methods through nucypher.eth.clients.Web3Client

Ideas (credit to @jMyles):

  • Are StakeHolder and Deployer characters that consume TransacingPower?
  • Does blockchain "connection" happen as part of TransactingPower.consume_power_up?

@KPrasch KPrasch added the API label Jun 17, 2019
@codecov
Copy link

codecov bot commented Jun 18, 2019

Codecov Report

Merging #1089 into alhambra-verde will decrease coverage by 2.11%.
The diff coverage is 82.34%.

Impacted file tree graph

@@                Coverage Diff                 @@
##           alhambra-verde    #1089      +/-   ##
==================================================
- Coverage           82.75%   80.64%   -2.12%     
==================================================
  Files                  68       68              
  Lines                8896     8777     -119     
==================================================
- Hits                 7362     7078     -284     
- Misses               1534     1699     +165
Impacted Files Coverage Δ
nucypher/policy/models.py 91.59% <ø> (ø) ⬆️
nucypher/cli/characters/felix.py 32.32% <0%> (-35.68%) ⬇️
nucypher/blockchain/eth/sol/compile.py 80% <0%> (ø) ⬆️
nucypher/characters/unlawful.py 46.42% <0%> (ø) ⬆️
nucypher/utilities/sandbox/middleware.py 90.58% <100%> (ø) ⬆️
nucypher/characters/base.py 86.97% <100%> (-0.07%) ⬇️
nucypher/blockchain/eth/decorators.py 77.14% <100%> (ø) ⬆️
nucypher/utilities/sandbox/constants.py 98.14% <100%> (ø) ⬆️
nucypher/config/characters.py 98.21% <100%> (-0.9%) ⬇️
nucypher/blockchain/economics.py 100% <100%> (ø) ⬆️
... and 58 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddf1d08...cec66a6. Read the comment docs.

@KPrasch KPrasch requested a review from vepkenez June 18, 2019 17:18
@KPrasch KPrasch force-pushed the circumflex branch 4 times, most recently from 98658df to fcf629a Compare June 19, 2019 22:24
@KPrasch KPrasch force-pushed the circumflex branch 2 times, most recently from 93a97ad to 430cb50 Compare June 20, 2019 00:02
@KPrasch KPrasch changed the title Condensed Blockchain API Unified BlockchainInterface API; Transaction Handling Jun 20, 2019
@KPrasch KPrasch marked this pull request as ready for review June 20, 2019 01:07
click.secho("OK", fg='green', nl=False, bold=True)
else:
click.secho("Failed", fg='red', nl=False, bold=True)
receipt = deployer.blockchain.client.w3.eth.waitForTransactionReceipt(txhash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
receipt = deployer.blockchain.client.w3.eth.waitForTransactionReceipt(txhash)
receipt = deployer.blockchain.w3.eth.waitForTransactionReceipt(txhash)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that w3 is exposed both in blockchain and blockchain.client?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that w3 is exposed both in blockchain and blockchain.client?

It's a good question, perhaps @vepkenez can help clarify, this has to do with how we are providing compatibility across clients, wrapping thier w3 instances.

KPrasch added a commit to KPrasch/nucypher that referenced this pull request Jun 20, 2019
Copy link
Contributor

@tuxxy tuxxy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! See my comment on the substantiate_stamp call, though.

Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like some of the simplifications that come with this PR, but I strongly reject the new version of BlockchainPower. This requires more discussion.

click.secho("OK", fg='green', nl=False, bold=True)
else:
click.secho("Failed", fg='red', nl=False, bold=True)
receipt = deployer.blockchain.client.w3.eth.waitForTransactionReceipt(txhash)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason that w3 is exposed both in blockchain and blockchain.client?

KPrasch added a commit to KPrasch/nucypher that referenced this pull request Jun 20, 2019
KPrasch added a commit to KPrasch/nucypher that referenced this pull request Jun 20, 2019
@KPrasch KPrasch changed the title Unified BlockchainInterface API; Transaction Handling [WIP] Unified BlockchainInterface API; Transaction Handling Jun 20, 2019
KPrasch added a commit to KPrasch/nucypher that referenced this pull request Jun 20, 2019
KPrasch added a commit to KPrasch/nucypher that referenced this pull request Jun 20, 2019
@KPrasch KPrasch changed the title [WIP] Unified BlockchainInterface API; Transaction Handling Unified BlockchainInterface API; Transaction Handling Jun 20, 2019
KPrasch added a commit to KPrasch/nucypher that referenced this pull request Jun 20, 2019
KPrasch added a commit to KPrasch/nucypher that referenced this pull request Jun 20, 2019
@KPrasch KPrasch changed the base branch from alhambra-verde to master June 21, 2019 05:20
@KPrasch KPrasch changed the base branch from master to alhambra-verde June 21, 2019 05:21
Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I was very tired of the interface.w3.eth everywhere 🙄

__DEFAULT_MIN_SEED_STAKE = 0

def __init__(self,
worker_address: str,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this parameter is not necessary anymore.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

from decimal import Decimal
from json import JSONDecodeError
from typing import Tuple, List, Dict, Union
from eth_utils import keccak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should we use, this or ours (nucypher.crypto.api.keccak_digest)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh - What's the difference?

"""

_default_crypto_powerups = [SigningPower, BlockchainPower]
_default_crypto_powerups = [SigningPower]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does Felix lose his BlockchainPower?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, I cannot determine a way for BlockchainPower to be consumed as a default powerup, it's constructed and consumed in the __init__ of the character.

Copy link
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@KPrasch KPrasch merged commit 0cb8025 into nucypher:alhambra-verde Jun 21, 2019
cygnusv pushed a commit that referenced this pull request Jun 26, 2019
cygnusv pushed a commit that referenced this pull request Jun 28, 2019
cygnusv pushed a commit that referenced this pull request Jul 4, 2019
@KPrasch KPrasch deleted the circumflex branch March 22, 2021 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants