diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..1e1491c824 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM ethereum/client-go:v1.13.4 + +RUN apk add --no-cache jq + +COPY entrypoint-l1.sh /entrypoint.sh + +VOLUME ["/db"] + +ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] diff --git a/README.md b/README.md index 0aa285e28c..ce4a8d7aef 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@
@@ -482,7 +482,7 @@ block production (which can lead to more rejected blocks), and avoids a prolonge readiness wait (`hypersdk` waits to mark itself as ready until it has seen a `ValidityWindow` of blocks). Looking ahead, support for continuous block production paves the way for the introduction -of [chain/validator-driven actions](https://github.com/ava-labs/hypersdk/issues/336), which should +of [chain/validator-driven actions](https://github.com/AnomalyFi/hypersdk/issues/336), which should be included on-chain every X seconds (like a price oracle update) regardless of how many user-submitted transactions are present. @@ -990,7 +990,7 @@ _This is a collection of posts from the community about the `hypersdk` and how t ## Future Work _If you want to take the lead on any of these items, please -[start a discussion](https://github.com/ava-labs/hypersdk/discussions) or reach +[start a discussion](https://github.com/AnomalyFi/hypersdk/discussions) or reach out on the Avalanche Discord._ * Use pre-specified state keys to process transactions in parallel (txs with no diff --git a/builder/dependencies.go b/builder/dependencies.go index 0b0cddb423..e830a2c32d 100644 --- a/builder/dependencies.go +++ b/builder/dependencies.go @@ -6,9 +6,9 @@ package builder import ( "context" + "github.com/AnomalyFi/hypersdk/chain" "github.com/ava-labs/avalanchego/snow/engine/common" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/hypersdk/chain" ) type VM interface { diff --git a/chain/auth_batch.go b/chain/auth_batch.go index e830829e50..cde195a246 100644 --- a/chain/auth_batch.go +++ b/chain/auth_batch.go @@ -4,8 +4,8 @@ package chain import ( + "github.com/AnomalyFi/hypersdk/workers" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/hypersdk/workers" ) const authWorkerBacklog = 16_384 diff --git a/chain/base.go b/chain/base.go index 3e6e746307..37dd1533e4 100644 --- a/chain/base.go +++ b/chain/base.go @@ -6,9 +6,9 @@ package chain import ( "fmt" + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/consts" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/consts" ) const BaseSize = consts.Uint64Len*2 + consts.IDLen diff --git a/chain/block.go b/chain/block.go index 61d0459ddb..6e8564d151 100644 --- a/chain/block.go +++ b/chain/block.go @@ -21,12 +21,15 @@ import ( oteltrace "go.opentelemetry.io/otel/trace" "go.uber.org/zap" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/state" - "github.com/ava-labs/hypersdk/utils" - "github.com/ava-labs/hypersdk/window" - "github.com/ava-labs/hypersdk/workers" + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/state" + "github.com/AnomalyFi/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/window" + "github.com/AnomalyFi/hypersdk/workers" + + ethhex "github.com/ethereum/go-ethereum/common/hexutil" + ethclient "github.com/ethereum/go-ethereum/ethclient" ) var ( @@ -42,6 +45,8 @@ type StatefulBlock struct { Txs []*Transaction `json:"txs"` + L1Head int64 `json:"l1_head"` + // StateRoot is the root of the post-execution state // of [Prnt]. // @@ -75,15 +80,37 @@ func (b *StatefulBlock) ID() (ids.ID, error) { // warpJob is used to signal to a listner that a *warp.Message has been // verified. type warpJob struct { - msg *warp.Message - signers int - verifiedChan chan bool - verified bool - warpNum int + msg *warp.Message + signers int + verifiedChan chan bool + verified bool + requiresBlock bool + verifiedRootsChan chan bool + verifiedRoots bool + warpNum int } func NewGenesisBlock(root ids.ID) *StatefulBlock { + // b, _ := new(big.Int).SetString("2", 16) + // num := (ethhex.Big)(*b) + // TODO need to add in Ethereum Block here + + ethereumNodeURL := "http://localhost:8545" + + // Create an RPC client + // client, err := ethrpc.Dial(ethereumNodeURL) + client, err := ethclient.Dial(ethereumNodeURL) + if err != nil { + fmt.Errorf("Failed to connect to the Ethereum client: %v", err) + } + + header, err := client.HeaderByNumber(context.Background(), nil) + if err != nil { + fmt.Errorf("Failed to retrieve the latest block number: %v", err) + } + return &StatefulBlock{ + L1Head: header.Number.Int64(), // We set the genesis block timestamp to be after the ProposerVM fork activation. // // This prevents an issue (when using millisecond timestamps) during ProposerVM activation @@ -99,6 +126,10 @@ func NewGenesisBlock(root ids.ID) *StatefulBlock { } } +type ETHBlock struct { + Number *ethhex.Big +} + // Stateless is defined separately from "Block" // in case external packages needs use the stateful block // without mocking VM or parent block @@ -111,10 +142,12 @@ type StatelessBlock struct { bytes []byte txsSet set.Set[ids.ID] - warpMessages map[ids.ID]*warpJob - containsWarp bool // this allows us to avoid allocating a map when we build - bctx *block.Context - vdrState validators.State + warpMessages map[ids.ID]*warpJob + containsWarp bool // this allows us to avoid allocating a map when we build + containsVerify bool // this allows us to avoid allocating a map when we build + + bctx *block.Context + vdrState validators.State results []*Result feeManager *FeeManager @@ -131,6 +164,7 @@ func NewBlock(vm VM, parent snowman.Block, tmstp int64) *StatelessBlock { Prnt: parent.ID(), Tmstmp: tmstp, Hght: parent.Height() + 1, + L1Head: vm.LastL1Head(), }, vm: vm, st: choices.Processing, @@ -209,11 +243,16 @@ func (b *StatelessBlock) populateTxs(ctx context.Context) error { if err != nil { return err } + if tx.VerifyBlock { + b.containsVerify = true + } b.warpMessages[tx.ID()] = &warpJob{ - msg: tx.WarpMessage, - signers: signers, - verifiedChan: make(chan bool, 1), - warpNum: len(b.warpMessages), + msg: tx.WarpMessage, + signers: signers, + requiresBlock: b.containsVerify, + verifiedChan: make(chan bool, 1), + verifiedRootsChan: make(chan bool, 1), + warpNum: len(b.warpMessages), } b.containsWarp = true } @@ -289,6 +328,9 @@ func (b *StatelessBlock) initializeBuilt( if tx.WarpMessage != nil { b.containsWarp = true } + if tx.VerifyBlock { + b.containsVerify = true + } } return nil } @@ -433,6 +475,33 @@ func (b *StatelessBlock) verifyWarpMessage(ctx context.Context, r Rules, msg *wa return true } +// TODO need to test +// verifyWarpBlock will attempt to verify a given warp block +func (b *StatelessBlock) verifyWarpBlock(ctx context.Context, r Rules, msg *warp.Message) (bool, error) { + block, err := UnmarshalWarpBlock(msg.UnsignedMessage.Payload) + + // TODO it is failing right here + + parentWarpBlock, err := b.vm.GetStatelessBlock(ctx, block.Prnt) + if err != nil { + b.vm.Logger().Warn("could not get parent", zap.Stringer("id", block.Prnt), zap.Error(err)) + return false, err + } else { + blockRoot, err := b.vm.GetStatelessBlock(ctx, block.StateRoot) + if err != nil { + b.vm.Logger().Debug("could not get block", zap.Stringer("id", block.StateRoot), zap.Error(err)) + return false, err + } else { + if blockRoot.Timestamp().Unix() < parentWarpBlock.Timestamp().Unix() { + b.vm.Logger().Warn("Too young of block", zap.Error(ErrTimestampTooEarly)) + return false, err + } + } + } + + return true, nil +} + // innerVerify executes the block on top of the provided [VerifyContext]. // // Invariants: @@ -459,7 +528,7 @@ func (b *StatelessBlock) innerVerify(ctx context.Context, vctx VerifyContext) er // Fetch view where we will apply block state transitions // // This call may result in our ancestry being verified. - parentView, err := vctx.View(ctx, &b.StateRoot, true) + parentView, err := vctx.View(ctx, true) if err != nil { return fmt.Errorf("%w: unable to load parent view", err) } @@ -542,6 +611,15 @@ func (b *StatelessBlock) innerVerify(ctx context.Context, vctx VerifyContext) er if b.vm.IsBootstrapped() && !invalidWarpResult { start := time.Now() verified := b.verifyWarpMessage(ctx, r, msg.msg) + if msg.requiresBlock && verified { + // TODO might need to do something with this error + verifiedBlockRoots, _ := b.verifyWarpBlock(ctx, r, msg.msg) + msg.verifiedRootsChan <- verifiedBlockRoots + msg.verifiedRoots = verifiedBlockRoots + if blockVerified != verifiedBlockRoots { + invalidWarpResult = true + } + } msg.verifiedChan <- verified msg.verified = verified log.Info( @@ -562,6 +640,9 @@ func (b *StatelessBlock) innerVerify(ctx context.Context, vctx VerifyContext) er // block) to avoid doing extra work. msg.verifiedChan <- blockVerified msg.verified = blockVerified + // TODO might need to fix this to verify + msg.verifiedRootsChan <- blockVerified + msg.verifiedRoots = blockVerified } } }() @@ -791,7 +872,7 @@ func (b *StatelessBlock) Processed() bool { // is height 0 (genesis). // // If [b.view] is nil (not processed), this function will either return an error or will -// run verification depending on the value of [blockRoot]. +// run verification (depending on whether the height is in [acceptedState]). // // We still need to handle returning the accepted state here because // the [VM] will call [View] on the preferred tip of the chain (whether or @@ -799,11 +880,11 @@ func (b *StatelessBlock) Processed() bool { // // Invariant: [View] with [verify] == true should not be called concurrently, otherwise, // it will result in undefined behavior. -func (b *StatelessBlock) View(ctx context.Context, blockRoot *ids.ID, verify bool) (state.View, error) { +func (b *StatelessBlock) View(ctx context.Context, verify bool) (state.View, error) { ctx, span := b.vm.Tracer().Start(ctx, "StatelessBlock.View", oteltrace.WithAttributes( attribute.Bool("processed", b.Processed()), - attribute.Bool("attemptVerify", blockRoot != nil), + attribute.Bool("verify", verify), ), ) defer span.End() @@ -813,6 +894,8 @@ func (b *StatelessBlock) View(ctx context.Context, blockRoot *ids.ID, verify boo return b.vm.State() } + // If block is processed, we can return either the accepted state + // or its pending view. if b.Processed() { if b.st == choices.Accepted { // We assume that base state was properly updated if this @@ -823,48 +906,50 @@ func (b *StatelessBlock) View(ctx context.Context, blockRoot *ids.ID, verify boo } return b.view, nil } - b.vm.Logger().Info("block not processed", - zap.Uint64("height", b.Hght), - zap.Stringer("blkID", b.ID()), - zap.Bool("attemptVerify", blockRoot != nil), - ) - if blockRoot == nil { - if !verify { - return nil, ErrBlockNotProcessed - } - // If we don't know the [blockRoot] but we want to [verify], - // we pessimistically execute the block. - // - // This could happen when building a block immediately after - // state sync finishes with no processing blocks. - } else { - // If the block is not processed but the caller only needs - // a reference to [acceptedState], we should just return it - // instead of re-verifying the block. - // - // This could happen if state sync finishes with a processing - // block. In this scenario, we will attempt to verify the block - // during accept and it will attempt to read the state associated - // with the root specified in [StateRoot] (which was the sync - // target). + // If the block is not processed but [acceptedState] equals the height + // of the block, we should return the accepted state. + // + // This can happen when we are building a child block immediately after + // restart (latest block will not be considered [Processed] because there + // will be no attached view from execution). + // + // We cannot use the merkle root to check against the accepted state + // because the block only contains the root of the parent block's post-execution. + if b.st == choices.Accepted { acceptedState, err := b.vm.State() if err != nil { return nil, err } - acceptedRoot, err := acceptedState.GetMerkleRoot(ctx) + acceptedHeightRaw, err := acceptedState.Get(HeightKey(b.vm.StateManager().HeightKey())) if err != nil { return nil, err } - if acceptedRoot == *blockRoot { + acceptedHeight := binary.BigEndian.Uint64(acceptedHeightRaw) + + if acceptedHeight == b.Hght { + b.vm.Logger().Info("accepted block not processed but found post-execution state on-disk", + zap.Uint64("height", b.Hght), + zap.Stringer("blkID", b.ID()), + zap.Bool("verify", verify), + ) return acceptedState, nil } - b.vm.Logger().Info("block root does not match accepted state", + b.vm.Logger().Info("accepted block not processed and does not match state on-disk", zap.Uint64("height", b.Hght), zap.Stringer("blkID", b.ID()), - zap.Stringer("accepted root", acceptedRoot), - zap.Stringer("block root", *blockRoot), + zap.Bool("verify", verify), ) + } else { + b.vm.Logger().Info("block not processed", + zap.Uint64("height", b.Hght), + zap.Stringer("blkID", b.ID()), + zap.Bool("verify", verify), + ) + } + + if !verify { + return nil, ErrBlockNotProcessed } // If there are no processing blocks when state sync finishes, @@ -975,7 +1060,7 @@ func (b *StatelessBlock) FeeManager() *FeeManager { func (b *StatefulBlock) Marshal() ([]byte, error) { size := consts.IDLen + consts.Uint64Len + consts.Uint64Len + consts.Uint64Len + window.WindowSliceSize + - consts.IntLen + codec.CummSize(b.Txs) + + consts.IntLen + codec.CummSize(b.Txs) + consts.IDLen + consts.IDLen + consts.Uint64Len + consts.Uint64Len p := codec.NewWriter(size, consts.NetworkSizeLimit) @@ -993,6 +1078,14 @@ func (b *StatefulBlock) Marshal() ([]byte, error) { b.authCounts[tx.Auth.GetTypeID()]++ } + // head, err := b.L1Head.Number.MarshalText() + // if err != nil { + // return nil, err + // } + // p.PackBytes(head) + + p.PackInt64(b.L1Head) + p.PackID(b.StateRoot) p.PackUint64(uint64(b.WarpResults)) bytes := p.Bytes() @@ -1028,6 +1121,23 @@ func UnmarshalBlock(raw []byte, parser Parser) (*StatefulBlock, error) { b.authCounts[tx.Auth.GetTypeID()]++ } + // var ( + // headBytes []byte + // num *ethhex.Big + // ) + + // bytes := make([]byte, dimensionStateLen*FeeDimensions) + + b.L1Head = p.UnpackInt64(false) + + // num.UnmarshalText(headBytes) + + // head := ETHBlock{ + // Number: num, + // } + + // b.L1Head = head + p.UnpackID(false, &b.StateRoot) b.WarpResults = set.Bits64(p.UnpackUint64(false)) @@ -1053,3 +1163,8 @@ func NewSyncableBlock(sb *StatelessBlock) *SyncableBlock { func (sb *SyncableBlock) String() string { return fmt.Sprintf("%d:%s root=%s", sb.Height(), sb.ID(), sb.StateRoot) } + +// Testing +func (b *StatelessBlock) MarkUnprocessed() { + b.view = nil +} diff --git a/chain/builder.go b/chain/builder.go index e1f5a19a90..7e2cf58a28 100644 --- a/chain/builder.go +++ b/chain/builder.go @@ -19,8 +19,8 @@ import ( "go.opentelemetry.io/otel/attribute" "go.uber.org/zap" - "github.com/ava-labs/hypersdk/keys" - "github.com/ava-labs/hypersdk/tstate" + "github.com/AnomalyFi/hypersdk/keys" + "github.com/AnomalyFi/hypersdk/tstate" ) const ( @@ -57,6 +57,7 @@ func HandlePreExecute(log logging.Logger, err error) bool { } } +// TODO this will be modified to add the L1 Head func BuildBlock( ctx context.Context, vm VM, @@ -85,7 +86,7 @@ func BuildBlock( // execute it. mempoolSize := vm.Mempool().Len(ctx) changesEstimate := math.Min(mempoolSize, maxViewPreallocation) - parentView, err := parent.View(ctx, nil, true) + parentView, err := parent.View(ctx, true) if err != nil { log.Warn("block building failed: couldn't get parent db", zap.Error(err)) return nil, err @@ -148,7 +149,7 @@ func BuildBlock( // Prefetch all transactions // - // TODO: unify logic with https://github.com/ava-labs/hypersdk/blob/4e10b911c3cd88e0ccd8d9de5210515b1d3a3ac4/chain/processor.go#L44-L79 + // TODO: unify logic with https://github.com/AnomalyFi/hypersdk/blob/4e10b911c3cd88e0ccd8d9de5210515b1d3a3ac4/chain/processor.go#L44-L79 var ( readyTxs = make(chan *txData, len(txs)) stopIndex = -1 @@ -322,6 +323,7 @@ func BuildBlock( // We wait as long as possible to verify the signature to ensure we don't // spend unnecessary time on an invalid tx. var warpErr error + var verifyError error if next.WarpMessage != nil { // We do not check the validity of [SourceChainID] because a VM could send // itself a message to trigger a chain upgrade. @@ -341,6 +343,38 @@ func BuildBlock( zap.Error(warpErr), ) } + if next.VerifyBlock && warpErr == nil { + fmt.Println("WE GOT INSIDE Builder") + block, err := UnmarshalWarpBlock(next.WarpMessage.UnsignedMessage.Payload) + + // TODO panic: runtime error: invalid memory address or nil pointer dereference. + // We cant get this block and then we compare it to the parent which causes issues + parentWarpBlock, err := vm.GetStatelessBlock(ctx, block.Prnt) + if err != nil { + log.Warn("could not get parent", zap.Stringer("id", block.Prnt), zap.Error(err)) + verifyError = err + } else { + blockRoot, err := vm.GetStatelessBlock(ctx, block.StateRoot) + if err != nil { + log.Debug("could not get block", zap.Stringer("id", block.StateRoot), zap.Error(err)) + verifyError = err + } else { + if blockRoot.Timestamp().Unix() < parentWarpBlock.Timestamp().Unix() { + log.Warn("Too young of block", zap.Error(ErrTimestampTooEarly)) + verifyError = ErrTimestampTooEarly + } + } + } + + if verifyError != nil { + log.Warn( + "block verification failed", + zap.Stringer("txID", next.ID()), + zap.Error(verifyError), + ) + } + + } } // If execution works, keep moving forward with new state @@ -379,7 +413,7 @@ func BuildBlock( r, ts, nextTime, - next.WarpMessage != nil && warpErr == nil, + next.WarpMessage != nil && warpErr == nil && verifyError == nil, ) if err != nil { // Returning an error here should be avoided at all costs (can be a DoS). Rather, @@ -399,7 +433,7 @@ func BuildBlock( } results = append(results, result) if next.WarpMessage != nil { - if warpErr == nil { + if warpErr == nil && verifyError == nil { // Add a bit if the warp message was verified b.WarpResults.Add(uint(warpCount)) } diff --git a/chain/consts.go b/chain/consts.go index c06b25f725..03b156f35e 100644 --- a/chain/consts.go +++ b/chain/consts.go @@ -6,8 +6,8 @@ package chain import ( "time" + "github.com/AnomalyFi/hypersdk/keys" "github.com/ava-labs/avalanchego/utils/units" - "github.com/ava-labs/hypersdk/keys" ) const ( diff --git a/chain/dependencies.go b/chain/dependencies.go index ae3703f84a..a06302bfd5 100644 --- a/chain/dependencies.go +++ b/chain/dependencies.go @@ -16,9 +16,9 @@ import ( "github.com/ava-labs/avalanchego/vms/platformvm/warp" "github.com/ava-labs/avalanchego/x/merkledb" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/state" - "github.com/ava-labs/hypersdk/workers" + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/state" + "github.com/AnomalyFi/hypersdk/workers" ) type ( @@ -45,6 +45,7 @@ type VM interface { IsBootstrapped() bool LastAcceptedBlock() *StatelessBlock + LastL1Head() int64 GetStatelessBlock(context.Context, ids.ID) (*StatelessBlock, error) GetVerifyContext(ctx context.Context, blockHeight uint64, parent ids.ID) (VerifyContext, error) @@ -84,7 +85,7 @@ type VM interface { } type VerifyContext interface { - View(ctx context.Context, blockRoot *ids.ID, verify bool) (state.View, error) + View(ctx context.Context, verify bool) (state.View, error) IsRepeat(ctx context.Context, oldestAllowed int64, txs []*Transaction, marker set.Bits, stop bool) (set.Bits, error) } diff --git a/chain/fee_manager.go b/chain/fee_manager.go index 8f31f2f91f..b985aefc42 100644 --- a/chain/fee_manager.go +++ b/chain/fee_manager.go @@ -8,9 +8,9 @@ import ( "fmt" "strconv" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/window" "github.com/ava-labs/avalanchego/utils/math" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/window" ) const ( diff --git a/chain/mock_action.go b/chain/mock_action.go index 07d717589c..c3530b02c6 100644 --- a/chain/mock_action.go +++ b/chain/mock_action.go @@ -2,7 +2,7 @@ // See the file LICENSE for licensing terms. // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ava-labs/hypersdk/chain (interfaces: Action) +// Source: github.com/AnomalyFi/hypersdk/chain (interfaces: Action) // Package chain is a generated GoMock package. package chain @@ -11,10 +11,10 @@ import ( context "context" reflect "reflect" + codec "github.com/AnomalyFi/hypersdk/codec" + state "github.com/AnomalyFi/hypersdk/state" ids "github.com/ava-labs/avalanchego/ids" warp "github.com/ava-labs/avalanchego/vms/platformvm/warp" - codec "github.com/ava-labs/hypersdk/codec" - state "github.com/ava-labs/hypersdk/state" gomock "github.com/golang/mock/gomock" ) diff --git a/chain/mock_auth.go b/chain/mock_auth.go index 62afa7b2c6..c5cda97901 100644 --- a/chain/mock_auth.go +++ b/chain/mock_auth.go @@ -2,7 +2,7 @@ // See the file LICENSE for licensing terms. // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ava-labs/hypersdk/chain (interfaces: Auth) +// Source: github.com/AnomalyFi/hypersdk/chain (interfaces: Auth) // Package chain is a generated GoMock package. package chain @@ -11,8 +11,8 @@ import ( context "context" reflect "reflect" - codec "github.com/ava-labs/hypersdk/codec" - state "github.com/ava-labs/hypersdk/state" + codec "github.com/AnomalyFi/hypersdk/codec" + state "github.com/AnomalyFi/hypersdk/state" gomock "github.com/golang/mock/gomock" ) diff --git a/chain/mock_auth_factory.go b/chain/mock_auth_factory.go index 445a63e71a..799c5d34a9 100644 --- a/chain/mock_auth_factory.go +++ b/chain/mock_auth_factory.go @@ -2,7 +2,7 @@ // See the file LICENSE for licensing terms. // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ava-labs/hypersdk/chain (interfaces: AuthFactory) +// Source: github.com/AnomalyFi/hypersdk/chain (interfaces: AuthFactory) // Package chain is a generated GoMock package. package chain diff --git a/chain/mock_rules.go b/chain/mock_rules.go index f993c9eca5..8bfb47c1a2 100644 --- a/chain/mock_rules.go +++ b/chain/mock_rules.go @@ -2,7 +2,7 @@ // See the file LICENSE for licensing terms. // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/ava-labs/hypersdk/chain (interfaces: Rules) +// Source: github.com/AnomalyFi/hypersdk/chain (interfaces: Rules) // Package chain is a generated GoMock package. package chain diff --git a/chain/processor.go b/chain/processor.go index 2fa4ad8e62..dd7e3893ba 100644 --- a/chain/processor.go +++ b/chain/processor.go @@ -11,9 +11,9 @@ import ( "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/trace" - "github.com/ava-labs/hypersdk/keys" - "github.com/ava-labs/hypersdk/state" - "github.com/ava-labs/hypersdk/tstate" + "github.com/AnomalyFi/hypersdk/keys" + "github.com/AnomalyFi/hypersdk/state" + "github.com/AnomalyFi/hypersdk/tstate" ) type fetchData struct { @@ -152,6 +152,7 @@ func (p *Processor) Execute( // TODO: parallel execution will greatly improve performance when actions // start taking longer than a few ns (i.e. with hypersdk programs). var warpVerified bool + blockVerified := true warpMsg, ok := p.blk.warpMessages[tx.ID()] if ok { select { @@ -160,7 +161,15 @@ func (p *Processor) Execute( return nil, nil, ctx.Err() } } - result, err := tx.Execute(ctx, feeManager, authCUs, txData.coldReads, txData.warmReads, sm, r, ts, t, ok && warpVerified) + // result, err := tx.Execute(ctx, feeManager, authCUs, txData.coldReads, txData.warmReads, sm, r, ts, t, ok && warpVerified) + if ok && tx.VerifyBlock { + select { + case blockVerified = <-warpMsg.verifiedRootsChan: + case <-ctx.Done(): + return nil, nil, ctx.Err() + } + } + result, err := tx.Execute(ctx, feeManager, authCUs, txData.coldReads, txData.warmReads, sm, r, ts, t, ok && warpVerified && blockVerified) if err != nil { return nil, nil, err } diff --git a/chain/result.go b/chain/result.go index 9064cbf103..e7d7d77635 100644 --- a/chain/result.go +++ b/chain/result.go @@ -4,9 +4,9 @@ package chain import ( + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/consts" "github.com/ava-labs/avalanchego/vms/platformvm/warp" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/consts" ) type Result struct { diff --git a/chain/transaction.go b/chain/transaction.go index d029a8c89a..eb16454963 100644 --- a/chain/transaction.go +++ b/chain/transaction.go @@ -13,15 +13,15 @@ import ( "github.com/ava-labs/avalanchego/utils/set" "github.com/ava-labs/avalanchego/vms/platformvm/warp" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/emap" - "github.com/ava-labs/hypersdk/keys" - "github.com/ava-labs/hypersdk/math" - "github.com/ava-labs/hypersdk/mempool" - "github.com/ava-labs/hypersdk/state" - "github.com/ava-labs/hypersdk/tstate" - "github.com/ava-labs/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/emap" + "github.com/AnomalyFi/hypersdk/keys" + "github.com/AnomalyFi/hypersdk/math" + "github.com/AnomalyFi/hypersdk/mempool" + "github.com/AnomalyFi/hypersdk/state" + "github.com/AnomalyFi/hypersdk/tstate" + "github.com/AnomalyFi/hypersdk/utils" ) var ( @@ -33,6 +33,7 @@ type Transaction struct { Base *Base `json:"base"` WarpMessage *warp.Message `json:"warpMessage"` Action Action `json:"action"` + VerifyBlock bool `json:"verifyBlock"` Auth Auth `json:"auth"` digest []byte @@ -53,11 +54,12 @@ type WarpResult struct { VerifyErr error } -func NewTx(base *Base, wm *warp.Message, act Action) *Transaction { +func NewTx(base *Base, wm *warp.Message, act Action, verifyBlock bool) *Transaction { return &Transaction{ Base: base, WarpMessage: wm, Action: act, + VerifyBlock: verifyBlock, } } @@ -72,9 +74,10 @@ func (t *Transaction) Digest() ([]byte, error) { } size := t.Base.Size() + codec.BytesLen(warpBytes) + - consts.ByteLen + t.Action.Size() + consts.ByteLen + consts.BoolLen + t.Action.Size() p := codec.NewWriter(size, consts.NetworkSizeLimit) t.Base.Marshal(p) + p.PackBool(t.VerifyBlock) p.PackBytes(warpBytes) p.PackByte(actionID) t.Action.Marshal(p) @@ -590,6 +593,7 @@ func (t *Transaction) Marshal(p *codec.Packer) error { return ErrWarpMessageNotInitialized } } + p.PackBool(t.VerifyBlock) p.PackBytes(warpBytes) p.PackByte(actionID) t.Action.Marshal(p) @@ -648,6 +652,9 @@ func UnmarshalTx( if err != nil { return nil, fmt.Errorf("%w: could not unmarshal base", err) } + + verifyBlock := p.UnpackBool() + var warpBytes []byte p.UnpackBytes(MaxWarpMessageSize, false, &warpBytes) var warpMessage *warp.Message @@ -702,6 +709,7 @@ func UnmarshalTx( tx.Action = action tx.WarpMessage = warpMessage tx.Auth = auth + tx.VerifyBlock = verifyBlock if err := p.Err(); err != nil { return nil, p.Err() } diff --git a/chain/warp_block.go b/chain/warp_block.go new file mode 100644 index 0000000000..acdf7ac5d4 --- /dev/null +++ b/chain/warp_block.go @@ -0,0 +1,54 @@ +// Copyright (C) 2023, Ava Labs, Inc. All rights reserved. +// See the file LICENSE for licensing terms. + +package chain + +import ( + "errors" + + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/ava-labs/avalanchego/ids" +) + +const WarpBlockSize = consts.Uint64Len + consts.Uint64Len + consts.IDLen + + consts.IDLen + consts.IDLen + +type WarpBlock struct { + Tmstmp int64 `json:"timestamp"` + Hght uint64 `json:"height"` + Prnt ids.ID `json:"parent"` + StateRoot ids.ID `json:"stateRoot"` + // TxID is the transaction that created this message. This is used to ensure + // there is WarpID uniqueness. + TxID ids.ID `json:"txID"` +} + +func (w *WarpBlock) Marshal() ([]byte, error) { + p := codec.NewWriter(WarpBlockSize, WarpBlockSize) + p.PackInt64(w.Tmstmp) + p.PackUint64(w.Hght) + p.PackID(w.Prnt) + p.PackID(w.StateRoot) + p.PackID(w.TxID) + return p.Bytes(), p.Err() +} + +func UnmarshalWarpBlock(b []byte) (*WarpBlock, error) { + var transfer WarpBlock + p := codec.NewReader(b, WarpBlockSize) + transfer.Tmstmp = p.UnpackInt64(true) + transfer.Hght = p.UnpackUint64(true) + p.UnpackID(false, &transfer.Prnt) + p.UnpackID(false, &transfer.StateRoot) + p.UnpackID(false, &transfer.TxID) + if err := p.Err(); err != nil { + return nil, err + } + ErrInvalidObjectDecode := errors.New("invalid object") + if !p.Empty() { + return nil, ErrInvalidObjectDecode + } + + return &transfer, nil +} diff --git a/cli/chain.go b/cli/chain.go index 43901643b9..c68f3828bd 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -11,16 +11,16 @@ import ( "strings" "time" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/pubsub" + "github.com/AnomalyFi/hypersdk/rpc" + "github.com/AnomalyFi/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/window" runner "github.com/ava-labs/avalanche-network-runner/client" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/units" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/pubsub" - "github.com/ava-labs/hypersdk/rpc" - "github.com/ava-labs/hypersdk/utils" - "github.com/ava-labs/hypersdk/window" "gopkg.in/yaml.v2" ) @@ -116,10 +116,13 @@ type AvalancheOpsConfig struct { CreatedNodes []struct { HTTPEndpoint string `yaml:"httpEndpoint"` } `yaml:"created_nodes"` - } `yaml:"resources"` + } `yaml:"resource"` + VMInstall struct { + ChainID string `yaml:"chain_id"` + } `yaml:"vm_install"` } -func (h *Handler) ImportOps(schainID string, opsPath string) error { +func (h *Handler) ImportOps(opsPath string) error { oldChains, err := h.DeleteChains() if err != nil { return err @@ -128,12 +131,6 @@ func (h *Handler) ImportOps(schainID string, opsPath string) error { utils.Outf("{{yellow}}deleted old chains:{{/}} %+v\n", oldChains) } - // Load chainID - chainID, err := ids.FromString(schainID) - if err != nil { - return err - } - // Load yaml file var opsConfig AvalancheOpsConfig yamlFile, err := os.ReadFile(opsPath) @@ -145,6 +142,12 @@ func (h *Handler) ImportOps(schainID string, opsPath string) error { return err } + // Load chainID + chainID, err := ids.FromString(opsConfig.VMInstall.ChainID) + if err != nil { + return err + } + // Add chains for _, node := range opsConfig.Resources.CreatedNodes { uri := fmt.Sprintf("%s/ext/bc/%s", node.HTTPEndpoint, chainID) @@ -222,7 +225,7 @@ func (h *Handler) WatchChain(hideTxs bool, getParser func(string, uint32, ids.ID tpsWindow = window.Window{} ) for ctx.Err() == nil { - blk, results, prices, err := scli.ListenBlock(ctx, parser) + blk, results, prices, realId, err := scli.ListenBlock(ctx, parser) if err != nil { return err } @@ -249,10 +252,12 @@ func (h *Handler) WatchChain(hideTxs bool, getParser func(string, uint32, ids.ID runningDuration := time.Since(start) tpsDivisor := math.Min(window.WindowSize, runningDuration.Seconds()) utils.Outf( - "{{green}}height:{{/}}%d {{green}}txs:{{/}}%d {{green}}root:{{/}}%s {{green}}size:{{/}}%.2fKB {{green}}units consumed:{{/}} [%s] {{green}}unit prices:{{/}} [%s] [{{green}}TPS:{{/}}%.2f {{green}}latency:{{/}}%dms {{green}}gap:{{/}}%dms]\n", + "{{green}}height:{{/}}%d l1head:{{/}}%s {{green}}txs:{{/}}%d {{green}}root:{{/}}%s {{green}}blockId:{{/}}%s {{green}}size:{{/}}%.2fKB {{green}}units consumed:{{/}} [%s] {{green}}unit prices:{{/}} [%s] [{{green}}TPS:{{/}}%.2f {{green}}latency:{{/}}%dms {{green}}gap:{{/}}%dms]\n", blk.Hght, + blk.L1Head, len(blk.Txs), blk.StateRoot, + realId, float64(blk.Size())/units.KiB, ParseDimensions(consumed), ParseDimensions(prices), @@ -262,10 +267,12 @@ func (h *Handler) WatchChain(hideTxs bool, getParser func(string, uint32, ids.ID ) } else { utils.Outf( - "{{green}}height:{{/}}%d {{green}}txs:{{/}}%d {{green}}root:{{/}}%s {{green}}size:{{/}}%.2fKB {{green}}units consumed:{{/}} [%s] {{green}}unit prices:{{/}} [%s]\n", + "{{green}}height:{{/}}%d l1head:{{/}}%s {{green}}txs:{{/}}%d {{green}}root:{{/}}%s {{green}}blockId:{{/}}%s {{green}}size:{{/}}%.2fKB {{green}}units consumed:{{/}} [%s] {{green}}unit prices:{{/}} [%s]\n", blk.Hght, + blk.L1Head, len(blk.Txs), blk.StateRoot, + realId, float64(blk.Size())/units.KiB, ParseDimensions(consumed), ParseDimensions(prices), diff --git a/cli/cli.go b/cli/cli.go index ef23d139ca..bd316d97e0 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -4,8 +4,8 @@ package cli import ( + "github.com/AnomalyFi/hypersdk/pebble" "github.com/ava-labs/avalanchego/database" - "github.com/ava-labs/hypersdk/pebble" ) type Handler struct { diff --git a/cli/dependencies.go b/cli/dependencies.go index 9e1f128466..c208fc1761 100644 --- a/cli/dependencies.go +++ b/cli/dependencies.go @@ -4,7 +4,7 @@ package cli import ( - "github.com/ava-labs/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" ) type Controller interface { diff --git a/cli/key.go b/cli/key.go index 3ede20f828..fb8bb6f639 100644 --- a/cli/key.go +++ b/cli/key.go @@ -6,10 +6,10 @@ package cli import ( "context" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/rpc" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/rpc" - "github.com/ava-labs/hypersdk/utils" ) func (h *Handler) GenerateKey() error { diff --git a/cli/prometheus.go b/cli/prometheus.go index 7aa9c53275..382b047ae3 100644 --- a/cli/prometheus.go +++ b/cli/prometheus.go @@ -12,8 +12,8 @@ import ( "os/exec" "time" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/utils" "github.com/pkg/browser" "gopkg.in/yaml.v2" ) @@ -53,7 +53,7 @@ type PrometheusConfig struct { ScrapeConfigs []*PrometheusScrapeConfig `yaml:"scrape_configs"` } -func (h *Handler) GeneratePrometheus(open bool, prometheusFile string, prometheusData string, getPanels func(ids.ID) []string) error { +func (h *Handler) GeneratePrometheus(baseURI string, openBrowser bool, startPrometheus bool, prometheusFile string, prometheusData string, getPanels func(ids.ID) []string) error { chainID, uris, err := h.PromptChain("select chainID", nil) if err != nil { return err @@ -102,7 +102,7 @@ func (h *Handler) GeneratePrometheus(open bool, prometheusFile string, prometheu // We must manually encode the params because prometheus skips any panels // that are not numerically sorted and `url.params` only sorts // lexicographically. - dashboard := "http://localhost:9090/graph" + dashboard := fmt.Sprintf("%s/graph", baseURI) for i, panel := range getPanels(chainID) { appendChar := "&" if i == 0 { @@ -111,12 +111,15 @@ func (h *Handler) GeneratePrometheus(open bool, prometheusFile string, prometheu dashboard = fmt.Sprintf("%s%sg%d.expr=%s&g%d.tab=0&g%d.step_input=1&g%d.range_input=5m", dashboard, appendChar, i, url.QueryEscape(panel), i, i, i) } - if !open { - utils.Outf("{{orange}}pre-built dashboard:{{/}} %s\n", dashboard) + if !startPrometheus { + if !openBrowser { + utils.Outf("{{orange}}pre-built dashboard:{{/}} %s\n", dashboard) + // Emit command to run prometheus + utils.Outf("{{green}}prometheus cmd:{{/}} /tmp/prometheus --config.file=%s --storage.tsdb.path=%s\n", prometheusFile, prometheusData) + return nil + } + return browser.OpenURL(dashboard) - // Emit command to run prometheus - utils.Outf("{{green}}prometheus cmd:{{/}} /tmp/prometheus --config.file=%s --storage.tsdb.path=%s\n", prometheusFile, prometheusData) - return nil } // Start prometheus and open browser @@ -132,6 +135,10 @@ func (h *Handler) GeneratePrometheus(open bool, prometheusFile string, prometheu case <-errChan: return case <-time.After(5 * time.Second): + if !openBrowser { + utils.Outf("{{orange}}pre-built dashboard:{{/}} %s\n", dashboard) + return + } utils.Outf("{{cyan}}opening dashboard{{/}}\n") if err := browser.OpenURL(dashboard); err != nil { utils.Outf("{{red}}unable to open dashboard:{{/}} %s\n", err.Error()) diff --git a/cli/prompt.go b/cli/prompt.go index c4ff4d6500..c36f14d51d 100644 --- a/cli/prompt.go +++ b/cli/prompt.go @@ -8,11 +8,11 @@ import ( "strconv" "strings" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/set" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/utils" "github.com/manifoldco/promptui" ) diff --git a/cli/spam.go b/cli/spam.go index fd57ed6a5c..e8bfd6859d 100644 --- a/cli/spam.go +++ b/cli/spam.go @@ -19,13 +19,13 @@ import ( "golang.org/x/sync/errgroup" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/pubsub" + "github.com/AnomalyFi/hypersdk/rpc" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/pubsub" - "github.com/ava-labs/hypersdk/rpc" - "github.com/ava-labs/hypersdk/utils" ) const ( @@ -136,6 +136,9 @@ func (h *Handler) Spam( utils.Outf("{{cyan}}overriding max fee:{{/}} %d\n", feePerTx) } witholding := feePerTx * uint64(numAccounts) + if balance < witholding { + return fmt.Errorf("insufficient funds (have=%d need=%d)", balance, witholding) + } distAmount := (balance - witholding) / uint64(numAccounts) utils.Outf( "{{yellow}}distributing funds to each account:{{/}} %s %s\n", diff --git a/cli/storage.go b/cli/storage.go index b93b61fc0e..5de977aa87 100644 --- a/cli/storage.go +++ b/cli/storage.go @@ -7,11 +7,11 @@ import ( "errors" "fmt" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/utils" ) const ( diff --git a/cli/utils.go b/cli/utils.go index 3869d38f14..8e31d34c00 100644 --- a/cli/utils.go +++ b/cli/utils.go @@ -7,9 +7,9 @@ import ( "context" "time" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/rpc" - "github.com/ava-labs/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/rpc" + "github.com/AnomalyFi/hypersdk/utils" ) const ( diff --git a/codec/optional_packer.go b/codec/optional_packer.go index 76379c1d0d..3d4696a286 100644 --- a/codec/optional_packer.go +++ b/codec/optional_packer.go @@ -4,10 +4,10 @@ package codec import ( + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/set" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" ) // OptionalPacker defines a struct that includes a Packer [ip], a bitset diff --git a/codec/optional_packer_test.go b/codec/optional_packer_test.go index deaadc4e6e..525dbb5df2 100644 --- a/codec/optional_packer_test.go +++ b/codec/optional_packer_test.go @@ -7,9 +7,9 @@ import ( "encoding/binary" "testing" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" "github.com/stretchr/testify/require" ) diff --git a/codec/packer.go b/codec/packer.go index 3e9515c459..c7e0f64743 100644 --- a/codec/packer.go +++ b/codec/packer.go @@ -9,9 +9,9 @@ import ( "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/wrappers" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/window" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/window" ) // Packer is a wrapper struct for the Packer struct diff --git a/codec/packer_test.go b/codec/packer_test.go index bf74a18c94..944e724083 100644 --- a/codec/packer_test.go +++ b/codec/packer_test.go @@ -6,10 +6,10 @@ package codec import ( "testing" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/window" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/window" "github.com/stretchr/testify/require" ) diff --git a/codec/type_parser.go b/codec/type_parser.go index 0614c7b151..9d50ea9e2e 100644 --- a/codec/type_parser.go +++ b/codec/type_parser.go @@ -4,7 +4,7 @@ package codec import ( - "github.com/ava-labs/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/consts" ) type decoder[T any, X any, Y any] struct { diff --git a/codec/type_parser_test.go b/codec/type_parser_test.go index 763032b747..dc9089d045 100644 --- a/codec/type_parser_test.go +++ b/codec/type_parser_test.go @@ -7,7 +7,7 @@ import ( "errors" "testing" - "github.com/ava-labs/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/consts" "github.com/stretchr/testify/require" ) diff --git a/codec/utils.go b/codec/utils.go index fffce7d533..85dc8c93fb 100644 --- a/codec/utils.go +++ b/codec/utils.go @@ -3,7 +3,7 @@ package codec -import "github.com/ava-labs/hypersdk/consts" +import "github.com/AnomalyFi/hypersdk/consts" type SizeType interface { Size() int diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000000..b837a155fd --- /dev/null +++ b/compose.yml @@ -0,0 +1,29 @@ +version: '3.4' + +# This Compose file is expected to be used with the devnet-up.sh script. +# The volumes below mount the configs generated by the script into each +# service. + +volumes: + l1_data: + + +services: + ################################################################################################## + # L1 + # + + l1: + build: + context: . + dockerfile: Dockerfile + ports: + - "8545:8545" + - "8546:8546" + - "7060:6060" + volumes: + - "l1_data:/db" + - "${PWD}/genesis-l1.json:/genesis.json" + - "${PWD}/test-jwt-secret.txt:/config/test-jwt-secret.txt" + environment: + GETH_MINER_RECOMMIT: 100ms \ No newline at end of file diff --git a/compose/docker-compose.yml b/compose/docker-compose.yml new file mode 100644 index 0000000000..63bacaa24f --- /dev/null +++ b/compose/docker-compose.yml @@ -0,0 +1,18 @@ +version: '3.4' + + +services: + da: + container_name: celestia-light-node + user: root + platform: "linux/x86_64" + image: "ghcr.io/celestiaorg/celestia-node:v0.11.0-rc2" + command: celestia light start --core.ip consensus-full-arabica-8.celestia-arabica.com --gateway --gateway.addr da --gateway.port 26659 --p2p.network arabica + environment: + - NODE_TYPE=light + - P2P_NETWORK=arabica + volumes: + - $HOME/.celestia-light-arabica-8/:/home/celestia/.celestia-light-arabica-8/ + ports: + - "26657:26657" + - "26659:26659" diff --git a/config/config.go b/config/config.go index eb56fbacbe..4ade3fa7c8 100644 --- a/config/config.go +++ b/config/config.go @@ -8,10 +8,10 @@ import ( "runtime" "time" + "github.com/AnomalyFi/hypersdk/trace" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/profiler" "github.com/ava-labs/avalanchego/utils/units" - "github.com/ava-labs/hypersdk/trace" ) const avalancheGoMinCPU = 4 @@ -39,7 +39,7 @@ func (c *Config) GetStateSyncServerDelay() time.Duration { return 0 } // used fo func (c *Config) GetParsedBlockCacheSize() int { return 128 } func (c *Config) GetStateHistoryLength() int { return 256 } -func (c *Config) GetAcceptedBlockWindow() int { return 768 } +func (c *Config) GetAcceptedBlockWindow() int { return 50_000 } func (c *Config) GetStateSyncMinBlocks() uint64 { return 768 } func (c *Config) GetAcceptorSize() int { return 1024 } diff --git a/eheap/eheap.go b/eheap/eheap.go index 453ee316da..16a462e187 100644 --- a/eheap/eheap.go +++ b/eheap/eheap.go @@ -6,7 +6,7 @@ package eheap import ( "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/heap" + "github.com/AnomalyFi/hypersdk/heap" ) // Item is the interface that any item put in the heap must adheare to. diff --git a/emap/emap.go b/emap/emap.go index b881776587..178d2a0db7 100644 --- a/emap/emap.go +++ b/emap/emap.go @@ -6,9 +6,9 @@ package emap import ( "sync" + "github.com/AnomalyFi/hypersdk/heap" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/set" - "github.com/ava-labs/hypersdk/heap" ) type bucket struct { diff --git a/emap/emap_test.go b/emap/emap_test.go index b3086a17d8..9b47c8a500 100644 --- a/emap/emap_test.go +++ b/emap/emap_test.go @@ -6,9 +6,9 @@ package emap import ( "testing" + "github.com/AnomalyFi/hypersdk/heap" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/set" - "github.com/ava-labs/hypersdk/heap" "github.com/stretchr/testify/require" ) diff --git a/entrypoint-l1.sh b/entrypoint-l1.sh new file mode 100644 index 0000000000..e46eecaa74 --- /dev/null +++ b/entrypoint-l1.sh @@ -0,0 +1,72 @@ +#!/bin/sh +set -exu + +VERBOSITY=${GETH_VERBOSITY:-3} +GETH_DATA_DIR=/db +GETH_CHAINDATA_DIR="$GETH_DATA_DIR/geth/chaindata" +GETH_KEYSTORE_DIR="$GETH_DATA_DIR/keystore" +GENESIS_FILE_PATH="${GENESIS_FILE_PATH:-/genesis.json}" +CHAIN_ID=$(cat "$GENESIS_FILE_PATH" | jq -r .config.chainId) +BLOCK_SIGNER_PRIVATE_KEY="ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" +BLOCK_SIGNER_ADDRESS="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" +RPC_PORT="${RPC_PORT:-8545}" +WS_PORT="${WS_PORT:-8546}" + +if [ ! -d "$GETH_KEYSTORE_DIR" ]; then + echo "$GETH_KEYSTORE_DIR missing, running account import" + echo -n "pwd" > "$GETH_DATA_DIR"/password + echo -n "$BLOCK_SIGNER_PRIVATE_KEY" | sed 's/0x//' > "$GETH_DATA_DIR"/block-signer-key + geth account import \ + --datadir="$GETH_DATA_DIR" \ + --password="$GETH_DATA_DIR"/password \ + "$GETH_DATA_DIR"/block-signer-key +else + echo "$GETH_KEYSTORE_DIR exists." +fi + +if [ ! -d "$GETH_CHAINDATA_DIR" ]; then + echo "$GETH_CHAINDATA_DIR missing, running init" + echo "Initializing genesis." + geth --verbosity="$VERBOSITY" init \ + --datadir="$GETH_DATA_DIR" \ + "$GENESIS_FILE_PATH" +else + echo "$GETH_CHAINDATA_DIR exists." +fi + +# Warning: Archive mode is required, otherwise old trie nodes will be +# pruned within minutes of starting the devnet. + +exec geth \ + --datadir="$GETH_DATA_DIR" \ + --verbosity="$VERBOSITY" \ + --http \ + --http.corsdomain="*" \ + --http.vhosts="*" \ + --http.addr=0.0.0.0 \ + --http.port="$RPC_PORT" \ + --http.api=web3,debug,eth,txpool,net,engine \ + --ws \ + --ws.addr=0.0.0.0 \ + --ws.port="$WS_PORT" \ + --ws.origins="*" \ + --ws.api=debug,eth,txpool,net,engine \ + --syncmode=full \ + --nodiscover \ + --maxpeers=1 \ + --networkid=$CHAIN_ID \ + --unlock=$BLOCK_SIGNER_ADDRESS \ + --mine \ + --miner.etherbase=$BLOCK_SIGNER_ADDRESS \ + --password="$GETH_DATA_DIR"/password \ + --allow-insecure-unlock \ + --rpc.allow-unprotected-txs \ + --authrpc.addr="0.0.0.0" \ + --authrpc.port="8551" \ + --authrpc.vhosts="*" \ + --authrpc.jwtsecret=/config/jwt-secret.txt \ + --gcmode=archive \ + --metrics \ + --metrics.addr=0.0.0.0 \ + --metrics.port=6060 \ + "$@" \ No newline at end of file diff --git a/examples/morpheusvm/.goreleaser.yml b/examples/morpheusvm/.goreleaser.yml index fccf0727ea..fc33dfe236 100644 --- a/examples/morpheusvm/.goreleaser.yml +++ b/examples/morpheusvm/.goreleaser.yml @@ -68,6 +68,8 @@ archives: name_template: 'morpheusvm_{{ .Version }}_{{ .Os }}_{{ .Arch }}' release: + make_latest: false # Should be done manually + mode: 'keep-existing' # Should not override releases github: - owner: ava-labs + owner: AnomalyFi name: hypersdk diff --git a/examples/morpheusvm/README.md b/examples/morpheusvm/README.md index ef54d1c92a..b884e7898e 100644 --- a/examples/morpheusvm/README.md +++ b/examples/morpheusvm/README.md @@ -5,10 +5,10 @@ The Choice is Yours --- diff --git a/examples/morpheusvm/actions/transfer.go b/examples/morpheusvm/actions/transfer.go index 6959e2cb27..8c5773bb50 100644 --- a/examples/morpheusvm/actions/transfer.go +++ b/examples/morpheusvm/actions/transfer.go @@ -6,16 +6,16 @@ package actions import ( "context" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/storage" + "github.com/AnomalyFi/hypersdk/state" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/vms/platformvm/warp" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - "github.com/ava-labs/hypersdk/examples/morpheusvm/storage" - "github.com/ava-labs/hypersdk/state" - "github.com/ava-labs/hypersdk/utils" ) var _ chain.Action = (*Transfer)(nil) diff --git a/examples/morpheusvm/auth/consts.go b/examples/morpheusvm/auth/consts.go index 67596fbc35..cc033b62f5 100644 --- a/examples/morpheusvm/auth/consts.go +++ b/examples/morpheusvm/auth/consts.go @@ -3,7 +3,7 @@ package auth -import "github.com/ava-labs/hypersdk/vm" +import "github.com/AnomalyFi/hypersdk/vm" // Note: Registry will error during initialization if a duplicate ID is assigned. We explicitly assign IDs to avoid accidental remapping. const ( diff --git a/examples/morpheusvm/auth/ed25519.go b/examples/morpheusvm/auth/ed25519.go index ac1b0aec5b..2b0718a6cf 100644 --- a/examples/morpheusvm/auth/ed25519.go +++ b/examples/morpheusvm/auth/ed25519.go @@ -6,13 +6,13 @@ package auth import ( "context" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/storage" + "github.com/AnomalyFi/hypersdk/state" "github.com/ava-labs/avalanchego/utils/math" "github.com/ava-labs/avalanchego/vms/platformvm/warp" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/storage" - "github.com/ava-labs/hypersdk/state" ) var _ chain.Auth = (*ED25519)(nil) diff --git a/examples/morpheusvm/auth/helpers.go b/examples/morpheusvm/auth/helpers.go index 340f44f367..733b2527b6 100644 --- a/examples/morpheusvm/auth/helpers.go +++ b/examples/morpheusvm/auth/helpers.go @@ -4,8 +4,8 @@ package auth import ( - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" ) func GetActor(auth chain.Auth) ed25519.PublicKey { diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/action.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/action.go index cd85820a10..ffcc6ba652 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/action.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/action.go @@ -6,8 +6,8 @@ package cmd import ( "context" - "github.com/ava-labs/hypersdk/examples/morpheusvm/actions" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/actions" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" "github.com/spf13/cobra" ) diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/chain.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/chain.go index 635eb6a632..8e2c8d5cb9 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/chain.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/chain.go @@ -6,11 +6,11 @@ package cmd import ( "context" + "github.com/AnomalyFi/hypersdk/chain" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/chain" "github.com/spf13/cobra" - brpc "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" + brpc "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" ) var chainCmd = &cobra.Command{ @@ -35,16 +35,16 @@ var importANRChainCmd = &cobra.Command{ } var importAvalancheOpsChainCmd = &cobra.Command{ - Use: "import-ops [chainID] [path]", + Use: "import-ops [path]", PreRunE: func(cmd *cobra.Command, args []string) error { - if len(args) != 2 { + if len(args) != 1 { return ErrInvalidArgs } - _, err := ids.FromString(args[0]) - return err + + return nil }, RunE: func(_ *cobra.Command, args []string) error { - return handler.Root().ImportOps(args[0], args[1]) + return handler.Root().ImportOps(args[0]) }, } diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/genesis.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/genesis.go index e48d9ba9bd..46adb9439a 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/genesis.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/genesis.go @@ -10,8 +10,8 @@ import ( "github.com/fatih/color" "github.com/spf13/cobra" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/genesis" ) var genesisCmd = &cobra.Command{ diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/handler.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/handler.go index a9ad95d70d..9965aaf55c 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/handler.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/handler.go @@ -6,15 +6,15 @@ package cmd import ( "context" + "github.com/AnomalyFi/hypersdk/cli" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + brpc "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/rpc" + hutils "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/cli" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - brpc "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" - "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" - "github.com/ava-labs/hypersdk/rpc" - hutils "github.com/ava-labs/hypersdk/utils" ) var _ cli.Controller = (*Controller)(nil) diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/key.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/key.go index 5ebe54dc59..25bcc64596 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/key.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/key.go @@ -6,11 +6,11 @@ package cmd import ( "context" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + brpc "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - brpc "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" - "github.com/ava-labs/hypersdk/utils" "github.com/spf13/cobra" ) diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/prometheus.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/prometheus.go index 09ea968afb..6b742246e4 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/prometheus.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/prometheus.go @@ -7,9 +7,9 @@ package cmd import ( "fmt" + "github.com/AnomalyFi/hypersdk/cli" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/cli" - "github.com/ava-labs/hypersdk/utils" "github.com/spf13/cobra" ) @@ -23,7 +23,7 @@ var prometheusCmd = &cobra.Command{ var generatePrometheusCmd = &cobra.Command{ Use: "generate", RunE: func(_ *cobra.Command, args []string) error { - return handler.Root().GeneratePrometheus(runPrometheus, prometheusFile, prometheusData, func(chainID ids.ID) []string { + return handler.Root().GeneratePrometheus(prometheusBaseURI, prometheusOpenBrowser, startPrometheus, prometheusFile, prometheusData, func(chainID ids.ID) []string { panels := []string{} panels = append(panels, fmt.Sprintf("increase(avalanche_%s_vm_hypersdk_chain_empty_block_built[5s])", chainID)) diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/resolutions.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/resolutions.go index d486678461..fb56e6a70c 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/resolutions.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/resolutions.go @@ -8,17 +8,17 @@ import ( "fmt" "reflect" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/cli" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/actions" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + brpc "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" + tutils "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/rpc" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/vms/platformvm/warp" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/cli" - "github.com/ava-labs/hypersdk/examples/morpheusvm/actions" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - brpc "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" - tutils "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" - "github.com/ava-labs/hypersdk/rpc" - "github.com/ava-labs/hypersdk/utils" ) // TODO: use websockets diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/root.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/root.go index 6618369624..aa78f10d9f 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/root.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/root.go @@ -7,8 +7,8 @@ import ( "fmt" "time" - "github.com/ava-labs/hypersdk/cli" - "github.com/ava-labs/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/cli" + "github.com/AnomalyFi/hypersdk/utils" "github.com/spf13/cobra" ) @@ -21,20 +21,22 @@ const ( var ( handler *Handler - dbPath string - genesisFile string - minUnitPrice []string - maxBlockUnits []string - windowTargetUnits []string - minBlockGap int64 - hideTxs bool - randomRecipient bool - maxTxBacklog int - checkAllChains bool - prometheusFile string - prometheusData string - runPrometheus bool - maxFee int64 + dbPath string + genesisFile string + minUnitPrice []string + maxBlockUnits []string + windowTargetUnits []string + minBlockGap int64 + hideTxs bool + randomRecipient bool + maxTxBacklog int + checkAllChains bool + prometheusBaseURI string + prometheusOpenBrowser bool + prometheusFile string + prometheusData string + startPrometheus bool + maxFee int64 rootCmd = &cobra.Command{ Use: "morpheus-cli", @@ -168,6 +170,18 @@ func init() { ) // prometheus + generatePrometheusCmd.PersistentFlags().StringVar( + &prometheusBaseURI, + "prometheus-base-uri", + "http://localhost:9090", + "prometheus server location", + ) + generatePrometheusCmd.PersistentFlags().BoolVar( + &prometheusOpenBrowser, + "prometheus-open-browser", + true, + "open browser to prometheus dashboard", + ) generatePrometheusCmd.PersistentFlags().StringVar( &prometheusFile, "prometheus-file", @@ -181,10 +195,10 @@ func init() { "prometheus data location", ) generatePrometheusCmd.PersistentFlags().BoolVar( - &runPrometheus, - "run-prometheus", + &startPrometheus, + "prometheus-start", true, - "start prometheus", + "start local prometheus server", ) prometheusCmd.AddCommand( generatePrometheusCmd, diff --git a/examples/morpheusvm/cmd/morpheus-cli/cmd/spam.go b/examples/morpheusvm/cmd/morpheus-cli/cmd/spam.go index bf00e68986..0acc521607 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/cmd/spam.go +++ b/examples/morpheusvm/cmd/morpheus-cli/cmd/spam.go @@ -6,15 +6,15 @@ package cmd import ( "context" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/actions" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + brpc "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" + "github.com/AnomalyFi/hypersdk/rpc" + "github.com/AnomalyFi/hypersdk/utils" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/actions" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - brpc "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" - "github.com/ava-labs/hypersdk/rpc" - "github.com/ava-labs/hypersdk/utils" "github.com/spf13/cobra" ) diff --git a/examples/morpheusvm/cmd/morpheus-cli/main.go b/examples/morpheusvm/cmd/morpheus-cli/main.go index a228a30aa1..6f3de5916a 100644 --- a/examples/morpheusvm/cmd/morpheus-cli/main.go +++ b/examples/morpheusvm/cmd/morpheus-cli/main.go @@ -7,8 +7,8 @@ package main import ( "os" - "github.com/ava-labs/hypersdk/examples/morpheusvm/cmd/morpheus-cli/cmd" - "github.com/ava-labs/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/cmd/morpheus-cli/cmd" + "github.com/AnomalyFi/hypersdk/utils" ) func main() { diff --git a/examples/morpheusvm/cmd/morpheusvm/main.go b/examples/morpheusvm/cmd/morpheusvm/main.go index 9cb97fe7bc..9d178a6597 100644 --- a/examples/morpheusvm/cmd/morpheusvm/main.go +++ b/examples/morpheusvm/cmd/morpheusvm/main.go @@ -8,11 +8,11 @@ import ( "fmt" "os" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/cmd/morpheusvm/version" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/controller" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/ulimit" "github.com/ava-labs/avalanchego/vms/rpcchainvm" - "github.com/ava-labs/hypersdk/examples/morpheusvm/cmd/morpheusvm/version" - "github.com/ava-labs/hypersdk/examples/morpheusvm/controller" "github.com/spf13/cobra" ) diff --git a/examples/morpheusvm/cmd/morpheusvm/version/version.go b/examples/morpheusvm/cmd/morpheusvm/version/version.go index 36020b2cd5..c0b3e10a79 100644 --- a/examples/morpheusvm/cmd/morpheusvm/version/version.go +++ b/examples/morpheusvm/cmd/morpheusvm/version/version.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/cobra" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/version" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/version" ) func init() { diff --git a/examples/morpheusvm/config/config.go b/examples/morpheusvm/config/config.go index 23ad2c4730..bdb576dafe 100644 --- a/examples/morpheusvm/config/config.go +++ b/examples/morpheusvm/config/config.go @@ -9,16 +9,16 @@ import ( "strings" "time" + "github.com/AnomalyFi/hypersdk/config" + "github.com/AnomalyFi/hypersdk/trace" + "github.com/AnomalyFi/hypersdk/vm" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/utils/profiler" - "github.com/ava-labs/hypersdk/config" - "github.com/ava-labs/hypersdk/trace" - "github.com/ava-labs/hypersdk/vm" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" - "github.com/ava-labs/hypersdk/examples/morpheusvm/version" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/version" ) var _ vm.Config = (*Config)(nil) diff --git a/examples/morpheusvm/consts/consts.go b/examples/morpheusvm/consts/consts.go index 5a6d79d2fa..ad14ade2e9 100644 --- a/examples/morpheusvm/consts/consts.go +++ b/examples/morpheusvm/consts/consts.go @@ -4,11 +4,11 @@ package consts import ( + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/consts" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/vms/platformvm/warp" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/consts" ) const ( diff --git a/examples/morpheusvm/controller/controller.go b/examples/morpheusvm/controller/controller.go index fb0eabf4e4..6be37551b3 100644 --- a/examples/morpheusvm/controller/controller.go +++ b/examples/morpheusvm/controller/controller.go @@ -7,26 +7,26 @@ import ( "context" "fmt" + "github.com/AnomalyFi/hypersdk/builder" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/gossiper" + hrpc "github.com/AnomalyFi/hypersdk/rpc" + hstorage "github.com/AnomalyFi/hypersdk/storage" + "github.com/AnomalyFi/hypersdk/vm" ametrics "github.com/ava-labs/avalanchego/api/metrics" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/snow" "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/hypersdk/builder" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/gossiper" - hrpc "github.com/ava-labs/hypersdk/rpc" - hstorage "github.com/ava-labs/hypersdk/storage" - "github.com/ava-labs/hypersdk/vm" "go.uber.org/zap" - "github.com/ava-labs/hypersdk/examples/morpheusvm/actions" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - "github.com/ava-labs/hypersdk/examples/morpheusvm/config" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" - "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" - "github.com/ava-labs/hypersdk/examples/morpheusvm/storage" - "github.com/ava-labs/hypersdk/examples/morpheusvm/version" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/actions" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/config" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/genesis" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/storage" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/version" ) var _ vm.Controller = (*Controller)(nil) diff --git a/examples/morpheusvm/controller/metrics.go b/examples/morpheusvm/controller/metrics.go index 0708cb636c..36afedbf26 100644 --- a/examples/morpheusvm/controller/metrics.go +++ b/examples/morpheusvm/controller/metrics.go @@ -4,9 +4,9 @@ package controller import ( + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" ametrics "github.com/ava-labs/avalanchego/api/metrics" "github.com/ava-labs/avalanchego/utils/wrappers" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" "github.com/prometheus/client_golang/prometheus" ) diff --git a/examples/morpheusvm/controller/resolutions.go b/examples/morpheusvm/controller/resolutions.go index f6c837ea68..03283fb790 100644 --- a/examples/morpheusvm/controller/resolutions.go +++ b/examples/morpheusvm/controller/resolutions.go @@ -6,13 +6,13 @@ package controller import ( "context" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/genesis" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/storage" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/trace" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" - "github.com/ava-labs/hypersdk/examples/morpheusvm/storage" ) func (c *Controller) Genesis() *genesis.Genesis { diff --git a/examples/morpheusvm/factory.go b/examples/morpheusvm/factory.go index c03c15cae1..38a80e97dd 100644 --- a/examples/morpheusvm/factory.go +++ b/examples/morpheusvm/factory.go @@ -7,7 +7,7 @@ import ( "github.com/ava-labs/avalanchego/utils/logging" "github.com/ava-labs/avalanchego/vms" - "github.com/ava-labs/hypersdk/examples/morpheusvm/controller" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/controller" ) var _ vms.Factory = &Factory{} diff --git a/examples/morpheusvm/genesis/genesis.go b/examples/morpheusvm/genesis/genesis.go index ec5fa88995..df5ec8445a 100644 --- a/examples/morpheusvm/genesis/genesis.go +++ b/examples/morpheusvm/genesis/genesis.go @@ -11,13 +11,13 @@ import ( "github.com/ava-labs/avalanchego/trace" smath "github.com/ava-labs/avalanchego/utils/math" - "github.com/ava-labs/hypersdk/chain" - hconsts "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/storage" - "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" - "github.com/ava-labs/hypersdk/state" - "github.com/ava-labs/hypersdk/vm" + "github.com/AnomalyFi/hypersdk/chain" + hconsts "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/storage" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/state" + "github.com/AnomalyFi/hypersdk/vm" ) var _ vm.Genesis = (*Genesis)(nil) diff --git a/examples/morpheusvm/genesis/rules.go b/examples/morpheusvm/genesis/rules.go index ec280d24fe..e495e2c48d 100644 --- a/examples/morpheusvm/genesis/rules.go +++ b/examples/morpheusvm/genesis/rules.go @@ -4,8 +4,8 @@ package genesis import ( + "github.com/AnomalyFi/hypersdk/chain" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/chain" ) var _ chain.Rules = (*Rules)(nil) diff --git a/examples/morpheusvm/go.mod b/examples/morpheusvm/go.mod index e9ea673027..13a3ac479b 100644 --- a/examples/morpheusvm/go.mod +++ b/examples/morpheusvm/go.mod @@ -1,8 +1,9 @@ -module github.com/ava-labs/hypersdk/examples/morpheusvm +module github.com/AnomalyFi/hypersdk/examples/morpheusvm go 1.20 require ( + github.com/AnomalyFi/hypersdk v0.0.0-00010101000000-000000000000 github.com/ava-labs/avalanche-network-runner v1.7.2 github.com/ava-labs/avalanchego v1.10.10 github.com/ava-labs/hypersdk v0.0.1 @@ -144,8 +145,9 @@ require ( google.golang.org/protobuf v1.30.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect + gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/ava-labs/hypersdk => ../../ +replace github.com/AnomalyFi/hypersdk => ../../ diff --git a/examples/morpheusvm/go.sum b/examples/morpheusvm/go.sum index 0460dae238..9bbfef99b2 100644 --- a/examples/morpheusvm/go.sum +++ b/examples/morpheusvm/go.sum @@ -1038,6 +1038,8 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= +gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/examples/morpheusvm/registry/registry.go b/examples/morpheusvm/registry/registry.go index 1b91d68f68..b9ffc64b66 100644 --- a/examples/morpheusvm/registry/registry.go +++ b/examples/morpheusvm/registry/registry.go @@ -4,14 +4,14 @@ package registry import ( + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/codec" "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/ava-labs/avalanchego/vms/platformvm/warp" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/examples/morpheusvm/actions" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/actions" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" ) // Setup types diff --git a/examples/morpheusvm/rpc/dependencies.go b/examples/morpheusvm/rpc/dependencies.go index 393b29344a..18221c8cdb 100644 --- a/examples/morpheusvm/rpc/dependencies.go +++ b/examples/morpheusvm/rpc/dependencies.go @@ -6,11 +6,11 @@ package rpc import ( "context" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/genesis" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/trace" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" ) type Controller interface { diff --git a/examples/morpheusvm/rpc/jsonrpc_client.go b/examples/morpheusvm/rpc/jsonrpc_client.go index c976888fb0..6c6699a064 100644 --- a/examples/morpheusvm/rpc/jsonrpc_client.go +++ b/examples/morpheusvm/rpc/jsonrpc_client.go @@ -9,14 +9,14 @@ import ( "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" - _ "github.com/ava-labs/hypersdk/examples/morpheusvm/registry" // ensure registry populated - "github.com/ava-labs/hypersdk/examples/morpheusvm/storage" - "github.com/ava-labs/hypersdk/requester" - "github.com/ava-labs/hypersdk/rpc" - "github.com/ava-labs/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/genesis" + _ "github.com/AnomalyFi/hypersdk/examples/morpheusvm/registry" // ensure registry populated + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/storage" + "github.com/AnomalyFi/hypersdk/requester" + "github.com/AnomalyFi/hypersdk/rpc" + "github.com/AnomalyFi/hypersdk/utils" ) type JSONRPCClient struct { diff --git a/examples/morpheusvm/rpc/jsonrpc_server.go b/examples/morpheusvm/rpc/jsonrpc_server.go index 86d71c4eb1..7729b78992 100644 --- a/examples/morpheusvm/rpc/jsonrpc_server.go +++ b/examples/morpheusvm/rpc/jsonrpc_server.go @@ -8,9 +8,9 @@ import ( "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" - "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/genesis" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" ) type JSONRPCServer struct { diff --git a/examples/morpheusvm/scripts/tests.integration.sh b/examples/morpheusvm/scripts/tests.integration.sh index 9a0ddb17b5..40e7bed925 100755 --- a/examples/morpheusvm/scripts/tests.integration.sh +++ b/examples/morpheusvm/scripts/tests.integration.sh @@ -29,7 +29,7 @@ run \ --fail-fast \ -cover \ -covermode=atomic \ --coverpkg=github.com/ava-labs/hypersdk/... \ +-coverpkg=github.com/AnomalyFi/hypersdk/... \ -coverprofile=integration.coverage.out \ ./tests/integration \ --vms 3 diff --git a/examples/morpheusvm/storage/storage.go b/examples/morpheusvm/storage/storage.go index 33d800f897..93184976c5 100644 --- a/examples/morpheusvm/storage/storage.go +++ b/examples/morpheusvm/storage/storage.go @@ -10,15 +10,15 @@ import ( "fmt" "sync" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/state" "github.com/ava-labs/avalanchego/database" "github.com/ava-labs/avalanchego/ids" smath "github.com/ava-labs/avalanchego/utils/math" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/state" - "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" ) type ReadState func(context.Context, [][]byte) ([][]byte, []error) diff --git a/examples/morpheusvm/tests/e2e/e2e_test.go b/examples/morpheusvm/tests/e2e/e2e_test.go index b9b48d59d8..419c0c58a3 100644 --- a/examples/morpheusvm/tests/e2e/e2e_test.go +++ b/examples/morpheusvm/tests/e2e/e2e_test.go @@ -11,19 +11,19 @@ import ( "testing" "time" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/actions" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + lrpc "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/rpc" + hutils "github.com/AnomalyFi/hypersdk/utils" runner_sdk "github.com/ava-labs/avalanche-network-runner/client" "github.com/ava-labs/avalanche-network-runner/rpcpb" "github.com/ava-labs/avalanchego/config" "github.com/ava-labs/avalanchego/ids" "github.com/ava-labs/avalanchego/utils/logging" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/actions" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - lrpc "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" - "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" - "github.com/ava-labs/hypersdk/rpc" - hutils "github.com/ava-labs/hypersdk/utils" "github.com/fatih/color" ginkgo "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" diff --git a/examples/morpheusvm/tests/integration/integration_test.go b/examples/morpheusvm/tests/integration/integration_test.go index f592d37a8b..14736c7c94 100644 --- a/examples/morpheusvm/tests/integration/integration_test.go +++ b/examples/morpheusvm/tests/integration/integration_test.go @@ -32,22 +32,22 @@ import ( "github.com/onsi/gomega" "go.uber.org/zap" - "github.com/ava-labs/hypersdk/chain" - "github.com/ava-labs/hypersdk/codec" - "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/pubsub" - "github.com/ava-labs/hypersdk/rpc" - hutils "github.com/ava-labs/hypersdk/utils" - "github.com/ava-labs/hypersdk/vm" - - "github.com/ava-labs/hypersdk/examples/morpheusvm/actions" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - lconsts "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/controller" - "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" - lrpc "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" - "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/chain" + "github.com/AnomalyFi/hypersdk/codec" + "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/pubsub" + "github.com/AnomalyFi/hypersdk/rpc" + hutils "github.com/AnomalyFi/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/vm" + + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/actions" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + lconsts "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/controller" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/genesis" + lrpc "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" ) var ( @@ -534,6 +534,11 @@ var _ = ginkgo.Describe("[Tx Processing]", func() { gomega.Ω(err).Should(gomega.BeNil()) gomega.Ω(submit(context.Background())).Should(gomega.BeNil()) + // Ensure we can handle case where accepted block is not processed + latestBlock := blocks[len(blocks)-1] + latestBlock.(*chain.StatelessBlock).MarkUnprocessed() + + // Accept new block (should use accepted state) accept := expectBlk(instances[1]) results := accept(true) diff --git a/examples/morpheusvm/tests/load/load_test.go b/examples/morpheusvm/tests/load/load_test.go index 38bb38f459..51967a61f0 100644 --- a/examples/morpheusvm/tests/load/load_test.go +++ b/examples/morpheusvm/tests/load/load_test.go @@ -35,22 +35,22 @@ import ( "github.com/onsi/gomega" "go.uber.org/zap" - "github.com/ava-labs/hypersdk/chain" - hconsts "github.com/ava-labs/hypersdk/consts" - "github.com/ava-labs/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/pebble" - hutils "github.com/ava-labs/hypersdk/utils" - "github.com/ava-labs/hypersdk/vm" - "github.com/ava-labs/hypersdk/workers" - - "github.com/ava-labs/hypersdk/examples/morpheusvm/actions" - "github.com/ava-labs/hypersdk/examples/morpheusvm/auth" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" - "github.com/ava-labs/hypersdk/examples/morpheusvm/controller" - "github.com/ava-labs/hypersdk/examples/morpheusvm/genesis" - trpc "github.com/ava-labs/hypersdk/examples/morpheusvm/rpc" - "github.com/ava-labs/hypersdk/examples/morpheusvm/utils" - "github.com/ava-labs/hypersdk/rpc" + "github.com/AnomalyFi/hypersdk/chain" + hconsts "github.com/AnomalyFi/hypersdk/consts" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/pebble" + hutils "github.com/AnomalyFi/hypersdk/utils" + "github.com/AnomalyFi/hypersdk/vm" + "github.com/AnomalyFi/hypersdk/workers" + + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/actions" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/auth" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/controller" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/genesis" + trpc "github.com/AnomalyFi/hypersdk/examples/morpheusvm/rpc" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/utils" + "github.com/AnomalyFi/hypersdk/rpc" ) const genesisBalance uint64 = hconsts.MaxUint64 diff --git a/examples/morpheusvm/utils/utils.go b/examples/morpheusvm/utils/utils.go index 5257835624..0cadcf37d3 100644 --- a/examples/morpheusvm/utils/utils.go +++ b/examples/morpheusvm/utils/utils.go @@ -4,9 +4,9 @@ package utils import ( - "github.com/ava-labs/hypersdk/crypto/ed25519" + "github.com/AnomalyFi/hypersdk/crypto/ed25519" - "github.com/ava-labs/hypersdk/examples/morpheusvm/consts" + "github.com/AnomalyFi/hypersdk/examples/morpheusvm/consts" ) func Address(pk ed25519.PublicKey) string { diff --git a/examples/tokenvm/.goreleaser.yml b/examples/tokenvm/.goreleaser.yml index 21aa157163..734876f4da 100644 --- a/examples/tokenvm/.goreleaser.yml +++ b/examples/tokenvm/.goreleaser.yml @@ -124,6 +124,8 @@ archives: name_template: 'tokenvm_{{ .Version }}_{{ .Os }}_{{ .Arch }}' release: + make_latest: false # Should be done manually + mode: 'keep-existing' # Should not override releases github: - owner: ava-labs + owner: AnomalyFi name: hypersdk diff --git a/examples/tokenvm/DEVNETS.md b/examples/tokenvm/DEVNETS.md deleted file mode 100644 index afa42e0358..0000000000 --- a/examples/tokenvm/DEVNETS.md +++ /dev/null @@ -1,482 +0,0 @@ -## Deploying Devnets -_In the world of Avalanche, we refer to short-lived, test Subnets as Devnets._ - -### Step 1: Install `avalanche-ops` -[avalanche-ops](https://github.com/ava-labs/avalanche-ops) provides a command-line -interface to setup nodes and install Custom VMs on both custom networks and on -Fuji using [AWS CloudFormation](https://aws.amazon.com/cloudformation/). - -You can view a full list of pre-built binaries on the [latest release -page](https://github.com/ava-labs/avalanche-ops/releases/tag/latest). - -#### Option 1: Install `avalanche-ops` on Mac -```bash -rm -f /tmp/avalancheup-aws -wget https://github.com/ava-labs/avalanche-ops/releases/download/latest/avalancheup-aws.aarch64-apple-darwin -mv ./avalancheup-aws.aarch64-apple-darwin /tmp/avalancheup-aws -chmod +x /tmp/avalancheup-aws -/tmp/avalancheup-aws --help -``` - -#### Option 2: Install `avalanche-ops` on Linux -```bash -rm -f /tmp/avalancheup-aws -wget https://github.com/ava-labs/avalanche-ops/releases/download/latest/avalancheup-aws.x86_64-unknown-linux-gnu -mv ./avalancheup-aws.x86_64-unknown-linux-gnu /tmp/avalancheup-aws -chmod +x /tmp/avalancheup-aws -/tmp/avalancheup-aws --help -``` - -### Step 2: Install and Configure `aws-cli` -Next, install the [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). This is used to -authenticate to AWS and manipulate CloudFormation. - -Once you've installed the AWS CLI, run `aws configure sso` to login to AWS locally. See [the avalanche-ops documentation](https://github.com/ava-labs/avalanche-ops#permissions) for additional details. Set a `profile_name` when logging in, as it will be referenced directly by avalanche-ops commands. - -### Step 3: Install `token-cli` -```bash -export ARCH_TYPE=$(uname -m) -[ $ARCH_TYPE = x86_64 ] && ARCH_TYPE=amd64 -echo ${ARCH_TYPE} -export OS_TYPE=$(uname | tr '[:upper:]' '[:lower:]') -echo ${OS_TYPE} -export HYPERSDK_VERSION="0.0.9" -rm -f /tmp/token-cli -wget "https://github.com/ava-labs/hypersdk/releases/download/v${HYPERSDK_VERSION}/hypersdk_${HYPERSDK_VERSION}_${OS_TYPE}_${ARCH_TYPE}.tar.gz" -mkdir tmp-hypersdk -tar -xvf hypersdk_${HYPERSDK_VERSION}_${OS_TYPE}_${ARCH_TYPE}.tar.gz -C tmp-hypersdk -rm -rf hypersdk_${HYPERSDK_VERSION}_${OS_TYPE}_${ARCH_TYPE}.tar.gz -mv tmp-hypersdk/token-cli /tmp/token-cli -rm -rf tmp-hypersdk -``` - -### Step 4: Download `tokenvm` -`tokenvm` is currently compiled with `GOAMD=v1`. If you want to significantly -improve the performance of cryptographic operations, you should consider -building with [`v3+`](https://github.com/golang/go/wiki/MinimumRequirements#amd64). - -```bash -export HYPERSDK_VERSION="0.0.9" -rm -f /tmp/tokenvm -wget "https://github.com/ava-labs/hypersdk/releases/download/v${HYPERSDK_VERSION}/hypersdk_${HYPERSDK_VERSION}_linux_amd64.tar.gz" -mkdir tmp-hypersdk -tar -xvf hypersdk_${HYPERSDK_VERSION}_linux_amd64.tar.gz -C tmp-hypersdk -rm -rf hypersdk_${HYPERSDK_VERSION}_linux_amd64.tar.gz -mv tmp-hypersdk/tokenvm /tmp/tokenvm -rm -rf tmp-hypersdk -``` - -*Note*: We must install the linux build because that is compatible with the AWS -deployment target. If you use Graivtron CPUs, make sure to use `arm64` here. - - -### Step 5: Plan Local Network Deploy - -Now we can spin up a new network of 6 nodes with some defaults: -- `avalanche-ops` supports [Graviton-based processors](https://aws.amazon.com/ec2/graviton/) (ARM64). Use `--arch-type arm64` to run nodes in ARM64 CPUs. -- `avalanche-ops` supports [EC2 Spot instances](https://aws.amazon.com/ec2/spot/) for cost savings. Use `--instance-mode=spot` to run instances in spot mode. -- `avalanche-ops` supports multi-region deployments. Use `--auto-regions 3` to distribute node across 3 regions. - -```bash -/tmp/avalancheup-aws default-spec \ ---arch-type amd64 \ ---os-type ubuntu20.04 \ ---anchor-nodes 3 \ ---non-anchor-nodes 3 \ ---regions us-west-2 \ ---instance-mode=on-demand \ ---instance-types='{"us-west-2":["c5.4xlarge"]}' \ ---ip-mode=ephemeral \ ---metrics-fetch-interval-seconds 60 \ ---network-name custom \ ---avalanchego-release-tag v1.10.3 \ ---create-dev-machine \ ---keys-to-generate 5 \ ---profile-nameplatformvm/vm.go:228 initializing last accepted {"blkID": "2EYLCg5YdYRx9h3g3odqDB49o35ekw6NtXqJaom7pb3Rpvmonc"} +[0;0m[0;36m[node1] [06-11|00:50:35.336] INFO
snowman/transitive.go:89 initializing consensus engine +[0;0m[0;36m[node1] [06-11|00:50:35.337] INFO server/server.go:269 adding route {"url": "/ext/bc/11111111111111111111111111111111LpoYY", "endpoint": ""} +[0;0m[0;36m[node1] [06-11|00:50:35.337] INFO indexer/index.go:100 created new index {"nextAcceptedIndex": 0} +[0;0m[0;36m[node1] [06-11|00:50:35.337] INFO server/server.go:308 adding route {"url": "/ext/index/P", "endpoint": "/block"} +[0;0m[0;36m[node1] [06-11|00:50:35.338] INFO
bootstrap/bootstrapper.go:115 starting bootstrapper +[0;0m[0;36m[node1] [06-11|00:50:35.338] INFO
common/bootstrapper.go:310 bootstrapping skipped {"reason": "no provided bootstraps"} +[0;0m[0;36m[node1] [06-11|00:50:35.338] INFO
bootstrap/bootstrapper.go:554 executing blocks {"numPendingJobs": 0} +[0;0m[0;36m[node1] [06-11|00:50:35.338] INFO
queue/jobs.go:224 executed operations {"numExecuted": 0} +[0;0m[0;36m[node1] [06-11|00:50:35.338] INFO
bootstrap/bootstrapper.go:599 waiting for the remaining chains in this subnet to finish syncing
+[0;0m[0;36m[node1] [06-11|00:50:35.338] INFO chains/manager.go:1338 starting chain creator
+[0;0m[0;36m[node1] [06-11|00:50:35.338] INFO chains/manager.go:319 creating chain {"subnetID": "11111111111111111111111111111111LpoYY", "chainID": "23JVJWr6QVJi91LuVNh8e2Cpd4vFe9ApVBzJf5yfq8hAFnd76Z", "vmID": "mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6"}
+[0;0m[0;36m[node1] [06-11|00:50:35.338] INFO server/server.go:184 HTTP API server listening {"host": "127.0.0.1", "port": 9650}
+[0;0m[0;36m[node1] [06-11|00:50:35.339] INFO chains/manager.go:1102 creating proposervm wrapper {"activationTime": "[12-05|05:00:00.000]", "minPChainHeight": 0, "minBlockDelay": "1s"}
+[0;0m[0;36m[node1] INFO [06-11|00:50:35.340] platformvm/vm.go:228 initializing last accepted {"blkID": "2EYLCg5YdYRx9h3g3odqDB49o35ekw6NtXqJaom7pb3Rpvmonc"}
+[0;0m[1;34m[node2] [06-11|00:50:35.636] INFO snowman/transitive.go:89 initializing consensus engine
+[0;0m[1;34m[node2] [06-11|00:50:35.637] INFO server/server.go:269 adding route {"url": "/ext/bc/11111111111111111111111111111111LpoYY", "endpoint": ""}
+[0;0m[1;34m[node2] [06-11|00:50:35.637] INFO indexer/index.go:100 created new index {"nextAcceptedIndex": 0}
+[0;0m[1;34m[node2] [06-11|00:50:35.638] INFO server/server.go:308 adding route {"url": "/ext/index/P", "endpoint": "/block"}
+[0;0m[1;34m[node2] [06-11|00:50:35.638] INFO bootstrap/bootstrapper.go:115 starting bootstrapper
+[0;0m[1;34m[node2] [06-11|00:50:35.638] INFO chains/manager.go:1338 starting chain creator
+[0;0m[1;34m[node2] [06-11|00:50:35.638] INFO server/server.go:184 HTTP API server listening {"host": "127.0.0.1", "port": 9652}
+[0;0m[0;36m[node1] DEBUG[06-11|00:50:35.753] common/bootstrapper.go:244 bootstrapping started syncing {"numVerticesInFrontier": 1}
+[0;0m[1;34m[node2] [06-11|00:50:35.755] INFO bootstrap/bootstrapper.go:554 executing blocks {"numPendingJobs": 0}
+[0;0m[1;34m[node2] [06-11|00:50:35.755] INFO queue/jobs.go:224 executed operations {"numExecuted": 0}
+[0;0m[1;34m[node2] [06-11|00:50:35.755] INFO bootstrap/bootstrapper.go:599 waiting for the remaining chains in this subnet to finish syncing
+[0;0m[1;34m[node2] [06-11|00:50:35.755] INFO chains/manager.go:319 creating chain {"subnetID": "11111111111111111111111111111111LpoYY", "chainID": "23JVJWr6QVJi91LuVNh8e2Cpd4vFe9ApVBzJf5yfq8hAFnd76Z", "vmID": "mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6"}
+[0;0m[1;34m[node2] [06-11|00:50:35.757] INFO chains/manager.go:1102 creating proposervm wrapper {"activationTime": "[12-05|05:00:00.000]", "minPChainHeight": 0, "minBlockDelay": "1s"}
+[0;0m[1;34m[node2] INFO [06-11|00:50:35.758] platformvm/vm.go:228 initializing last accepted {"blkID": "2EYLCg5YdYRx9h3g3odqDB49o35ekw6NtXqJaom7pb3Rpvmonc"}
+[0;0m[0;37m[node3] [06-11|00:50:36.005] INFO snowman/transitive.go:89 initializing consensus engine
+[0;0m[0;37m[node3] [06-11|00:50:36.006] INFO server/server.go:269 adding route {"url": "/ext/bc/11111111111111111111111111111111LpoYY", "endpoint": ""}
+[0;0m[0;37m[node3] [06-11|00:50:36.006] INFO indexer/index.go:100 created new index {"nextAcceptedIndex": 0}
+[0;0m[0;37m[node3] [06-11|00:50:36.006] INFO server/server.go:308 adding route {"url": "/ext/index/P", "endpoint": "/block"}
+[0;0m[0;37m[node3] [06-11|00:50:36.007] INFO bootstrap/bootstrapper.go:115 starting bootstrapper
+[0;0m[0;37m[node3] [06-11|00:50:36.007] INFO chains/manager.go:1338 starting chain creator
+[0;0m[0;37m[node3] [06-11|00:50:36.007] INFO server/server.go:184 HTTP API server listening {"host": "127.0.0.1", "port": 9654}
+[0;0m[1;34m[node2] DEBUG[06-11|00:50:36.110] common/bootstrapper.go:244 bootstrapping started syncing {"numVerticesInFrontier": 1}
+[0;0m[0;37m[node3] [06-11|00:50:36.117] INFO bootstrap/bootstrapper.go:554 executing blocks {"numPendingJobs": 0}
+[0;0m[0;37m[node3] [06-11|00:50:36.117] INFO queue/jobs.go:224 executed operations {"numExecuted": 0}
+[0;0m[0;37m[node3] [06-11|00:50:36.117] INFO bootstrap/bootstrapper.go:599 waiting for the remaining chains in this subnet to finish syncing
+[0;0m[0;37m[node3] [06-11|00:50:36.117] INFO chains/manager.go:319 creating chain {"subnetID": "11111111111111111111111111111111LpoYY", "chainID": "23JVJWr6QVJi91LuVNh8e2Cpd4vFe9ApVBzJf5yfq8hAFnd76Z", "vmID": "mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6"}
+[0;0m[0;37m[node3] [06-11|00:50:36.118] INFO chains/manager.go:1102 creating proposervm wrapper {"activationTime": "[12-05|05:00:00.000]", "minPChainHeight": 0, "minBlockDelay": "1s"}
+[0;0m[0;37m[node3] INFO [06-11|00:50:36.119]