-
由 Nathan Hourt 提交于
OK, so this turned out to be a **massive** refactor that I thought I'd never finish, and no, I don't remember everything that changed here, but I think it all worked out to be better than before, and almost all of it was fairly necessary/the best of available options. Whew. I am SO glad this is finally done. High level goal: Continue refining the native contracts (ref #15), specifically walling off their state into their own contract DBs rather than globally shared (read: stuff that race conditions are made of) general blockchain state. The first real change I made in this commit, which precipitated the avalanche of changes that followed before the project became consistent again, was to move the account balance out of account_object (globally shared) to an object known only to the Eos Contract, thus eliminating the possibility of race conditions/nondeterministic behavior. The trouble is, balances are set at genesis. Genesis is processed by chain_controller. chain_controller cannot know about balances, since those are an abstraction defined on top of the Eos contract, which is an abstraction defined on top of chain_controller. So all of genesis had to be reimagined, and quite a lot of architectural changes had to be made in order to create a logically consistent solution. Changes (probably incomplete): - Fix up notifications within the native contract to support precondition validation as well as application - Add notify handlers for CreateAccount to Eos and Staked Balance contracts - Move account's liquid balance of EOS from account_object to BalanceObject - Replace {producer,account}_object::id_type with AccountName most everywhere except block_header, which still contains a producer_object::id_type (potentially in violation of protocol standards, but I want to confirm that before fixing it) - Reason: The name is not significantly slower, as it's fixed length so no heap allocs, and it simplifies the code in quite a few places by allowing us to look up objects directly rather than indirectly by looking up an ID to get an intermediate object to get a handle for the object we really wanted - Replace native_system_contract_plugin with native_contract library - Reason: The plugin was getting in the way. The native system contract C++ implementation is simply too fundamental unless/until we have a scripted implementation that works until the native implementation gets installed - Completely reimagine genesis initialization, taking it largely out of the hands of chain_controller and putting it in the hands of native_contract - Reason: chain_controller understands relatively little about genesis. It understands global_property_object and producer_object, but not BalanceObject or StakedBalanceObject, etc... It also doesn't understand the native_contract, and things like installing the native contract, setting up accounts/balances, etc. all need to be handled by something... native_contract is the most logical place to put it. Sorry for the enormous commit... alas, this was the first time I got it all building again and passing tests in days.
55a84709