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

zoneconcierge: permissioned integration #291

Merged
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
41284f3
Fix: Consumer integration e2e test deps
maurolacy Nov 20, 2024
427dc45
Fix: e2e test targets
maurolacy Nov 20, 2024
bd8c221
Disable broken / failing e2e tests from e2e target
maurolacy Nov 20, 2024
63f33d0
Update copy / download contracts scripts
maurolacy Nov 20, 2024
53c3f30
Update contracts to latest v0.11.0
maurolacy Nov 20, 2024
b5b2d6a
Update babylon-sdk tag to (WIP) rewards e2e branch
maurolacy Nov 20, 2024
66ce706
Add babylon-sdk as sub-module
maurolacy Nov 21, 2024
326ec1e
Use babylon-sdk submodule ref during ibcsim-bcd build
maurolacy Nov 21, 2024
3ec459a
init
SebastianElvis Nov 22, 2024
b2e98f0
Add finality contract to e2e test setup
maurolacy Nov 22, 2024
f7e6b4f
Improve flaky IBC transfer back checks
maurolacy Nov 22, 2024
9db92ee
Clean network before staking tests
maurolacy Nov 22, 2024
837cd10
Add consumer rewards test to bcd suite
maurolacy Nov 22, 2024
06a6aec
Update rewards e2e branch to latest
maurolacy Nov 23, 2024
21e977a
Rename to cc for consistency
maurolacy Nov 24, 2024
ce11ec8
Add balance / balances grpc queries to consumer controller
maurolacy Nov 24, 2024
8506e9e
Revert "Add consumer rewards test to bcd suite"
maurolacy Nov 24, 2024
fd0f423
some rename
SebastianElvis Nov 24, 2024
75482f0
Now add consumer rewards test to bcd suite
maurolacy Nov 25, 2024
45059e0
Revert "Now add consumer rewards test to bcd suite"
maurolacy Nov 25, 2024
44917f0
Now really add consumer rewards test to bcd suite
maurolacy Nov 25, 2024
bfa37b7
Update rewards e2e branch to latest
maurolacy Nov 25, 2024
b5325e9
Add extra empty rewards check
maurolacy Nov 25, 2024
75f0103
Remove TODO
maurolacy Nov 25, 2024
2db01d0
rm auto consumer reg
SebastianElvis Nov 26, 2024
5a3862d
ensure IBC light client existence upon IBC handshake
SebastianElvis Nov 26, 2024
3929eb2
some tests
SebastianElvis Nov 26, 2024
84ee829
adjust e2e
SebastianElvis Nov 26, 2024
3738ab0
Move babylon-sdk to v0.6.0 tag
maurolacy Nov 26, 2024
0ea6c23
Fix gosimple lint
maurolacy Nov 26, 2024
dcdc7dc
Fix / replace deprecated methods
maurolacy Nov 26, 2024
606e2d6
Revert "Add babylon-sdk as sub-module"
maurolacy Nov 26, 2024
1d4ebfc
Revert to using babylon-sdk clone / checkout during ibcsim-bcd build
maurolacy Nov 26, 2024
bc2e4bd
Fix: first / main consumer fp data races
maurolacy Nov 26, 2024
b1a2eb1
Merge branch 'f/consumer-reward-e2e' into feat/permissioned-integration
SebastianElvis Nov 26, 2024
47cd2fa
flag for permissioned integration
SebastianElvis Nov 26, 2024
d0b97f1
test register consumer
SebastianElvis Nov 26, 2024
8180c5c
fix some e2e
SebastianElvis Nov 27, 2024
1d65bd7
fix proto
SebastianElvis Nov 27, 2024
ff186b8
bump contract
SebastianElvis Nov 27, 2024
ac4ce0e
Merge branch 'base/consumer-chain-support' into feat/permissioned-int…
SebastianElvis Nov 27, 2024
0e03967
fix
SebastianElvis Nov 27, 2024
6e1079a
minor
SebastianElvis Nov 27, 2024
eeacea5
try
SebastianElvis Nov 27, 2024
a77060b
debug
SebastianElvis Nov 28, 2024
6deca9e
fix bcd image
SebastianElvis Nov 28, 2024
5b6f5c5
minor
SebastianElvis Nov 28, 2024
de84d88
fix e2e
SebastianElvis Nov 28, 2024
c725217
pr comments
SebastianElvis Dec 2, 2024
6fec03a
point babylon sdk to main
SebastianElvis Dec 2, 2024
a3f6322
fix
SebastianElvis Dec 2, 2024
d8eccac
pr comments
SebastianElvis Dec 2, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ jobs:
go-version: 1.21
- name: Start BCD consumer integration containers
run: |
sudo make -C contrib/images start-bcd-consumer-integration
sudo make start-bcd-consumer-integration
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
- name: Run BCD consumer integration test
run: |
sudo make test-e2e-cache-bcd-consumer-integration
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ clean-e2e:
docker container rm -f $(shell docker container ls -a -q) || true
docker network prune -f || true

test-e2e-cache-bcd-consumer-integration: start-bcd-consumer-integration
test-e2e-cache-bcd-consumer-integration:
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
go test -run TestBCDConsumerIntegrationTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e

test-e2e-cache-btc-timestamping:
Expand Down Expand Up @@ -446,7 +446,7 @@ build-docker: ## Build babylond Docker image
build-docker-e2e:
$(MAKE) -C contrib/images babylond-e2e
$(MAKE) -C contrib/images e2e-init-chain
$(MAKE) -C contrib/images build-bcd-consumer-integration
$(MAKE) -C contrib/images build-ibcsim-bcd
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved

build-cosmos-relayer-docker: ## Build Docker image for the Cosmos relayer
$(MAKE) -C contrib/images cosmos-relayer
Expand Down
52 changes: 28 additions & 24 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,30 @@ func (ak *AppKeepers) InitKeepers(
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

wasmOpts = append(owasm.RegisterCustomPlugins(&ak.EpochingKeeper, &ak.CheckpointingKeeper, &ak.BTCLightClientKeeper, &ak.ZoneConciergeKeeper), wasmOpts...)
wasmOpts = append(owasm.RegisterGrpcQueries(*bApp.GRPCQueryRouter(), appCodec), wasmOpts...)

ak.WasmKeeper = wasmkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[wasmtypes.StoreKey]),
ak.AccountKeeper,
ak.BankKeeper,
ak.StakingKeeper,
distrkeeper.NewQuerier(ak.DistrKeeper),
ak.IBCFeeKeeper,
ak.IBCKeeper.ChannelKeeper,
ak.IBCKeeper.PortKeeper,
scopedWasmKeeper,
ak.TransferKeeper,
bApp.MsgServiceRouter(),
bApp.GRPCQueryRouter(),
homePath,
wasmConfig,
WasmCapabilities(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
wasmOpts...,
)

// register the proposal types
// Deprecated: Avoid adding new handlers, instead use the new proposal flow
// by granting the governance module the right to execute the message.
Expand Down Expand Up @@ -487,6 +511,9 @@ func (ak *AppKeepers) InitKeepers(
runtime.NewKVStoreService(keys[bsctypes.StoreKey]),
ak.AccountKeeper,
ak.BankKeeper,
ak.IBCKeeper.ClientKeeper,
ak.IBCKeeper.ChannelKeeper,
ak.WasmKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)

Expand Down Expand Up @@ -529,6 +556,7 @@ func (ak *AppKeepers) InitKeepers(
runtime.NewKVStoreService(keys[zctypes.StoreKey]),
ak.IBCFeeKeeper,
ak.IBCKeeper.ClientKeeper,
ak.IBCKeeper.ConnectionKeeper,
ak.IBCKeeper.ChannelKeeper,
ak.IBCKeeper.PortKeeper,
ak.AccountKeeper,
Expand Down Expand Up @@ -578,30 +606,6 @@ func (ak *AppKeepers) InitKeepers(
// If evidence needs to be handled for the app, set routes in router here and seal
ak.EvidenceKeeper = *evidenceKeeper

wasmOpts = append(owasm.RegisterCustomPlugins(&ak.EpochingKeeper, &ak.CheckpointingKeeper, &ak.BTCLightClientKeeper, &ak.ZoneConciergeKeeper), wasmOpts...)
wasmOpts = append(owasm.RegisterGrpcQueries(*bApp.GRPCQueryRouter(), appCodec), wasmOpts...)

ak.WasmKeeper = wasmkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[wasmtypes.StoreKey]),
ak.AccountKeeper,
ak.BankKeeper,
ak.StakingKeeper,
distrkeeper.NewQuerier(ak.DistrKeeper),
ak.IBCFeeKeeper,
ak.IBCKeeper.ChannelKeeper,
ak.IBCKeeper.PortKeeper,
scopedWasmKeeper,
ak.TransferKeeper,
bApp.MsgServiceRouter(),
bApp.GRPCQueryRouter(),
homePath,
wasmConfig,
WasmCapabilities(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
wasmOpts...,
)

ibcWasmConfig :=
ibcwasmtypes.WasmConfig{
DataDir: filepath.Join(homePath, "ibc_08-wasm"),
Expand Down
4 changes: 1 addition & 3 deletions contrib/images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ build-ibcsim-bcd:
ibcsim-bcd-rmi:
docker rmi babylonlabs-io/ibcsim-bcd 2>/dev/null; true

build-bcd-consumer-integration: babylond-e2e build-ibcsim-bcd

start-bcd-consumer-integration: stop-bcd-consumer-integration
ibcsim-bcd/pre-deployment.sh
docker compose -f ibcsim-bcd/docker-compose.yml up -d
Expand All @@ -45,4 +43,4 @@ stop-bcd-consumer-integration:
docker compose -f ibcsim-bcd/docker-compose.yml down
rm -rf ibcsim-bcd/.testnets

.PHONY: all babylond babylond-before-upgrade cosmos-relayer e2e-init-chain babylond-rmi babylond-rmi-upgrade cosmos-relayer-rmi build-ibcsim-bcd ibcsim-bcd-rmi build-bcd-consumer-integration-test start-bcd-consumer-integration-test stop-bcd-consumer-integration-test
.PHONY: all babylond babylond-before-upgrade cosmos-relayer e2e-init-chain babylond-rmi babylond-rmi-upgrade cosmos-relayer-rmi build-ibcsim-bcd ibcsim-bcd-rmi start-bcd-consumer-integration-test stop-bcd-consumer-integration-test
6 changes: 3 additions & 3 deletions contrib/images/ibcsim-bcd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ COPY --from=build-env /go/bin/bcd /usr/bin/bcd
WORKDIR /ibcsim-bcd
COPY contrib/images/ibcsim-bcd/wrapper.sh /ibcsim-bcd/wrapper.sh
COPY contrib/images/ibcsim-bcd/setup-bcd.sh /ibcsim-bcd/setup-bcd.sh
COPY --from=build-env /work/babylon-sdk/tests/testdata/babylon_contract.wasm /ibcsim-bcd/babylon_contract.wasm
COPY --from=build-env /work/babylon-sdk/tests/testdata/btc_staking.wasm /ibcsim-bcd/btc_staking.wasm
COPY --from=build-env /work/babylon-sdk/tests/testdata/btc_finality.wasm /ibcsim-bcd/btc_finality.wasm
COPY test/e2e/bytecode/babylon_contract.wasm /ibcsim-bcd/babylon_contract.wasm
COPY test/e2e/bytecode/btc_staking.wasm /ibcsim-bcd/btc_staking.wasm
COPY test/e2e/bytecode/btc_finality.wasm /ibcsim-bcd/btc_finality.wasm
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved

ENV BABYLON_HOME=/data/node1/babylond
ENV BABYLON_NODE_RPC="http://babylondnode1:26657"
Expand Down
74 changes: 37 additions & 37 deletions proto/babylon/btcstaking/v1/packet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,70 +58,70 @@ message NewFinalityProvider {
// upon a BTC delegation newly receives covenant signatures and thus becomes active
message ActiveBTCDelegation {
// staker_addr is the address to receive rewards from BTC delegation.
string staker_addr = 11;
string staker_addr = 1;
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
// btc_pk_hex is the Bitcoin secp256k1 PK of this BTC delegation
// the PK follows encoding in BIP-340 spec in hex format
string btc_pk_hex = 1;
string btc_pk_hex = 2;
// fp_btc_pk_list is the list of BIP-340 PKs of the finality providers that
// this BTC delegation delegates to
repeated string fp_btc_pk_list = 2;
repeated string fp_btc_pk_list = 3;
// start_height is the start BTC height of the BTC delegation
// it is the start BTC height of the timelock
uint32 start_height = 3;
uint32 start_height = 4;
// end_height is the end height of the BTC delegation
// it is the end BTC height of the timelock - w
uint32 end_height = 4;
uint32 end_height = 5;
// total_sat is the total amount of BTC stakes in this delegation
// quantified in satoshi
uint64 total_sat = 5;
uint64 total_sat = 6;
// staking_tx is the staking tx
bytes staking_tx = 6;
bytes staking_tx = 7;
// slashing_tx is the slashing tx
bytes slashing_tx = 7;
bytes slashing_tx = 8;
// delegator_slashing_sig is the signature on the slashing tx
// by the delegator (i.e., SK corresponding to btc_pk) as string hex.
// It will be a part of the witness for the staking tx output.
bytes delegator_slashing_sig = 8;
bytes delegator_slashing_sig = 9;
// covenant_sigs is a list of adaptor signatures on the slashing tx
// by each covenant member
// It will be a part of the witness for the staking tx output.
repeated CovenantAdaptorSignatures covenant_sigs = 9;
repeated CovenantAdaptorSignatures covenant_sigs = 10;
// staking_output_idx is the index of the staking output in the staking tx
uint32 staking_output_idx = 10;
uint32 staking_output_idx = 11;
// unbonding_time used in unbonding output timelock path and in slashing transactions
// change outputs
uint32 unbonding_time = 13;
uint32 unbonding_time = 12;
// undelegation_info is the undelegation info of this delegation.
BTCUndelegationInfo undelegation_info = 14;
BTCUndelegationInfo undelegation_info = 13;
// params version used to validate delegation
uint32 params_version = 15;
uint32 params_version = 14;
}

// BTCUndelegationInfo provides all necessary info about the undeleagation
message BTCUndelegationInfo {
// unbonding_tx is the transaction which will transfer the funds from staking
// output to unbonding output. Unbonding output will usually have lower timelock
// than staking output.
bytes unbonding_tx = 1;
// delegator_unbonding_sig is the signature on the unbonding tx
// by the delegator (i.e., SK corresponding to btc_pk).
// It effectively proves that the delegator wants to unbond and thus
// Babylon will consider this BTC delegation unbonded. Delegator's BTC
// on Bitcoin will be unbonded after timelock.
bytes delegator_unbonding_sig = 2;
// covenant_unbonding_sig_list is the list of signatures on the unbonding tx
// by covenant members
repeated SignatureInfo covenant_unbonding_sig_list = 3;
// slashing_tx is the unbonding slashing tx
bytes slashing_tx = 4;
// delegator_slashing_sig is the signature on the slashing tx
// by the delegator (i.e., SK corresponding to btc_pk).
// It will be a part of the witness for the unbonding tx output.
bytes delegator_slashing_sig = 5;
// covenant_slashing_sigs is a list of adaptor signatures on the
// unbonding slashing tx by each covenant member
// It will be a part of the witness for the staking tx output.
repeated CovenantAdaptorSignatures covenant_slashing_sigs = 6;
// unbonding_tx is the transaction which will transfer the funds from staking
// output to unbonding output. Unbonding output will usually have lower timelock
// than staking output.
bytes unbonding_tx = 1;
// slashing_tx is the slashing tx for unbonding transactions
// It is partially signed by SK corresponding to btc_pk, but not signed by
// finality provider or covenant yet.
bytes slashing_tx = 2;
// delegator_slashing_sig is the signature on the slashing tx
// by the delegator (i.e., SK corresponding to btc_pk).
// It will be a part of the witness for the unbonding tx output.
bytes delegator_slashing_sig = 3;
// covenant_slashing_sigs is a list of adaptor signatures on the slashing tx
// by each covenant member
// It will be a part of the witness for the staking tx output.
repeated CovenantAdaptorSignatures covenant_slashing_sigs = 4;
// covenant_unbonding_sig_list is the list of signatures on the unbonding tx
// by covenant members
// It must be provided after processing undelegate message by Babylon
repeated SignatureInfo covenant_unbonding_sig_list = 5;
// delegator_unbonding_info is the information about transaction which spent
// the staking output
DelegatorUnbondingInfo delegator_unbonding_info = 6;
}

// SlashedBTCDelegation is an IBC packet sent from Babylon to consumer
Expand Down
36 changes: 35 additions & 1 deletion proto/babylon/btcstkconsumer/v1/btcstkconsumer.proto
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
syntax = "proto3";
package babylon.btcstkconsumer.v1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";

option go_package = "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types";

// ConsumerType defines the type of consumer chain
enum ConsumerType {
// COSMOS represents a Cosmos SDK chain consumer
COSMOS = 0;
// ETH_L2 represents an Ethereum L2 chain consumer
ETH_L2 = 1;
}

// ConsumerRegister is the registration information of a consumer
message ConsumerRegister {
// consumer_id is the ID of the consumer
// - for Cosmos SDK chains, the consumer ID will be the IBC client ID
// - for ETH L2 chains, the consumer ID will be the chain ID of the ETH L2
// chain
string consumer_id = 1;
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
// consumer_name is the name of the consumer
string consumer_name = 2;
// consumer_description is a description for the consumer (can be empty)
string consumer_description = 3;
}
// consumer_metadata is necessary metadata of the consumer, and the data
// depends on the type of integration
oneof consumer_metadata {
CosmosConsumerMetadata cosmos_consumer_metadata = 4;
ETHL2ConsumerMetadata eth_l2_consumer_metadata = 5;
};
}

// CosmosConsumerMetadata is the metadata for the Cosmos integration
message CosmosConsumerMetadata {
// client_id defines the IBC client ID for the consumer chain
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
string client_id = 1;
// channel_id defines the IBC channel ID for the consumer chain
string channel_id = 2;
}

// ETHL2ConsumerMetadata is the metadata for the ETH L2 integration
message ETHL2ConsumerMetadata {
// finality_contract_address is the address of the finality contract for
// the ETH L2 integration
string finality_contract_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}
6 changes: 5 additions & 1 deletion proto/babylon/btcstkconsumer/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ option go_package = "github.com/babylonlabs-io/babylon/x/btcstkconsumer/types";
message Params {
option (amino.name) = "babylon/x/btcstkconsumer/v1/Params";
option (gogoproto.equal) = true;
}

// permissioned_integration is a flag to enable permissioned integration, i.e.,
// requiring governance proposal to approve new integrations.
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
bool permissioned_integration = 1;
}
3 changes: 3 additions & 0 deletions proto/babylon/btcstkconsumer/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ message MsgRegisterConsumer {
string consumer_name = 3;
// consumer_description is a description for the consumer (can be empty)
string consumer_description = 4;
// eth_l2_finality_contract_address is the address of the finality contract
// (if set, then this means this is an ETH L2 integration)
string eth_l2_finality_contract_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
}

// MsgRegisterConsumerResponse is the response to the MsgRegisterConsumer message.
Expand Down
12 changes: 1 addition & 11 deletions proto/babylon/zoneconcierge/v1/packet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ message ZoneconciergePacketData {
oneof packet {
BTCTimestamp btc_timestamp = 1;
babylon.btcstaking.v1.BTCStakingIBCPacket btc_staking = 2;
ConsumerRegisterIBCPacket consumer_register = 3;
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
ConsumerSlashingIBCPacket consumer_slashing = 4;
ConsumerSlashingIBCPacket consumer_slashing = 3;
SebastianElvis marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -57,15 +56,6 @@ message BTCTimestamp {
babylon.zoneconcierge.v1.ProofFinalizedChainInfo proof = 6;
}

// ConsumerRegisterIBCPacket defines the packet data for Consumer registration
message ConsumerRegisterIBCPacket {
// consumer_name is a unique identifier for the consumer chain
string consumer_name = 1;

// consumer_description is a brief explanation of the consumer chain's purpose
string consumer_description = 2;
}

// ConsumerSlashingIBCPacket defines the slashing information that a Consumer sends to Babylon's ZoneConcierge upon a
// Consumer slashing event.
// It includes the FP public key, the Consumer block height at the slashing event, and the double sign evidence.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ type SignatureInfo struct {
}

type BtcUndelegationInfo struct {
UnbondingTx []byte `json:"unbonding_tx"`
DelegatorUnbondingSig []byte `json:"delegator_unbonding_sig"`
CovenantUnbondingSigs []SignatureInfo `json:"covenant_unbonding_sig_list"`
SlashingTx []byte `json:"slashing_tx"`
DelegatorSlashingSig []byte `json:"delegator_slashing_sig"`
CovenantSlashingSigs []CovenantAdaptorSignatures `json:"covenant_slashing_sigs"`
UnbondingTx []byte `json:"unbonding_tx"`
SlashingTx []byte `json:"slashing_tx"`
DelegatorSlashingSig []byte `json:"delegator_slashing_sig"`
CovenantSlashingSigs []*CovenantAdaptorSignatures `json:"covenant_slashing_sigs"`
CovenantUnbondingSigList []*SignatureInfo `json:"covenant_unbonding_sig_list"`
DelegatorUnbondingInfo *DelegatorUnbondingInfo `json:"delegator_unbonding_info"`
}

type DelegatorUnbondingInfo struct {
SpendStakeTx []byte `json:"spend_stake_tx"`
}

type ActiveBtcDelegation struct {
Expand Down
Loading
Loading