Skip to content

Commit

Permalink
Merge branch 'staking-rewards' into staking-rename
Browse files Browse the repository at this point in the history
  • Loading branch information
iansuvak committed Sep 18, 2024
2 parents a7998b8 + 9e80079 commit 491ae79
Show file tree
Hide file tree
Showing 7 changed files with 671 additions and 1 deletion.
634 changes: 634 additions & 0 deletions abi-bindings/go/INativeMinter/INativeMinter.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions scripts/abi_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ DEFAULT_CONTRACT_LIST="TeleporterMessenger TeleporterRegistry ExampleERC20 Examp

PROXY_LIST="TransparentUpgradeableProxy ProxyAdmin"

SUBNET_EVM_LIST="INativeMinter"

CONTRACT_LIST=
HELP=
while [ $# -gt 0 ]; do
Expand Down Expand Up @@ -103,4 +105,11 @@ forge build --skip test --force --extra-output-files abi bin --contracts lib/ope
cd $TELEPORTER_PATH/lib/openzeppelin-contracts/contracts/proxy/transparent
generate_bindings "${contract_names[@]}"

contract_names=($SUBNET_EVM_LIST)
cd $TELEPORTER_PATH/
forge build --skip test --force --extra-output-files abi bin --contracts lib/subnet-evm/contracts/contracts/interfaces

cd $TELEPORTER_PATH/lib/subnet-evm/contracts/contracts/interfaces
generate_bindings "${contract_names[@]}"

exit 0
2 changes: 2 additions & 0 deletions tests/flows/validator-manager/native_delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func NativeDelegation(network interfaces.LocalNetwork) {
pChainInfo,
)

utils.AddNativeMinterAdmin(ctx, subnetAInfo, fundedKey, stakingManagerAddress)

_ = utils.InitializeNativeTokenValidatorSet(
ctx,
fundedKey,
Expand Down
2 changes: 2 additions & 0 deletions tests/flows/validator-manager/native_token_staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func NativeTokenStakingManager(network interfaces.LocalNetwork) {
pChainInfo,
)

utils.AddNativeMinterAdmin(ctx, subnetAInfo, fundedKey, stakingManagerContractAddress)

_ = utils.InitializeNativeTokenValidatorSet(
ctx,
fundedKey,
Expand Down
2 changes: 2 additions & 0 deletions tests/flows/validator-manager/poa_to_pos.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ func PoAMigrationToPoS(network interfaces.LocalNetwork) {
)
Expect(err).Should(BeNil())

utils.AddNativeMinterAdmin(ctx, subnetAInfo, fundedKey, proxyAddress)

rewardCalculatorAddress, _ := utils.DeployExampleRewardCalculator(
ctx,
fundedKey,
Expand Down
20 changes: 20 additions & 0 deletions tests/utils/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ import (
"github.com/ava-labs/awm-relayer/peers"
"github.com/ava-labs/awm-relayer/signature-aggregator/aggregator"
sigAggConfig "github.com/ava-labs/awm-relayer/signature-aggregator/config"
"github.com/ava-labs/subnet-evm/accounts/abi/bind"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/eth/tracers"
"github.com/ava-labs/subnet-evm/ethclient"
subnetEvmInterfaces "github.com/ava-labs/subnet-evm/interfaces"
"github.com/ava-labs/subnet-evm/precompile/contracts/nativeminter"
nativeMinter "github.com/ava-labs/teleporter/abi-bindings/go/INativeMinter"
"github.com/ava-labs/teleporter/tests/interfaces"
gasUtils "github.com/ava-labs/teleporter/utils/gas-utils"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -562,3 +565,20 @@ func NewSignatureAggregator(apiUri string, subnets []ids.ID) *aggregator.Signatu
messageCreator,
)
}

// Funded key must have admin access to set new admin.
func AddNativeMinterAdmin(
ctx context.Context,
subnet interfaces.SubnetTestInfo,
fundedKey *ecdsa.PrivateKey,
address common.Address,
) {
nativeMinterPrecompile, err := nativeMinter.NewINativeMinter(nativeminter.ContractAddress, subnet.RPCClient)
Expect(err).Should(BeNil())

opts, err := bind.NewKeyedTransactorWithChainID(fundedKey, subnet.EVMChainID)
Expect(err).Should(BeNil())
tx, err := nativeMinterPrecompile.SetAdmin(opts, address)
Expect(err).Should(BeNil())
WaitForTransactionSuccess(ctx, subnet, tx.Hash())
}
3 changes: 2 additions & 1 deletion tests/utils/warp-genesis-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"blockTimestamp": 0,
"adminAddresses": [
"0xAcB633F5B00099c7ec187eB00156c5cd9D854b5B",
"0x3405506b3711859c5070949ed9b700c7ba7bf750"
"0x3405506b3711859c5070949ed9b700c7ba7bf750",
"0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
]
}
},
Expand Down

0 comments on commit 491ae79

Please sign in to comment.