aboutsummaryrefslogtreecommitdiffstats
path: root/core
Commit message (Collapse)AuthorAgeFilesLines
* core: vm: sqlvm: ast: return error messages from GetTypeTing-Wei Lan2019-03-294-45/+85
| | | | | | | | To allow callers to provide precise error messages, return an error message in addition to an error code from GetType of TypeNode. Drop DataTypeEncode because it is never used by any code and it has become a simple wrapper of GetType.
* core: vm: sqlvm: schema: move methods of DataTypeMajorTing-Wei Lan2019-03-291-10/+10
| | | | We will add more methods to DataType.
* core: vm: sqlvm: schema: move Rest to the bottomTing-Wei Lan2019-03-291-1/+3
| | | | It is a special field which should not be accessed by any other files.
* core: vm: sqlvm: schema: unsigned integers can never be negativeTing-Wei Lan2019-03-291-2/+2
|
* core: vm: sqlvm: use common.HashLength instead of 32Ting-Wei Lan2019-03-293-9/+10
| | | | Keep them consisitent with ast/types.go.
* core: vm: remain first byte, if it is not VM enum.Jhih-Ming Huang2019-03-261-3/+1
| | | | | * If first byte is not VM enum, we should reserve it as checking VM type. * Remove debug print.
* core: vm: sqlvm: ast: implement decimal to uint64Jhih-Ming Huang2019-03-264-26/+82
| | | | | deciaml.IntPart() returns int64, so we have to implement a function to convert deciaml to uint64 for reading primary id from Raw.
* core: vm: sqlvm: runtime: implement opLoadJhih-Ming Huang2019-03-262-8/+510
|
* core: vm: sqlvm: common: storage: implement storage util functionsJhih-Ming Huang2019-03-263-1/+201
| | | | | Implement some storage utility functions, including shift slot, get dynamic byte and get primary key hash.
* core: vm: sqlvm: schema: implment get column field type and set offsetJhih-Ming Huang2019-03-262-2/+243
| | | | | Since we have to packing our data in slot, it needs to calculate each column field's slot and byte offset.
* core: vm: sqlvm: runtime: add loadRegister funcJhih-Ming Huang2019-03-262-1/+10
| | | | Implement load register to input operands, before each op.
* core: vm: sqlvm: ast: add size func and move error code to errors.goJhih-Ming Huang2019-03-263-19/+69
| | | | Move error code to errors.go, and implement Size method for column field.
* core: vm: sqlvm: types: fix encode bug when exponent is negative (#270)yenlinlai2019-03-262-4/+10
| | | | | It is possible that the number to encode is produced by arithmetic operations and has negative exponent even when it is an integer. Properly handle this case and modify test cases to check it.
* core: vm: sqlvm: schema: add structs to identify an object in a schemaTing-Wei Lan2019-03-261-0/+26
| | | | | These structs will be used in identifier nodes to store references to objects defined in the schema or the command itself.
* core: vm: sqlvm: schema: mark if an index are referenced by foreign keysTing-Wei Lan2019-03-261-0/+36
| | | | | | | In order to check foreign keys efficiently during deletion, an index should be marked when it is referenced by foreign keys. Since we now have flags which cannot be declared directly from the source code, two helper functions are added to distinguish between two groups of flags.
* core: vm: sqlvm: schema: reorder fields and enumsTing-Wei Lan2019-03-261-6/+19
| | | | | Reorder fields and enums according to the grammar file to make it easier to check whether all features supported by the grammar are implemented.
* core: vm: sqlvm: schema: drop pointers from slicesTing-Wei Lan2019-03-262-9/+9
| | | | | | | The number of tables, columns, indices are all limited to 256, so we don't have to do much memory copying during appending. Drop pointers from slices to save memory for storing pointers and possibly improve locality.
* core: vm: sqlvm: parser: check if a number literal is an integerTing-Wei Lan2019-03-262-976/+1045
| | | | | | ORDER BY and GROUP BY options have to decide whether an expression is a reference to the column specified in SELECT command by checking whether it consists of only one integer literal.
* core: vm: sqlvm: make a common interface for statementsTing-Wei Lan2019-03-265-1622/+2281
| | | | | | | So Parse now returns a []ast.StmtNode instead of a generic []ast.Node, which should be clearer on what the return value looks like. This also adds a field recording the verb use to identify the statement in order to provide better error messages.
* core: vm: sqlvm: errors: remove token fieldTing-Wei Lan2019-03-265-474/+440
| | | | | | | | Now both position and length are both recorded in the error struct, recording the token in the error struct no longer provides any benefit. It is easy to find the token when position and length are known, but requiring all error locations to fill the field is complicated because they have to access the source code to find the token.
* core: vm: fix typoTing-Wei Lan2019-03-261-1/+1
|
* remove dexon/crypto/sha3 pkg.Jhih-Ming Huang2019-03-263-7/+8
|
* core: vm: sqlvm: add shared variables (#228)Meng-Ying Yang2019-03-263-11/+19
|
* core: vm: sqlvm: add ESCAPE grammarwmin02019-03-264-653/+768
| | | | | Provide ESCAPE grammar for specifying escape character in like pattern matching.
* core: vm: sqlvm: errors: add length fieldTing-Wei Lan2019-03-265-442/+484
| | | | | When an error corresponds to a source code token, it should be able to report the length of the token in addition to the position.
* core: vm: sqlvm: limit the depth of AST to 1024Ting-Wei Lan2019-03-263-7/+50
| | | | | Since we traverse an AST by calling functions recursively, we have to protect the parser by limiting the depth of an AST.
* core: vm: sqlvm: parser: move generated code to internal packageTing-Wei Lan2019-03-265-1565/+1585
| | | | | | | | Code generated by pigeon includes many exported symbols which should not be used by any other code other than the parser itself. To prevent them from being misused, we used to hide them by editing the generated code with sed. This commit removes the unreliable sed trick by putting generated code to internal package.
* core: vm: sqlvm: ast: use non-empty interfaces in DataType{En,De}codeTing-Wei Lan2019-03-262-80/+34
| | | | | | | In addition to changes required to move DataTypeEncode and DataTypeDecode to use TypeNode interface, this commit also unifies the meaning of 'Size' field in 'FixedBytesTypeNode'. It always counts the length in bytes now.
* core: vm: sqlvm: errors: fix typoTing-Wei Lan2019-03-261-1/+1
|
* core: vm: sqlvm: parser: don't use @, #, $ in unquoted identifiersTing-Wei Lan2019-03-262-35/+34
| | | | | | These symbols are allowed in Microsoft SQL or PostgreSQL, but the SQL standard doesn't mention them. It is still possible to use these symbols as identifiers by putting them in double quotes.
* core: sqlvm: schema: define type for table/column/index/sequence sizeyenlin.lai2019-03-262-5/+17
| | | | | The size of table in db and column/index/sequence in a table is bounded by uint8. Define types for better readability.
* core: vm: sqlvm: ast: handle error in AST printerTing-Wei Lan2019-03-262-33/+63
| | | | Catch the error reported by fmt.Fprintf and report it to the caller.
* core: vm: sqlvm: fill source code position in AST nodesTing-Wei Lan2019-03-267-1141/+1510
| | | | | | | | | | | | | | | Now all AST nodes should have position information recorded during parsing. These fields are intended to be used to report errors and make debugging easier. However, precise location of each token is currently unavailable. It can be done in the future if it becomes necessary. To make it easier to traverse an AST, GetChildren is modified to skip nil nodes in the output. This means callers of GetChildren don't have to check for nil in returned slices. AST printer is modified to print the position and the corresponding source code token. A few special handling for interfaces are removed because reflection works better for structs.
* core: vm: sqlvm: ast: use pointer receiversTing-Wei Lan2019-03-261-89/+89
| | | | | | | Since all nodes must be declared as pointers to satisfy the interface, it is no longer meaningful to use value receivers. It should make the code look more consistent and reduce the amount of memory copying during function calls because these structs takes at least 8 bytes.
* core: vm: sqlvm: ast: remove pointer indicator in printer outputTing-Wei Lan2019-03-261-5/+4
| | | | | | Since our 'Node' interface includes methods which must be implemented with pointer receivers, all AST nodes are now referenced with pointers and the '*' pointer indicator is no longer useful.
* core: vm: sqlvm: check if a number is a valid addressTing-Wei Lan2019-03-265-334/+312
| | | | | | | | | | | | This commit implements isAddress function to allow a number literal to be considered as an address literal. Since Solidity only allows '0x' to be written in lower case, we remove the handling of upper case '0X' to keep the behavior in sync with Solidity. In addition to isAddress implementation, this commit also removes 'String' methods from AST nodes to prevent them from implementing the builtin 'Stringer' interface. Therefore, our AST printer is now able to print struct fields of value nodes instead of only one string.
* core: vm: sqlvm: introduce interfaces for AST nodesTing-Wei Lan2019-03-269-1704/+2956
| | | | | | | | | In order to make our AST easier and safer to use, all declarations with empty interface type are now removed. This changes also makes it possible to traverse the AST without using reflection or understanding what each type means because all AST nodes have at least one common interface.
* core: vm: sqlvm: runtime entrypoing error handlingMeng-Ying Yang2019-03-263-5/+14
| | | | Return error.Error to reveal more information about returned error.
* core: vm: sqlvm: parser: toDecimal handle .0wmin02019-03-262-0/+4
| | | | | To cover the pitfall of decimal.fromString, we need to add leading 0 at '^\.[0-9]+' case.
* core: rebase dev and fix lintJhih-Ming Huang2019-03-269-4414/+25
|
* core: vm: sqlvm: types support data rangeMeng-Ying Yang2019-03-262-0/+82
| | | | | The data range is deterministic for specific type, `GetMinMax` is helper function to generate min, max value for clients.
* core: vm: sqlvm: export instruction's member (#197)JM2019-03-262-6/+6
|
* core: vm: sqlvm: revert Tuple structure (#193)JM2019-03-261-4/+5
|
* core: vm: sqlvm: modify Tuple.Data.Value typeJhih-Ming Huang2019-03-261-7/+3
| | | | | Modify Tuple.Data.Value type from *big.Int to interface{} and remove Max, Min.
* core: vm: sqlvm: shared interfaces and paramsJhih-Ming Huang2019-03-266-0/+245
| | | | | | | After reconstructing commits, we move shared interfaces and params as first runtime implementation. In this commit we define OP codes, runtime flow and entrypoint, and basic operand structs and minor helper components.
* core: vm: sqlvm: add schema define and implement rlp serializationwmin02019-03-264-42/+310
| | | | Implement schema struct and handle its rlp serialization.
* core: vm: sqlvm: ast: add encoder/decoder for decimal to byteswmin02019-03-262-11/+196
| | | | | | | | Add encoder/decoder to convert between decimal and bytes. Also handle issues below. * Signed & Unsigned * Padding * Floating point of fixed
* core: vm: sqlvm: ast: data type encoder and decoderwmin02019-03-262-0/+244
| | | | | Implement encode & decode function to convert between type node and 2-bytes type described on spec.
* core: vm: sqlvm: ast: don't hardcode output and indent in PrintASTTing-Wei Lan2019-03-262-26/+35
| | | | | It is now possible to write AST dump to a writer other than stdout and use indent string other than 2 spaces.
* core: vm: sqlvm: process non-UTF-8 input and escape sequencesTing-Wei Lan2019-03-268-337/+579
| | | | | | | | | | | | | | | Our parser is able to process queries with invalid UTF-8, provided that it is compatible with ASCII. Since doing so requires encoding the input before passing to pigeon, Parse* functions generated by pigeon are unexported because they should not be used directly. Escape sequences in string literals and identifiers are now recognized. In addition to escape sequences supported by solidity, we support \U similar to the one supported by Go to allow users to specify non-BMP Unicode code point without using multiple \x escapes. AST printer is modified to quote non-printable characters in strings to prevent control characters from messing up the terminal.
* core: vm: sqlvm: parser: properly handle errorsTing-Wei Lan2019-03-266-1242/+1637
| | | | | | Instead of ignoring errors, errors returned from external functions are normalized and reported to users. Errors which should be impossible to occur are converted to panic calls.
* core: vm: sqlvm: remove optional interface and add print tag for detailwmin02019-03-263-99/+49
| | | | | | | There are some changes in print ast utility. 1. instead of using optional interface to get detail, use reflect 2. implement a `print` field tag for printer switching detail mode or not
* core: vm: sqlvm: move AST and parser to their own packagesTing-Wei Lan2019-03-268-1837/+2010
| | | | | | | | In order to avoid putting too many different things in single package and allow other projects to reuse the syntax tree and the parser, these two components are moved to different packages and all nodes used in AST are now exported. A lot of comments are added in this commit to pass golint checks.
* core: vm: sqlvm: add a tool to run gofmt on pigeon sourcesTing-Wei Lan2019-03-261-0/+253
| | | | | | This tool is good enough to format our sqlvm grammar file. It is not guaranteed to work for all valid pigeon files, and it only process multi-line Go code blocks.
* core: vm: sqlvm: add sql language parser prototypingwmin02019-03-266-0/+8899
| | | | | | | | | Add sql language parser prototyping along with 1. grammar file implemented with github.com/mna/pigeon 2. ast node struct definition 3. simple parser test which only test if error existed 4. ast printer utility for visualizing parsing result
* core: vm: vm interface (#164)JM2019-03-2613-68/+712
|
* core: vm: extract stateDB and contract outjm2019-03-2624-394/+459
| | | | | Extract stateDB and contract out from core/vm/evm to core/vm, such that other vm type can use the common modules.
* core: vm: refactor file structurejm2019-03-2657-836/+5247
| | | | | For support other vm types, this pr modified the core/vm file structures.
* core: set extended round block reward to zero (#298)Wei-Ning Huang2019-03-262-1/+66
| | | | | To discourage DKG set from prolonging the round indefinitely, we set the block reward of the extended round to 0. The gas fee is send to the DEXON governance owner for safe keeping and later used by the foundation.
* core: vm: fix DKG reset (#296)Wei-Ning Huang2019-03-242-23/+26
|
* core/vm: remove round from addDKG functions (#279)Jimmy Hu2019-03-215-129/+93
| | | | | | | | * vendor: sync to latest core * core/vm: remove addDKG functions * core: fix conflict
* core: vm: deny duplicate public key from registering (#289)Wei-Ning Huang2019-03-202-1/+20
|
* core: vm: pay fine to governance owner and trigger set size recalculation (#288)Wei-Ning Huang2019-03-201-1/+5
|
* consensus: dexcon: disqualify dead node (#280)Wei-Ning Huang2019-03-204-39/+230
| | | | | | | | | | Since a qualified node might fail stopped, we need to remove them from qualified nodes to maintain network integrity. We do this by inspect the previous round to see if there are dead nodes. A dead node is a notary set node that does not propose any block in the previous round. We disqualify them by fining them so their staked value is 1 wei below minStake. This make them unqualified for being notary set in the follow on rounds.
* core: check coinbase for empty block (#282)Jimmy Hu2019-03-191-6/+13
|
* core: vm: emit event when transfering owner (#277)Wei-Ning Huang2019-03-193-0/+48
|
* core: fix headerchain coinbase validationWei-Ning Huang2019-03-191-2/+7
| | | | Coinbase address is the owner address of the node.
* core: vm: automatically calculate notary set size (#276)Wei-Ning Huang2019-03-193-10/+95
|
* core: vm: add extra checks to prevent DKG spamming (#272)Wei-Ning Huang2019-03-194-62/+177
| | | | Add two maps to check the uniqueness of DKGMasterPublicKey and DKGComplaints to prevent malicious actors from spamming it.
* core: vm: fix naming consistencyWei-Ning Huang2019-03-192-11/+11
|
* core: check reset of dkg types when adding (#268)Jimmy Hu2019-03-171-0/+16
| | | | | | * vendor: sync to latest core * core: check dkg reset
* core: vm: reorder minGasPriceLocWei-Ning Huang2019-03-171-1/+1
|
* core: fill in genesis timstamp and remove dMoment from protocol handshake (#263)Wei-Ning Huang2019-03-172-1/+14
| | | | | Fill in dmoment as genesis block timestamp. This allow us to remove dMoment check from protocol handshake since genesis block hash itself will protect us against different dMoment.
* dex: implement recovery mechanism (#258)Wei-Ning Huang2019-03-172-5/+5
| | | | | | | | | * dex: implement recovery mechanism The DEXON recovery protocol allows us to use the Ethereum blockchain as a fallback consensus chain to coordinate recovery. * fix
* core: vm: group min gas price with related state variables (#257)Wei-Ning Huang2019-03-143-16/+16
|
* core: vm: implement transfer node ownership (#255)Wei-Ning Huang2019-03-143-9/+83
|
* core: vm: create new oracle contract instance in each call (#251)Wei-Ning Huang2019-03-133-6/+16
| | | | | Since the VM might be called from different source (downloader, RPC, etc.). We need to make the call state separate. Modify the calling sequence so a new oracle contract instance is used on each run.
* vendor: sync to latest core (#253)Jimmy Hu2019-03-132-3/+56
|
* core/vm: use core util to get threshold of tsig (#250)Jimmy Hu2019-03-131-3/+4
|
* params: update testnet config to 40 nodesJimmy Hu2019-03-131-1/+1
|
* vendor: sync to latest core and fix conflictJimmy Hu2019-03-121-2/+2
|
* core: touch verifierCache at 90% of round (#247)Jimmy Hu2019-03-121-2/+35
|
* app: new app test flow (#244)bojie2019-03-126-65/+8
|
* core: vm: remove delegation mechanism (#245)Wei-Ning Huang2019-03-126-997/+263
| | | | | | | | | | | | | The current delegation mechanism are prone to unstaking attack. i.e. a malicious attacker could unstake a small amount from a lot of node it staked before and make them unqualified, which leads to potential failure of the network. Since DEXON does not use consensus like DPoS, node is required to have at least MinStake in order to become a node. Voting mechanism is not required in our system since qualified node does not depends on the number of votes. Instead of managing the delegation mechanism in governance contract, we should let the owner manage the delegation and reward distribution mechanism on their own.
* core: vm: expose CRSRound and DKGRound and fix consistency (#236)Wei-Ning Huang2019-03-123-60/+118
|
* app: refactor app run as single chain (#226)bojie2019-03-121-146/+14
|
* core: fix dkgJimmy Hu2019-03-121-12/+47
|
* params: Change taipei to 40 nodes (#227)Jimmy Hu2019-03-121-1/+1
|
* dex: fill in correct coinbase address (#223)Wei-Ning Huang2019-03-121-0/+9
| | | Also remove app_test.go because of the refactor bojie@ is working on.
* params: Update config (#224)Jimmy Hu2019-03-121-1/+1
| | | | | | * params: Update config * Update taipei to 30 nodes setup
* core: vm: validate addDKGMasterPublicKey caller properly (#220)Wei-Ning Huang2019-03-123-60/+59
| | | | | | There are two keys in the system: one is the owner's key which is used for stake / unstake. The other is the node key which is used for DKG related operations. We need to allow them to be different so fund renmains safe even if the the node key is lost.
* core: vm: flatten governanceWei-Ning Huang2019-03-1210-524/+523
|
* core: sync to latest core (#214)Jimmy Hu2019-03-123-7/+20
| | | | | * vendor: sync to latest core * fix for single chain
* params: add Yilan network (#207)Mission Liao2019-03-123-0/+25
| | | | | | * Add Yilan network * Fixup: remove dummy log
* core: Fixed gas price (#205)Jimmy Hu2019-03-126-2/+96
| | | | | | | | | | * core/vm: update abi * core/vm: add MinGasPrice to gov * params: Add MinGasPrice to Config * dex: SuggestPrice from Governance * test: add minGasPrice to genesis.json * core: check underpriced tx * dex: verify with gas price
* core: set oracle contract's code (#209)Sonic2019-03-122-1/+6
| | | So that other contract can call oracle contract.
* fee: fix wrong gas used (#208)bojie2019-03-121-0/+2
|
* core: Remove K, Phi and NumChains from Governance (#198)Jimmy Hu2019-03-125-174/+37
| | | | | | * change default sync_core.sh * vendor: sync to latest core * core: Remove K, Phi and NumChain
* copy testnet config to taipeiJimmy Hu2019-03-121-1/+1
|
* core/vm: fix getConfigState (#203)Jimmy Hu2019-03-121-4/+3
|
* vm: reset DKG (#190)Jimmy Hu2019-03-124-70/+562
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm: Update gov abi * vm: Add DKGResetCount to state helper * vm: add getter * vm: Add DKGReset event * vm: Add resetDKG method * vm: check resetDKG criteria * vm: Add new CRS * vm: add helper pop2DByteArray * vm: emit event * vm: Add CoreMock to GovernanceContract * vm: bug fix * add test for resetDKG * vm: Add test * fix test * Modify mock interface
* transaction: use all transaction gas to reduce attack intention (#180)bojie2019-03-121-1/+25
| | | The ci test in /tests will use origin evm logic.
* core/vm: modify Withdrawn event and add NodeRemoved event (#179)Jimmy Hu2019-03-122-4/+31
| | | | | | * core/vm: add delegatorAddr to withdrawn event * core/vm: update gov abi * core/vm: add NodeRemoved event
* core: vm: refactor governance and add node info oracle (#174)Wei-Ning Huang2019-03-125-682/+953
|
* core: vm: Add amount to undelegate event (#176)Jimmy Hu2019-03-122-4/+9
|
* core: vm: more change to the randomness calculation (#175)Wei-Ning Huang2019-03-121-5/+5
| | | | To prevent attacker from sending TX through a intermediate contract. Always use the original tx sender's adddress and nonce.
* core: vm: modify randomness calculation algorithm (#173)Wei-Ning Huang2019-03-122-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | The original algorithm used for calculating algorithm is vulnerable to cross context re-entry attack. Example as follows: contract B { event Value(uint256 value); uint256 public value; function call() public { value = rand; emit Value(value); } } contract A { function randTwice(address bAddr) public { B b = B(bAddr); b.call.gas(100000)(); b.call.gas(100000)(); } } The two `b.call` will result in the same randomness value. This commit fix the issue by recording a called index used to store how many times opRand is called, and use it as argument to the Keccak call.
* consensus: dexcon: snapshot round height when finalizing block (#170)Wei-Ning Huang2019-03-123-106/+0
| | | | Instead of having BP to send a tx to register the round height, just modify the state when finalizing block.
* core, dex/downloader: polish headers verification and blocks insertion logic ↵Sonic2019-03-128-509/+614
| | | | | | | | (#168) Refactor GenerateDexonChain function, move governance tx logic to the user of GenerateDexonChain (testchain_test.go) and move fake node set code to FakeDexcon.
* travis: re-encrypt GCP credential file (#165)bojie2019-03-121-1/+1
|
* params: update testnet genesis and dMomentWei-Ning Huang2019-03-121-2/+1
|
* core, dex: use block hash as witness data (#160)Sonic2019-03-125-50/+17
| | | | | | | | | | Using only state root and receipt root as witness data can not protect other fields in block header, ex: bloom, difficulty, gas limit, gas used... So that everyone can manipulate these fields to create as many valid blocks at the same height as he want. Although this will not effect the state, one can spam us when syncing. Using block hash as witness data can solve this.
* blockchain: add mutex lock to prevent fork (#159)bojie2019-03-121-1/+6
|
* core: sync to latest core (#158)Jimmy Hu2019-03-121-1/+1
| | | | | | * vendor: sync to latest core * param: Update config * core: update genesis alloc
* app: fix reward bug with empty block (#155)bojie2019-03-121-3/+2
| | | | | | | | * app: fix reward bug with empty block * make block generation consistent * revert change to dmoment in genesis.json
* app: remove pending block logic (#149)bojie2019-03-126-296/+197
|
* core: update taipei allocJimmy Hu2019-03-121-1/+1
|
* params: update genesis configWei-Ning Huang2019-03-123-16/+21
|
* consensus: implement DEXON cryptoeconomics v4.0 (#145)Wei-Ning Huang2019-03-125-57/+153
|
* core: vm: add totalSupply and totalStaked in the governance contract (#144)Wei-Ning Huang2019-03-124-35/+144
| | | | | | | Add totalSupply and totalStaked in the governance contract for the preperation of DEXON cryptoeconomics 4.0. Also removed the unstaked variable in node info and improve tests for delegate/undeleate.
* core: vm: move governance abi to a separate file (#143)Wei-Ning Huang2019-03-122-1053/+1074
|
* core: vm: emit events for more governance actions (#142)Wei-Ning Huang2019-03-121-0/+145
|
* core: update testnet genesis_allocJimmy Hu2019-03-121-1/+1
|
* core: update taipei network genesis allocWei-Ning Huang2019-03-121-1/+1
|
* core: fix corner case when initializing round height (#134)Sonic2019-03-121-1/+1
|
* app: implement logic for prepare/verify correctly when chain number change ↵bojie2019-03-125-19/+122
| | | | (#118)
* core: vm: implement byzantine reporting mechanism (#128)Wei-Ning Huang2019-03-122-48/+578
|
* params: update taipei genesis config (#130)Wei-Ning Huang2019-03-121-1/+1
|
* core, indexer, dex: fix DexconApp block deliver after synced (#122)Sonic2019-03-121-5/+6
| | | | | | | When starts a bp node to sync with the network, bc.chainLastHeight map may not be initialized yet. Just return error if we can not get chain last height when preparing payload and verify block.
* core: fix vm wrong round height context (#124)Sonic2019-03-121-0/+45
| | | | Let roundHeightMap be corret whenever we starting a bp node.
* core: update taipei testnet genesis config and alloc (#119)Wei-Ning Huang2019-03-121-1/+1
|
* core: vm: add missing unittests for nodes/delegators (#116)Wei-Ning Huang2019-03-122-3/+13
|
* params: update taipei testnet genesis and config (#113)Wei-Ning Huang2019-03-122-3/+5
|
* core/vm: Add fine to governance. (#107)Jimmy Hu2019-03-122-132/+292
| | | | | | | | * core/vm: Add Fined field to nodeInfo. * core/vm: Add PayFine to Governance * Not qualify if staked-fine < minStake() * Add test for fine * Update genesis hash
* core: add database/sql support for more types (#102)Meng-Ying Yang2019-03-122-8/+112
| | | | | | | | | * core: types: add database/sql support for BlockNonce * common: add database/sql support with Big New Big type is declared to let big.Int support database/sql by implementing Scan() and Value() on new type.
* vendor: sync DEXON core and fix conflicts/missings (#101)Mission Liao2019-03-121-4/+6
| | | | | | | Merging these commits in DEXON consensus core: - https://github.com/dexon-foundation/dexon-consensus/commit/dce509a13ef5873b9cae3c1cabdb97e219b6fb7d - https://github.com/dexon-foundation/dexon-consensus/commit/6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6 - https://github.com/dexon-foundation/dexon-consensus/commit/c1ed57c4abaf1f4758e52f082bb7114ad00c8b39
* core/types: SigCache with a limited size (#98)Jimmy Hu2019-03-122-21/+33
| | | | | | * core/types: SigCache with a limited size * minor tweaks
* core, dex, internal: block proposer syncing (first iteration) (#96)Sonic2019-03-122-57/+2
| | | | | | | | | | | | | | | | | | | | | | * dex, internal: block proposer syncing (first iteration) * core: find block from db if not in memory This fix handles stopping proposing and then restarting * core: no need to reorg when reset Dexon will not fork. This commit also fix when a block confirm but its parent is not in db yet, during restarting proposing. * dex: always accept NewBlockMsg, NewBlockHashesMsg We need to accept NewBlockMsg, NewBlockHashesMsg to sync current block with other peers in block proposer mode when syncing lattice data. It's a waste when the node is synced and start proposing. Todo: control msg processing on/off more granular, accept NewBlockMsg, NewBlockHashesMsg when syncing, but stop when synced.
* core: vm: Add `MPKReady` to governance (#97)Jimmy Hu2019-03-122-0/+174
| | | | | | * core/vm: Add DKGMPKReady * param: update GenesisHash * vendor: sync to latest core
* core/vm: fix nodes method in governanceJimmy Hu2019-03-121-1/+1
|
* dex: remove duplicate declaration of WitnessData (#92)Wei-Ning Huang2019-03-122-7/+0
| | | | Remove duplicate declaration of WitnessData and remove the TxHash field in witness data since it does not need to be witnessed.
* core: vm: add undelegate fund lockup mechanism (#94)Wei-Ning Huang2019-03-123-41/+236
| | | | | Only allow a user to withdraw funds after a certain lockup period. This way, the fund of a bad actor could be confiscated before he could escape.
* core: update genesis allocJimmy Hu2019-03-121-1/+1
|
* vendor: sync to latest core (#91)Mission Liao2019-03-123-1/+108
| | | | | | - Implement new methods in db to cache DKG private key. - Implement new methods in db to cache compaction chain tip.
* cache: prune cache correctly (#88)bojie2019-03-121-2/+1
|
* core: governance interface should return correct DKG master public keys (#85)Wei-Ning Huang2019-03-122-24/+21
|
* core, dex: polish sync (#75)Sonic2019-03-121-0/+3
| | | | | | | | | | | | | | | - Broadcasting blocks at chain head event is not correct when the full node is not running in block proposer mode. Introduce NewFinalizedBlockEvent, this event is post by the full node which runs in block proposer mode when a block is witnessed and resulting in some blocks are considered finalized. - Non block proposer node will still broadcast blocks at the following moment (same as ethereum): 1. a sync with a peer is terminated successfully 2. a block passes the fetcher's header check during inserting blocks 3. a block is successfully inserted by fetcher - Don't trigger a sync when we are not behind other peers more than acceptable distance. Fetcher is able to cover this.
* core, dex: Timeout for prepare payload (#72)Jimmy Hu2019-03-122-8/+13
| | | | | | * Timeout on prepare payload * Leave 2 CPU for others * Add hardLimit and softLimit to PreparePayload
* app: add app test case and benchmark (#66)bojie2019-03-123-13/+268
|
* dex: verify header that imported from fetcher (#68)Sonic2019-03-121-0/+4
|
* Fix lintWei-Ning Huang2019-03-122-3/+3
|
* core: Update genesis alloc. (#63)Jimmy Hu2019-03-121-1/+1
|
* core: panic if fork found when inserting header chain (#61)Wei-Ning Huang2019-03-121-1/+6
|
* tests: fix testsWei-Ning Huang2019-03-121-1/+10
|
* dex: fix testsWei-Ning Huang2019-03-121-0/+2
|
* core: fix testsWei-Ning Huang2019-03-122-4/+5
|
* core: vm: fix power2 table calculation (#50)Wei-Ning Huang2019-03-121-3/+3
|
* core: commit states at snapshot height (#49)Sonic2019-03-121-2/+7
|
* core: add Taipei testnet (#47)Wei-Ning Huang2019-03-121-1/+13
| | | | Add a new testnet named Taipei.
* core: various changes on tps tuning (#46)Wei-Ning Huang2019-03-125-11/+14
|
* core: increase tx pool sizeWei-Ning Huang2019-03-121-4/+4
|
* core, dex, downloader: refactor governanceSonic2019-03-122-25/+61
|
* core, dex, dex/downloader: restore insertChain to upstream versionSonic2019-03-122-20/+18
| | | | | Also rename InsertChain2, insertChain2, InsertHeaderChain2, ValidateHeaderChain2
* dex: implement downloader for dexSonic2019-03-121-0/+5
| | | | | | | | | | | We need governance state to verify block's signature (randomness), but in ethereum fast sync mode, eth downloader only downloads the whole state of pivot block, so we don't have governance state to verify the downloaded block that is before pivot block if we don't processing transaction. To avoid running transactions, dex downloader also downloads the governance state (merkle proof and storage) at snapshot height of each round, so that we can verify blocks in fast sync mode.
* core: implement insert chain, headerchain logicSonic2019-03-123-0/+521
|
* core: support extracting governance state from state trieSonic2019-03-123-0/+73
|
* core: add global signature cache and improve concurrency (#42)Wei-Ning Huang2019-03-124-53/+86
| | | | | From the go trace result, the bottleneck hides in the lock of StoreTxCache. To improve this, we update the cache in a batched fassion.
* core, dex: Batch process touchSender. Lower priority for tx. (#41)Jimmy Hu2019-03-121-13/+19
| | | | | | | * dex: Add a tx queue in broadcast * Modify queue parameter * Priority select all messages except tx * Batch process TouchSenders
* dex: add BlockDB, which implements consensus core's blockdb.BlockDatabase (#36)Sonic2019-03-122-0/+58
|
* core: vm: change offset type to int256Wei-Ning Huang2019-03-121-2/+7
| | | | | Since we use -1 to represent the offset of empty value, we should make the return type int256 instead of uint256.
* governance: implement delegate/undelegate function and add tests (#33)Wei-Ning Huang2019-03-124-111/+1152
| | | | | Implement delegate/undelegate function to allow others to delegate it's fund to stake on a node. Also added governance contract tests.
* core: blockchain: fix concurrent map read and write (#34)Wei-Ning Huang2019-03-121-4/+7
|
* core: more fix on light node synchronization (#32)Wei-Ning Huang2019-03-123-67/+50
| | | | | | Fix gas calculation in governance contract. Correctly register round height when processing pending blocks. We should register the mapping when we get the pending block instead of waiting for block confirmation.
* core: vm: add minStake to governance contract variable (#31)Wei-Ning Huang2019-03-122-1/+42
|
* core: fix light node synchronization issue (#30)Wei-Ning Huang2019-03-124-9/+18
| | | | | InsertChain() need to record the correct roundHeight mapping in order to process snapshotRoundHeight() governance method correctly.
* core: revert changes to StateProcessor.Process (#29)Wei-Ning Huang2019-03-122-10/+10
|
* app: add cache to reuse same tx address which has already recovered (#26)BJ42019-03-123-3/+41
|
* core: refactor validator and fix light node sync (#25)Wei-Ning Huang2019-03-128-147/+92
| | | | | | | | Remove custom Dexon validator by adding a new `ValidateWitnessData` method into the validator interface. This allow us to properly detect know blocks. This also allow other gdex "light" client to sync compaction chain. Also, setup a standalone RPC node for handling RPC reqeusts.
* core: use storeRoundHeight to avoid type mismatch (#21)Sonic2019-03-121-9/+6
| | | No need to store round 0, it's already pushed in genesis block
* dex, core: Fix make fail (#24)Jimmy Hu2019-03-121-1/+1
|
* core, dex: Optimize sender calculation in block transactions. (#22)Jimmy Hu2019-03-122-0/+34
| | | | | | * Add Transactions.TouchSenders that calculates sender and update cache * Use TouchSenders to fill the caches
* core: validate DKG set with correct nodeset in round-2 (#19)Wei-Ning Huang2019-03-124-32/+63
| | | | | * vendor: sync consensus core * core: validate DKG set with correct nodeset in round-2
* core: vm: Optimize evm (#13)Jimmy Hu2019-03-125-18/+282
| | | | | | | * core: vm: add an EVM benchmark * core: vm: optimize stack allocation and instruction for calculating 2^n * Add DEXONBet bench
* core: push height of round 0 in genesis block (#17)Sonic2019-03-122-8/+11
| | | | | | | * core: push height of round 0 in genesis block * vm: fix governance dispatch method name mismatch with abi also rename RoundHeightLoc to roundHeightLoc
* dex: return correct pending nonce (#14)Wei-Ning Huang2019-03-121-2/+11
| | | | We need to return the correct pending nonce (include those in the tx pool). Also, StateAndHeaderByNumber is also fixed to use pending block.
* params: fix genesis block config and use testnet for test (#10)Wei-Ning Huang2019-03-121-3/+3
|
* core: fix staked calculation in genesis (#8)Jimmy Hu2019-03-121-4/+0
|
* core: vm: expose governance contract ABI (#5)Wei-Ning Huang2019-03-121-2/+2
|
* core: blockchain: fix NewBlockChainWithDexonValidator (#4)Wei-Ning Huang2019-03-121-1/+1
|
* core: genesis: make ToBlock() compatible with legacy ethereum code (#3)Wei-Ning Huang2019-03-121-28/+36
| | | | Make ToBlock() compatible with legacy ethereum code so we can run tests normally.
* app: fix core testBJ42019-03-127-37/+144
|
* core: vm: governance: add node infoWei-Ning Huang2019-03-126-10/+149
|
* core: validate roundHeight mapping in governance contractWei-Ning Huang2019-03-125-4/+43
|
* core: GenerateChainWithRoundChange for testingSonic2019-03-123-0/+598
|
* app: lock by chain correctly and remove old core in vendorBJ42019-03-121-46/+49
|
* core: vm: governance: remove maxIntervalWei-Ning Huang2019-03-121-32/+0
|
* core: vm: add nodesLengh method for reading nodeSet sizeWei-Ning Huang2019-03-121-0/+20
|
* Rename import due to dexon-consensus renameWei-Ning Huang2019-03-123-18/+18
|
* dex: minor refactorWei-Ning Huang2019-03-121-6/+5
|
* app: add lock to prevent concurrent map read writeBojie Wu2019-03-121-0/+3
|
* core: tx_pool: remove transactions on BlockConfirmed eventWei-Ning Huang2019-03-124-41/+53
|
* dex: add block gas limit into governanceWei-Ning Huang2019-03-121-0/+35
|
* app: using lock correctly to use map safelyBojie Wu2019-03-121-56/+86
|
* app: fix concurrent map read write issue and accept fail transaction when ↵Bojie Wu2019-03-121-1/+7
| | | | round change
* core: fix blockReward serializationWei-Ning Huang2019-03-122-37/+28
|
* app: add cache mechanism to increase performanceBojie Wu2019-03-123-149/+133
|
* core: set correct balance for governance contractWei-Ning Huang2019-03-122-1/+7
|
* dex: return round in get block rpc outputWei-Ning Huang2019-03-122-4/+5
|
* app: fix concurrent read write issue with mapBojie Wu2019-03-121-0/+6
|
* dex: remove uneeded info from block headerWei-Ning Huang2019-03-123-90/+87
|
* core: types: fix header marshal jsonSonic2019-03-122-34/+72
|
* vendor: sync consensus core and fix conflictWei-Ning Huang2019-03-121-7/+8
|
* app: correct process pending block logicBojie Wu2019-03-121-126/+111
|
* dex: fix missing randomness assignmentWei-Ning Huang2019-03-121-1/+1
|
* dex: fix DKG round switchingWei-Ning Huang2019-03-121-6/+18
|
* dex: fix round switching and initialize dMoment correctlyWei-Ning Huang2019-03-121-1/+2
|
* dex: misc fixesWei-Ning Huang2019-03-121-3/+3
|
* app: check nonce and balance in prepare payloadBojie Wu2019-03-122-5/+3
|
* core: included Dexcon metadata in blockWei-Ning Huang2019-03-121-2/+3
|
* Remove reference of Rinkeby network.Wei-Ning Huang2019-03-122-26/+1
| | | | We do not need ethereum Rinkeby network in our system, remove it.
* core: populate genesisAlloc in source code with DEXON genesis dataWei-Ning Huang2019-03-123-15/+46
|
* dex: use RLP to encode contract payload dataWei-Ning Huang2019-03-121-6/+6
|
* app: implement verify block logicBojie Wu2019-03-122-1/+51
|
* consensus: dexcon: fetch config from stateWei-Ning Huang2019-03-121-19/+22
|
* core: vm: add blockReward to governanceWei-Ning Huang2019-03-122-4/+39
|
* dex: fix public key parsing due to changes in consensus coreWei-Ning Huang2019-03-121-1/+4
|
* core: set governance owner in genesisWei-Ning Huang2019-03-121-1/+3
|
* params: load blockReward from genesis JSON fileWei-Ning Huang2019-03-121-0/+1
|
* app: fixup message formatWei-Ning Huang2019-03-121-3/+3
|
* app: implement new insert blocks logicBojie Wu2019-03-123-18/+246
|
* test: create account storage for governance contractWei-Ning Huang2019-03-121-1/+1
|
* core/dex: fix governance contract implementationWei-Ning Huang2019-03-121-19/+13
|
* core: vm: implement RAND opcode supportWei-Ning Huang2019-03-129-0/+45
| | | | | | DEXON has a built-in on chain random oracle that allow one to retrieve a random variable. Add a new opcode `RAND` to load the random variable onto the stack.
* dex/core: misc bug fixesWei-Ning Huang2019-03-122-2/+3
|
* app: correct dexon application logicBojie Wu2019-03-122-48/+37
|
* core: fix nil map initializationWei-Ning Huang2019-03-121-0/+7
|
* app: init mapBojie Wu2019-03-121-15/+17
|
* core: setup stake in order so genesis block is deterministicWei-Ning Huang2019-03-121-1/+26
|
* core: vm: modify dkg thresholdJimmy Hu2019-03-121-1/+1
|
* core: vm: add GovernanceStateHelper testWei-Ning Huang2019-03-122-0/+98
|
* core: populate genesis CRS in genesis stateWei-Ning Huang2019-03-121-0/+5
|
* dex: bug fix to allow running geth without crashingWei-Ning Huang2019-03-122-9/+1
|
* dex: implement sendTx related governance methodsWei-Ning Huang2019-03-121-0/+5
|
* core: vm: validate if mpk, complaint, finalize is in DKG setWei-Ning Huang2019-03-121-36/+62
|
* core: vm: allow other people to stake for a nodeWei-Ning Huang2019-03-121-6/+0
|
* dex: implement some governance interface functionsWei-Ning Huang2019-03-121-213/+342
|
* dex: governance: implement governance interfaceWei-Ning Huang2019-03-122-11/+23
|
* app: implement new interface methodBojie Wu2019-03-121-0/+56
|
* core: populate dexon configuration in SetupGenesisBlockWei-Ning Huang2019-03-122-31/+28
|
* dex: implement dexon application interfaceBojie Wu2019-03-121-0/+4
|