-
Notifications
You must be signed in to change notification settings - Fork 324
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
[staking] ReadState API support Candidate ID #4276
Conversation
can you rebase this PR? i think lots of code has already checked in |
a25cf86
to
5ee2ecf
Compare
if err != nil { | ||
return nil, 0, err | ||
} | ||
cand = c.GetByIdentifier(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible Id
and OwnerAddress
both exist? if yes, which one takes precedence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, now if both conditions are set, it means that they need to be fulfilled at mean while.
@@ -76,7 +76,7 @@ func (r *CandidateByAddressStateContext) EncodeToEth(resp *iotexapi.ReadStateRes | |||
|
|||
data, err := r.Method.Outputs.Pack(cand) | |||
if err != nil { | |||
return "", nil | |||
return "", err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this is a typo/bug in current code? we don't have a test for this? add one if not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, existed typo, but it's not easy to cause error for abi pack
As discussed offline, let's change the logic of creating delegate to:
such that an account who doesn't own a delegate could always create a delegate. Make sure the scenario works in this PR. |
335baa3
to
b535120
Compare
agreed, discussed offline we can use logic similar to |
c1d6b3f
to
78350fc
Compare
Quality Gate failedFailed conditions |
return owner, nil | ||
} | ||
h := append(owner.Bytes(), byteutil.Uint64ToBytesBigEndian(height)...) | ||
for i := 0; i < 1000; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you quickly test how much time this 1000 loop will take? I'm thinking 128 should be enough to generate a diff ID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goos: darwin
goarch: arm64
pkg: github.com/iotexproject/iotex-core/action/protocol/staking
BenchmarkLoop-10 2366 489271 ns/op 33397 B/op 1024 allocs/op
around 0.5ms, benchmark exclude query from csm. I think it's acceptable
@@ -478,11 +478,28 @@ func (c *candSR) readStateCandidateByName(ctx context.Context, req *iotexapi.Rea | |||
} | |||
|
|||
func (c *candSR) readStateCandidateByAddress(ctx context.Context, req *iotexapi.ReadStakingDataRequest_CandidateByAddress) (*iotextypes.CandidateV2, uint64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deprecate this api
Description
Due to the introduction of a new
ID
as a unique identifier by the Candidate, the following modifications need to be made to the API:candidateByAddress
,candidateByName
, andcandidates
APIs to v3, adding 'id' to the returned results.candidateByID
; the original meaning of thecandidateByAddress
is to query based on the owner's address.It's based on iotexproject/iotex-proto#151
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: