rename ChainLock to MessagePublication
Change-Id: If74e74c00957c202c7de1cc61204b6cc12ad3a8a
This commit is contained in:
parent
fad00804e0
commit
9f514e2786
|
@ -331,7 +331,7 @@ func runBridge(cmd *cobra.Command, args []string) {
|
|||
defer rootCtxCancel()
|
||||
|
||||
// Ethereum lock event channel
|
||||
lockC := make(chan *common.ChainLock)
|
||||
lockC := make(chan *common.MessagePublication)
|
||||
|
||||
// Ethereum incoming guardian set updates
|
||||
setC := make(chan *common.GuardianSet)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package common
|
||||
|
||||
type BridgeWatcher interface {
|
||||
WatchLockups(events chan *ChainLock) error
|
||||
WatchLockups(events chan *MessagePublication) error
|
||||
}
|
||||
|
|
|
@ -1,29 +1,18 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"github.com/certusone/wormhole/bridge/pkg/vaa"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
||||
"github.com/certusone/wormhole/bridge/pkg/vaa"
|
||||
)
|
||||
|
||||
type ChainLock struct {
|
||||
type MessagePublication struct {
|
||||
TxHash common.Hash // TODO: rename to identifier? on Solana, this isn't actually the tx hash
|
||||
Timestamp time.Time
|
||||
|
||||
Nonce uint32
|
||||
|
||||
SourceAddress vaa.Address
|
||||
TargetAddress vaa.Address
|
||||
|
||||
SourceChain vaa.ChainID
|
||||
TargetChain vaa.ChainID
|
||||
|
||||
TokenChain vaa.ChainID
|
||||
TokenAddress vaa.Address
|
||||
TokenDecimals uint8
|
||||
|
||||
Amount *big.Int
|
||||
Nonce uint32
|
||||
EmitterChain vaa.ChainID
|
||||
EmitterAddress vaa.Address
|
||||
Payload []byte
|
||||
}
|
||||
|
|
|
@ -76,17 +76,17 @@ type (
|
|||
pendingLocks map[eth_common.Hash]*pendingLock
|
||||
pendingLocksGuard sync.Mutex
|
||||
|
||||
lockChan chan *common.ChainLock
|
||||
lockChan chan *common.MessagePublication
|
||||
setChan chan *common.GuardianSet
|
||||
}
|
||||
|
||||
pendingLock struct {
|
||||
lock *common.ChainLock
|
||||
lock *common.MessagePublication
|
||||
height uint64
|
||||
}
|
||||
)
|
||||
|
||||
func NewEthBridgeWatcher(url string, bridge eth_common.Address, minConfirmations uint64, lockEvents chan *common.ChainLock, setEvents chan *common.GuardianSet) *EthBridgeWatcher {
|
||||
func NewEthBridgeWatcher(url string, bridge eth_common.Address, minConfirmations uint64, lockEvents chan *common.MessagePublication, setEvents chan *common.GuardianSet) *EthBridgeWatcher {
|
||||
return &EthBridgeWatcher{url: url, bridge: bridge, minConfirmations: minConfirmations, lockChan: lockEvents, setChan: setEvents, pendingLocks: map[eth_common.Hash]*pendingLock{}}
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ func (e *EthBridgeWatcher) Run(ctx context.Context) error {
|
|||
return
|
||||
}
|
||||
|
||||
lock := &common.ChainLock{
|
||||
lock := &common.MessagePublication{
|
||||
TxHash: ev.Raw.TxHash,
|
||||
Timestamp: time.Unix(int64(b.Time()), 0),
|
||||
Nonce: ev.Nonce,
|
||||
|
|
|
@ -39,15 +39,11 @@ func init() {
|
|||
|
||||
// handleLockup processes a lockup received from a chain and instantiates our deterministic copy of the VAA. A lockup
|
||||
// event may be received multiple times until it has been successfully completed.
|
||||
func (p *Processor) handleLockup(ctx context.Context, k *common.ChainLock) {
|
||||
supervisor.Logger(ctx).Info("lockup confirmed",
|
||||
zap.Stringer("source_chain", k.SourceChain),
|
||||
zap.Stringer("target_chain", k.TargetChain),
|
||||
zap.Stringer("source_addr", k.SourceAddress),
|
||||
zap.Stringer("target_addr", k.TargetAddress),
|
||||
zap.Stringer("token_chain", k.TokenChain),
|
||||
zap.Stringer("token_addr", k.TokenAddress),
|
||||
zap.Stringer("amount", k.Amount),
|
||||
func (p *Processor) handleLockup(ctx context.Context, k *common.MessagePublication) {
|
||||
supervisor.Logger(ctx).Info("message publication confirmed",
|
||||
zap.Stringer("emitter_chain", k.EmitterChain),
|
||||
zap.Stringer("emitter_address", k.EmitterAddress),
|
||||
zap.Uint32("nonce", k.Nonce),
|
||||
zap.Stringer("txhash", k.TxHash),
|
||||
zap.Time("timestamp", k.Timestamp),
|
||||
)
|
|
@ -52,7 +52,7 @@ type (
|
|||
|
||||
type Processor struct {
|
||||
// lockC is a channel of observed chain lockups
|
||||
lockC chan *common.ChainLock
|
||||
lockC chan *common.MessagePublication
|
||||
// setC is a channel of guardian set updates
|
||||
setC chan *common.GuardianSet
|
||||
|
||||
|
@ -97,7 +97,7 @@ type Processor struct {
|
|||
|
||||
func NewProcessor(
|
||||
ctx context.Context,
|
||||
lockC chan *common.ChainLock,
|
||||
lockC chan *common.MessagePublication,
|
||||
setC chan *common.GuardianSet,
|
||||
sendC chan []byte,
|
||||
obsvC chan *gossipv1.SignedObservation,
|
||||
|
|
|
@ -21,10 +21,10 @@ import (
|
|||
)
|
||||
|
||||
type SolanaWatcher struct {
|
||||
bridge solana.PublicKey
|
||||
wsUrl string
|
||||
rpcUrl string
|
||||
lockEvent chan *common.ChainLock
|
||||
bridge solana.PublicKey
|
||||
wsUrl string
|
||||
rpcUrl string
|
||||
messageEvent chan *common.MessagePublication
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -63,8 +63,8 @@ func init() {
|
|||
prometheus.MustRegister(queryLatency)
|
||||
}
|
||||
|
||||
func NewSolanaWatcher(wsUrl, rpcUrl string, bridgeAddress solana.PublicKey, lockEvents chan *common.ChainLock) *SolanaWatcher {
|
||||
return &SolanaWatcher{bridge: bridgeAddress, wsUrl: wsUrl, rpcUrl: rpcUrl, lockEvent: lockEvents}
|
||||
func NewSolanaWatcher(wsUrl, rpcUrl string, bridgeAddress solana.PublicKey, messageEvents chan *common.MessagePublication) *SolanaWatcher {
|
||||
return &SolanaWatcher{bridge: bridgeAddress, wsUrl: wsUrl, rpcUrl: rpcUrl, messageEvent: messageEvents}
|
||||
}
|
||||
|
||||
func (s *SolanaWatcher) Run(ctx context.Context) error {
|
||||
|
@ -107,7 +107,7 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
|
|||
|
||||
logger.Info("current Solana height", zap.Uint64("slot", uint64(slot)))
|
||||
|
||||
// Find TransferOutProposal accounts without a VAA
|
||||
// Find MessagePublicationAccount accounts without a VAA
|
||||
rCtx, cancel = context.WithTimeout(ctx, time.Second*5)
|
||||
defer cancel()
|
||||
start = time.Now()
|
||||
|
@ -116,7 +116,7 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
|
|||
Commitment: rpc.CommitmentMax, // TODO: deprecated, use Finalized
|
||||
Filters: []rpc.RPCFilter{
|
||||
{
|
||||
DataSize: 1184, // Search for TransferOutProposal accounts
|
||||
DataSize: 1184, // Search for MessagePublicationAccount accounts
|
||||
},
|
||||
{
|
||||
Memcmp: &rpc.RPCFilterMemcmp{
|
||||
|
@ -159,7 +159,7 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
|
|||
var txHash eth_common.Hash
|
||||
copy(txHash[:], acc.Pubkey[:])
|
||||
|
||||
lock := &common.ChainLock{
|
||||
lock := &common.MessagePublication{
|
||||
TxHash: txHash,
|
||||
Timestamp: proposal.LockupTime,
|
||||
Nonce: proposal.Nonce,
|
||||
|
@ -175,7 +175,7 @@ func (s *SolanaWatcher) Run(ctx context.Context) error {
|
|||
|
||||
solanaLockupsConfirmed.Inc()
|
||||
logger.Info("found lockup without VAA", zap.Stringer("lockup_address", acc.Pubkey))
|
||||
s.lockEvent <- lock
|
||||
s.messageEvent <- lock
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
|
|
@ -44,13 +44,13 @@ type (
|
|||
SolanaVAASubmitter struct {
|
||||
url string
|
||||
|
||||
lockChan chan *common.ChainLock
|
||||
vaaChan chan *vaa.VAA
|
||||
messageChan chan *common.MessagePublication
|
||||
vaaChan chan *vaa.VAA
|
||||
}
|
||||
)
|
||||
|
||||
func NewSolanaVAASubmitter(url string, lockEvents chan *common.ChainLock, vaaQueue chan *vaa.VAA) *SolanaVAASubmitter {
|
||||
return &SolanaVAASubmitter{url: url, lockChan: lockEvents, vaaChan: vaaQueue}
|
||||
func NewSolanaVAASubmitter(url string, lockEvents chan *common.MessagePublication, vaaQueue chan *vaa.VAA) *SolanaVAASubmitter {
|
||||
return &SolanaVAASubmitter{url: url, messageChan: lockEvents, vaaChan: vaaQueue}
|
||||
}
|
||||
|
||||
func (e *SolanaVAASubmitter) Run(ctx context.Context) error {
|
||||
|
|
|
@ -31,7 +31,7 @@ type (
|
|||
urlLCD string
|
||||
bridge string
|
||||
|
||||
lockChan chan *common.ChainLock
|
||||
lockChan chan *common.MessagePublication
|
||||
setChan chan *common.GuardianSet
|
||||
}
|
||||
)
|
||||
|
@ -78,7 +78,7 @@ type clientRequest struct {
|
|||
}
|
||||
|
||||
// NewTerraBridgeWatcher creates a new terra bridge watcher
|
||||
func NewTerraBridgeWatcher(urlWS string, urlLCD string, bridge string, lockEvents chan *common.ChainLock, setEvents chan *common.GuardianSet) *BridgeWatcher {
|
||||
func NewTerraBridgeWatcher(urlWS string, urlLCD string, bridge string, lockEvents chan *common.MessagePublication, setEvents chan *common.GuardianSet) *BridgeWatcher {
|
||||
return &BridgeWatcher{urlWS: urlWS, urlLCD: urlLCD, bridge: bridge, lockChan: lockEvents, setChan: setEvents}
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ func (e *BridgeWatcher) Run(ctx context.Context) error {
|
|||
logger.Error("cannot decode hex", zap.String("value", txHash.String()))
|
||||
continue
|
||||
}
|
||||
lock := &common.ChainLock{
|
||||
lock := &common.MessagePublication{
|
||||
TxHash: txHashValue,
|
||||
Timestamp: time.Unix(blockTime.Int(), 0),
|
||||
Nonce: uint32(nonce.Uint()),
|
||||
|
|
Loading…
Reference in New Issue