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/rpc/preimages.go

36 lines
884 B

package rpc
import (
"context"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
)
type PreimagesService struct {
hmy *hmy.Harmony
}
// NewPreimagesAPI creates a new API for the RPC interface
func NewPreimagesAPI(hmy *hmy.Harmony, version string) rpc.API {
var service interface{} = &PreimagesService{hmy}
return rpc.API{
Namespace: version,
Version: APIVersion,
Service: service,
Public: true,
}
}
Hip30 : localnet account migration fix (#4508) * flags: set up preimage flags * hip30: set up preimage import, export, api * save pre-images by default * add pre images api * goimports * commit rpc preimages file * preimages: re-generate them using CLI * add metrics and numbers for pre-images * automate generation after import * move from rpc to core * goimports * add back core/preimages.go file * HIP-30: sharding configuration boilerplate * update comments * goimports * HIP-30: minimum validator commission of 7% Based on #4495, which must be merged before this PR. This PR should be rebased with dev after #4495 is merged to retain atomicity of changes by pull request. * goimports * HIP-30: Emission split implementation Note that the allocated split of the emission goes directly to the recipient (and not via the Reward). This is because rewards are indexed by validator and not by delegator, and the recipient may/may not have any delegations which we can reward. Even if one was guaranteed to exist, it would mess up the math of the validator. * set up mainnet recipient of emission split * HIP-30: Emission split addresses for non mainnet * HIP-30: deactivate shard 2 and 3 validators * goimports * update test * goimports * migrate balance uring epoch T - 1 highly untested code. also missing is the ability to generate a pre-migration report for future verification. * update test * export prometheus metric when no error importing preimage * add comment * test account migration in localnet * add preimages flags to rootflags * enable preimages on the whitelist * add the generate method * fix cropping log * fix cropping log * cropping startpoint when bigger than endpoint * add support for the rpcblocknumer type * enable import api * use earlies block * debug logs * debug logs * debug logs * debug logs * fix error catching * fix error catching * make end optional for the comand line * fix cropping logic * improve error when apply message fails * add balance on the error * fix importing * remove unused imports * create preimage for genesis block * fix consensus with No Migration Possible * use correct header for migration * process all tx in all block for non shard 0 --------- Co-authored-by: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Co-authored-by: Diego Nava <diego.nava77@hotmail.com> Co-authored-by: Diego Nava <8563843+diego1q2w@users.noreply.github.com>
1 year ago
func (s *PreimagesService) Export(ctx context.Context, path string) error {
// these are by default not blocking
return core.ExportPreimages(s.hmy.BlockChain, path)
}
func (s *PreimagesService) Verify(ctx context.Context) (uint64, error) {
currentBlock := s.hmy.CurrentBlock()
// these are by default not blocking
return core.VerifyPreimages(currentBlock.Header(), s.hmy.BlockChain)
}