Skip to content

Commit

Permalink
Merge branch 'master' into dzmitryhil/remove-unused-dockerfile-part
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitryhil authored Mar 7, 2024
2 parents 3fad809 + d5cf3c0 commit 08080c4
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 14 deletions.
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,7 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
Expand Down
37 changes: 37 additions & 0 deletions integration-tests/contract/keys_rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,40 @@ func TestKeysRotationWithRecovery(t *testing.T) {
require.NoError(t, err)
require.Equal(t, xrplToCoreumXRPLTokenTransferEvidence.Amount.String(), coreumRecipientBalance.Balance.Amount.String())
}

func TestKeysRotationWithProhibitedAddresses(t *testing.T) {
t.Parallel()

ctx, chains := integrationtests.NewTestingContext(t)

initialRelayers := genRelayers(ctx, t, chains, 1)
owner, contractClient := integrationtests.DeployAndInstantiateContract(
ctx,
t,
chains,
initialRelayers,
uint32(len(initialRelayers)),
20,
defaultTrustSetLimitAmount,
xrpl.GenPrivKeyTxSigner().Account().String(),
uint32(10),
)
// recover tickets to be able to create operations from coreum to XRPL
recoverTickets(ctx, t, contractClient, owner, initialRelayers, 100)

prohibitedXRPLAddresses, err := contractClient.GetProhibitedXRPLAddresses(ctx)
require.NoError(t, err)

// keys rotation
for i := 0; i < len(prohibitedXRPLAddresses); i++ {
newRelayers := genRelayers(ctx, t, chains, 2)
// set one address from prohibited list
newRelayers[0].XRPLAddress = prohibitedXRPLAddresses[i]
_, err = contractClient.RotateKeys(ctx,
owner,
newRelayers,
1,
)
require.True(t, coreum.IsProhibitedAddressError(err), err)
}
}
2 changes: 1 addition & 1 deletion integration-tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ replace (
)

require (
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20231219065050-077b204f5543
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240306133015-8a9ec4eb1bf0
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240220134751-03b0f19e9a28
github.com/CoreumFoundation/coreumbridge-xrpl/relayer v1.0.0
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM=
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20231219065050-077b204f5543 h1:BEegqwAFIRfym2hfqiBbRUTi28jK/u8Bn/1cwtK+ldI=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20231219065050-077b204f5543/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240306133015-8a9ec4eb1bf0 h1:1PSfqh5NFBxCUJnZlPdQxx7BAdlqfQEjPm8MgvPZDJo=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240306133015-8a9ec4eb1bf0/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240220134751-03b0f19e9a28 h1:Xey8FAt4XtmlQsOQvHu45KjFOWU/TE8pOx54aLvgMPk=
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240220134751-03b0f19e9a28/go.mod h1:m17GEOObKO0uMNRSeitPFjjne55MSbzFeTlAONaMGkI=
github.com/CosmWasm/wasmd v0.44.0 h1:2sbcoCAvfjCs1O0SWt53xULKjkV06dbSFthEViIC6Zg=
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/xrpl/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ func validateTxsHashesInChannel(
case <-scanCtx.Done():
return scanCtx.Err()
case tx := <-txsCh:
// validate that we have all sent hashed and no duplicated
// validate that we have all sent hashes
hash := strings.ToUpper(tx.GetHash().String())
if _, found := expectedHashes[hash]; !found {
return errors.Errorf("not found expected tx hash:%s", hash)
continue
}

delete(expectedHashes, hash)
Expand Down
7 changes: 7 additions & 0 deletions relayer/client/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ type ContractClient interface {
operationID uint32,
) (*sdk.TxResponse, error)
GetPendingOperations(ctx context.Context) ([]coreum.Operation, error)
GetTransactionEvidences(ctx context.Context) ([]coreum.TransactionEvidence, error)
}

// XRPLRPCClient is XRPL RPC client interface.
Expand Down Expand Up @@ -1058,6 +1059,12 @@ func (b *BridgeClient) GetPendingOperations(ctx context.Context) ([]coreum.Opera
return b.contractClient.GetPendingOperations(ctx)
}

// GetTransactionEvidences returns a list of not confirmed transaction evidences.
func (b *BridgeClient) GetTransactionEvidences(ctx context.Context) ([]coreum.TransactionEvidence, error) {
b.log.Info(ctx, "Getting transaction evidences")
return b.contractClient.GetTransactionEvidences(ctx)
}

func (b *BridgeClient) validateXRPLBridgeAccountBalance(
ctx context.Context,
xrplBridgeAccount rippledata.Account,
Expand Down
1 change: 1 addition & 0 deletions relayer/cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ type BridgeClient interface {
operationID uint32,
) error
GetPendingOperations(ctx context.Context) ([]coreum.Operation, error)
GetTransactionEvidences(ctx context.Context) ([]coreum.TransactionEvidence, error)
}

// BridgeClientProvider is function which returns the BridgeClient from the input cmd.
Expand Down
15 changes: 15 additions & 0 deletions relayer/cmd/cli/cli_mocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 29 additions & 2 deletions relayer/cmd/cli/coreum_cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ func CoreumCmd(bcp BridgeClientProvider) (*cobra.Command, error) {
coreumQueryCmd.AddCommand(RelayerFeesCmd(bcp))
coreumQueryCmd.AddCommand(PendingOperationsCmd(bcp))
coreumQueryCmd.AddCommand(ProhibitedXRPLAddressesCmd(bcp))
coreumQueryCmd.AddCommand(TransactionEvidencesCmd(bcp))

AddHomeFlag(coreumQueryCmd)

keyringCoreumCmd, err := KeyringCmd(CoreumKeyringSuffix, constant.CoinType,
Expand Down Expand Up @@ -917,7 +919,7 @@ func PendingOperationsCmd(bcp BridgeClientProvider) *cobra.Command {
if err != nil {
return err
}
log.Info(ctx, "Got pending operations", zap.Any("pendingOperations", pendingOperations))
log.Info(ctx, "Got pending operations", zap.Any("operations", pendingOperations))

return nil
}),
Expand Down Expand Up @@ -945,13 +947,38 @@ $ prohibited-xrpl-addresses %s
components.Log.Info(
ctx,
"Got prohibited XRPL addresses",
zap.Any("prohibitedXRPLAddresses", prohibitedXRPLAddresses),
zap.Any("addresses", prohibitedXRPLAddresses),
)
return nil
}),
}
}

