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

feat(contracts): add event params & make explicit un/cmp names #11

Merged
merged 8 commits into from
Aug 23, 2024
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
1 change: 1 addition & 0 deletions client/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,6 @@ func SplitAndTrim(input string) []string {
ret = append(ret, r)
}
}

return ret
}
4 changes: 2 additions & 2 deletions client/x/evmstaking/keeper/deposit.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
)

func (k Keeper) ProcessDeposit(ctx context.Context, ev *bindings.IPTokenStakingDeposit) error {
depositorPubkey, err := k1util.PubKeyBytesToCosmos(ev.DepositorPubkey)
depositorPubkey, err := k1util.PubKeyBytesToCosmos(ev.DelegatorCmpPubkey)
if err != nil {
return errors.Wrap(err, "depositor pubkey to cosmos")
}

validatorPubkey, err := k1util.PubKeyBytesToCosmos(ev.ValidatorPubkey)
validatorPubkey, err := k1util.PubKeyBytesToCosmos(ev.ValidatorCmpPubkey)
if err != nil {
return errors.Wrap(err, "validator pubkey to cosmos")
}
Expand Down
2 changes: 1 addition & 1 deletion client/x/evmstaking/keeper/redelegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

func (k Keeper) ProcessRedelegate(ctx context.Context, ev *bindings.IPTokenStakingRedelegate) error {
depositorPubkey, err := k1util.PubKeyBytesToCosmos(ev.DepositorPubkey)
depositorPubkey, err := k1util.PubKeyBytesToCosmos(ev.DelegatorCmpPubkey)
if err != nil {
return errors.Wrap(err, "depositor pubkey to cosmos")
}
Expand Down
2 changes: 1 addition & 1 deletion client/x/evmstaking/keeper/redelegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *TestSuite) TestRedelegation() {
redelTokens := stakingKeeper.TokensFromConsensusPower(ctx, 5)

ipTokenRedelegate := &bindings.IPTokenStakingRedelegate{
DepositorPubkey: pubKeys[0].Bytes(),
DelegatorCmpPubkey: pubKeys[0].Bytes(),
ValidatorSrcPubkey: pubKeys[1].Bytes(),
ValidatorDstPubkey: pubKeys[2].Bytes(),
Amount: big.NewInt(redelTokens.Int64()), // multiply power reduction of 1000000
Expand Down
2 changes: 1 addition & 1 deletion client/x/evmstaking/keeper/set_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func (k Keeper) ProcessSetWithdrawalAddress(ctx context.Context, ev *bindings.IPTokenStakingSetWithdrawalAddress) error {
depositorPubkey, err := k1util.PubKeyBytesToCosmos(ev.DepositorPubkey)
depositorPubkey, err := k1util.PubKeyBytesToCosmos(ev.DelegatorCmpPubkey)
if err != nil {
return errors.Wrap(err, "depositor pubkey to cosmos")
}
Expand Down
2 changes: 1 addition & 1 deletion client/x/evmstaking/keeper/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

func (k Keeper) ProcessCreateValidator(ctx context.Context, ev *bindings.IPTokenStakingCreateValidator) error {
// When creating a validator, it's self-delegation. Thus, validator pubkey is also delegation pubkey.
validatorPubkey, err := k1util.PubKeyBytesToCosmos(ev.ValidatorPubkey)
validatorPubkey, err := k1util.PubKeyBytesToCosmos(ev.ValidatorCmpPubkey)
if err != nil {
return errors.Wrap(err, "validator pubkey to cosmos")
}
Expand Down
4 changes: 2 additions & 2 deletions client/x/evmstaking/keeper/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ func (k Keeper) EnqueueEligiblePartialWithdrawal(ctx context.Context, withdrawal
}

func (k Keeper) ProcessWithdraw(ctx context.Context, ev *bindings.IPTokenStakingWithdraw) error {
depositorPubkey, err := k1util.PubKeyBytesToCosmos(ev.DepositorPubkey)
depositorPubkey, err := k1util.PubKeyBytesToCosmos(ev.DelegatorCmpPubkey)
if err != nil {
return errors.Wrap(err, "depositor pubkey to cosmos")
}

validatorPubkey, err := k1util.PubKeyBytesToCosmos(ev.ValidatorPubkey)
validatorPubkey, err := k1util.PubKeyBytesToCosmos(ev.ValidatorCmpPubkey)
if err != nil {
return errors.Wrap(err, "validator pubkey to cosmos")
}
Expand Down
200 changes: 101 additions & 99 deletions contracts/bindings/iptokenstaking.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/iptokenstaking_more.go

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions contracts/bindings/iptokenstaking_storage_layout.json
Original file line number Diff line number Diff line change
@@ -1,71 +1,71 @@
{
"storage": [
{
"astId": 2581,
"astId": 42049,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "minStakeAmount",
"offset": 0,
"slot": "0",
"type": "t_uint256"
},
{
"astId": 2584,
"astId": 42052,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "minUnstakeAmount",
"offset": 0,
"slot": "1",
"type": "t_uint256"
},
{
"astId": 2587,
"astId": 42055,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "minRedelegateAmount",
"offset": 0,
"slot": "2",
"type": "t_uint256"
},
{
"astId": 2590,
"astId": 42058,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "withdrawalAddressChangeInterval",
"offset": 0,
"slot": "3",
"type": "t_uint256"
},
{
"astId": 2596,
"astId": 42064,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "validatorMetadata",
"offset": 0,
"slot": "4",
"type": "t_mapping(t_bytes_memory_ptr,t_struct(ValidatorMetadata)2257_storage)"
"type": "t_mapping(t_bytes_memory_ptr,t_struct(ValidatorMetadata)41288_storage)"
},
{
"astId": 2601,
"astId": 42069,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "delegatorTotalStakes",
"offset": 0,
"slot": "5",
"type": "t_mapping(t_bytes_memory_ptr,t_uint256)"
},
{
"astId": 2608,
"astId": 42076,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "delegatorValidatorStakes",
"offset": 0,
"slot": "6",
"type": "t_mapping(t_bytes_memory_ptr,t_mapping(t_bytes_memory_ptr,t_uint256))"
},
{
"astId": 2614,
"astId": 42082,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "delegatorOperators",
"offset": 0,
"slot": "7",
"type": "t_mapping(t_bytes_memory_ptr,t_struct(AddressSet)1954_storage)"
"type": "t_mapping(t_bytes_memory_ptr,t_struct(AddressSet)2028_storage)"
},
{
"astId": 2619,
"astId": 42087,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "withdrawalAddressChange",
"offset": 0,
Expand Down Expand Up @@ -109,19 +109,19 @@
"numberOfBytes": "32",
"value": "t_mapping(t_bytes_memory_ptr,t_uint256)"
},
"t_mapping(t_bytes_memory_ptr,t_struct(AddressSet)1954_storage)": {
"t_mapping(t_bytes_memory_ptr,t_struct(AddressSet)2028_storage)": {
"encoding": "mapping",
"key": "t_bytes_memory_ptr",
"label": "mapping(bytes => struct EnumerableSet.AddressSet)",
"numberOfBytes": "32",
"value": "t_struct(AddressSet)1954_storage"
"value": "t_struct(AddressSet)2028_storage"
},
"t_mapping(t_bytes_memory_ptr,t_struct(ValidatorMetadata)2257_storage)": {
"t_mapping(t_bytes_memory_ptr,t_struct(ValidatorMetadata)41288_storage)": {
"encoding": "mapping",
"key": "t_bytes_memory_ptr",
"label": "mapping(bytes => struct IIPTokenStaking.ValidatorMetadata)",
"numberOfBytes": "32",
"value": "t_struct(ValidatorMetadata)2257_storage"
"value": "t_struct(ValidatorMetadata)41288_storage"
},
"t_mapping(t_bytes_memory_ptr,t_uint256)": {
"encoding": "mapping",
Expand All @@ -135,36 +135,36 @@
"label": "string",
"numberOfBytes": "32"
},
"t_struct(AddressSet)1954_storage": {
"t_struct(AddressSet)2028_storage": {
"encoding": "inplace",
"label": "struct EnumerableSet.AddressSet",
"numberOfBytes": "64",
"members": [
{
"astId": 1953,
"astId": 2027,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "_inner",
"offset": 0,
"slot": "0",
"type": "t_struct(Set)1639_storage"
"type": "t_struct(Set)1713_storage"
}
]
},
"t_struct(Set)1639_storage": {
"t_struct(Set)1713_storage": {
"encoding": "inplace",
"label": "struct EnumerableSet.Set",
"numberOfBytes": "64",
"members": [
{
"astId": 1634,
"astId": 1708,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "_values",
"offset": 0,
"slot": "0",
"type": "t_array(t_bytes32)dyn_storage"
},
{
"astId": 1638,
"astId": 1712,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "_positions",
"offset": 0,
Expand All @@ -173,53 +173,53 @@
}
]
},
"t_struct(ValidatorMetadata)2257_storage": {
"t_struct(ValidatorMetadata)41288_storage": {
"encoding": "inplace",
"label": "struct IIPTokenStaking.ValidatorMetadata",
"numberOfBytes": "128",
"members": [
{
"astId": 2246,
"astId": 41277,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "exists",
"offset": 0,
"slot": "0",
"type": "t_bool"
},
{
"astId": 2248,
"astId": 41279,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "moniker",
"offset": 0,
"slot": "1",
"type": "t_string_storage"
},
{
"astId": 2250,
"astId": 41281,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "totalStake",
"offset": 0,
"slot": "2",
"type": "t_uint256"
},
{
"astId": 2252,
"astId": 41283,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "commissionRate",
"offset": 0,
"slot": "3",
"type": "t_uint32"
},
{
"astId": 2254,
"astId": 41285,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "maxCommissionRate",
"offset": 4,
"slot": "3",
"type": "t_uint32"
},
{
"astId": 2256,
"astId": 41287,
"contract": "src/protocol/IPTokenStaking.sol:IPTokenStaking",
"label": "maxCommissionChangeRate",
"offset": 8,
Expand Down
7 changes: 7 additions & 0 deletions contracts/foundry.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[profile.default]
src = "src"
out = "out"
test = "test"
libs = ["node_modules"]
optimizer = true
optimizer_runs = 20000
solc = "0.8.23"
via_ir = true

extra_output = ["storageLayout"]

remappings = [
"forge-std/=node_modules/forge-std/src",
Expand Down
Loading
Loading