Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat v3.5 implementation #339

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions bridges/ethMultiversX/bridgeExecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,45 @@ func (executor *bridgeExecutor) ResetRetriesCountOnMultiversX() {
executor.quorumRetriesOnMultiversX = 0
}

//// GetAndStoreBatchFromMultiversX fetches the logs containing sc calls metadata for the current batch from MultiversX side
//func (executor *bridgeExecutor) GetAndStoreBatchFromMultiversX(ctx context.Context, nonce uint64) error {
// batch, err := executor.multiversXClient.GetBatch(ctx, nonce)
// if err != nil {
// return err
// }
//
// isBatchInvalid := batch.ID != nonce || len(batch.Deposits) == 0
// if isBatchInvalid {
// return fmt.Errorf("%w, requested nonce: %d, fetched nonce: %d, num deposits: %d",
// ErrFinalBatchNotFound, nonce, batch.ID, len(batch.Deposits))
// }
//
// batch, err = executor.addBatchSCMetadataMvx(ctx, batch)
// if err != nil {
// return err
// }
// executor.batch = batch
//
// return nil
//}
//
//func (executor *bridgeExecutor) addBatchSCMetadataMvx(ctx context.Context, transfers *bridgeCore.TransferBatch) (*bridgeCore.TransferBatch, error) {
// if transfers == nil {
// return nil, ErrNilBatch
// }
//
// events, err := executor.multiversXClient.GetBatchSCMetadata(ctx, transfers.ID, transfers.BlockNumber)
// if err != nil {
// return nil, err
// }
//
// for i, t := range transfers.Deposits {
// transfers.Deposits[i] = executor.addMetadataToTransfer(t, events)
// }
//
// return transfers, nil
//}

// GetAndStoreBatchFromEthereum fetches and stores the batch from the ethereum client
func (executor *bridgeExecutor) GetAndStoreBatchFromEthereum(ctx context.Context, nonce uint64) error {
batch, isFinal, err := executor.ethereumClient.GetBatch(ctx, nonce)
Expand Down
1 change: 1 addition & 0 deletions bridges/ethMultiversX/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type MultiversXClient interface {
GetLastExecutedEthBatchID(ctx context.Context) (uint64, error)
GetLastExecutedEthTxID(ctx context.Context) (uint64, error)
GetCurrentNonce(ctx context.Context) (uint64, error)
GetBatchSCMetadata(ctx context.Context, nonce uint64, blockNumber uint64)

ProposeSetStatus(ctx context.Context, batch *bridgeCore.TransferBatch) (string, error)
ProposeTransfer(ctx context.Context, batch *bridgeCore.TransferBatch) (string, error)
Expand Down
27 changes: 27 additions & 0 deletions clients/multiversx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
addressPublicKeyConverter bridgeCore.AddressConverter
statusHandler bridgeCore.StatusHandler
clientAvailabilityAllowDelta uint64
eventsBlockRangeFrom uint64

Check failure on line 66 in clients/multiversx/client.go

View workflow job for this annotation

GitHub Actions / golangci linter

field `eventsBlockRangeFrom` is unused (unused)

Check failure on line 66 in clients/multiversx/client.go

View workflow job for this annotation

GitHub Actions / golangci linter

field `eventsBlockRangeFrom` is unused (unused)
eventsBlockRangeTo uint64

Check failure on line 67 in clients/multiversx/client.go

View workflow job for this annotation

GitHub Actions / golangci linter

field `eventsBlockRangeTo` is unused (unused)

Check failure on line 67 in clients/multiversx/client.go

View workflow job for this annotation

GitHub Actions / golangci linter

field `eventsBlockRangeTo` is unused (unused)

lastNonce uint64
retriesAvailabilityCheck uint64
Expand Down Expand Up @@ -236,6 +238,31 @@
return len(response) == 0 || (len(response) == 1 && len(response[0]) == 0)
}

// GetBatchSCMetadata returns the emitted logs in a batch that hold metadata for SC execution on ETH
//func (c *client) GetBatchSCMetadata(ctx context.Context, nonce uint64, blockNumber uint64) {
// proxy := c.proxy
//
// safeContractAddress, err := c.safeContractAddress.AddressAsBech32String()
// if err != nil {
// c.log.Error("error getting safe contract address", "error", err)
// return
// }
//
// query := core.FilterQuery{
// Addresses: []string{safeContractAddress},
// Topics: [][]byte{},
// FromBlock: core2.OptionalUint64{Value: blockNumber + c.eventsBlockRangeFrom, HasValue: true},
// ToBlock: core2.OptionalUint64{Value: blockNumber + c.eventsBlockRangeTo, HasValue: true},
// }
//
// logs, err := proxy.FilterLogs(ctx, &query)
// if err != nil {
// c.log.Error("error filtering logs", "error", err)
// return
// }
//
//}

func (c *client) createPendingBatchFromResponse(ctx context.Context, responseData [][]byte) (*bridgeCore.TransferBatch, error) {
numFieldsForTransaction := 6
dataLen := len(responseData)
Expand Down
1 change: 1 addition & 0 deletions clients/multiversx/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Proxy interface {
GetESDTTokenData(ctx context.Context, address core.AddressHandler, tokenIdentifier string, queryOptions api.AccountQueryOptions) (*data.ESDTFungibleTokenData, error)
GetTransactionInfoWithResults(ctx context.Context, hash string) (*data.TransactionInfo, error)
ProcessTransactionStatus(ctx context.Context, hexTxHash string) (transaction.TxStatus, error)
//FilterLogs(ctx context.Context, filter *core.FilterQuery) ([]*transaction.Events, error)
IsInterfaceNil() bool
}

Expand Down
Loading