Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into chains/mainnet-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkCherepovskyi committed Sep 3, 2024
2 parents b6a9415 + 9f50670 commit 00c7ca8
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 90 deletions.
21 changes: 18 additions & 3 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54961,7 +54961,7 @@ paths:
description: params holds all the parameters of this module.
type: object
properties:
contract_address:
source_contract_address:
type: string
root:
type: string
Expand All @@ -54974,6 +54974,11 @@ paths:
root_timestamp:
type: string
format: int64
block_height:
type: string
format: uint64
destination_contract_address:
type: string
description: >-
QueryParamsResponse is response type for the Query/Params RPC
method.
Expand Down Expand Up @@ -92159,7 +92164,7 @@ definitions:
rarimo.rarimocore.rootupdater.Params:
type: object
properties:
contract_address:
source_contract_address:
type: string
root:
type: string
Expand All @@ -92172,6 +92177,11 @@ definitions:
root_timestamp:
type: string
format: int64
block_height:
type: string
format: uint64
destination_contract_address:
type: string
description: Params defines the parameters for the module.
rarimo.rarimocore.rootupdater.QueryParamsResponse:
type: object
Expand All @@ -92180,7 +92190,7 @@ definitions:
description: params holds all the parameters of this module.
type: object
properties:
contract_address:
source_contract_address:
type: string
root:
type: string
Expand All @@ -92193,6 +92203,11 @@ definitions:
root_timestamp:
type: string
format: int64
block_height:
type: string
format: uint64
destination_contract_address:
type: string
description: QueryParamsResponse is response type for the Query/Params RPC method.
rarimo.rarimocore.tokenmanager.Collection:
type: object
Expand Down
7 changes: 4 additions & 3 deletions proto/rarimocore/op_passport_root_update.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ option go_package = "github.com/rarimo/rarimo-core/x/rarimocore/types";

message PassportRootUpdate {
string root = 1;
string contract_address = 2;
int64 timestamp = 3;
uint64 block_height = 4;
string source_contract_address = 2;
string destination_contract_address = 3;
int64 timestamp = 4;
uint64 block_height = 5;
}


5 changes: 3 additions & 2 deletions proto/rootupdater/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ option go_package = "github.com/rarimo/rarimo-core/x/rootupdater/types";

// Params defines the parameters for the module.
message Params {
string contract_address = 1;
string source_contract_address = 1;
string root = 2;
string last_signed_root = 3;
string last_signed_root_index = 4;
string event_name = 5;
int64 root_timestamp = 6;
uint64 block_height = 7;
}
string destination_contract_address = 8;
}
9 changes: 5 additions & 4 deletions x/rarimocore/crypto/operation/op_passport_root_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (
)

type PassportRootUpdateContent struct {
ContractAddress []byte
Root []byte
RootTimestamp []byte
SourceContractAddress []byte
DestinationContractAddress []byte
Root []byte
RootTimestamp []byte
}

const hashPassportRootUpdatePrefix = "Rarimo passport root"

var _ merkle.Content = PassportRootUpdateContent{}

func (c PassportRootUpdateContent) CalculateHash() []byte {
return eth.Keccak256([]byte(hashPassportRootUpdatePrefix), c.ContractAddress, c.Root, c.RootTimestamp)
return eth.Keccak256([]byte(hashPassportRootUpdatePrefix), c.SourceContractAddress, c.DestinationContractAddress, c.Root, c.RootTimestamp)
}

func (c PassportRootUpdateContent) Equals(other merkle.Content) bool {
Expand Down
7 changes: 4 additions & 3 deletions x/rarimocore/crypto/pkg/op_passport_root_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func GetPassportRootUpdate(operation types.Operation) (*types.PassportRootUpdate

func GetPassportRootUpdateContent(op *types.PassportRootUpdate) (*operation.PassportRootUpdateContent, error) {
return &operation.PassportRootUpdateContent{
ContractAddress: hexutil.MustDecode(op.ContractAddress),
Root: operation.To32Bytes(hexutil.MustDecode(op.Root)),
RootTimestamp: operation.To32Bytes(new(big.Int).SetInt64(op.Timestamp).Bytes()),
SourceContractAddress: hexutil.MustDecode(op.SourceContractAddress),
DestinationContractAddress: hexutil.MustDecode(op.DestinationContractAddress),
Root: operation.To32Bytes(hexutil.MustDecode(op.Root)),
RootTimestamp: operation.To32Bytes(new(big.Int).SetInt64(op.Timestamp).Bytes()),
}, nil
}
119 changes: 86 additions & 33 deletions x/rarimocore/types/op_passport_root_update.pb.go

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

9 changes: 5 additions & 4 deletions x/rootupdater/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ func (k Keeper) EndBlocker(ctx sdk.Context) {

// Creating operation to be signed by TSS parties
index, err := k.rarimo.CreateRootUpdateOperation(ctx, types.ModuleName, &rarimocoremoduletypes.PassportRootUpdate{
ContractAddress: params.ContractAddress,
Root: params.Root,
Timestamp: params.RootTimestamp,
BlockHeight: params.BlockHeight,
SourceContractAddress: params.SourceContractAddress,
DestinationContractAddress: params.DestinationContractAddress,
Root: params.Root,
Timestamp: params.RootTimestamp,
BlockHeight: params.BlockHeight,
})

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion x/rootupdater/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (k Keeper) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *eth
return nil
}

contractAddress, err := hexutil.Decode(params.ContractAddress)
contractAddress, err := hexutil.Decode(params.SourceContractAddress)
if err != nil {
// If return an error here, the whole EVM module won't work
k.Logger(ctx).Error("failed to decode contract address")
Expand Down
Loading

0 comments on commit 00c7ca8

Please sign in to comment.