Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Fraud prover working through end of PRE_EXECUTION #131

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/omgx-sync-tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
name: omgx_sync-tests

on:
push:
branches:
- 'master'
- 'develop'
- 'regenesis/*'
pull_request:
workflow_dispatch:
on: workflow_dispatch

jobs:
integration-sync-test:
Expand Down
3 changes: 3 additions & 0 deletions integration-tests/test/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import {
getContractInterface,
predeploys,
} from '@eth-optimism/contracts'

import { injectL2Context, remove0x, Watcher } from '@eth-optimism/core-utils'

import {
Contract,
Wallet,
Expand All @@ -17,6 +19,7 @@ import {
BigNumber,
utils,
} from 'ethers'

import { cleanEnv, str, num } from 'envalid'

export const GWEI = BigNumber.from(1e9)
Expand Down
130 changes: 129 additions & 1 deletion l2geth/internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,29 +572,154 @@ type HeaderMeta struct {
}

func (s *PublicBlockChainAPI) GetStateDiff(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (diffdb.Diff, error) {

_, header, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)

log.Debug("GetStateDiff Inside", "header", header, "err", err)

if err != nil {
return nil, err
}

//Why are we adding one to the header.Number?
//it's wrong anyway? Data are indexed by L1 block, not L2 header.Number
return s.b.GetDiff( new(big.Int).Add(header.Number, big.NewInt(1)) )
}

// GetStateDiffProof returns the Merkle-proofs corresponding to all the accounts and
// storage slots which were touched for a given block number or hash.
func (s *PublicBlockChainAPI) GetStateDiffProofCT(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, blockNr int64) (*StateDiffProof, error) {

state, header, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)

log.Debug("GetStateDiffProofCP", "state", state, "header", header, "err", err, "blockNr", blockNr)

if state == nil || header == nil || err != nil {
log.Debug("GetStateDiff - returning early ", "err", err)
return nil, err
}

//log.Debug("trying to get GetStateDiff", "blockNrOrHash", blockNrOrHash)

// get the changed accounts for this block
//diffs, err := s.GetStateDiff(ctx, blockNrOrHash)
diffs, err := s.b.GetDiff( big.NewInt(blockNr) )

log.Debug("GetStateDiff", "blockNrOrHash", blockNrOrHash, "diffs", diffs, "err", err)

if err != nil {
return nil, err
}
return s.b.GetDiff(new(big.Int).Add(header.Number, big.NewInt(1)))

// for each changed account, get their proof
var accounts []AccountResult

for address, keys := range diffs {
// need to convert the hashes to strings, we could maybe refactor getProof
// alternatively
keyStrings := make([]string, len(keys))
for i, key := range keys {
keyStrings[i] = key.Key.String()
}

log.Debug("range diffs", "address", address, "keyStrings", keyStrings, "blockNrOrHash", blockNrOrHash)

// get the proofs
res, err := s.GetProof(ctx, address, keyStrings, blockNrOrHash)
if err != nil {
return nil, err
}

accounts = append(accounts, *res)
}

// add some metadata
stateDiffProof := &StateDiffProof{
Header: &HeaderMeta{
Number: header.Number,
Hash: header.Hash(),
StateRoot: header.Root,
Timestamp: header.Time,
},
Accounts: accounts,
}

return stateDiffProof, state.Error()
}


// GetStateDiffProof returns the Merkle-proofs corresponding to all the accounts and
// storage slots which were touched for a given block number or hash.
func (s *PublicBlockChainAPI) GetStateDiffProof(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*StateDiffProof, error) {

state, header, err := s.b.StateAndHeaderByNumberOrHash(ctx, blockNrOrHash)

log.Debug("GetStateDiffProof", "state", state, "header", header, "err", err)

// l2geth_1 | DEBUG[06-15|03:11:28.137] GetStateDiffProof
// state="&{
// db:0xc0004febc0
// trie:0xc0040262d0
// diffdb:0xc000621f50
// stateObjects:map[]
// stateObjectsPending:map[]
// stateObjectsDirty:map[]
// dbErr:<nil>
// refund:0
// thash:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
// bhash:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
// txIndex:0
// logs:map[]
// logSize:0
// preimages:map[]
// journal:0xc00383ad00
// validRevisions:[]
// nextRevisionId:0
// AccountReads:0s
// AccountHashes:0s
// AccountUpdates:0s
// AccountCommits:0s
// StorageReads:0s
// StorageHashes:0s
// StorageUpdates:0s
// StorageCommits:0s}"
// header="&{
// ParentHash:[49 241 235 130 244 54 173 215 246 148 108 159 0 250 76 200 201 148 17 10 159 150 255 230 177 130 54 234 198 213 172 171]
// UncleHash:[29 204 77 232 222 199 93 122 171 133 181 103 182 204 212 26 211 18 69 27 148 138 116 19 240 161 66 253 64 212 147 71]
// Coinbase:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
// Root:[80 20 133 164 141 35 40 255 92 248 89 114 62 26 60 164 133 124 0 178 46 26 79 3 248 51 120 44 103 135 35 139]
// TxHash:[110 169 88 113 16 161 104 52 41 89 229 63 116 72 249 99 242 7 191 1 149 127 227 58 3 5 94 46 70 40 63 117]
// ReceiptHash:[68 167 48 233 96 112 194 136 91 87 60 164 34 203 52 191 92 209 210 185 79 163 155 235 215 139 38 33 74 178 72 236]
// Bloom:[0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 128 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 128 0 0 128 0 0 0 0 0 0 0 0 0 16 0 0 0 0 0 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 0 0 0 0 0 0 0 0 0 0 0 128 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 0 0 0]
// Difficulty:+2
// Number:+7
// GasLimit:9000000
// GasUsed:960445
// Time:1623726690
// Extra:[217 131 1 9 10 132 103 101 116 104 137 103 111 49 46 49 53 46 49 51 133 108 105 110 117 120 0 0 0 0 0 0 200 176 92 171 136 27 78 21 239 155 89 120 53 190 166 94 91 85 197 211 1 100 182 194 50 152 243 27 64 180 8 220 55 234 7 160 85 70 9 140 152 214 216 67 36 92 163 52 29 127 30 142 99 96 226 148 15 237 65 33 120 160 249 135 1]
// MixDigest:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
// Nonce:[0 0 0 0 0 0 0 0]}"
// err=nil

if state == nil || header == nil || err != nil {
//log.Debug("GetStateDiff - returning early ", "err", err)
return nil, err
}

//log.Debug("trying to get GetStateDiff", "blockNrOrHash", blockNrOrHash)

// get the changed accounts for this block
diffs, err := s.GetStateDiff(ctx, blockNrOrHash)

//log.Debug("GetStateDiff", "blockNrOrHash", blockNrOrHash, "diffs", diffs, "err", err)

if err != nil {
return nil, err
}

// for each changed account, get their proof
var accounts []AccountResult

for address, keys := range diffs {
// need to convert the hashes to strings, we could maybe refactor getProof
// alternatively
Expand All @@ -603,6 +728,8 @@ func (s *PublicBlockChainAPI) GetStateDiffProof(ctx context.Context, blockNrOrHa
keyStrings[i] = key.Key.String()
}

//log.Debug("range diffs", "address", address, "keyStrings", keyStrings, "blockNrOrHash", blockNrOrHash)

// get the proofs
res, err := s.GetProof(ctx, address, keyStrings, blockNrOrHash)
if err != nil {
Expand Down Expand Up @@ -2219,3 +2346,4 @@ func (s *PublicNetAPI) PeerCount() hexutil.Uint {
func (s *PublicNetAPI) Version() string {
return fmt.Sprintf("%d", s.networkVersion)
}

19 changes: 7 additions & 12 deletions omgx_utilities/fraud-prover/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@
NODE_ENV=local
L1_NODE_WEB3_URL=http://localhost:9545
L2_NODE_WEB3_URL=http://localhost:8545
VERIFIER_WEB3_URL=http://localhost:8045
VERIFIER_WEB3_URL=http://localhost:8547
ADDRESS_MANAGER_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
ETH1_ADDRESS_RESOLVER_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
L1_WALLET_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
TEST_PRIVATE_KEY_1=0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
TEST_PRIVATE_KEY_2=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
FRAUD_PRIVATE_KEY=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
L1_BLOCK_OFFSET=0
L1_START_OFFSET=0
L2_BLOCK_OFFSET=1
L1_WALLET_KEY=0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd
TEST_PRIVATE_KEY_1=0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1
TEST_PRIVATE_KEY_2=0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd
FRAUD_PRIVATE_KEY=0x689af8efa8c651a91ad287602527f3af2fe9f6501a7ac4b061667b5a93e037fd
NO_TIMEOUT=true
POLLING_INTERVAL=5000
RUN_GAS_LIMIT=8999999
RELAY_GAS_LIMIT=8999999
TARGET_GAS_LIMIT=9000000000
DEPLOY_GAS_LIMIT=4000000
RUN_GAS_LIMIT=15000000
RETRIES=60
CHAIN_ID=28
1 change: 0 additions & 1 deletion omgx_utilities/fraud-prover/.prettierrc.json

This file was deleted.

23 changes: 0 additions & 23 deletions omgx_utilities/fraud-prover/Dockerfile.fraud-prover

This file was deleted.

Loading