-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Description
The current implementation of eth_getCode does not cache the result when bytecode contains "prohibited opcodes"
hiero-json-rpc-relay/packages/relay/src/lib/eth.ts
Lines 1206 to 1218 in 7955dae
| const prohibitedOpcodes = ['CALLCODE', 'DELEGATECALL', 'SELFDESTRUCT', 'SUICIDE']; | |
| const opcodes = asm.disassemble(result?.entity.runtime_bytecode); | |
| const hasProhibitedOpcode = | |
| opcodes.filter((opcode) => prohibitedOpcodes.indexOf(opcode.opcode.mnemonic) > -1).length > 0; | |
| if (!hasProhibitedOpcode) { | |
| await this.cacheService.set( | |
| cachedLabel, | |
| result?.entity.runtime_bytecode, | |
| EthImpl.ethGetCode, | |
| requestDetails, | |
| ); | |
| return result?.entity.runtime_bytecode; | |
| } |
This was initially put in place because some of these opcodes might change indeed the bytecode at a given address. However, the cache label already takes into account the blockNumber
| const cachedLabel = `getCode.${address}.${blockNumber}`; |
so these opcodes shouldn't affect the result.
Improve caching strategy for eth_getCode when blockNumber is not latest.
quiet-node
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request