Skip to content
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

Merge consortium v2 to master #174

Merged
merged 58 commits into from
Nov 9, 2022
Merged

Merge consortium v2 to master #174

merged 58 commits into from
Nov 9, 2022

Conversation

minh-bq
Copy link
Contributor

@minh-bq minh-bq commented Nov 9, 2022

No description provided.

linh-1 and others added 30 commits November 7, 2022 14:17
…um wrapper (#90)

* feat(consortiumV2): implement Engine interface

just implement empty interface, function not yet

* fix(consortiumV2): remove consortium v2

* fix(consortiumV2): clean up consortium v2

* feat(consortiumV2): implement Consortium wrapper for v1

* feat(consortiumV2): implement SetGetSCValidatorsFn and SetGetFenixValidators

* feat(consortiumV2): implement Authorize

* fix(consortiumV2): Authorize params

* fix(consortiumV2): rename consortium to main for helping review
* feat(consortiumV2): implement Consortium v2 interface

* feat(consortiumV2): implement logic for Consortium wrapper to call v2 or v1
…#94)

* feat(consortiumV2): implement function to interacting with smart contract directly

* fix: missing new parameters

* fix: missing new parameters

* fix: invalid check consortium config nil

* fix: use signer hash instead of hash method
* feat: implement Snapshot methods

* feat: implement isMajorityFork method

* chore: implement isMajorityFork method

* fix: update loadSnapshot location

* fix: update store location

* chore: comment unused method

* chore: remove RecentForkHashes property
* feat: implement Consortium v2 verify method

* refactor: comment unused check in verifyCascadingFields

* refactor: use misc.VerifyGaslimit instead
)

* feat: implement Finalize and FinalizeAndAssemble methods

* fix: remove init contract

* fix: remove unused import

* fix: missing import
* fix: call smart contract through backend instead of ethapi

* feat: Add BlockContext to simulated backend to prevent cycle import while using it in consensus package

* refactor: move contract to common

* fix: case sensitive

* fix: case sensitive

* fix: remove NewFaker

* fix: case sensitive

* refactor: call opts with BlockNumber

* fix: add missing header

* fix: assign systemTxs to ReceivedTxs

* feat (dnk90): Add balance to system address instead of coinbase, if block number is within consortiumV2 fork

* update (dnk90): use IsConsortiumV2 function instead

* refactor: impl Backend interface

* fix: spelling mistake

* refactor: eliminate magic number

* refactor: call update validators

* fix: checkpoint time

* fix: replace manual calculation by IsOnConsortiumV2

Co-authored-by: kien Dang <kien.15@gmail.com>
* fix: Add updateValidators to `Finalize` method to make sure `updateValidators` transaction is processed in received sides

* fix: wrong validation when calling updateValidations
- Add `addNode` function to support adding new nodes
- Change NewContractIntegrator param from `*ConsortiumBackend` to `bind.ContractBackend` interface to make it more flexible (we can adapt different backends lately)
* fix: worker starts before getValidatorsSC is set

* fix: call `SetGetSCValidatorsFn` instead of `SetGetFenixValidators` in `Consortium.SetGetSCValidatorsFn`

* fix: pointer issue when validating current block is end of v1 or not
* feat: implement Seal method

* feat: implement CalcDifficulty and Delay methods

* chore: add switch condition for Delay and Author
* chore: Add signFnTx to contract integrator, add deploy validators to generated validators

* fix: change FinanlizeAssemble that returns receipts to apply changing receipts length during processing system contracts

* fix: change gas limit

* fix: Add check recent to v1/verifySeal

* chore: Add contract_test which contains deploy and addNode codes

* fix: applying v2 contract from v1
* fix: Implement `PoSA` interface methods to main Consortium in order to get system contracts in v2

* chore: Remove unnecessary line
- Remove redundant logs
- Remove systemcontracts package
- Move generated_contracts to consortium package
* fix: reorgs and incorrect nonce in consortium-v2

* chore: Remove getValidatorsFromLastCheckpoint, use snapshot instead
* feat: integrate smart contract

* chore: remove dposStaking config

* chore: change generated contract from PascalCase to snake_case

* chore: remove validators contract

* chore: remove contract tests

* chore: add comment to avoid misleading
We accept that the system transactions will not be in the pending state so it is
unnecessary to call FinalizeAndAssemble in non-validator node. Move this call to
be called only on validator node
…#125)

* chore: fix missing signTxFn, clear outdate recents, check missing tx in state_processor

* chore: check tx.To instead of tx
linh-1 and others added 26 commits November 7, 2022 14:17
* fix: unknown ancestor

* chore: remove unused log

* fix: remove line on comment

* fix: remove unnecessary comment
* Remove unused variables and functions

* Remove deadcode when checking system transactions
* feat: Implement log precompiled contract

* chore: minify consortiumLog's abi

* chore: Add consortium precompiled contracts to list

* chore: only allow log in debug mode (--vmdebug or `DEBUG` env is set to "true")

* chore: Remove redundant function which get method from abi and input
* feat: Implement `sortValidators` precompiled contract

* fix: add caller to the contract, since caller is the actual caller instead of sender from transaction

* chore: add testcase which simulates a call from a user who trigger system contract to call `sort` precompiled contract

* fix: incorrect get validators function should be `getValidatorCandidates` instead
* docs(contract): add comments

* docs(contract): update comment for GetValidators
…le signing issue (#143)

* feat: Implement verifyHeaders precompiled contract which detects double signing issue

* chore: Remove unnecessary log init

* chore: simplify unit test, add chainId and change Number to big.Int

* chore: clean up code

* nit: comment to hacky (`unpack`) function

* chore: Add condition signer must equal to coinbase to prevent user uses fake signature
* docs(v2consortium): add code comments

* docs(v2consortium): update Close comment

* docs(v2consortium): fix typo error
…tant (#141)

* docs(consortium-main): add code comment, remove unused ValidatorBytesLength constant

* docs(consortium-main): fix typo
* fix: align precompiled requirements

* test: update TestConsortiumValidatorSorting_Run2

* test: update compiled code

* chore(precompiled): update consortiumValidatorSorting comments
…#156)

* feat: impl update validator set by precompiled

* chore: rename filterCandidatesUnmaintained to pickCandidatesIsRunning

* fix: do not fill whitelist slots by others node

* fix: remove filter maintaining nodes

* test: update bytecode and abi of syncNewValidatorSet

* test(precompiled): update pickValidatorSet logic

create candidateMap maps address with isTrustedOrganizations to prevent the order changes

* fix: slice the candidates if the size is larger than newValidatorCount

* fix: change []bool isTrustedOrganizations to []*big.Int

* fix: out of bound waitingCandidates

* refactor(precompiled): update contract ABI
Other networkids than 2020, 2021 gets the devnet.json as the genesisPath by
default. We delete all default params on testnet and devnet, all params must be
provided through RONIN_PARAMS variable.
Currently, validator only calls SubmitBlockReward when there is transaction
reward but the contract assumes this fuction is called in every block. Change
this to match smart contract assumption.
While testing, we observe a chain hang due to system transactions always revert
because a contract is out of token. We change this behavior to accept that
system transactions may revert and still produce block in these cases.
* Update to the latest contract ABI

* Add more information to debug log in applyMessage
The hardfork block number is assumed to be divisible to both old epoch and new
epoch
@minh-bq minh-bq requested review from DNK90 and linh-1 November 9, 2022 10:30
@minh-bq minh-bq merged commit b80370d into master Nov 9, 2022
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.

3 participants