Skip to content

Commit

Permalink
Miscellaneous fixes/improvements for evm, client, consensus and crypto (
Browse files Browse the repository at this point in the history
#2040)

* Miscellaneous fixes/improvements for evm, client, consensus and crypto

* skip header validation while runBlock if block picked from blockchain

* update the ethereum-cryptography to 1.1.2 with 0 msgHash fix
  • Loading branch information
g11tech authored Jul 15, 2022
1 parent a60b878 commit 22a30ae
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 64 deletions.
88 changes: 44 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/block/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@ethereumjs/trie": "5.0.0-beta.1",
"@ethereumjs/tx": "4.0.0-beta.1",
"@ethereumjs/util": "8.0.0-beta.1",
"ethereum-cryptography": "^1.0.3",
"ethereum-cryptography": "^1.1.2",
"rlp": "4.0.0-beta.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/blockchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@ethereumjs/util": "8.0.0-beta.1",
"abstract-level": "^1.0.3",
"debug": "^4.3.3",
"ethereum-cryptography": "^1.0.3",
"ethereum-cryptography": "^1.1.2",
"level": "^8.0.0",
"lru-cache": "^5.1.1",
"memory-level": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/client/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ const args = yargs(hideBin(process.argv))
describe:
'Save tx receipts and logs in the meta db (warning: may use a large amount of storage). With `--rpc` allows querying via eth_getLogs (max 10000 logs per request) and eth_getTransactionReceipt (within `--txLookupLimit`)',
boolean: true,
default: true,
})
.option('disableBeaconSync', {
describe:
Expand Down
8 changes: 7 additions & 1 deletion packages/client/bin/startRpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Server as RPCServer } from 'jayson/promise'
import { readFileSync, writeFileSync } from 'fs-extra'
import { RPCManager } from '../lib/rpc'
import { RPCManager, saveReceiptsMethods } from '../lib/rpc'
import { EthereumClient } from '../lib/client'
import {
MethodConfig,
Expand Down Expand Up @@ -83,6 +83,12 @@ export function startRPCServers(client: EthereumClient, args: RPCArgs) {
rpcEngine && rpcEngineAuth ? parseJwtSecret(config, jwtSecretPath) : Buffer.from([])
let withEngineMethods = false

if ((rpc || rpcEngine) && !config.saveReceipts) {
logger?.warn(
`Starting client without --saveReceipts might lead to interop issues with a CL especially if the CL intends to propose blocks, omitting methods=${saveReceiptsMethods}`
)
}

if (rpc || ws) {
let rpcHttpServer
withEngineMethods = rpcEngine && rpcEnginePort === rpcport && rpcEngineAddr === rpcaddr
Expand Down
8 changes: 7 additions & 1 deletion packages/client/lib/execution/vmexecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,14 @@ export class VMExecution extends Execution {
// (signer states might have moved on when sync is ahead)
skipBlockValidation = true
}

// we are skipping header validation because the block has been picked from the
// blockchain and header should have already been validated while putBlock
const result = await this.vm.runBlock({
block,
root: parentState,
skipBlockValidation,
skipHeaderValidation: true,
})
void this.receiptsManager?.saveReceipts(block, result.receipts)
txCounter += block.transactions.length
Expand Down Expand Up @@ -318,7 +322,9 @@ export class VMExecution extends Execution {
vm._common.setHardforkByBlockNumber(blockNumber, td)

if (txHashes.length === 0) {
const res = await vm.runBlock({ block })
// we are skipping header validation because the block has been picked from the
// blockchain and header should have already been validated while putBlock
const res = await vm.runBlock({ block, skipHeaderValidation: true })
this.config.logger.info(
`Executed block num=${blockNumber} hash=0x${block.hash().toString('hex')} txs=${
block.transactions.length
Expand Down
9 changes: 3 additions & 6 deletions packages/client/lib/rpc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { EthereumClient } from '../client'
import * as modules from './modules'
import { INTERNAL_ERROR } from './error-code'

export const saveReceiptsMethods = ['getLogs', 'getTransactionReceipt', 'getTransactionByHash']

/**
* @module rpc
*/
Expand Down Expand Up @@ -34,12 +36,7 @@ export class RPCManager {
const mod = new (modules as any)[modName](this._client)
const rpcMethods = RPCManager.getMethodNames((modules as any)[modName])
for (const methodName of rpcMethods) {
if (
!this._config.saveReceipts &&
(methodName === 'getLogs' ||
methodName === 'getTransactionReceipt' ||
methodName === 'getTransactionByHash')
) {
if (!this._config.saveReceipts && saveReceiptsMethods.includes(methodName)) {
continue
}
const concatedMethodName = `${modName.toLowerCase()}_${methodName}`
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"connect": "^3.7.0",
"cors": "^2.8.5",
"debug": "^4.3.3",
"ethereum-cryptography": "^1.0.3",
"ethereum-cryptography": "^1.1.2",
"fs-extra": "^10.0.0",
"it-pipe": "^1.1.0",
"it-pushable": "^1.4.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/devp2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"bl": "^1.1.2",
"debug": "^4.3.3",
"@ethereumjs/util": "8.0.0-beta.1",
"ethereum-cryptography": "^1.1.0",
"ethereum-cryptography": "^1.1.2",
"inherits": "^2.0.1",
"ip": "^1.1.3",
"k-bucket": "^5.0.0",
Expand Down
Loading

0 comments on commit 22a30ae

Please sign in to comment.