From 6eead81b5296240cbef44ce7f4a79395947552f9 Mon Sep 17 00:00:00 2001 From: ZE0TRON Date: Mon, 9 Dec 2019 20:23:21 +0300 Subject: [PATCH] works like a charm --- consensus/ethash/sealer.go | 4 ++++ core/block_validator.go | 4 ++++ genesis.json | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 genesis.json diff --git a/consensus/ethash/sealer.go b/consensus/ethash/sealer.go index 43db1fcb7f..770b8b0d9f 100644 --- a/consensus/ethash/sealer.go +++ b/consensus/ethash/sealer.go @@ -50,6 +50,10 @@ var ( // the block's difficulty requirements. func (ethash *Ethash) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error { // If we're running a fake PoW, simply return a 0 nonce immediately + if len(block.Transactions()) == 0 { + log.Info("Sealing paused, waiting for transactions") + return nil + } if ethash.config.PowMode == ModeFake || ethash.config.PowMode == ModeFullFake { header := block.Header() header.Nonce, header.MixDigest = types.BlockNonce{}, common.Hash{} diff --git a/core/block_validator.go b/core/block_validator.go index b36ca56d7f..19c8a476d5 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -82,12 +82,16 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD if block.GasUsed() != usedGas { return fmt.Errorf("invalid gas used (remote: %d local: %d)", block.GasUsed(), usedGas) } + if block.GasUsed() == 0 { + return fmt.Errorf("krds napiyon bos block bu") + } // Validate the received block's bloom with the one derived from the generated receipts. // For valid blocks this should always validate to true. rbloom := types.CreateBloom(receipts) if rbloom != header.Bloom { return fmt.Errorf("invalid bloom (remote: %x local: %x)", header.Bloom, rbloom) } + // Tre receipt Trie's root (R = (Tr [[H1, R1], ... [Hn, R1]])) receiptSha := types.DeriveSha(receipts) if receiptSha != header.ReceiptHash { diff --git a/genesis.json b/genesis.json new file mode 100644 index 0000000000..b37e455a39 --- /dev/null +++ b/genesis.json @@ -0,0 +1,34 @@ +{ + "config": { + "chainId": 12331445, + "homesteadBlock": 0, + "eip150Block": 0, + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0 + }, + "alloc": { + "0x2dBc8820de97670590f40Fa4996D177657A2bc9A": { + "balance": "1000000" + }, + "0x8AFdC8c097CF75ebbAAFccA194735Bd77bc50b69": { + "balance": "1000000" + }, + "0xb6fbB120C1FA8F55392E3555A402360Ad3F5ed85": { + "balance": "1000000" + }, + "0x3EE1a1148088CbdA3361CeD72c696130b67b7FfD": { + "balance": "1" + } + }, + "coinbase": "0x0000000000000000000000000000000000000000", + "difficulty": "0x20000", + "extraData": "", + "gasLimit": "0x2fefd8", + "nonce": "0x0000000000000042", + "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "timestamp": "0x00" +} \ No newline at end of file