Skip to content

Commit

Permalink
client, vm -> vm execution: removed stateDB from LightEthereumService…
Browse files Browse the repository at this point in the history
…, removed checkpointing exception for zero tx blocks in VM.runBlocks()
  • Loading branch information
holgerd77 committed Jan 6, 2021
1 parent bd32047 commit dc2c99e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/client/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export default class EthereumClient extends events.EventEmitter {
: new LightEthereumService({
config: this.config,
chainDB: options.chainDB,
stateDB: options.stateDB,
}),
]
this.opened = false
Expand Down
17 changes: 5 additions & 12 deletions packages/vm/lib/runBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,19 @@ export default async function runBlock(this: VM, opts: RunBlockOpts): Promise<Ru
}

// Checkpoint state
// (only do checkpointing when txs are executed)
// TODO: determine if checkpointing is needed in a block
// context at all or CPs in runTx() are sufficient
if (block.transactions.length > 0) {
await state.checkpoint()
}
await state.checkpoint()

let result
try {
result = await applyBlock.bind(this)(block, opts)
} catch (err) {
if (block.transactions.length > 0) {
await state.revert()
}
await state.revert()
throw err
}

// Persist state
if (block.transactions.length > 0) {
await state.commit()
}
await state.commit()

const stateRoot = await state.getStateRoot(false)

// Given the generate option, either set resulting header
Expand Down

0 comments on commit dc2c99e

Please sign in to comment.