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