The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/rosetta/services/call_service.go

569 lines
18 KiB

package services
import (
"context"
"encoding/json"
Mainnet Release Candidate 2023.1.2 (#4376) * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0 Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0. - [Release notes](https://github.com/ipld/go-ipld-prime/releases) - [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md) - [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0) --- updated-dependencies: - dependency-name: github.com/ipld/go-ipld-prime dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump golang.org/x/net from 0.3.0 to 0.7.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Small fixes. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * activate epoch * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review "--port flag". * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * Commented golangci. * staged stream sync v1.0 * fix protocol tests * fix spell * remove unused struct * fix rosetta test * add comments and refactor verify sig * add comments, remove extra function * add comment * refactor errors, rename metrics * refactor p2p host creation * fix initsync and host creation * fix short range hash chain * fix beacon node detection for p2p protocol * refactor stream peer cooldown and fix protocol beacon node field * refactor p2p host and routing * fix p2p discovery test issue * add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue * terminal print the peer id and proto id * fix boot complete message when node is shut down * add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue * fix self query issue * fix test NewDNSSyncingPeerProvider * [testnet] disable leader rotation * fix discovery issue for legacy sync * add watermark low/high options for p2p connection manager * add test for new conn manager flags * fix dedent * add comment to inform about p2p connection manager options * fix max height issue * add a separate log for get max height error * fix log * feat: triesInMemory flag * fix: panic if TriesInMemory is 1 to 2 * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed timers locks. * Removed fbft locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional logs. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * Fix formatting. * Rebased onto dev. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Fix review comment. * Go mod tidy. * Set to EpochTBD. * Fix tests. * [core] fix state handling of self destruct If a contract self destructs to self and then receives funds within the same transaction, it is possible for its stale state to be saved. This change removes that possibility by checking for deleted state objects before returning them. * Fixed race error. * rpc: add configurable http and `eth_call` timeout * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fixed code review. * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * staged stream sync v1.0 * refactor errors, rename metrics * fix p2p discovery test issue * add watermark low/high options for p2p connection manager * fix dedent * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Go mod tidy. * remove default timeouts * Rotate external leaders on non-beacon chains. * Fix nil panic. * Fixes. * Update singleton.go * evm: don't return extcode for validators Due to technical debt, validator information is stored in the code field of the address. The code field can be accessed in Solidity for an arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy` or helper commands (such as `address.code.Length`). The presence of this field is used by contract developers to (erroneously) deny smart contract access to other smart contracts (and therefore, validators). This PR fixes that oversight by returning the same values as other EOAs for known validator addresses. Obviously, it needs a hard fork that will be scheduled separately. * Fix context passing. * Clean up code. * Removed engine dependency. * Fix possible panic. * Clean up code. * Network type. * Fix tests. * Revert "Removed engine dependency." (#4392) * Revert "Fix tests." This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a. * Revert "Network type." This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76. * Revert "Clean up code." This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2. * Revert "Fix possible panic." This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085. * Revert "Removed engine dependency." This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859. * gitignore the cache folder (#4389) * stable localnet with external validator (#4388) * stable localnet with external validator * ignore deploy config file comments * reduce node launched in localnet * update makefile * localnet configuration - add more fn * fix validator information command typo --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Co-authored-by: frozen <355847+Frozen@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”> Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com> Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local> Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
"time"
"github.com/coinbase/rosetta-sdk-go/server"
"github.com/coinbase/rosetta-sdk-go/types"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
internal_common "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/rosetta/common"
rpc2 "github.com/harmony-one/harmony/rpc"
"github.com/pkg/errors"
)
var CallMethod = []string{
"hmyv2_call",
"hmyv2_getCode",
"hmyv2_getStorageAt",
"hmyv2_getDelegationsByDelegator",
"hmyv2_getDelegationsByDelegatorByBlockNumber",
"hmyv2_getDelegationsByValidator",
"hmyv2_getAllValidatorAddresses",
"hmyv2_getAllValidatorInformation",
"hmyv2_getAllValidatorInformationByBlockNumber",
"hmyv2_getElectedValidatorAddresses",
"hmyv2_getValidatorInformation",
"hmyv2_getCurrentUtilityMetrics",
"hmyv2_getMedianRawStakeSnapshot",
"hmyv2_getStakingNetworkInfo",
"hmyv2_getSuperCommittees",
}
type CallAPIService struct {
hmy *hmy.Harmony
publicContractAPI rpc.API
publicStakingAPI rpc.API
publicBlockChainAPI rpc.API
}
// Call implements the /call endpoint.
func (c *CallAPIService) Call(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
switch request.Method {
case "hmyv2_call":
return c.call(ctx, request)
case "hmyv2_getCode":
return c.getCode(ctx, request)
case "hmyv2_getStorageAt":
return c.getStorageAt(ctx, request)
case "hmyv2_getDelegationsByDelegator":
return c.getDelegationsByDelegator(ctx, request)
case "hmyv2_getDelegationsByDelegatorByBlockNumber":
return c.getDelegationsByDelegatorByBlockNumber(ctx, request)
case "hmyv2_getDelegationsByValidator":
return c.getDelegationsByValidator(ctx, request)
case "hmyv2_getAllValidatorAddresses":
return c.getAllValidatorAddresses(ctx)
case "hmyv2_getAllValidatorInformation":
return c.getAllValidatorInformation(ctx, request)
case "hmyv2_getAllValidatorInformationByBlockNumber":
return c.getAllValidatorInformationByBlockNumber(ctx, request)
case "hmyv2_getElectedValidatorAddresses":
return c.getElectedValidatorAddresses(ctx)
case "hmyv2_getValidatorInformation":
return c.getValidatorInformation(ctx, request)
case "hmyv2_getCurrentUtilityMetrics":
return c.getCurrentUtilityMetrics()
case "hmyv2_getMedianRawStakeSnapshot":
return c.getMedianRawStakeSnapshot()
case "hmyv2_getStakingNetworkInfo":
return c.getStakingNetworkInfo(ctx)
case "hmyv2_getSuperCommittees":
return c.getSuperCommittees()
}
return nil, common.NewError(common.ErrCallMethodInvalid, map[string]interface{}{
"message": "method not supported",
})
}
Mainnet Release Candidate 2023.1.2 (#4376) * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0 Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0. - [Release notes](https://github.com/ipld/go-ipld-prime/releases) - [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md) - [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0) --- updated-dependencies: - dependency-name: github.com/ipld/go-ipld-prime dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump golang.org/x/net from 0.3.0 to 0.7.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Small fixes. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * activate epoch * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review "--port flag". * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * Commented golangci. * staged stream sync v1.0 * fix protocol tests * fix spell * remove unused struct * fix rosetta test * add comments and refactor verify sig * add comments, remove extra function * add comment * refactor errors, rename metrics * refactor p2p host creation * fix initsync and host creation * fix short range hash chain * fix beacon node detection for p2p protocol * refactor stream peer cooldown and fix protocol beacon node field * refactor p2p host and routing * fix p2p discovery test issue * add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue * terminal print the peer id and proto id * fix boot complete message when node is shut down * add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue * fix self query issue * fix test NewDNSSyncingPeerProvider * [testnet] disable leader rotation * fix discovery issue for legacy sync * add watermark low/high options for p2p connection manager * add test for new conn manager flags * fix dedent * add comment to inform about p2p connection manager options * fix max height issue * add a separate log for get max height error * fix log * feat: triesInMemory flag * fix: panic if TriesInMemory is 1 to 2 * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed timers locks. * Removed fbft locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional logs. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * Fix formatting. * Rebased onto dev. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Fix review comment. * Go mod tidy. * Set to EpochTBD. * Fix tests. * [core] fix state handling of self destruct If a contract self destructs to self and then receives funds within the same transaction, it is possible for its stale state to be saved. This change removes that possibility by checking for deleted state objects before returning them. * Fixed race error. * rpc: add configurable http and `eth_call` timeout * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fixed code review. * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * staged stream sync v1.0 * refactor errors, rename metrics * fix p2p discovery test issue * add watermark low/high options for p2p connection manager * fix dedent * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Go mod tidy. * remove default timeouts * Rotate external leaders on non-beacon chains. * Fix nil panic. * Fixes. * Update singleton.go * evm: don't return extcode for validators Due to technical debt, validator information is stored in the code field of the address. The code field can be accessed in Solidity for an arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy` or helper commands (such as `address.code.Length`). The presence of this field is used by contract developers to (erroneously) deny smart contract access to other smart contracts (and therefore, validators). This PR fixes that oversight by returning the same values as other EOAs for known validator addresses. Obviously, it needs a hard fork that will be scheduled separately. * Fix context passing. * Clean up code. * Removed engine dependency. * Fix possible panic. * Clean up code. * Network type. * Fix tests. * Revert "Removed engine dependency." (#4392) * Revert "Fix tests." This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a. * Revert "Network type." This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76. * Revert "Clean up code." This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2. * Revert "Fix possible panic." This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085. * Revert "Removed engine dependency." This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859. * gitignore the cache folder (#4389) * stable localnet with external validator (#4388) * stable localnet with external validator * ignore deploy config file comments * reduce node launched in localnet * update makefile * localnet configuration - add more fn * fix validator information command typo --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Co-authored-by: frozen <355847+Frozen@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”> Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com> Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local> Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
func NewCallAPIService(
hmy *hmy.Harmony,
limiterEnable bool,
rateLimit int,
evmCallTimeout time.Duration,
) server.CallAPIServicer {
return &CallAPIService{
hmy: hmy,
Mainnet Release Candidate 2023.1.2 (#4376) * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * Bump github.com/aws/aws-sdk-go from 1.33.0 to 1.34.0 Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.33.0 to 1.34.0. - [Release notes](https://github.com/aws/aws-sdk-go/releases) - [Changelog](https://github.com/aws/aws-sdk-go/blob/v1.34.0/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-go/compare/v1.33.0...v1.34.0) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com> * Bump github.com/ipld/go-ipld-prime from 0.9.0 to 0.19.0 Bumps [github.com/ipld/go-ipld-prime](https://github.com/ipld/go-ipld-prime) from 0.9.0 to 0.19.0. - [Release notes](https://github.com/ipld/go-ipld-prime/releases) - [Changelog](https://github.com/ipld/go-ipld-prime/blob/master/CHANGELOG.md) - [Commits](https://github.com/ipld/go-ipld-prime/compare/v0.9.0...v0.19.0) --- updated-dependencies: - dependency-name: github.com/ipld/go-ipld-prime dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Bump golang.org/x/net from 0.3.0 to 0.7.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.3.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/compare/v0.3.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> * Small fixes. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * activate epoch * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review "--port flag". * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * Commented golangci. * staged stream sync v1.0 * fix protocol tests * fix spell * remove unused struct * fix rosetta test * add comments and refactor verify sig * add comments, remove extra function * add comment * refactor errors, rename metrics * refactor p2p host creation * fix initsync and host creation * fix short range hash chain * fix beacon node detection for p2p protocol * refactor stream peer cooldown and fix protocol beacon node field * refactor p2p host and routing * fix p2p discovery test issue * add MaxAdvertiseWaitTime to handle advertisements interval and address stream connection issue * terminal print the peer id and proto id * fix boot complete message when node is shut down * add new config option ( ForceReachabilityPublic ) to fix local-net consensus issue * fix self query issue * fix test NewDNSSyncingPeerProvider * [testnet] disable leader rotation * fix discovery issue for legacy sync * add watermark low/high options for p2p connection manager * add test for new conn manager flags * fix dedent * add comment to inform about p2p connection manager options * fix max height issue * add a separate log for get max height error * fix log * feat: triesInMemory flag * fix: panic if TriesInMemory is 1 to 2 * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed timers locks. * Removed fbft locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional logs. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * Fix formatting. * Rebased onto dev. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * comment activation * 295 epoch * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Fix review comment. * Go mod tidy. * Set to EpochTBD. * Fix tests. * [core] fix state handling of self destruct If a contract self destructs to self and then receives funds within the same transaction, it is possible for its stale state to be saved. This change removes that possibility by checking for deleted state objects before returning them. * Fixed race error. * rpc: add configurable http and `eth_call` timeout * remove default timeouts * store the evm call timeout in rosetta object * [cmd] actually apply ToRPCServerConfig * Removed unused method. * Rotate external leaders on non-beacon chains. * Fix nil panic. * in progress. * in progress. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fixed code review. * Fix review comments. * Returned locks in rotateLeader. * Rebased onto dev. * staged stream sync v1.0 * refactor errors, rename metrics * fix p2p discovery test issue * add watermark low/high options for p2p connection manager * fix dedent * in progress. * consensus check is forked * fix * Cleanup and fix update pub keys. * fix fix fix fix fix * activate epoch * EpochTBD for leader rotation epoch. * 295 epoch * Decider no longer requires public keys as a dependency. (#4289) * Consensus doesn't require anymore `Node` as a circular dependency. * Proper blockchain initialization. * Rwlock consensus. * Removed channels. * Removed view change locks. * Removed multiSigMutex locks. * Removed leader locks. * Removed additional locks and isViewChange. * Added locks detected by race. * Added locks detected by race. * Locks for start. * Removed additional locks. * Removed additional locks. * Make func private. * Make VerifyBlock private. * Make IsLeader private. * Make ParseFBFTMessage private. * Fix remove locks. * Added additional locks. * Added additional locks. * Added readSignatureBitmapPayload locks. * Added HandleMessageUpdate locks. * Added LastMile locks. * Locks for IsValidatorInCommittee. * Fixed locks. * Fixed tests. * Fixed lock. * Rebased over leader rotation. * in progress. * consensus check is forked * update master * fix leader * check leader for N blocks * fix * fix * Cleanup and fix update pub keys. * Rotate leader. * fix fix fix fix fix * Cleaned. * Cache for `GetLeaderPubKeyFromCoinbase`, removed `NthNextHmyExt`. * Fix failed tests. * Fixed code review. * Fix review comments. * Merged leader rotation. * Rebased on dev. * Rebased on dev. * Fix usage of private methods. * Fix usage of private methods. * Fix usage of private methods. * Removed deadcode, LockedFBFTPhase. * Fix review comment. * Go mod tidy. * remove default timeouts * Rotate external leaders on non-beacon chains. * Fix nil panic. * Fixes. * Update singleton.go * evm: don't return extcode for validators Due to technical debt, validator information is stored in the code field of the address. The code field can be accessed in Solidity for an arbitrary address using `extcodesize`, `extcodehash`, and `extcodecopy` or helper commands (such as `address.code.Length`). The presence of this field is used by contract developers to (erroneously) deny smart contract access to other smart contracts (and therefore, validators). This PR fixes that oversight by returning the same values as other EOAs for known validator addresses. Obviously, it needs a hard fork that will be scheduled separately. * Fix context passing. * Clean up code. * Removed engine dependency. * Fix possible panic. * Clean up code. * Network type. * Fix tests. * Revert "Removed engine dependency." (#4392) * Revert "Fix tests." This reverts commit 597ba2d6f1ed54ff599b9d9b8940c7285ab1277a. * Revert "Network type." This reverts commit 5e1878aedca3989dc0f34161dae1833e43ca6a76. * Revert "Clean up code." This reverts commit 15885f4c9b9263746827172b4f4f56d0926d18e2. * Revert "Fix possible panic." This reverts commit 1a70d5eb66cdbf8a23791806b71a323eed320085. * Revert "Removed engine dependency." This reverts commit 8c2ff803f709f944cfc8b1278f35cf5b2cacf859. * gitignore the cache folder (#4389) * stable localnet with external validator (#4388) * stable localnet with external validator * ignore deploy config file comments * reduce node launched in localnet * update makefile * localnet configuration - add more fn * fix validator information command typo --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Co-authored-by: frozen <355847+Frozen@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: “GheisMohammadi” <“Gheis.Mohammadi@gmail.com”> Co-authored-by: “GheisMohammadi” <36589218+GheisMohammadi@users.noreply.github.com> Co-authored-by: Sun Hyuk Ahn <sunhyukahn@Suns-MacBook-Pro.local> Co-authored-by: Soph <35721420+sophoah@users.noreply.github.com>
2 years ago
publicContractAPI: rpc2.NewPublicContractAPI(hmy, rpc2.V2, limiterEnable, rateLimit, evmCallTimeout),
publicStakingAPI: rpc2.NewPublicStakingAPI(hmy, rpc2.V2),
publicBlockChainAPI: rpc2.NewPublicBlockchainAPI(hmy, rpc2.V2, limiterEnable, rateLimit),
}
}
func (c *CallAPIService) getSuperCommittees() (*types.CallResponse, *types.Error) {
committees, err := c.hmy.GetSuperCommittees()
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get super committees error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": committees,
},
}, nil
}
func (c *CallAPIService) getStakingNetworkInfo(
ctx context.Context,
) (*types.CallResponse, *types.Error) {
publicBlockChainAPI := c.publicBlockChainAPI.Service.(*rpc2.PublicBlockchainService)
resp, err := publicBlockChainAPI.GetStakingNetworkInfo(ctx)
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get staking network info error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": resp,
},
}, nil
}
func (c *CallAPIService) getMedianRawStakeSnapshot() (*types.CallResponse, *types.Error) {
snapshot, err := c.hmy.GetMedianRawStakeSnapshot()
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get median raw stake snapshot error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": snapshot,
},
}, nil
}
func (c *CallAPIService) getCurrentUtilityMetrics() (*types.CallResponse, *types.Error) {
metric, err := c.hmy.GetCurrentUtilityMetrics()
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get current utility metrics error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": metric,
},
}, nil
}
func (c *CallAPIService) getValidatorInformation(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
stakingAPI := c.publicStakingAPI.Service.(*rpc2.PublicStakingService)
args := GetValidatorInformationRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
resp, err := stakingAPI.GetValidatorInformation(ctx, args.ValidatorAddr)
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get validator information error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": resp,
},
}, nil
}
func (c *CallAPIService) getElectedValidatorAddresses(
ctx context.Context,
) (*types.CallResponse, *types.Error) {
stakingAPI := c.publicStakingAPI.Service.(*rpc2.PublicStakingService)
addresses, err := stakingAPI.GetElectedValidatorAddresses(ctx)
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get elected validator addresses error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": addresses,
},
}, nil
}
func (c *CallAPIService) getAllValidatorInformationByBlockNumber(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
stakingAPI := c.publicStakingAPI.Service.(*rpc2.PublicStakingService)
args := GetAllValidatorInformationByBlockNumberRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
resp, err := stakingAPI.GetAllValidatorInformationByBlockNumber(ctx, args.PageNumber, rpc2.BlockNumber(args.BlockNumber))
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get all validator information by block number error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": resp,
},
}, nil
}
func (c *CallAPIService) getAllValidatorInformation(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
stakingAPI := c.publicStakingAPI.Service.(*rpc2.PublicStakingService)
args := GetAllValidatorInformationRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
resp, err := stakingAPI.GetAllValidatorInformation(ctx, args.PageNumber)
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get all validator information error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": resp,
},
}, nil
}
func (c *CallAPIService) getAllValidatorAddresses(
ctx context.Context,
) (*types.CallResponse, *types.Error) {
stakingAPI := c.publicStakingAPI.Service.(*rpc2.PublicStakingService)
addresses, err := stakingAPI.GetAllValidatorAddresses(ctx)
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get all validator addresses error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": addresses,
},
}, nil
}
func (c *CallAPIService) getDelegationsByValidator(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
stakingAPI := c.publicStakingAPI.Service.(*rpc2.PublicStakingService)
args := GetDelegationsByValidatorRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
resp, err := stakingAPI.GetDelegationsByValidator(ctx, args.ValidatorAddr)
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get delegations by validator error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": resp,
},
}, nil
}
func (c *CallAPIService) getDelegationsByDelegatorByBlockNumber(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
stakingAPI := c.publicStakingAPI.Service.(*rpc2.PublicStakingService)
args := GetDelegationByDelegatorAddrAndBlockNumRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
addr, err := internal_common.Bech32ToAddress(args.DelegatorAddr)
if err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "delegator address error").Error(),
})
}
addOrList := rpc2.AddressOrList{Address: &addr}
resp, err := stakingAPI.GetDelegationsByDelegatorByBlockNumber(ctx, addOrList, rpc2.BlockNumber(args.BlockNum))
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get delegations by delegator and number error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": resp,
},
}, nil
}
func (c *CallAPIService) getDelegationsByDelegator(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
stakingAPI := c.publicStakingAPI.Service.(*rpc2.PublicStakingService)
args := GetDelegationsByDelegatorAddrRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
resp, err := stakingAPI.GetDelegationsByDelegator(ctx, args.DelegatorAddr)
if err != nil {
return nil, common.NewError(common.ErrGetStakingInfo, map[string]interface{}{
"message": errors.WithMessage(err, "get delegations by delegator error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": resp,
},
}, nil
}
func (c *CallAPIService) getStorageAt(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
contractAPI := c.publicContractAPI.Service.(*rpc2.PublicContractService)
args := GetStorageAtRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
res, err := contractAPI.GetStorageAt(ctx, args.Addr, args.Key, rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(args.BlockNum)))
if err != nil {
return nil, common.NewError(common.ErrCallExecute, map[string]interface{}{
"message": errors.WithMessage(err, "get storage at error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": res.String(),
},
}, nil
}
func (c *CallAPIService) getCode(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
contractAPI := c.publicContractAPI.Service.(*rpc2.PublicContractService)
args := GetCodeRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
code, err := contractAPI.GetCode(ctx, args.Addr, rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(args.BlockNum)))
if err != nil {
return nil, common.NewError(common.ErrCallExecute, map[string]interface{}{
"message": errors.WithMessage(err, "get code error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": code.String(),
},
}, nil
}
func (c *CallAPIService) call(
ctx context.Context, request *types.CallRequest,
) (*types.CallResponse, *types.Error) {
contractAPI := c.publicContractAPI.Service.(*rpc2.PublicContractService)
args := CallRequest{}
if err := args.UnmarshalFromInterface(request.Parameters); err != nil {
return nil, common.NewError(common.ErrCallParametersInvalid, map[string]interface{}{
"message": errors.WithMessage(err, "invalid parameters").Error(),
})
}
data, err := contractAPI.Call(ctx, args.CallArgs, rpc.BlockNumberOrHashWithNumber(rpc.BlockNumber(args.BlockNum)))
if err != nil {
return nil, common.NewError(common.ErrCallExecute, map[string]interface{}{
"message": errors.WithMessage(err, "call smart contract error").Error(),
})
}
return &types.CallResponse{
Result: map[string]interface{}{
"result": data.String(),
},
}, nil
}
type CallRequest struct {
rpc2.CallArgs
BlockNum int64 `json:"block_num"`
}
func (cr *CallRequest) UnmarshalFromInterface(args interface{}) error {
var callRequest CallRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &callRequest); err != nil {
return err
}
*cr = callRequest
return nil
}
type GetCodeRequest struct {
Addr string `json:"addr"`
BlockNum int64 `json:"block_num"`
}
func (cr *GetCodeRequest) UnmarshalFromInterface(args interface{}) error {
var getCodeRequest GetCodeRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &getCodeRequest); err != nil {
return err
}
*cr = getCodeRequest
return nil
}
type GetStorageAtRequest struct {
Addr string `json:"addr"`
Key string `json:"key"`
BlockNum int64 `json:"block_num"`
}
func (sr *GetStorageAtRequest) UnmarshalFromInterface(args interface{}) error {
var getStorageAt GetStorageAtRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &getStorageAt); err != nil {
return err
}
*sr = getStorageAt
return nil
}
type GetDelegationsByDelegatorAddrRequest struct {
DelegatorAddr string `json:"delegator_addr"`
}
func (r *GetDelegationsByDelegatorAddrRequest) UnmarshalFromInterface(args interface{}) error {
var getDelegationsByDelegatorAddrRequest GetDelegationsByDelegatorAddrRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &getDelegationsByDelegatorAddrRequest); err != nil {
return err
}
*r = getDelegationsByDelegatorAddrRequest
return nil
}
type GetDelegationByDelegatorAddrAndBlockNumRequest struct {
DelegatorAddr string `json:"delegator_addr"`
BlockNum int64 `json:"block_num"`
}
func (r *GetDelegationByDelegatorAddrAndBlockNumRequest) UnmarshalFromInterface(args interface{}) error {
var getDelegationByDelegatorAddrAndBlockNumRequest GetDelegationByDelegatorAddrAndBlockNumRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &getDelegationByDelegatorAddrAndBlockNumRequest); err != nil {
return err
}
*r = getDelegationByDelegatorAddrAndBlockNumRequest
return nil
}
type GetDelegationsByValidatorRequest struct {
ValidatorAddr string `json:"validator_addr"`
}
func (r *GetDelegationsByValidatorRequest) UnmarshalFromInterface(args interface{}) error {
var getDelegationsByValidatorRequest GetDelegationsByValidatorRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &getDelegationsByValidatorRequest); err != nil {
return err
}
*r = getDelegationsByValidatorRequest
return nil
}
type GetAllValidatorInformationRequest struct {
PageNumber int `json:"page_number"`
}
func (r *GetAllValidatorInformationRequest) UnmarshalFromInterface(args interface{}) error {
var getAllValidatorInformationRequest GetAllValidatorInformationRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &getAllValidatorInformationRequest); err != nil {
return err
}
*r = getAllValidatorInformationRequest
return nil
}
type GetAllValidatorInformationByBlockNumberRequest struct {
PageNumber int `json:"page_number"`
BlockNumber int64 `json:"block_number"`
}
func (r *GetAllValidatorInformationByBlockNumberRequest) UnmarshalFromInterface(args interface{}) error {
var getAllValidatorInformationByBlockNumber GetAllValidatorInformationByBlockNumberRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &getAllValidatorInformationByBlockNumber); err != nil {
return err
}
*r = getAllValidatorInformationByBlockNumber
return nil
}
type GetValidatorInformationRequest struct {
ValidatorAddr string `json:"validator_addr"`
}
func (r *GetValidatorInformationRequest) UnmarshalFromInterface(args interface{}) error {
var getValidatorInformationRequest GetValidatorInformationRequest
data, err := json.Marshal(args)
if err != nil {
return err
}
if err := json.Unmarshal(data, &getValidatorInformationRequest); err != nil {
return err
}
*r = getValidatorInformationRequest
return nil
}