diff --git a/core/res/null.json b/core/res/null.json index 52e2a20fec..e8d363c8be 100644 --- a/core/res/null.json +++ b/core/res/null.json @@ -29,7 +29,6 @@ "seal": { "generic": "0x0" }, - "score": "0x20000", "author": "tccqyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhhn9p3", "timestamp": "0x00", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/core/res/solo.json b/core/res/solo.json index 8c673610d0..7f05dee7c6 100644 --- a/core/res/solo.json +++ b/core/res/solo.json @@ -36,7 +36,6 @@ "seal": { "generic": "0x0" }, - "score": "0x20000", "author": "tccqyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhhn9p3", "timestamp": "0x00", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/core/res/tendermint.json b/core/res/tendermint.json index 8317a29246..984fe5a0d7 100644 --- a/core/res/tendermint.json +++ b/core/res/tendermint.json @@ -52,7 +52,6 @@ ] } }, - "score": "0x20000", "author": "tccq8qlwpt7xcs9lec3c8tyt3kqxlgsus8q4qp3m6ft", "timestamp": "0x00", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/core/src/blockchain/blockchain.rs b/core/src/blockchain/blockchain.rs index 4c33c0a07e..d9f905f11c 100644 --- a/core/src/blockchain/blockchain.rs +++ b/core/src/blockchain/blockchain.rs @@ -43,7 +43,7 @@ const BEST_PROPOSAL_BLOCK_KEY: &[u8] = b"best-proposal-block"; pub struct BlockChain { /// The hash of the best block of the canonical chain. best_block_hash: RwLock, - /// The hash of the block which has the best score among the proposal blocks + /// The hash of the block which has the best possibility among the proposal blocks best_proposal_block_hash: RwLock, headerchain: HeaderChain, @@ -230,7 +230,7 @@ impl BlockChain { { cinfo!( BLOCKCHAIN, - "Block #{}({}) has higher total score, changing the best proposal/canonical chain.", + "Block #{}({}) has higher block number and lower view, changing the best proposal/canonical chain.", new_header.number(), new_header.hash() ); diff --git a/core/src/blockchain/headerchain.rs b/core/src/blockchain/headerchain.rs index 9787cf9d6a..68a2b87a13 100644 --- a/core/src/blockchain/headerchain.rs +++ b/core/src/blockchain/headerchain.rs @@ -43,7 +43,7 @@ pub struct HeaderChain { // All locks must be captured in the order declared here. /// The hash of the best block of the canonical chain. best_header_hash: RwLock, - /// The hash of the block which has the best score among the proposal blocks + /// The hash of the block which has the best possibility among the proposal blocks best_proposal_header_hash: RwLock, // cache @@ -287,7 +287,7 @@ impl HeaderChain { if is_new_best { ctrace!( HEADERCHAIN, - "Block header #{}({}) has higher total score, changing the best proposal/canonical chain.", + "Block header #{}({}) has higher block number and lower view, changing the best proposal/canonical chain.", new_header.number(), new_header.hash() ); diff --git a/core/src/views/header.rs b/core/src/views/header.rs index a53c8519d6..18f9a2ad4b 100644 --- a/core/src/views/header.rs +++ b/core/src/views/header.rs @@ -17,7 +17,7 @@ use ccrypto::blake256; use ckey::Address; use ctypes::{BlockHash, BlockNumber}; -use primitives::{Bytes, H256, U256}; +use primitives::{Bytes, H256}; use rlp::Rlp; /// View onto block header rlp. @@ -75,29 +75,24 @@ impl<'a> HeaderView<'a> { self.rlp.val_at(4).unwrap() } - /// Returns block score. - pub fn score(&self) -> U256 { - self.rlp.val_at(5).unwrap() - } - /// Returns block number. pub fn number(&self) -> BlockNumber { - self.rlp.val_at(6).unwrap() + self.rlp.val_at(5).unwrap() } /// Returns timestamp. pub fn timestamp(&self) -> u64 { - self.rlp.val_at(7).unwrap() + self.rlp.val_at(6).unwrap() } /// Returns block extra data. pub fn extra_data(&self) -> Bytes { - self.rlp.val_at(8).unwrap() + self.rlp.val_at(7).unwrap() } /// Returns a vector of post-RLP-encoded seal fields. pub fn seal(&self) -> Vec { - const SIZE_WITHOUT_SEAL: usize = 9; + const SIZE_WITHOUT_SEAL: usize = 8; let item_count = self.rlp.item_count().unwrap(); let mut seal = Vec::with_capacity(item_count - SIZE_WITHOUT_SEAL); diff --git a/rpc/src/v1/types/block.rs b/rpc/src/v1/types/block.rs index b025198d06..09a4afec30 100644 --- a/rpc/src/v1/types/block.rs +++ b/rpc/src/v1/types/block.rs @@ -18,7 +18,7 @@ use super::Transaction; use ccore::{Block as CoreBlock, LocalizedTransaction}; use ckey::{NetworkId, PlatformAddress}; use ctypes::{BlockHash, BlockNumber}; -use primitives::{H256, U256}; +use primitives::H256; #[derive(Debug, Serialize)] #[serde(rename_all = "camelCase")] @@ -34,7 +34,6 @@ pub struct Block { state_root: H256, next_validator_set_hash: H256, - score: U256, seal: Vec>, hash: BlockHash, @@ -65,7 +64,6 @@ impl Block { state_root: *block.header.state_root(), next_validator_set_hash: *block.header.next_validator_set_hash(), - score: U256::default(), seal: block.header.seal().to_vec(), hash: block.header.hash(), diff --git a/spec/JSON-RPC.md b/spec/JSON-RPC.md index 59603df947..28ecdf1ee1 100644 --- a/spec/JSON-RPC.md +++ b/spec/JSON-RPC.md @@ -36,7 +36,6 @@ A string that starts with "(NetworkID)c", and Bech32 string follows. For example - transactions: `Transaction[]` - transactionsRoot: `H256` - parentHash: `H256` - - score: `number` - seal: `string[]` - stateRoot: `H256` - timestamp: `number` @@ -567,7 +566,6 @@ Errors: `Invalid Params` ], "transactionsRoot":"0xa4a8229a90d91e9a38b17f95c9ac2d01f46b10553e62c68df5bbfe1cc5b3e164", "parentHash":"0xbc4f7e7b1dded863c500147243d78436ca297bfae64e1ec2d17396286cf14b6e", - "score":"0x20000", "seal":[ ], @@ -629,7 +627,6 @@ Errors: `Invalid Params` ], "transactionsRoot":"0x0270d11d2bd21a0ec8e78d1c4e918103d7c4b02fdf734051231cb9eea90ae88e", "parentHash":"0xddf9fece0c6dee067a409e73a299bca21cec2d8300dff45739a5b76c680f378d", - "score":"0x20000", "seal":[ ], diff --git a/sync/src/block/extension.rs b/sync/src/block/extension.rs index c21df4a7b0..7755fa16d7 100644 --- a/sync/src/block/extension.rs +++ b/sync/src/block/extension.rs @@ -745,7 +745,7 @@ impl Extension { match self.header_downloaders.entry(*from) { Entry::Occupied(mut peer) => { if !peer.get_mut().update(seq, best_hash) { - cdebug!(SYNC, "Peer #{} status updated but score is less than before", from); + cdebug!(SYNC, "Peer #{} status updated but seqeunce is less than before", from); return } } diff --git a/test/src/e2e.long/invalidBlockPropagation.helper.ts b/test/src/e2e.long/invalidBlockPropagation.helper.ts index ca59ce02b3..381f3db667 100644 --- a/test/src/e2e.long/invalidBlockPropagation.helper.ts +++ b/test/src/e2e.long/invalidBlockPropagation.helper.ts @@ -58,7 +58,6 @@ async function setup(): Promise<[Header, Block, Header]> { new H256(block0.transactionsRoot), new H256(block0.nextValidatorSetHash), new H256(block0.stateRoot), - new U256(`${block0.score}`), block0.seal ); const author1 = Address.fromString(block1.author); @@ -71,7 +70,6 @@ async function setup(): Promise<[Header, Block, Header]> { new H256(block1.transactionsRoot), new H256(block1.nextValidatorSetHash), new H256(block1.stateRoot), - new U256(2222222222222), block1.seal ); const author3 = Address.fromString(block0.author); @@ -84,7 +82,6 @@ async function setup(): Promise<[Header, Block, Header]> { new H256(block2.transactionsRoot), new H256(block2.nextValidatorSetHash), new H256(block2.stateRoot), - new U256(33333333333333), block2.seal ); return [header0, block1, header2]; @@ -120,14 +117,12 @@ async function testBody( ttransactionRoot?: H256; tstateRoot?: H256; tnextValidatorSetHash?: H256; - tscore?: U256; tseal?: number[][]; } ) { const { tnumber, textraData, - tscore, tparent, tauthor, ttransactionRoot, @@ -137,7 +132,6 @@ async function testBody( } = params; const bestHash = header2.hashing(); - const bestScore = header2.getScore(); const author4 = Address.fromString(block1.author); const header = new Header( @@ -149,7 +143,6 @@ async function testBody( new H256(block1.transactionsRoot), new H256(block1.nextValidatorSetHash), new H256(block1.stateRoot), - new U256(2222222222222), block1.seal ); @@ -174,15 +167,13 @@ async function testBody( if (tnextValidatorSetHash != null) { header.setNextValidatorSetHash(tnextValidatorSetHash); } - if (tscore != null) { - header.setScore(tscore); - } if (tseal != null) { header.setSeal(tseal); } const genesis = mock.genesisHash; - await mock.sendStatus(bestScore, bestHash, genesis); + const seq = new U256(0); + await mock.sendStatus(seq, bestHash, genesis); await mock.sendBlockHeaderResponse([ header0.toEncodeObject(), header.toEncodeObject(), diff --git a/test/src/e2e.long/invalidBlockPropagation8.test.ts b/test/src/e2e.long/invalidBlockPropagation8.test.ts deleted file mode 100644 index 418b8c8342..0000000000 --- a/test/src/e2e.long/invalidBlockPropagation8.test.ts +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018-2019 Kodebox, Inc. -// This file is part of CodeChain. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -import { U256 } from "foundry-primitives/lib"; -import "mocha"; -import { createTestSuite } from "./invalidBlockPropagation.helper"; - -const INVALID_SCORE = new U256(9999999999999999999999999999999999999999); -const params = { - tscore: INVALID_SCORE -}; -createTestSuite(8, "OnChain invalid score block propagation test", params); diff --git a/test/src/e2e.long/invalidBlockPropagation9.test.ts b/test/src/e2e.long/invalidBlockPropagation9.test.ts index 5481eb0b9c..8d9fe63cf5 100644 --- a/test/src/e2e.long/invalidBlockPropagation9.test.ts +++ b/test/src/e2e.long/invalidBlockPropagation9.test.ts @@ -21,4 +21,4 @@ const INVALID_SEAL = [Buffer.from("DEADBEEF")]; const params = { tseal: INVALID_SEAL }; -createTestSuite(9, "OnChain invalid score seal propagation test", params); +createTestSuite(9, "OnChain invalid seal propagation test", params); diff --git a/test/src/e2e.long/onChainBlockValid.test.ts b/test/src/e2e.long/onChainBlockValid.test.ts index d899f49f95..46e3e13d3e 100644 --- a/test/src/e2e.long/onChainBlockValid.test.ts +++ b/test/src/e2e.long/onChainBlockValid.test.ts @@ -76,7 +76,6 @@ describe("Test onChain block communication", async function() { new H256(genesisBlock.transactionsRoot), new H256(genesisBlock.stateRoot), new H256(genesisBlock.nextValidatorSetHash), - new U256(`${genesisBlock.score}`), genesisBlock.seal ); const author2PlatformAddr = Address.fromString(block1.author); @@ -89,7 +88,6 @@ describe("Test onChain block communication", async function() { new H256(block1.transactionsRoot), new H256(block1.stateRoot), new H256(block1.nextValidatorSetHash), - new U256(2222222222222), block1.seal ); const author3PlatformAddr = Address.fromString(block2.author); @@ -102,7 +100,6 @@ describe("Test onChain block communication", async function() { new H256(block2.transactionsRoot), new H256(block2.stateRoot), new H256(block2.nextValidatorSetHash), - new U256(33333333333333), block2.seal ); @@ -137,8 +134,7 @@ describe("Test onChain block communication", async function() { header2.toEncodeObject() ], [[], []], - header2.hashing(), - header2.getScore() + header2.hashing() ); await mock.waitStatusMessage(); diff --git a/test/src/helper/mock/blockSyncMessage.ts b/test/src/helper/mock/blockSyncMessage.ts index 09ea60eab2..330539e169 100644 --- a/test/src/helper/mock/blockSyncMessage.ts +++ b/test/src/helper/mock/blockSyncMessage.ts @@ -39,7 +39,7 @@ type BlockSyncMessageBody = IStatus | IRequest | IResponse; interface IStatus { type: "status"; - totalScore: U256; + seq: U256; bestHash: H256; genesisHash: H256; } @@ -64,14 +64,12 @@ export class BlockSyncMessage { if (msgId === MessageType.MESSAGE_ID_STATUS) { Emitter.emit("status"); const msg = decodedmsg[1]; - const totalScore = new U256( - parseInt(msg[0].toString("hex"), 16) || 0 - ); + const seq = new U256(parseInt(msg[0].toString("hex"), 16) || 0); const bestHash = new H256(msg[1].toString("hex")); const genesisHash = new H256(msg[2].toString("hex")); return new BlockSyncMessage({ type: "status", - totalScore, + seq, bestHash, genesisHash }); @@ -123,7 +121,7 @@ export class BlockSyncMessage { return [ MessageType.MESSAGE_ID_STATUS, [ - this.body.totalScore.toEncodeObject(), + this.body.seq.toEncodeObject(), this.body.bestHash.toEncodeObject(), this.body.genesisHash.toEncodeObject() ] diff --git a/test/src/helper/mock/cHeader.ts b/test/src/helper/mock/cHeader.ts index 137b59460e..030530a913 100644 --- a/test/src/helper/mock/cHeader.ts +++ b/test/src/helper/mock/cHeader.ts @@ -29,10 +29,9 @@ export class Header { const stateRoot = new H256(decodedmsg[2].toString("hex")); const transactionsRoot = new H256(decodedmsg[3].toString("hex")); const nextValidatorSetHash = new H256(decodedmsg[4].toString("hex")); - const score = decodedmsg[5]; - const number = new U256(parseInt(decodedmsg[6].toString("hex"), 16)); - const timestamp = new U256(parseInt(decodedmsg[7].toString("hex"), 16)); - const extraData = decodedmsg[8]; + const number = new U256(parseInt(decodedmsg[5].toString("hex"), 16)); + const timestamp = new U256(parseInt(decodedmsg[6].toString("hex"), 16)); + const extraData = decodedmsg[7]; // Be careful of the order! Three roots have same types, so mistake on the order will not be catched by typechecker. const header = new Header( @@ -44,11 +43,10 @@ export class Header { transactionsRoot, stateRoot, nextValidatorSetHash, - score, [] ); - for (let i = 9; i < decodedmsg.getLength(); i++) { + for (let i = 8; i < decodedmsg.getLength(); i++) { header.seal.push(decodedmsg[i]); } @@ -62,7 +60,6 @@ export class Header { private transactionsRoot: H256; private stateRoot: H256; private nextValidatorSetHash: H256; - private score: U256; private seal: number[][]; private hash: null | H256; private bareHash: null | H256; @@ -76,7 +73,6 @@ export class Header { transactionsRoot: H256, stateRoot: H256, nextValidatorSetHash: H256, - score: U256, seal: number[][], hash?: H256, bareHash?: H256 @@ -89,7 +85,6 @@ export class Header { this.transactionsRoot = transactionsRoot; this.stateRoot = stateRoot; this.nextValidatorSetHash = nextValidatorSetHash; - this.score = score; this.seal = seal; this.hash = hash == null ? this.hashing() : hash; this.bareHash = bareHash == null ? null : bareHash; @@ -127,10 +122,6 @@ export class Header { this.nextValidatorSetHash = root; } - public setScore(score: U256) { - this.score = score; - } - public setSeal(seal: number[][]) { this.seal = seal; } @@ -143,10 +134,6 @@ export class Header { return this.bareHash; } - public getScore(): U256 { - return this.score; - } - public default(): Header { return new Header( new H256( @@ -159,9 +146,6 @@ export class Header { BLAKE_NULL_RLP, BLAKE_NULL_RLP, BLAKE_NULL_RLP, - new U256( - "0000000000000000000000000000000000000000000000000000000000000000" - ), [] ); } @@ -173,7 +157,6 @@ export class Header { this.stateRoot.toEncodeObject(), this.transactionsRoot.toEncodeObject(), this.nextValidatorSetHash.toEncodeObject(), - this.score.toEncodeObject(), this.number.toEncodeObject(), this.timestamp.toEncodeObject(), this.extraData diff --git a/test/src/helper/mock/example/send-block.ts b/test/src/helper/mock/example/send-block.ts index 8ff2442c37..5383c51976 100644 --- a/test/src/helper/mock/example/send-block.ts +++ b/test/src/helper/mock/example/send-block.ts @@ -20,8 +20,7 @@ async function sendBlock() { header2.toEncodeObject() ], [[], []], - header2.hashing(), - header2.getScore() + header2.hashing() ); await mock.end(); diff --git a/test/src/helper/mock/index.ts b/test/src/helper/mock/index.ts index 4d975f1bf1..af79d60921 100644 --- a/test/src/helper/mock/index.ts +++ b/test/src/helper/mock/index.ts @@ -68,7 +68,7 @@ export class Mock { this.p2psocket.enableLog(); } - public async establish(bestHash?: H256, bestScore?: U256) { + public async establish(bestHash?: H256) { await this.p2psocket.connect(); let isStatusArrived; @@ -84,8 +84,6 @@ export class Mock { await this.waitStatusMessage(); } - const score = - bestScore == undefined ? new U256("99999999999999999") : bestScore; const best = bestHash == undefined ? new H256( @@ -93,8 +91,8 @@ export class Mock { ) : bestHash; const genesis = this.p2psocket.getGenesisHash(); - this.sendStatus(score, best, genesis); - + const seq = new U256(0); + this.sendStatus(seq, best, genesis); await this.waitHeaderRequest(); if (this.log) { @@ -192,10 +190,10 @@ export class Mock { return null; } - public async sendStatus(score: U256, bestHash: H256, genesisHash: H256) { + public async sendStatus(seq: U256, bestHash: H256, genesisHash: H256) { const msg = new BlockSyncMessage({ + seq, type: "status", - totalScore: score, bestHash, genesisHash }); @@ -257,17 +255,15 @@ export class Mock { public async sendEncodedBlock( header: EncodedHeaders, body: EncodedBodies, - bestBlockHash: H256, - bestBlockScore: U256 + bestBlockHash: H256 ) { if (this.log) { console.log("Send blocks"); } - const score = bestBlockScore; const best = bestBlockHash; const genesis = this.p2psocket.getGenesisHash(); - await this.sendStatus(score, best, genesis); - + const seq = new U256(0); + this.sendStatus(seq, best, genesis); await this.sendBlockHeaderResponse(header); if (this.log) { console.log("Send header response"); @@ -288,11 +284,10 @@ export class Mock { console.log("Send blocks"); } const bestBlock = header[header.length - 1]; - const score = bestBlock.getScore(); const best = bestBlock.hashing(); const genesis = this.p2psocket.getGenesisHash(); - await this.sendStatus(score, best, genesis); - + const seq = new U256(0); + await this.sendStatus(seq, best, genesis); await this.sendBlockHeaderResponse(header.map(h => h.toEncodeObject())); if (this.log) { console.log("Send header response"); @@ -419,7 +414,6 @@ export class Mock { const nextValidatorSetHash = new H256( "45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0" ); - const score = new U256(131072); const seal: any[] = []; const header = new Header( parentHash, @@ -430,7 +424,6 @@ export class Mock { transactionsRoot, stateRoot, nextValidatorSetHash, - score, seal ); @@ -452,7 +445,6 @@ export class Mock { const nextValidatorSetHash = new H256( "45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0" ); - const score = new U256(999999999999999); const seal: any[] = []; const header = new Header( parentHash, @@ -463,7 +455,6 @@ export class Mock { transactionsRoot, stateRoot, nextValidatorSetHash, - score, seal ); @@ -485,7 +476,6 @@ export class Mock { const nextValidatorSetHash = new H256( "45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0" ); - const score = new U256(999999999999999); const seal: any[] = []; const header = new Header( parentHash, @@ -496,7 +486,6 @@ export class Mock { transactionsRoot, stateRoot, nextValidatorSetHash, - score, seal ); @@ -598,7 +587,7 @@ export class Mock { const block: any = RLP.decode(message.message); const oldOn: Parameters[0] = { step: { - height: readUIntRLP(block[0][6]), + height: readUIntRLP(block[0][5]), view: message.view, step: TendermintStep.Propose }, @@ -606,9 +595,9 @@ export class Mock { }; if (verifyEd25519(digest(oldOn), signature, pub)) { const newHeader = [ - ...block[0].slice(0, 7), - new U64(readUIntRLP(block[0][7]) + 1).toEncodeObject(), // timestamp - ...block[0].slice(8) + ...block[0].slice(0, 6), + new U64(readUIntRLP(block[0][6]) + 1).toEncodeObject(), // timestamp + ...block[0].slice(7) ]; const newDigest = digest({ ...oldOn, diff --git a/test/src/scheme/mempool.json b/test/src/scheme/mempool.json index b179b447dd..31f7a08b0a 100644 --- a/test/src/scheme/mempool.json +++ b/test/src/scheme/mempool.json @@ -30,7 +30,6 @@ "seal": { "generic": "0x0" }, - "score": "0x20000", "author": "tccqyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhhn9p3", "timestamp": "0x00", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/src/scheme/solo-block-reward-50.json b/test/src/scheme/solo-block-reward-50.json index da9e2882e9..980db5c332 100644 --- a/test/src/scheme/solo-block-reward-50.json +++ b/test/src/scheme/solo-block-reward-50.json @@ -37,7 +37,6 @@ "seal": { "generic": "0x0" }, - "score": "0x20000", "author": "tccqyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhhn9p3", "timestamp": "0x00", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/src/scheme/tendermint-dynval.json b/test/src/scheme/tendermint-dynval.json index 1d3ad19e76..9b08828a6b 100644 --- a/test/src/scheme/tendermint-dynval.json +++ b/test/src/scheme/tendermint-dynval.json @@ -54,7 +54,6 @@ ] } }, - "score": "0x20000", "author": "tccq8zjtcf7d27l55hgthudmhx0g7zd6dw9rg9c77t5", "timestamp": "0x00", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/src/scheme/tendermint-int.json b/test/src/scheme/tendermint-int.json index b050e7b81d..3fd198a546 100644 --- a/test/src/scheme/tendermint-int.json +++ b/test/src/scheme/tendermint-int.json @@ -54,7 +54,6 @@ ] } }, - "score": "0x20000", "author": "tccq8zjtcf7d27l55hgthudmhx0g7zd6dw9rg9c77t5", "timestamp": "0x00", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/src/scheme/tendermint-tps.json b/test/src/scheme/tendermint-tps.json index 827560a999..d37b3006bd 100644 --- a/test/src/scheme/tendermint-tps.json +++ b/test/src/scheme/tendermint-tps.json @@ -52,7 +52,6 @@ ] } }, - "score": "0x20000", "author": "tccq94guhkrfndnehnca06dlkxcfuq0gdlamvw9ga4f", "timestamp": "0x00", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", diff --git a/test/src/sdk/core/Block.ts b/test/src/sdk/core/Block.ts index 06a7264132..a2b93f0fef 100644 --- a/test/src/sdk/core/Block.ts +++ b/test/src/sdk/core/Block.ts @@ -17,7 +17,6 @@ export interface BlockData { transactionsRoot: H256; stateRoot: H256; nextValidatorSetHash: H256; - score: U256; seal: number[][]; hash: H256; transactions: SignedTransaction[]; @@ -31,7 +30,6 @@ export interface BlockJSON { transactionsRoot: string; stateRoot: string; nextValidatorSetHash: string; - score: string; seal: number[][]; hash: string; transactions: SignedTransactionJSON[]; @@ -50,7 +48,6 @@ export class Block { transactionsRoot, stateRoot, nextValidatorSetHash, - score, seal, hash, transactions @@ -64,7 +61,6 @@ export class Block { transactionsRoot: new H256(transactionsRoot), stateRoot: new H256(stateRoot), nextValidatorSetHash: new H256(nextValidatorSetHash), - score: new U256(score), seal, hash: new H256(hash), transactions: transactions.map(fromJSONToSignedTransaction) @@ -78,7 +74,6 @@ export class Block { public transactionsRoot: H256; public stateRoot: H256; public nextValidatorSetHash: H256; - public score: U256; public seal: number[][]; public hash: H256; public transactions: SignedTransaction[]; @@ -93,7 +88,6 @@ export class Block { transactionsRoot, stateRoot, nextValidatorSetHash, - score, seal, hash, transactions @@ -106,7 +100,6 @@ export class Block { this.transactionsRoot = transactionsRoot; this.stateRoot = stateRoot; this.nextValidatorSetHash = nextValidatorSetHash; - this.score = score; this.seal = seal; this.hash = hash; this.transactions = transactions; @@ -122,7 +115,6 @@ export class Block { transactionsRoot, stateRoot, nextValidatorSetHash, - score, seal, hash, transactions @@ -136,7 +128,6 @@ export class Block { transactionsRoot: transactionsRoot.toJSON(), stateRoot: stateRoot.toJSON(), nextValidatorSetHash: nextValidatorSetHash.toJSON(), - score: score.value.toString(), seal: seal.map(buffer => [...buffer]), hash: hash.toJSON(), transactions: transactions.map(p => p.toJSON()) @@ -153,7 +144,6 @@ export class Block { transactionsRoot, stateRoot, nextValidatorSetHash, - score, seal, transactions } = this; @@ -164,7 +154,6 @@ export class Block { blockHeader.push(stateRoot.toEncodeObject()); blockHeader.push(transactionsRoot.toEncodeObject()); blockHeader.push(nextValidatorSetHash.toEncodeObject()); - blockHeader.push(score.toEncodeObject()); blockHeader.push(number); blockHeader.push(timestamp); blockHeader.push(`0x${Buffer.from(extraData).toString("hex")}`); diff --git a/test/src/sdk/core/__test__/Block.spec.ts b/test/src/sdk/core/__test__/Block.spec.ts index 8c5cf6e33f..7a8bfbf310 100644 --- a/test/src/sdk/core/__test__/Block.spec.ts +++ b/test/src/sdk/core/__test__/Block.spec.ts @@ -40,7 +40,6 @@ test("toJSON", () => { nextValidatorSetHash: new H256( "3333333333333333333333333333333333333333333333333333333333333333" ), - score: new U256(3), seal: [], hash: new H256( "4444444444444444444444444444444444444444444444444444444444444444" diff --git a/types/src/header.rs b/types/src/header.rs index 63c891f3fe..04908cfba0 100644 --- a/types/src/header.rs +++ b/types/src/header.rs @@ -54,8 +54,6 @@ pub struct Header { /// Next validator set hash. next_validator_set_hash: H256, - /// Block score. - score: U256, /// Vector of post-RLP-encoded fields. seal: Vec, @@ -79,7 +77,6 @@ impl Default for Header { state_root: BLAKE_NULL_RLP, next_validator_set_hash: BLAKE_NULL_RLP, - score: U256::default(), seal: vec![], hash: RefCell::new(None), bare_hash: RefCell::new(None), @@ -87,7 +84,7 @@ impl Default for Header { } } -const SIZE_WITHOUT_SEAL: usize = 9; +const SIZE_WITHOUT_SEAL: usize = 8; impl Header { /// Create a new, default-valued, header. @@ -210,11 +207,6 @@ impl Header { self.next_validator_set_hash = a; self.note_dirty() } - /// Set the score field of the header. - pub fn set_score(&mut self, a: U256) { - self.score = a; - self.note_dirty(); - } /// Set the seal field of the header. pub fn set_seal(&mut self, a: Vec) { self.seal = a; @@ -261,7 +253,6 @@ impl Header { s.append(&self.state_root); s.append(&self.transactions_root); s.append(&self.next_validator_set_hash); - s.append(&self.score); s.append(&self.number); s.append(&self.timestamp); s.append(&self.extra_data); @@ -310,10 +301,9 @@ impl Decodable for Header { state_root: r.val_at(2)?, transactions_root: r.val_at(3)?, next_validator_set_hash: r.val_at(4)?, - score: r.val_at(5)?, - number: r.val_at(6)?, - timestamp: cmp::min(r.val_at::(7)?, u64::max_value().into()).as_u64(), - extra_data: r.val_at(8)?, + number: r.val_at(5)?, + timestamp: cmp::min(r.val_at::(6)?, u64::max_value().into()).as_u64(), + extra_data: r.val_at(7)?, seal: vec![], hash: RefCell::new(Some(blake256(r.as_raw()))), bare_hash: RefCell::new(None),