-
Notifications
You must be signed in to change notification settings - Fork 81
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
core: init native interops in the genesis block #894
Conversation
1455f62
to
07b9cd8
Compare
07b9cd8
to
0642931
Compare
@fyrchik: please take a look, I'll rebase it afterwards. |
Codecov Report
@@ Coverage Diff @@
## master #894 +/- ##
==========================================
+ Coverage 63.32% 64.15% +0.82%
==========================================
Files 195 192 -3
Lines 16451 16198 -253
==========================================
- Hits 10418 10392 -26
+ Misses 5495 5275 -220
+ Partials 538 531 -7
Continue to review full report at Codecov.
|
0642931
to
4107f06
Compare
Updated and improved, it's important to merge this tomorrow, so have a look at it. |
} | ||
r := io.NewBinReaderFromBuf(b) | ||
balance.DecodeBinary(r) | ||
|
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.
Why do you have an empty line here but not in Bytes()
?
pkg/core/native/native_neo.go
Outdated
if err != nil { | ||
return err | ||
} | ||
if err := n.ModifyAccountVotes(oldAcc, ic.DAO, (&big.Int{}).Not(&acc.Balance)); err != nil { |
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.
It is not Not
, but Neg
.
We also use new(big.Int)
in every other place.
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.
It is not Not, but Neg.
Yep, it was fixed in some subsequent commit, maybe I need to shuffle these changes a little.
var ( | ||
pKeys []*keys.PublicKey | ||
err error | ||
) | ||
if len(txx) == 0 { |
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.
When invoked with non-zero sized slice, it is used for calculating NextConsensus
field.
DBFT needs to be changed, but for now we can return GetNextBlockValidators
when invoked with non-zero slice.
https://github.com/neo-project/neo/blob/master/src/neo/Consensus/ConsensusContext.cs#L349
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.
I don't think DBFT needs any change wrt this. We already do return next block validators from GetValidators
.
pkg/core/native/native_neo.go
Outdated
@@ -446,7 +450,7 @@ func (n *NEO) getNextBlockValidators(ic *interop.Context, _ []vm.StackItem) vm.S | |||
func (n *NEO) GetNextBlockValidatorsInternal(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error) { | |||
si := d.GetStorageItem(n.Hash, nextValidatorsKey) | |||
if si == nil { | |||
return bc.GetStandByValidators() |
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.
If validatorsCount
is not yet initialized, GetValidatorsInternal
can fail, no?
https://github.com/neo-project/neo/blob/master/src/neo/SmartContract/Native/Tokens/NeoToken.cs#L264
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.
It's initialized now in Initialize
at block 0, so I don't think we have any problem.
The notion of NativeContractState shouldn't ever existed, native contract is a contract and its state is saved as regular contract state which is critical because we'll have MPT calculations over this state soon. Initial minting should be done in Neo.Native.Deploy because it generates notification that should have proper transaction context. RegisterNative() shouldn't exist as a public method, native contracts are only registered at block 0 and they can do it internally, no outside user should be able to mess with it. Move some structures from `native` package to `interop` also to avoid circular references as interop.Context has to have a list of native contracts (exposing them via Blockchainer is again too dangerous, it's too powerful tool).
It fails at the moment and it doesn't make sense at conceptual level.
nil is not a good StackItem, we have proper VM-level Null for this.
As it should be done (although current serialization format is not quite right).
This technically breaks voting with UTXO-based NEO (processTXWithValidators*), but we're moving towards the new system.
As it's one of the use cases.
9016cb4
to
5c9e3e5
Compare
It has all the methods required now, so you can register, vote and get voting results. Fixes #865.
They're completely replaced now by the NEO native contract voting system.
5c9e3e5
to
e6f5cff
Compare
Updated to mention #865 as it technically fixes it now. |
closes #836