-
-
Save yoavw/bdf6d532b75ede6f60ca8404a7131335 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/exec/run-fraud-prover.ts b/src/exec/run-fraud-prover.ts | |
index bcca529..0239a6d 100644 | |
--- a/src/exec/run-fraud-prover.ts | |
+++ b/src/exec/run-fraud-prover.ts | |
@@ -18,6 +18,8 @@ const L2_BLOCK_OFFSET = env.L2_BLOCK_OFFSET || '1' | |
const L1_START_OFFSET = env.L1_START_OFFSET || '0' | |
const L1_BLOCK_FINALITY = env.L1_BLOCK_FINALITY || '0' | |
const FROM_L2_TRANSACTION_INDEX = env.FROM_L2_TRANSACTION_INDEX || '0' | |
+const FORCE_BAD_ROOT = env.FORCE_BAD_ROOT || '0' | |
+const ADDRESS_MANAGER = env.ADDRESS_MANAGER || '' | |
const main = async () => { | |
const l2Provider = new JsonRpcProvider(L2_NODE_WEB3_URL) | |
@@ -44,6 +46,8 @@ const main = async () => { | |
l1StartOffset: parseInt(L1_START_OFFSET, 10), | |
l1BlockFinality: parseInt(L1_BLOCK_FINALITY, 10), | |
runGasLimit: parseInt(RUN_GAS_LIMIT, 10), | |
+ forceBadRoot: parseInt(FORCE_BAD_ROOT, 0), | |
+ addressManager: ADDRESS_MANAGER, | |
}) | |
await service.start() | |
diff --git a/src/services/fraud-prover.service.ts b/src/services/fraud-prover.service.ts | |
index 8ecafa2..f7cee90 100644 | |
--- a/src/services/fraud-prover.service.ts | |
+++ b/src/services/fraud-prover.service.ts | |
@@ -44,6 +44,8 @@ interface FraudProverOptions { | |
l2BlockOffset: number | |
l1StartOffset: number | |
l1BlockFinality: number | |
+ forceBadRoot: number | |
+ addressManager: string | |
} | |
export class FraudProverService extends BaseService<FraudProverOptions> { | |
@@ -56,6 +58,8 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
l2BlockOffset: 1, | |
l1StartOffset: 0, | |
l1BlockFinality: 0, | |
+ forceBadRoot: 0, | |
+ addressManager: '', | |
} | |
private state: { | |
@@ -119,7 +123,7 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
this.state.l2Provider = new L2ProviderWrapper(this.options.l2RpcProvider) | |
this.logger.info('Connecting to Lib_AddressManager...') | |
- const addressManagerAddress = await this.state.l2Provider.getAddressManagerAddress() | |
+ const addressManagerAddress = this.options.addressManager || await this.state.l2Provider.getAddressManagerAddress() | |
this.state.Lib_AddressManager = loadContract( | |
'Lib_AddressManager', | |
addressManagerAddress, | |
@@ -277,6 +281,9 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
proof.stateDiffProof.accountStateProofs | |
) | |
+console.log(await OVM_StateTransitioner.phase()) | |
+console.log(this.options.runGasLimit) | |
+console.log(proof.transactionProof.transaction) | |
this.logger.info('Executing transaction...') | |
try { | |
await ( | |
@@ -284,16 +291,21 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
proof.transactionProof.transaction, | |
{ | |
gasLimit: this.options.runGasLimit, | |
+ gasPrice: 0, // YW | |
} | |
) | |
).wait() | |
+console.log(await OVM_StateTransitioner.phase()) | |
} catch (err) { | |
- await OVM_StateTransitioner.callStatic.applyTransaction( | |
+console.log(err) | |
+ const xxx = await OVM_StateTransitioner.callStatic.applyTransaction( | |
proof.transactionProof.transaction, | |
{ | |
gasLimit: this.options.runGasLimit, | |
+ gasPrice: 0, // YW | |
} | |
) | |
+console.log(xxx,this.options.runGasLimit) | |
} | |
this.logger.info('Transaction successfully executed.') | |
@@ -332,7 +344,7 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
OVM_StateTransitioner, | |
OVM_StateManager, | |
proof.stateDiffProof.accountStateProofs, | |
- proof.storageTries | |
+ proof.storageTries, | |
) | |
this.logger.info('Committing account state updates...') | |
@@ -345,7 +357,11 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
this.logger.info('Completing the state transition...') | |
try { | |
- await (await OVM_StateTransitioner.completeTransition()).wait() | |
+ await (await OVM_StateTransitioner.completeTransition( | |
+ { | |
+ gasPrice: 0, // YW | |
+ } | |
+)).wait() | |
} catch (err) { | |
try { | |
await OVM_StateTransitioner.callStatic.completeTransition() | |
@@ -395,7 +411,7 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
await this._finalizeFraudVerification( | |
proof.preStateRootProof, | |
proof.postStateRootProof, | |
- proof.transactionProof.transaction | |
+ proof.transactionProof.transaction, | |
) | |
this.logger.info('Fraud proof finalized! Congrats.') | |
@@ -444,6 +460,13 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
index + this.options.l2BlockOffset | |
) | |
+ if (this.options.forceBadRoot > 0 && index + this.options.l2BlockOffset == this.options.forceBadRoot) { | |
+ this.logger.info('Forcing a fraud proof for '+index) | |
+ this.logger.info('L1 State Root', { l1StateRoot }) | |
+ this.logger.info('L2 State Root', { l2StateRoot }) | |
+ return index | |
+ } | |
+ | |
if (l1StateRoot !== l2StateRoot) { | |
this.logger.info('State roots do not match') | |
this.logger.info('L1 State Root', { l1StateRoot }) | |
@@ -618,9 +641,11 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
to: null, | |
data: deployCode, | |
gasLimit: this.options.deployGasLimit, | |
+ gasPrice: 0, // YW | |
}) | |
const result = await response.wait() | |
+ console.log(result.contractAddress) | |
return result.contractAddress | |
} | |
@@ -666,7 +691,10 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
await OVM_StateTransitioner.proveContractState( | |
accountStateProof.address, | |
ethContractAddress, | |
- rlp.encode(accountStateProof.accountProof) | |
+ rlp.encode(accountStateProof.accountProof), | |
+ { | |
+ gasPrice: 0, // YW | |
+ } | |
) | |
).wait() | |
@@ -729,7 +757,10 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
await OVM_StateTransitioner.proveStorageSlot( | |
accountStateProof.address, | |
toBytes32(slot.key), | |
- rlp.encode(slot.proof) | |
+ rlp.encode(slot.proof), | |
+ { | |
+ gasPrice: 0, // YW | |
+ } | |
) | |
).wait() | |
@@ -858,6 +889,7 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
accountInclusionProof, | |
{ | |
gasLimit: this.options.deployGasLimit, | |
+ gasPrice: 0, // YW | |
} | |
) | |
).wait() | |
@@ -870,6 +902,7 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
accountInclusionProof, | |
{ | |
gasLimit: this.options.deployGasLimit, | |
+ gasPrice: 0, // YW | |
} | |
) | |
} catch (err) { | |
@@ -994,6 +1027,7 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
slotInclusionProof, | |
{ | |
gasLimit: this.options.deployGasLimit, | |
+ gasPrice: 0, // YW | |
} | |
) | |
).wait() | |
@@ -1007,6 +1041,7 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
slotInclusionProof, | |
{ | |
gasLimit: this.options.deployGasLimit, | |
+ gasPrice: 0, // YW | |
} | |
) | |
} catch (err) { | |
@@ -1061,7 +1096,10 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
transactionProof.transaction, | |
transactionProof.transactionChainElement, | |
transactionProof.transactionBatchHeader, | |
- transactionProof.transactionProof | |
+ transactionProof.transactionProof, | |
+ { | |
+ gasPrice: 0, // YW | |
+ } | |
) | |
).wait() | |
} catch (err) { | |
@@ -1090,6 +1128,7 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
postStateRootProof: StateRootBatchProof, | |
transaction: OvmTransaction | |
): Promise<void> { | |
+ console.log("State roots: ",preStateRootProof.stateRoot,postStateRootProof.stateRoot) | |
try { | |
await ( | |
await this.state.OVM_FraudVerifier.connect( | |
@@ -1101,7 +1140,10 @@ export class FraudProverService extends BaseService<FraudProverOptions> { | |
hashOvmTransaction(transaction), | |
postStateRootProof.stateRoot, | |
postStateRootProof.stateRootBatchHeader, | |
- postStateRootProof.stateRootProof | |
+ postStateRootProof.stateRootProof, | |
+ { | |
+ gasPrice: 0, // YW | |
+ } | |
) | |
).wait() | |
} catch (err) { | |
diff --git a/src/utils/providers/l1-provider-wrapper.ts b/src/utils/providers/l1-provider-wrapper.ts | |
index 4bc8ee7..25c6502 100644 | |
--- a/src/utils/providers/l1-provider-wrapper.ts | |
+++ b/src/utils/providers/l1-provider-wrapper.ts | |
@@ -244,6 +244,7 @@ export class L1ProviderWrapper { | |
blockNumber: context.ctxBlockNumber.toNumber(), | |
timestamp: context.ctxTimestamp.toNumber(), | |
gasLimit: emGasLimit, | |
+ gasPrice: 0, // YW | |
entrypoint: '0x4200000000000000000000000000000000000005', | |
l1TxOrigin: '0x' + '00'.repeat(20), | |
l1QueueOrigin: 0, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment