Explicit epoch in contract calls
This commit is contained in:
parent
56b59fdfd3
commit
799004c159
|
@ -25,8 +25,8 @@ const bridgeAbi = [
|
|||
'event ForceSign()',
|
||||
'function getThreshold(uint16 epoch) view returns (uint16)',
|
||||
'function getParties(uint16 epoch) view returns (uint16)',
|
||||
'function getRangeSize() view returns (uint16)',
|
||||
'function getValidators() view returns (address[])'
|
||||
'function getRangeSize(uint16 epoch) view returns (uint16)',
|
||||
'function getValidators(uint16 epoch) view returns (address[])'
|
||||
]
|
||||
const bridge = new ethers.Contract(HOME_BRIDGE_ADDRESS, bridgeAbi, provider)
|
||||
const validatorAddress = ethers.utils.computeAddress(`0x${VALIDATOR_PRIVATE_KEY}`)
|
||||
|
@ -176,8 +176,8 @@ async function processEpochStart(event) {
|
|||
epoch = event.values.epoch
|
||||
epochStart = blockNumber
|
||||
logger.info(`Epoch ${epoch} started`)
|
||||
rangeSize = await bridge.getRangeSize()
|
||||
isCurrentValidator = (await bridge.getValidators()).includes(validatorAddress)
|
||||
rangeSize = await bridge.getRangeSize(epoch)
|
||||
isCurrentValidator = (await bridge.getValidators(epoch)).includes(validatorAddress)
|
||||
if (isCurrentValidator) {
|
||||
logger.info(`${validatorAddress} is a current validator`)
|
||||
} else {
|
||||
|
@ -236,10 +236,10 @@ async function initialize() {
|
|||
blockNumber = saved
|
||||
foreignNonce[epoch] = parseInt(await redis.get(`foreignNonce${epoch}`), 10) || 0
|
||||
}
|
||||
rangeSize = await bridge.getRangeSize()
|
||||
rangeSize = await bridge.getRangeSize(epoch)
|
||||
logger.debug(`Range size ${rangeSize}`)
|
||||
logger.debug('Checking if current validator')
|
||||
isCurrentValidator = (await bridge.getValidators()).includes(validatorAddress)
|
||||
isCurrentValidator = (await bridge.getValidators(epoch)).includes(validatorAddress)
|
||||
if (isCurrentValidator) {
|
||||
logger.info(`${validatorAddress} is a current validator`)
|
||||
} else {
|
||||
|
|
|
@ -421,20 +421,25 @@ app.post('/transfer', transfer)
|
|||
votesProxyApp.get('/vote/startVoting', voteStartVoting)
|
||||
votesProxyApp.get('/vote/startKeygen', voteStartKeygen)
|
||||
votesProxyApp.get('/vote/cancelKeygen', voteCancelKeygen)
|
||||
|
||||
votesProxyApp.use('/vote', (req, res, next) => {
|
||||
if (/^[0-9]+$/.test(req.query.attempt)) {
|
||||
req.attempt = parseInt(req.query.attempt, 10).toString(16)
|
||||
logger.debug(`Vote attempt 0x${req.attempt}`)
|
||||
next()
|
||||
} else if (!req.query.attempt) {
|
||||
req.attempt = '0'
|
||||
logger.debug('Vote attempt 0x00')
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
votesProxyApp.get('/vote/addValidator/:validator', voteAddValidator)
|
||||
votesProxyApp.get('/vote/removeValidator/:validator', voteRemoveValidator)
|
||||
votesProxyApp.get('/vote/changeThreshold/:threshold', voteChangeThreshold)
|
||||
votesProxyApp.get('/vote/changeCloseEpoch/:closeEpoch', voteChangeCloseEpoch)
|
||||
votesProxyApp.get('/info', info)
|
||||
|
||||
votesProxyApp.use('/vote', (req, res, next) => {
|
||||
if (/^[0-9]*$/.test(req.query.attempt)) {
|
||||
req.attempt = req.query.attempt ? parseInt(req.query.attempt, 10).toString(16) : '0'
|
||||
logger.debug(`Vote attempt 0x${req.attempt}`)
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
async function main() {
|
||||
sideValidatorNonce = await sideWallet.getTransactionCount()
|
||||
|
||||
|
|
Loading…
Reference in New Issue