// TransactionEvidencesCmd prints the not confirmed transaction evidences.
func TransactionEvidencesCmd(bcp BridgeClientProvider) *cobra.Command {
return &cobra.Command{
Use: "transaction-evidences",
Short: "Print not confirmed transaction evidences.",
RunE: runBridgeCmd(bcp,
func(cmd *cobra.Command, args []string, components runner.Components, bridgeClient BridgeClient) error {
ctx := cmd.Context()

transactionEvidences, err := bridgeClient.GetTransactionEvidences(ctx)
if err != nil {
return err
}

log, err := GetCLILogger()
if err != nil {
return err
}
log.Info(ctx, "Got transaction evidences", zap.Any("evidences", transactionEvidences))

return nil
}),
}
}

// CoreumTxPreRun is Coreum transaction CMD pre-run function.
func CoreumTxPreRun(bcp BridgeClientProvider) func(cmd *cobra.Command, args []string) error {
return runBridgeCmd(bcp,
Expand Down
10 changes: 10 additions & 0 deletions relayer/cmd/cli/coreum_cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,16 @@ func TestProhibitedXRPLAddressesCmd(t *testing.T) {
executeQueryCmd(t, cli.ProhibitedXRPLAddressesCmd(mockBridgeClientProvider(bridgeClientMock)), initConfig(t)...)
}

func TestTransactionEvidencesCmd(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

bridgeClientMock := NewMockBridgeClient(ctrl)

bridgeClientMock.EXPECT().GetTransactionEvidences(gomock.Any()).Return([]coreum.TransactionEvidence{}, nil)
executeQueryCmd(t, cli.TransactionEvidencesCmd(mockBridgeClientProvider(bridgeClientMock)), initConfig(t)...)
}

func executeCoreumTxCmd(t *testing.T, bcp cli.BridgeClientProvider, cmd *cobra.Command, args ...string) {
cli.AddCoreumTxFlags(cmd)
cmd.PreRunE = cli.CoreumTxPreRun(bcp)
Expand Down
2 changes: 1 addition & 1 deletion relayer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ replace (

require (
cosmossdk.io/math v1.2.0
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20231219065050-077b204f5543
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240306133015-8a9ec4eb1bf0
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240220134751-03b0f19e9a28
github.com/CosmWasm/wasmd v0.44.0
github.com/cosmos/cosmos-sdk v0.47.8
Expand Down
4 changes: 2 additions & 2 deletions relayer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ChainSafe/go-schnorrkel v1.0.0 h1:3aDA67lAykLaG1y3AOjs88dMxC88PgUuHRrLeDnvGIM=
github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z7vcchBSbMBEhCw4=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20231219065050-077b204f5543 h1:BEegqwAFIRfym2hfqiBbRUTi28jK/u8Bn/1cwtK+ldI=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20231219065050-077b204f5543/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240306133015-8a9ec4eb1bf0 h1:1PSfqh5NFBxCUJnZlPdQxx7BAdlqfQEjPm8MgvPZDJo=
github.com/CoreumFoundation/coreum-tools v0.4.1-0.20240306133015-8a9ec4eb1bf0/go.mod h1:VD93vCHkxYaT/RhOesXTFgd/GQDW54tr0BqGi5JU1c0=
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240220134751-03b0f19e9a28 h1:Xey8FAt4XtmlQsOQvHu45KjFOWU/TE8pOx54aLvgMPk=
github.com/CoreumFoundation/coreum/v4 v4.0.0-20240220134751-03b0f19e9a28/go.mod h1:m17GEOObKO0uMNRSeitPFjjne55MSbzFeTlAONaMGkI=
github.com/CosmWasm/wasmd v0.44.0 h1:2sbcoCAvfjCs1O0SWt53xULKjkV06dbSFthEViIC6Zg=
Expand Down
2 changes: 1 addition & 1 deletion relayer/xrpl/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func (c *RPCClient) AccountTx(
MinLedger: minLedger,
MaxLedger: maxLedger,
Binary: false,
Forward: false,
Forward: true,
Limit: c.cfg.PageLimit,
Marker: marker,
}
Expand Down
4 changes: 1 addition & 3 deletions relayer/xrpl/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ func (s *AccountScanner) scanTransactions(
lastLedger = prevProcessedLedger
prevProcessedLedger = int64(tx.LedgerSequence)
}
indexRegistryFunc(float64(prevProcessedLedger))
if tx == nil {
continue
}
Expand All @@ -209,9 +210,6 @@ func (s *AccountScanner) scanTransactions(
}
}
}
if prevProcessedLedger != 0 {
indexRegistryFunc(float64(prevProcessedLedger))
}
if len(accountTxResult.Marker) == 0 {
lastLedger = prevProcessedLedger
break
Expand Down

0 comments on commit 08080c4

Please sign in to comment.