-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpc, cli: support gas claim and asset transfer #694
Conversation
Codecov Report
@@ Coverage Diff @@
## master #694 +/- ##
==========================================
- Coverage 65.76% 65.42% -0.34%
==========================================
Files 128 128
Lines 10916 11084 +168
==========================================
+ Hits 7179 7252 +73
- Misses 3456 3550 +94
- Partials 281 282 +1
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #694 +/- ##
==========================================
- Coverage 65.94% 65.61% -0.33%
==========================================
Files 130 130
Lines 11196 11381 +185
==========================================
+ Hits 7383 7468 +85
- Misses 3525 3621 +96
- Partials 288 292 +4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #694 +/- ##
=========================================
- Coverage 65.76% 65.4% -0.36%
=========================================
Files 128 128
Lines 10916 11087 +171
=========================================
+ Hits 7179 7252 +73
- Misses 3456 3553 +97
- Partials 281 282 +1
Continue to review full report at Codecov.
|
// TODO: storeBlock needs some more love, its implemented as in the original | ||
// project. This for the sake of development speed and understanding of what | ||
// is happening here, quite allot as you can see :). If things are wired together | ||
// and all tests are in place, we can make a more optimized and cleaner implementation. | ||
func (bc *Blockchain) storeBlock(block *block.Block) error { | ||
cache := newCachedDao(bc.dao.store) | ||
if err := cache.StoreAsBlock(block, 0); err != nil { | ||
fee := bc.getSystemFeeAmount(block.PrevHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have topBlock
in Blockchain
, maybe it's worth saving sysFee the same way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
topBlock
is used to get top block/header without accessing the database.
With sysFee
I see no situations where it can be useful. sysFee
is needed in claim calculations and all blocks accessed there are surely not from the top.
With possible auto-claiming in NEO3.0 it can be useful though.
Regarding sometimes failing tests: Regarding |
Calculating amount of GAS that can be claimed is required for getclaimable RPC.
To make it easy to get unclaimed coins for the specified account they must be tracked together.
Marshalling it and taking all but last byte violates incapsulation and is just wrong in case transaction already contains any witnesses.
Simple transfer from multisig account to the account of one of the validators.
Write uint32 length before every block.
This is needed to form correct Claim transaction.
When testing CLI it is useful to have some spent coins on an account with a known key.
GAS can be claimed via `wallet claim` command. This will claim first get all claimable outputs via `getclaimable` RPC and then form a transaction signed byte the private key from the wallet.
Recalculating system fee can be rather costly if done frequently.
Because accumulated system fee is stored for every block, it is easy to calculate sum with just to reads.
It uses getunspents RPC for getting UTXO and forming transaction.
Target of the transaction output may not yet exist in database.
Claim tx have no GAS inputs and a positive output which can lead to negative network fee.
Otherwise it is possible to make outputs which will sum to the expected value, but steal GAS from some other account.
It is used in both CLI and RPC.
Closes #669, #670 .
Also: