Skip to content

Commit

Permalink
Merge pull request #26 from maticnetwork/revert-back
Browse files Browse the repository at this point in the history
Don't attempt to recover check point signer list
  • Loading branch information
jdkanani authored Feb 10, 2021
2 parents 03a6f0b + 3e7094c commit e07fd24
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 70 deletions.
21 changes: 0 additions & 21 deletions root/abis/DecodeCheckpointSignerList.json

This file was deleted.

3 changes: 0 additions & 3 deletions root/config/goerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
},
"decoderForPoSPortalData": {
"address": "0x8fcFA769D420AdA837206294eb054Ad514a7a8a0"
},
"decodeCheckpointSignerList": {
"address": "0x4d350e8A3C0D57714d3b80c9e2030ab8f1Bb7875"
}
}
}
3 changes: 0 additions & 3 deletions root/config/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
},
"decoderForPoSPortalData": {
"address": "0x13E301F8d9563e3D8d48F1d21aE8110B22558cd5"
},
"decodeCheckpointSignerList": {
"address": "0x3c54B08A5b4EB5f68a69BbCf963C694eCf025e14"
}
}
}
1 change: 0 additions & 1 deletion root/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ type Checkpoint @entity {
start: BigInt!
end: BigInt!
root: Bytes!
signers: [Bytes!]!
transactionHash: Bytes!
timestamp: BigInt!
}
Expand Down
42 changes: 3 additions & 39 deletions root/src/mappings/checkpoint.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Address, BigInt, Value } from '@graphprotocol/graph-ts'
import { BigInt } from '@graphprotocol/graph-ts'
import { NewHeaderBlock } from '../../generated/Rootchain/Rootchain'
import { Checkpoint } from '../../generated/schema'

import { decodeCheckpointSignerListAddress } from '../network'
import { DecodeCheckpointSignerList } from '../../generated/Rootchain/DecodeCheckpointSignerList'

let MAX_DEPOSITS = BigInt.fromI32(10000)

export function handleNewHeaderBlock(event: NewHeaderBlock): void {
Expand All @@ -13,6 +10,7 @@ export function handleNewHeaderBlock(event: NewHeaderBlock): void {

// use checkpoint number as id
let entity = new Checkpoint('checkpoint:' + checkpointNumber.toString())

entity.proposer = event.params.proposer
entity.headerBlockId = event.params.headerBlockId
entity.checkpointNumber = checkpointNumber
Expand All @@ -24,40 +22,6 @@ export function handleNewHeaderBlock(event: NewHeaderBlock): void {
entity.transactionHash = event.transaction.hash
entity.timestamp = event.block.timestamp

// Attempting to create an instance of `DecodeCheckpointSignerList` smart contract
// to be used for figuring out who are those check point signers i.e. validators
let decoder = DecodeCheckpointSignerList.bind(Address.fromString(decodeCheckpointSignerListAddress))

// 👇 is being done because there's a possibly decoding might fail
// if bad input is provided with
//
// @note This is nothing but a precautionary measurement
let callResult = decoder.try_decode(event.transaction.input)

// This condition will be true if during decoding
// contract faces some issue
//
// If it does, only proposer address will be kept
// in signer list, because we failed to extract out
// all signer addresses
//
// @note Proposer itself is a signer.
if (callResult.reverted) {

let previousOwners = entity.signers
previousOwners.push(event.params.proposer)
entity.signers = previousOwners

// save entity
entity.save()

return

}

// extracted out signer list stored in entity
entity.signers = Value.fromAddressArray(callResult.value).toBytesArray()

// save entity
entity.save()

}
1 change: 0 additions & 1 deletion root/src/network.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export const network: string = '{{ network }}'
export const stakingNftAddress: string = '{{ contracts.stakingNft.address }}'
export const registryAddress: string = '{{ contracts.registry.address }}'
export const decoderForPoSPortalData: string = '{{ contracts.decoderForPoSPortalData.address }}'
export const decodeCheckpointSignerListAddress: string = '{{ contracts.decodeCheckpointSignerList.address }}'
2 changes: 0 additions & 2 deletions root/subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ dataSources:
abis:
- name: Rootchain
file: ./abis/Rootchain.json
- name: DecodeCheckpointSignerList
file: ./abis/DecodeCheckpointSignerList.json
eventHandlers:
- event: NewHeaderBlock(indexed address,indexed uint256,indexed uint256,uint256,uint256,bytes32)
handler: handleNewHeaderBlock
Expand Down

0 comments on commit e07fd24

Please sign in to comment.