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

refactor(assets): validator pubkey -> id #253

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
8 changes: 4 additions & 4 deletions precompiles/assets/IAssets.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ interface IAssets {
/// @param clientChainID is the layerZero chainID if it is supported.
// It might be allocated by Exocore when the client chain isn't supported
// by layerZero
/// @param validatorPubkey The validator's pubkey
/// @param validatorID The validator's identifier (index or pubkey)
/// @param stakerAddress The staker address
/// @param opAmount The amount to deposit
function depositNST(
uint32 clientChainID,
bytes calldata validatorPubkey,
bytes calldata validatorID,
bytes calldata stakerAddress,
uint256 opAmount
) external returns (bool success, uint256 latestAssetState);
Expand All @@ -66,12 +66,12 @@ interface IAssets {
/// @param clientChainID is the layerZero chainID if it is supported.
// It might be allocated by Exocore when the client chain isn't supported
// by layerZero
/// @param validatorPubkey The validator's pubkey
/// @param validatorID The validator's identifier (index or pubkey)
/// @param withdrawAddress The withdraw address
/// @param opAmount The withdraw amount
function withdrawNST(
uint32 clientChainID,
bytes calldata validatorPubkey,
bytes calldata validatorID,
bytes calldata withdrawAddress,
uint256 opAmount
) external returns (bool success, uint256 latestAssetState);
Expand Down
4 changes: 2 additions & 2 deletions precompiles/assets/abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
{
"internalType": "bytes",
"name": "validatorPubkey",
"name": "validatorID",
"type": "bytes"
},
{
Expand Down Expand Up @@ -300,7 +300,7 @@
},
{
"internalType": "bytes",
"name": "validatorPubkey",
"name": "validatorID",
"type": "bytes"
},
{
Expand Down
2 changes: 1 addition & 1 deletion precompiles/assets/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (p Precompile) DepositOrWithdraw(
depositWithdrawParams.StakerAddress, depositWithdrawParams.AssetsAddress)
err = p.assetsKeeper.UpdateNSTValidatorListForStaker(ctx, assetID,
hexutil.Encode(depositWithdrawParams.StakerAddress),
hexutil.Encode(depositWithdrawParams.ValidatorPubkey),
hexutil.Encode(depositWithdrawParams.ValidatorID),
MaxMustermann2 marked this conversation as resolved.
Show resolved Hide resolved
opAmount)
if err != nil {
return nil, err
Expand Down
8 changes: 5 additions & 3 deletions precompiles/assets/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ func (p Precompile) DepositWithdrawParams(ctx sdk.Context, method *abi.Method, a
depositWithdrawParams.Action = assetstypes.WithdrawLST
}
case MethodDepositNST, MethodWithdrawNST:
validatorPubkey, ok := args[1].([]byte)
if !ok || len(validatorPubkey) == 0 {
validatorID, ok := args[1].([]byte)
// the length of the public key / identifier is not fixed. it depends on the source chain.
// for example, in Ethereum we have a uint256 == validator index but in Sui it is 96 bytes.
if !ok || len(validatorID) == 0 {
return nil, fmt.Errorf(exocmn.ErrContractInputParaOrType, 1, "[]byte", args[1])
}
// generate the virtual address for native restaking asset
depositWithdrawParams.AssetsAddress = assetstypes.GenerateNSTAddr(clientChainAddrLength)
// todo: add a check for the validator pubkey
depositWithdrawParams.ValidatorPubkey = validatorPubkey
depositWithdrawParams.ValidatorID = validatorID
MaxMustermann2 marked this conversation as resolved.
Show resolved Hide resolved
if method.Name == MethodDepositNST {
depositWithdrawParams.Action = assetstypes.DepositNST
} else {
Expand Down
2 changes: 1 addition & 1 deletion x/assets/keeper/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type DepositWithdrawParams struct {
AssetsAddress []byte
StakerAddress []byte
OpAmount sdkmath.Int
ValidatorPubkey []byte
ValidatorID []byte
}

// PerformDepositOrWithdraw the assets precompile contract will call this function to update asset state
Expand Down
Loading