Compare commits

...

3 Commits

Author SHA1 Message Date
semantic-release-bot 89749d9a8f chore(release): 0.1.0-develop.62 [skip ci]
# [0.1.0-develop.62](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.61...v0.1.0-develop.62) (2023-10-24)

### Features

* add basic non-verifying eth_getLogs support ([b405ee2](b405ee2581))
2023-10-24 00:24:21 +00:00
Derrick Hammer 833a007a1f
Merge remote-tracking branch 'origin/develop' into develop 2023-10-23 20:23:28 -04:00
Derrick Hammer b405ee2581
feat: add basic non-verifying eth_getLogs support 2023-10-23 20:23:23 -04:00
4 changed files with 29 additions and 3 deletions

View File

@ -1,3 +1,10 @@
# [0.1.0-develop.62](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.61...v0.1.0-develop.62) (2023-10-24)
### Features
* add basic non-verifying eth_getLogs support ([b405ee2](https://git.lumeweb.com/LumeWeb/libethsync/commit/b405ee2581953acc6e8a66dece1a8d1789d5428d))
# [0.1.0-develop.61](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.60...v0.1.0-develop.61) (2023-09-16) # [0.1.0-develop.61](https://git.lumeweb.com/LumeWeb/libethsync/compare/v0.1.0-develop.60...v0.1.0-develop.61) (2023-09-16)

4
npm-shrinkwrap.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.61", "version": "0.1.0-develop.62",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.61", "version": "0.1.0-develop.62",
"dependencies": { "dependencies": {
"@chainsafe/as-sha256": "^0.3.1", "@chainsafe/as-sha256": "^0.3.1",
"@chainsafe/bls": "7.1.1", "@chainsafe/bls": "7.1.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/libethsync", "name": "@lumeweb/libethsync",
"version": "0.1.0-develop.61", "version": "0.1.0-develop.62",
"type": "module", "type": "module",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -72,6 +72,7 @@ export default class VerifyingProvider implements IClientVerifyingProvider {
eth_estimateGas: this.estimateGas, eth_estimateGas: this.estimateGas,
eth_sendRawTransaction: this.sendRawTransaction, eth_sendRawTransaction: this.sendRawTransaction,
eth_getTransactionReceipt: this.getTransactionReceipt, eth_getTransactionReceipt: this.getTransactionReceipt,
eth_getLogs: this.getLogs,
}), }),
); );
private rpc: RPC; private rpc: RPC;
@ -396,6 +397,19 @@ export default class VerifyingProvider implements IClientVerifyingProvider {
}; };
} }
private async getLogs(...args: any) {
const { result: logs, success } = await this.rpc.request({
method: "eth_getLogs",
params: [args],
});
if (!(success && logs)) {
return null;
}
return logs;
}
private async getVMCopy(): Promise<VM> { private async getVMCopy(): Promise<VM> {
if (this.vm === null) { if (this.vm === null) {
const blockchain = await Blockchain.create({ common: this.common }); const blockchain = await Blockchain.create({ common: this.common });
@ -519,6 +533,7 @@ export default class VerifyingProvider implements IClientVerifyingProvider {
await vm.stateManager.commit(); await vm.stateManager.commit();
return vm; return vm;
} }
private async getBlockHeader( private async getBlockHeader(
blockOpt: BlockNumberOrTag, blockOpt: BlockNumberOrTag,
): Promise<BlockHeader> { ): Promise<BlockHeader> {
@ -527,6 +542,7 @@ export default class VerifyingProvider implements IClientVerifyingProvider {
const blockHash = await this.getBlockHash(blockNumber); const blockHash = await this.getBlockHash(blockNumber);
return this.getBlockHeaderByHash(blockHash); return this.getBlockHeaderByHash(blockHash);
} }
private getBlockNumberByBlockNumberOrTag(blockOpt: BlockNumberOrTag): bigint { private getBlockNumberByBlockNumberOrTag(blockOpt: BlockNumberOrTag): bigint {
// TODO: add support for blockOpts below // TODO: add support for blockOpts below
if ( if (
@ -548,6 +564,7 @@ export default class VerifyingProvider implements IClientVerifyingProvider {
return blockNumber; return blockNumber;
} }
} }
private async waitForBlockNumber(blockNumber: bigint) { private async waitForBlockNumber(blockNumber: bigint) {
if (blockNumber <= this.latestBlockNumber) return; if (blockNumber <= this.latestBlockNumber) return;
console.log(`waiting for blockNumber ${blockNumber}`); console.log(`waiting for blockNumber ${blockNumber}`);
@ -638,6 +655,7 @@ export default class VerifyingProvider implements IClientVerifyingProvider {
return true; return true;
} }
private verifyCodeHash(code: Bytes, codeHash: Bytes32): boolean { private verifyCodeHash(code: Bytes, codeHash: Bytes32): boolean {
return ( return (
(code === "0x" && codeHash === "0x" + KECCAK256_NULL_S) || (code === "0x" && codeHash === "0x" + KECCAK256_NULL_S) ||
@ -664,6 +682,7 @@ export default class VerifyingProvider implements IClientVerifyingProvider {
); );
} }
} }
private async getBlock(header: BlockHeader) { private async getBlock(header: BlockHeader) {
const { result: blockInfo, success } = await this.rpc.request({ const { result: blockInfo, success } = await this.rpc.request({
method: "eth_getBlockByNumber", method: "eth_getBlockByNumber",