diff --git a/go.mod b/go.mod index da46b1d2016..8ce4086f3b7 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/coreos/go-semver v0.3.0 github.com/ethereum/go-ethereum v1.14.3 github.com/ethersphere/go-price-oracle-abi v0.2.0 - github.com/ethersphere/go-storage-incentives-abi v0.8.6 + github.com/ethersphere/go-storage-incentives-abi v0.9.0-rc3 github.com/ethersphere/go-sw3-abi v0.6.5 github.com/ethersphere/langos v1.0.0 github.com/go-playground/validator/v10 v10.11.1 diff --git a/go.sum b/go.sum index 956c674a405..09b91a216ae 100644 --- a/go.sum +++ b/go.sum @@ -236,8 +236,8 @@ github.com/ethereum/go-ethereum v1.14.3 h1:5zvnAqLtnCZrU9uod1JCvHWJbPMURzYFHfc2e github.com/ethereum/go-ethereum v1.14.3/go.mod h1:1STrq471D0BQbCX9He0hUj4bHxX2k6mt5nOQJhDNOJ8= github.com/ethersphere/go-price-oracle-abi v0.2.0 h1:wtIcYLgNZHY4BjYwJCnu93SvJdVAZVvBaKinspyyHvQ= github.com/ethersphere/go-price-oracle-abi v0.2.0/go.mod h1:sI/Qj4/zJ23/b1enzwMMv0/hLTpPNVNacEwCWjo6yBk= -github.com/ethersphere/go-storage-incentives-abi v0.8.6 h1:M9WwEtWoxVHKehBAoPMzQhXlzlBetuXsrGgoFvM5I8Y= -github.com/ethersphere/go-storage-incentives-abi v0.8.6/go.mod h1:SXvJVtM4sEsaSKD0jc1ClpDLw8ErPoROZDme4Wrc/Nc= +github.com/ethersphere/go-storage-incentives-abi v0.9.0-rc3 h1:TCCGtf1jODBUusTiH94Nhgw03apgchQZaJ03L/vt4z4= +github.com/ethersphere/go-storage-incentives-abi v0.9.0-rc3/go.mod h1:SXvJVtM4sEsaSKD0jc1ClpDLw8ErPoROZDme4Wrc/Nc= github.com/ethersphere/go-sw3-abi v0.6.5 h1:M5dcIe1zQYvGpY2K07UNkNU9Obc4U+A1fz68Ho/Q+XE= github.com/ethersphere/go-sw3-abi v0.6.5/go.mod h1:BmpsvJ8idQZdYEtWnvxA8POYQ8Rl/NhyCdF0zLMOOJU= github.com/ethersphere/langos v1.0.0 h1:NBtNKzXTTRSue95uOlzPN4py7Aofs0xWPzyj4AI1Vcc= diff --git a/pkg/storageincentives/redistribution/redistribution.go b/pkg/storageincentives/redistribution/redistribution.go index 42fa4ee6cf1..c09e4e94222 100644 --- a/pkg/storageincentives/redistribution/redistribution.go +++ b/pkg/storageincentives/redistribution/redistribution.go @@ -116,7 +116,7 @@ func (c *contract) Claim(ctx context.Context, proofs ChunkInclusionProofs) (comm // Commit submits the obfusHash hash by sending a transaction to the blockchain. func (c *contract) Commit(ctx context.Context, obfusHash []byte, round uint64) (common.Hash, error) { - callData, err := c.incentivesContractABI.Pack("commit", common.BytesToHash(obfusHash), common.BytesToHash(c.overlay.Bytes()), round) + callData, err := c.incentivesContractABI.Pack("commit", common.BytesToHash(obfusHash), round) if err != nil { return common.Hash{}, err } @@ -131,7 +131,7 @@ func (c *contract) Commit(ctx context.Context, obfusHash []byte, round uint64) ( } txHash, err := c.sendAndWait(ctx, request, 50) if err != nil { - return txHash, fmt.Errorf("commit: obfusHash %v overlay %v: %w", common.BytesToHash(obfusHash), common.BytesToHash(c.overlay.Bytes()), err) + return txHash, fmt.Errorf("commit: obfusHash %v: %w", common.BytesToHash(obfusHash), err) } return txHash, nil @@ -139,7 +139,7 @@ func (c *contract) Commit(ctx context.Context, obfusHash []byte, round uint64) ( // Reveal submits the storageDepth, reserveCommitmentHash and RandomNonce in a transaction to blockchain. func (c *contract) Reveal(ctx context.Context, storageDepth uint8, reserveCommitmentHash []byte, RandomNonce []byte) (common.Hash, error) { - callData, err := c.incentivesContractABI.Pack("reveal", common.BytesToHash(c.overlay.Bytes()), storageDepth, common.BytesToHash(reserveCommitmentHash), common.BytesToHash(RandomNonce)) + callData, err := c.incentivesContractABI.Pack("reveal", storageDepth, common.BytesToHash(reserveCommitmentHash), common.BytesToHash(RandomNonce)) if err != nil { return common.Hash{}, err } diff --git a/pkg/storageincentives/redistribution/redistribution_test.go b/pkg/storageincentives/redistribution/redistribution_test.go index 022e88fc3bf..8080fdb9770 100644 --- a/pkg/storageincentives/redistribution/redistribution_test.go +++ b/pkg/storageincentives/redistribution/redistribution_test.go @@ -267,7 +267,7 @@ func TestRedistribution(t *testing.T) { var obfus [32]byte testobfus := common.Hex2Bytes("hash") copy(obfus[:], testobfus) - expectedCallData, err := redistributionContractABI.Pack("commit", obfus, common.BytesToHash(owner.Bytes()), uint64(0)) + expectedCallData, err := redistributionContractABI.Pack("commit", obfus, uint64(0)) if err != nil { t.Fatal(err) } @@ -310,7 +310,7 @@ func TestRedistribution(t *testing.T) { randomNonce := common.BytesToHash(common.Hex2Bytes("nonce")) depth := uint8(10) - expectedCallData, err := redistributionContractABI.Pack("reveal", common.BytesToHash(owner.Bytes()), depth, reserveCommitmentHash, randomNonce) + expectedCallData, err := redistributionContractABI.Pack("reveal", depth, reserveCommitmentHash, randomNonce) if err != nil { t.Fatal(err) } @@ -402,7 +402,7 @@ func TestRedistribution(t *testing.T) { t.Run("invalid call data", func(t *testing.T) { t.Parallel() - expectedCallData, err := redistributionContractABI.Pack("commit", common.BytesToHash(common.Hex2Bytes("some hash")), common.BytesToHash(common.Hex2Bytes("some address")), uint64(0)) + expectedCallData, err := redistributionContractABI.Pack("commit", common.BytesToHash(common.Hex2Bytes("some hash")), uint64(0)) if err != nil { t.Fatal(err) } diff --git a/pkg/storageincentives/staking/contract.go b/pkg/storageincentives/staking/contract.go index f5a340b2b93..9bee2c5170d 100644 --- a/pkg/storageincentives/staking/contract.go +++ b/pkg/storageincentives/staking/contract.go @@ -155,7 +155,7 @@ func (c *contract) sendTransaction(ctx context.Context, callData []byte, desc st } func (c *contract) sendDepositStakeTransaction(ctx context.Context, owner common.Address, stakedAmount *big.Int, nonce common.Hash) (*types.Receipt, error) { - callData, err := c.stakingContractABI.Pack("depositStake", owner, nonce, stakedAmount) + callData, err := c.stakingContractABI.Pack("manageStake", nonce, stakedAmount) if err != nil { return nil, err } @@ -171,7 +171,7 @@ func (c *contract) sendDepositStakeTransaction(ctx context.Context, owner common func (c *contract) getStake(ctx context.Context, overlay swarm.Address) (*big.Int, error) { var overlayAddr [32]byte copy(overlayAddr[:], overlay.Bytes()) - callData, err := c.stakingContractABI.Pack("stakeOfOverlay", overlayAddr) + callData, err := c.stakingContractABI.Pack("stakeOfAddress", overlayAddr) if err != nil { return nil, err } @@ -183,7 +183,7 @@ func (c *contract) getStake(ctx context.Context, overlay swarm.Address) (*big.In return nil, fmt.Errorf("get stake: overlayAddress %d: %w", overlay, err) } - results, err := c.stakingContractABI.Unpack("stakeOfOverlay", result) + results, err := c.stakingContractABI.Unpack("stakeOfAddress", result) if err != nil { return nil, err } @@ -300,7 +300,7 @@ func (c *contract) withdrawFromStake(ctx context.Context, stakedAmount *big.Int) var overlayAddr [32]byte copy(overlayAddr[:], c.overlay.Bytes()) - callData, err := c.stakingContractABI.Pack("withdrawFromStake", overlayAddr, stakedAmount) + callData, err := c.stakingContractABI.Pack("withdrawFromStake", stakedAmount) if err != nil { return nil, err } diff --git a/pkg/storageincentives/staking/contract_test.go b/pkg/storageincentives/staking/contract_test.go index 24133631b99..cc70a6fe32d 100644 --- a/pkg/storageincentives/staking/contract_test.go +++ b/pkg/storageincentives/staking/contract_test.go @@ -42,7 +42,7 @@ func TestDepositStake(t *testing.T) { totalAmount := big.NewInt(100000000000000000) prevStake := big.NewInt(0) - expectedCallData, err := stakingContractABI.Pack("depositStake", common.BytesToHash(owner.Bytes()), nonce, stakedAmount) + expectedCallData, err := stakingContractABI.Pack("manageStake", nonce, stakedAmount) if err != nil { t.Fatal(err) } @@ -59,7 +59,7 @@ func TestDepositStake(t *testing.T) { return txHashApprove, nil } if *request.To == stakingContractAddress { - if !bytes.Equal(expectedCallData[:100], request.Data[:100]) { + if !bytes.Equal(expectedCallData[:80], request.Data[:80]) { return common.Hash{}, fmt.Errorf("got wrong call data. wanted %x, got %x", expectedCallData, request.Data) } return txHashDeposited, nil @@ -103,7 +103,7 @@ func TestDepositStake(t *testing.T) { totalAmount := big.NewInt(100000000000000000) prevStake := big.NewInt(2) - expectedCallData, err := stakingContractABI.Pack("depositStake", common.BytesToHash(owner.Bytes()), nonce, big.NewInt(100000000000000000)) + expectedCallData, err := stakingContractABI.Pack("manageStake", nonce, big.NewInt(100000000000000000)) if err != nil { t.Fatal(err) } @@ -120,7 +120,7 @@ func TestDepositStake(t *testing.T) { return txHashApprove, nil } if *request.To == stakingContractAddress { - if !bytes.Equal(expectedCallData[:100], request.Data[:100]) { + if !bytes.Equal(expectedCallData[:80], request.Data[:80]) { return common.Hash{}, fmt.Errorf("got wrong call data. wanted %x, got %x", expectedCallData, request.Data) } return txHashDeposited, nil @@ -371,7 +371,7 @@ func TestDepositStake(t *testing.T) { return txHashApprove, nil } if *request.To == stakingContractAddress { - if !bytes.Equal(expectedCallData[:100], request.Data[:100]) { + if !bytes.Equal(expectedCallData[:80], request.Data[:80]) { return common.Hash{}, fmt.Errorf("got wrong call data. wanted %x, got %x", expectedCallData, request.Data) } return txHashDeposited, nil @@ -432,7 +432,7 @@ func TestDepositStake(t *testing.T) { return txHashApprove, nil } if *request.To == stakingContractAddress { - if !bytes.Equal(expectedCallData[:100], request.Data[:100]) { + if !bytes.Equal(expectedCallData[:80], request.Data[:80]) { return common.Hash{}, fmt.Errorf("got wrong call data. wanted %x, got %x", expectedCallData, request.Data) } return txHashDeposited, nil @@ -510,7 +510,7 @@ func TestGetStake(t *testing.T) { t.Parallel() prevStake := big.NewInt(0) - expectedCallData, err := stakingContractABI.Pack("stakeOfOverlay", common.BytesToHash(addr.Bytes())) + expectedCallData, err := stakingContractABI.Pack("stakeOfAddress", common.BytesToHash(addr.Bytes())) if err != nil { t.Fatal(err) } @@ -546,7 +546,7 @@ func TestGetStake(t *testing.T) { t.Run("error with unpacking", func(t *testing.T) { t.Parallel() - expectedCallData, err := stakingContractABI.Pack("stakeOfOverlay", common.BytesToHash(addr.Bytes())) + expectedCallData, err := stakingContractABI.Pack("stakeOfAddress", common.BytesToHash(addr.Bytes())) if err != nil { t.Fatal(err) } @@ -581,7 +581,7 @@ func TestGetStake(t *testing.T) { t.Parallel() prevStake := big.NewInt(0) - expectedCallData, err := stakingContractABI.Pack("stakeOfOverlay", common.BytesToHash(owner.Bytes())) + expectedCallData, err := stakingContractABI.Pack("stakeOfAddress", common.BytesToHash(owner.Bytes())) if err != nil { t.Fatal(err) } @@ -658,12 +658,12 @@ func TestWithdrawStake(t *testing.T) { t.Fatal(err) } - expectedCallDataForWithdraw, err := stakingContractABI.Pack("withdrawFromStake", common.BytesToHash(addr.Bytes()), stakedAmount) + expectedCallDataForWithdraw, err := stakingContractABI.Pack("withdrawFromStake", stakedAmount) if err != nil { t.Fatal(err) } - expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfOverlay", common.BytesToHash(addr.Bytes())) + expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfAddress", common.BytesToHash(addr.Bytes())) if err != nil { t.Fatal(err) } @@ -766,7 +766,7 @@ func TestWithdrawStake(t *testing.T) { invalidStakedAmount := big.NewInt(0) - expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfOverlay", common.BytesToHash(addr.Bytes())) + expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfAddress", common.BytesToHash(addr.Bytes())) if err != nil { t.Fatal(err) } @@ -805,12 +805,12 @@ func TestWithdrawStake(t *testing.T) { if err == nil { t.Fatal(err) } - _, err = stakingContractABI.Pack("withdrawFromStake", stakedAmount) + _, err = stakingContractABI.Pack("withdrawFromStake", common.BytesToHash(addr.Bytes()), stakedAmount) if err == nil { t.Fatal(err) } - _, err = stakingContractABI.Pack("stakeOfOverlay", stakedAmount) + _, err = stakingContractABI.Pack("stakeOfAddress", stakedAmount) if err == nil { t.Fatal(err) } @@ -826,12 +826,12 @@ func TestWithdrawStake(t *testing.T) { t.Fatal(err) } - expectedCallDataForWithdraw, err := stakingContractABI.Pack("withdrawFromStake", common.BytesToHash(addr.Bytes()), stakedAmount) + expectedCallDataForWithdraw, err := stakingContractABI.Pack("withdrawFromStake", stakedAmount) if err != nil { t.Fatal(err) } - expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfOverlay", common.BytesToHash(addr.Bytes())) + expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfAddress", common.BytesToHash(addr.Bytes())) if err != nil { t.Fatal(err) } @@ -899,12 +899,12 @@ func TestWithdrawStake(t *testing.T) { t.Fatal(err) } - expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfOverlay", common.BytesToHash(addr.Bytes())) + expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfAddress", common.BytesToHash(addr.Bytes())) if err != nil { t.Fatal(err) } - expectedCallDataForWithdraw, err := stakingContractABI.Pack("withdrawFromStake", common.BytesToHash(addr.Bytes()), stakedAmount) + expectedCallDataForWithdraw, err := stakingContractABI.Pack("withdrawFromStake", stakedAmount) if err != nil { t.Fatal(err) } @@ -1003,7 +1003,7 @@ func TestWithdrawStake(t *testing.T) { t.Fatal(err) } - expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfOverlay", common.BytesToHash(addr.Bytes())) + expectedCallDataForGetStake, err := stakingContractABI.Pack("stakeOfAddress", common.BytesToHash(addr.Bytes())) if err != nil { t.Fatal(err) }