bridge: have all nodes submit VAAs to Solana
VAAs are deduplicated by the on-chain contracts. For Ethereum,
submission happens outside of the bridge anyway, and for Solana, the
first tx to be confirmed wins. Subsequent attempts to submit it
will fail in preflight, so the fee won't be spent multiple times.
This eliminates the need for leader selection and fixes #20.
ghstack-source-id: 60388d532c
Pull Request resolved: https://github.com/certusone/wormhole/pull/51
This commit is contained in:
parent
91241ee852
commit
e5e6690f35
|
@ -227,19 +227,12 @@ func vaaConsensusProcessor(lockC chan *common.ChainLock, setC chan *common.Guard
|
|||
zap.Int("have_sigs", len(sigs)),
|
||||
)
|
||||
|
||||
if *unsafeDevMode && len(sigs) >= quorum {
|
||||
idx, err := devnet.GetDevnetIndex()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(sigs) >= quorum {
|
||||
vaaBytes, err := signed.Marshal()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// TODO: proper leader selection
|
||||
|
||||
if t, ok := v.Payload.(*vaa.BodyTransfer); ok {
|
||||
switch {
|
||||
case t.TargetChain == vaa.ChainIDSolana:
|
||||
|
@ -248,24 +241,23 @@ func vaaConsensusProcessor(lockC chan *common.ChainLock, setC chan *common.Guard
|
|||
zap.Any("vaa", signed),
|
||||
zap.String("bytes", hex.EncodeToString(vaaBytes)))
|
||||
|
||||
if idx == 1 {
|
||||
vaaC <- signed
|
||||
}
|
||||
vaaC <- signed
|
||||
case t.TargetChain == vaa.ChainIDEthereum:
|
||||
// cross-submit to Solana for data availability
|
||||
if idx == 1 {
|
||||
vaaC <- signed
|
||||
}
|
||||
vaaC <- signed
|
||||
|
||||
timeout, cancel := context.WithTimeout(ctx, 15*time.Second)
|
||||
tx, err := devnet.SubmitVAA(timeout, *ethRPC, signed)
|
||||
cancel()
|
||||
if err != nil {
|
||||
logger.Error("failed to submit lockup to Ethereum", zap.Error(err))
|
||||
break
|
||||
// In dev mode, submit VAA to Ethereum. For production, the bridge won't
|
||||
// have an Ethereum account and the user retrieves the VAA and submits the transactions themselves.
|
||||
if *unsafeDevMode {
|
||||
timeout, cancel := context.WithTimeout(ctx, 15*time.Second)
|
||||
tx, err := devnet.SubmitVAA(timeout, *ethRPC, signed)
|
||||
cancel()
|
||||
if err != nil {
|
||||
logger.Error("failed to submit lockup to Ethereum", zap.Error(err))
|
||||
break
|
||||
}
|
||||
logger.Info("lockup submitted to Ethereum", zap.Any("tx", tx))
|
||||
}
|
||||
logger.Info("lockup submitted to Ethereum", zap.Any("tx", tx))
|
||||
|
||||
default:
|
||||
logger.Error("we don't know how to submit this VAA",
|
||||
zap.String("digest", hash),
|
||||
|
@ -276,8 +268,6 @@ func vaaConsensusProcessor(lockC chan *common.ChainLock, setC chan *common.Guard
|
|||
} else {
|
||||
panic(fmt.Sprintf("unknown VAA payload type: %+v", v))
|
||||
}
|
||||
} else if !*unsafeDevMode {
|
||||
panic("not implemented") // TODO
|
||||
} else {
|
||||
logger.Info("quorum not met, doing nothing",
|
||||
zap.String("digest", hash))
|
||||
|
@ -292,12 +282,7 @@ func checkDevModeGuardianSetUpdate(ctx context.Context, vaaC chan *vaa.VAA, gs *
|
|||
logger := supervisor.Logger(ctx)
|
||||
|
||||
if *unsafeDevMode {
|
||||
idx, err := devnet.GetDevnetIndex()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get devnet index: %s")
|
||||
}
|
||||
|
||||
if idx == 0 && (uint(len(gs.Keys)) != *devNumGuardians) {
|
||||
if uint(len(gs.Keys)) != *devNumGuardians {
|
||||
v := devnet.DevnetGuardianSetVSS(*devNumGuardians)
|
||||
|
||||
logger.Info(fmt.Sprintf("guardian set has %d members, expecting %d - submitting VAA",
|
||||
|
|
Loading…
Reference in New Issue