Fix race condition where p2p is faster than ETH
This commit is contained in:
parent
ec6e261c43
commit
b6b2d21bde
|
@ -222,53 +222,56 @@ func ethLockupProcessor(lockC chan *common.ChainLock, setC chan *common.Guardian
|
||||||
agg[i] = ok
|
agg[i] = ok
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deep copy the VAA and add signatures
|
if state.lockupSignatures[hash].ourVAA != nil {
|
||||||
v := state.lockupSignatures[hash].ourVAA
|
// We have seen it on chain!
|
||||||
signed := &vaa.VAA{
|
// Deep copy the VAA and add signatures
|
||||||
Version: v.Version,
|
v := state.lockupSignatures[hash].ourVAA
|
||||||
GuardianSetIndex: v.GuardianSetIndex,
|
signed := &vaa.VAA{
|
||||||
Signatures: sigs,
|
Version: v.Version,
|
||||||
Timestamp: v.Timestamp,
|
GuardianSetIndex: v.GuardianSetIndex,
|
||||||
Payload: v.Payload,
|
Signatures: sigs,
|
||||||
}
|
Timestamp: v.Timestamp,
|
||||||
|
Payload: v.Payload,
|
||||||
// 2/3+ majority required for VAA to be valid - wait until we have quorum to submit VAA.
|
|
||||||
quorum := int(math.Ceil((float64(len(gs.Keys)) / 3) * 2))
|
|
||||||
|
|
||||||
logger.Info("aggregation state for eth lockup",
|
|
||||||
zap.String("vaahash", hash),
|
|
||||||
zap.Any("set", gs.KeysAsHexStrings()),
|
|
||||||
zap.Uint32("index", gs.Index),
|
|
||||||
zap.Bools("aggregation", agg),
|
|
||||||
zap.Int("required_sigs", quorum),
|
|
||||||
zap.Int("have_sigs", len(sigs)),
|
|
||||||
)
|
|
||||||
|
|
||||||
if *unsafeDevMode && len(sigs) >= quorum {
|
|
||||||
_, err := devnet.GetDevnetIndex()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vaaBytes, err := signed.Marshal()
|
// 2/3+ majority required for VAA to be valid - wait until we have quorum to submit VAA.
|
||||||
if err != nil {
|
quorum := int(math.Ceil((float64(len(gs.Keys)) / 3) * 2))
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.Info("submitting signed VAA to Solana",
|
logger.Info("aggregation state for eth lockup",
|
||||||
zap.String("vaahash", hash),
|
zap.String("vaahash", hash),
|
||||||
zap.Any("vaa", signed),
|
zap.Any("set", gs.KeysAsHexStrings()),
|
||||||
zap.Binary("bytes", vaaBytes))
|
zap.Uint32("index", gs.Index),
|
||||||
|
zap.Bools("aggregation", agg),
|
||||||
|
zap.Int("required_sigs", quorum),
|
||||||
|
zap.Int("have_sigs", len(sigs)),
|
||||||
|
)
|
||||||
|
|
||||||
// TODO: actually submit to Solana once the agent works and has a reasonable key
|
if *unsafeDevMode && len(sigs) >= quorum {
|
||||||
//if idx == 0 {
|
_, err := devnet.GetDevnetIndex()
|
||||||
// vaaC <- state.lockupSignatures[hash].ourVAA
|
if err != nil {
|
||||||
//}
|
return err
|
||||||
} else if !*unsafeDevMode {
|
}
|
||||||
panic("not implemented") // TODO
|
|
||||||
} else {
|
vaaBytes, err := signed.Marshal()
|
||||||
logger.Info("quorum not met, doing nothing",
|
if err != nil {
|
||||||
zap.String("vaahash", hash))
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.Info("submitting signed VAA to Solana",
|
||||||
|
zap.String("vaahash", hash),
|
||||||
|
zap.Any("vaa", signed),
|
||||||
|
zap.Binary("bytes", vaaBytes))
|
||||||
|
|
||||||
|
// TODO: actually submit to Solana once the agent works and has a reasonable key
|
||||||
|
//if idx == 0 {
|
||||||
|
// vaaC <- state.lockupSignatures[hash].ourVAA
|
||||||
|
//}
|
||||||
|
} else if !*unsafeDevMode {
|
||||||
|
panic("not implemented") // TODO
|
||||||
|
} else {
|
||||||
|
logger.Info("quorum not met, doing nothing",
|
||||||
|
zap.String("vaahash", hash))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue