diff --git a/chain/block.go b/chain/block.go index d915fa2e5f..1a062b7f1e 100644 --- a/chain/block.go +++ b/chain/block.go @@ -50,7 +50,7 @@ type StatefulBlock struct { // or [Verify], which reduces the amount of time we are // blocking the consensus engine from voting on the block, // starting the verification of another block, etc. - StateRoot ids.ID `json:"stateRoot"` + StateRoot ids.ID `json:"stateRoot"` size int @@ -100,8 +100,8 @@ type StatelessBlock struct { bytes []byte txsSet set.Set[ids.ID] - bctx *block.Context - vdrState validators.State + bctx *block.Context + vdrState validators.State results []*Result feeManager *fees.Manager diff --git a/chain/builder.go b/chain/builder.go index 9d4f1120f2..ea12487d6f 100644 --- a/chain/builder.go +++ b/chain/builder.go @@ -129,7 +129,7 @@ func BuildBlock( txsAttempted = 0 results = []*Result{} - sm = vm.StateManager() + sm = vm.StateManager() // prepareStreamLock ensures we don't overwrite stream prefetching spawned // asynchronously. diff --git a/chain/consts.go b/chain/consts.go index 4dba91a246..568f2a3f14 100644 --- a/chain/consts.go +++ b/chain/consts.go @@ -16,10 +16,10 @@ const ( // This value should be (much) less than the value of [ProposerWindow], otherwise honest // nodes may not build during their allocated window to avoid increasing the skew of the // chain time. - FutureBound = 1 * time.Second - HeightKeyChunks = 1 - TimestampKeyChunks = 1 - FeeKeyChunks = 8 // 96 (per dimension) * 5 (num dimensions) + FutureBound = 1 * time.Second + HeightKeyChunks = 1 + TimestampKeyChunks = 1 + FeeKeyChunks = 8 // 96 (per dimension) * 5 (num dimensions) // MaxKeyDependencies must be greater than the maximum number of key dependencies // any single task could have when executing a task. diff --git a/chain/transaction.go b/chain/transaction.go index 057f7f02a7..5dafb4cb04 100644 --- a/chain/transaction.go +++ b/chain/transaction.go @@ -27,23 +27,23 @@ var ( ) type Transaction struct { - Base *Base `json:"base"` + Base *Base `json:"base"` // TODO: turn [Action] into an array (#335) Action Action `json:"action"` Auth Auth `json:"auth"` - digest []byte - bytes []byte - size int - id ids.ID + digest []byte + bytes []byte + size int + id ids.ID stateKeys state.Keys } func NewTx(base *Base, act Action) *Transaction { return &Transaction{ - Base: base, - Action: act, + Base: base, + Action: act, } } diff --git a/cli/spam.go b/cli/spam.go index 90afdbba82..16978d538f 100644 --- a/cli/spam.go +++ b/cli/spam.go @@ -111,7 +111,7 @@ func (h *Handler) Spam( return err } action := getTransfer(keys[0].Address, 0) - maxUnits, err := chain.EstimateMaxUnits(parser.Rules(time.Now().UnixMilli()), action, factory, nil) + maxUnits, err := chain.EstimateMaxUnits(parser.Rules(time.Now().UnixMilli()), action, factory) if err != nil { return err } @@ -167,7 +167,7 @@ func (h *Handler) Spam( accounts[i] = pk // Send funds - _, tx, err := cli.GenerateTransactionManual(parser, nil, getTransfer(pk.Address, distAmount), factory, feePerTx) + _, tx, err := cli.GenerateTransactionManual(parser, getTransfer(pk.Address, distAmount), factory, feePerTx) if err != nil { return err } @@ -316,7 +316,7 @@ func (h *Handler) Spam( if maxFee != nil { fee = *maxFee } - _, tx, err := issuer.c.GenerateTransactionManual(parser, nil, action, factory, fee, tm) + _, tx, err := issuer.c.GenerateTransactionManual(parser, action, factory, fee, tm) if err != nil { utils.Outf("{{orange}}failed to generate tx:{{/}} %v\n", err) continue @@ -424,7 +424,7 @@ func (h *Handler) Spam( if err != nil { return err } - _, tx, err := cli.GenerateTransactionManual(parser, nil, getTransfer(key.Address, returnAmt), f, feePerTx) + _, tx, err := cli.GenerateTransactionManual(parser, getTransfer(key.Address, returnAmt), f, feePerTx) if err != nil { return err } diff --git a/examples/morpheusvm/genesis/genesis.go b/examples/morpheusvm/genesis/genesis.go index 6ebf7b0361..bfe536e32b 100644 --- a/examples/morpheusvm/genesis/genesis.go +++ b/examples/morpheusvm/genesis/genesis.go @@ -77,7 +77,7 @@ func Default() *Genesis { ValidityWindow: 60 * hconsts.MillisecondsPerSecond, // ms // Tx Fee Compute Parameters - BaseComputeUnits: 1, + BaseComputeUnits: 1, // Tx Fee Storage Parameters // diff --git a/examples/morpheusvm/storage/storage.go b/examples/morpheusvm/storage/storage.go index c4763eeb51..7db1a7eee6 100644 --- a/examples/morpheusvm/storage/storage.go +++ b/examples/morpheusvm/storage/storage.go @@ -40,10 +40,10 @@ const ( txPrefix = 0x0 // stateDB - balancePrefix = 0x0 - heightPrefix = 0x1 - timestampPrefix = 0x2 - feePrefix = 0x3 + balancePrefix = 0x0 + heightPrefix = 0x1 + timestampPrefix = 0x2 + feePrefix = 0x3 ) const BalanceChunks uint16 = 1 diff --git a/examples/tokenvm/actions/outputs.go b/examples/tokenvm/actions/outputs.go index 424443e823..1c4fd03622 100644 --- a/examples/tokenvm/actions/outputs.go +++ b/examples/tokenvm/actions/outputs.go @@ -4,33 +4,33 @@ package actions var ( - OutputValueZero = []byte("value is zero") - OutputMemoTooLarge = []byte("memo is too large") - OutputAssetIsNative = []byte("cannot mint native asset") - OutputAssetAlreadyExists = []byte("asset already exists") - OutputAssetMissing = []byte("asset missing") - OutputInTickZero = []byte("in rate is zero") - OutputOutTickZero = []byte("out rate is zero") - OutputSupplyZero = []byte("supply is zero") - OutputSupplyMisaligned = []byte("supply is misaligned") - OutputOrderMissing = []byte("order is missing") - OutputUnauthorized = []byte("unauthorized") - OutputWrongIn = []byte("wrong in asset") - OutputWrongOut = []byte("wrong out asset") - OutputWrongOwner = []byte("wrong owner") - OutputInsufficientInput = []byte("insufficient input") - OutputInsufficientOutput = []byte("insufficient output") - OutputValueMisaligned = []byte("value is misaligned") - OutputSymbolEmpty = []byte("symbol is empty") - OutputSymbolIncorrect = []byte("symbol is incorrect") - OutputSymbolTooLarge = []byte("symbol is too large") - OutputDecimalsIncorrect = []byte("decimal is incorrect") - OutputDecimalsTooLarge = []byte("decimal is too large") - OutputMetadataEmpty = []byte("metadata is empty") - OutputMetadataTooLarge = []byte("metadata is too large") - OutputSameInOut = []byte("same asset used for in and out") - OutputAnycast = []byte("anycast output") - OutputWrongDestination = []byte("wrong destination") - OutputMustFill = []byte("must fill request") - OutputInvalidDestination = []byte("invalid destination") + OutputValueZero = []byte("value is zero") + OutputMemoTooLarge = []byte("memo is too large") + OutputAssetIsNative = []byte("cannot mint native asset") + OutputAssetAlreadyExists = []byte("asset already exists") + OutputAssetMissing = []byte("asset missing") + OutputInTickZero = []byte("in rate is zero") + OutputOutTickZero = []byte("out rate is zero") + OutputSupplyZero = []byte("supply is zero") + OutputSupplyMisaligned = []byte("supply is misaligned") + OutputOrderMissing = []byte("order is missing") + OutputUnauthorized = []byte("unauthorized") + OutputWrongIn = []byte("wrong in asset") + OutputWrongOut = []byte("wrong out asset") + OutputWrongOwner = []byte("wrong owner") + OutputInsufficientInput = []byte("insufficient input") + OutputInsufficientOutput = []byte("insufficient output") + OutputValueMisaligned = []byte("value is misaligned") + OutputSymbolEmpty = []byte("symbol is empty") + OutputSymbolIncorrect = []byte("symbol is incorrect") + OutputSymbolTooLarge = []byte("symbol is too large") + OutputDecimalsIncorrect = []byte("decimal is incorrect") + OutputDecimalsTooLarge = []byte("decimal is too large") + OutputMetadataEmpty = []byte("metadata is empty") + OutputMetadataTooLarge = []byte("metadata is too large") + OutputSameInOut = []byte("same asset used for in and out") + OutputAnycast = []byte("anycast output") + OutputWrongDestination = []byte("wrong destination") + OutputMustFill = []byte("must fill request") + OutputInvalidDestination = []byte("invalid destination") ) diff --git a/examples/tokenvm/cmd/token-cli/cmd/action.go b/examples/tokenvm/cmd/token-cli/cmd/action.go index eeb991e602..2a150b48a9 100644 --- a/examples/tokenvm/cmd/token-cli/cmd/action.go +++ b/examples/tokenvm/cmd/token-cli/cmd/action.go @@ -6,20 +6,13 @@ package cmd import ( "context" - "errors" - "time" "github.com/ava-labs/avalanchego/ids" - "github.com/ava-labs/avalanchego/utils/set" - "github.com/ava-labs/hypersdk/chain" "github.com/ava-labs/hypersdk/codec" "github.com/ava-labs/hypersdk/consts" "github.com/ava-labs/hypersdk/examples/tokenvm/actions" frpc "github.com/ava-labs/hypersdk/examples/tokenvm/cmd/token-faucet/rpc" tconsts "github.com/ava-labs/hypersdk/examples/tokenvm/consts" - trpc "github.com/ava-labs/hypersdk/examples/tokenvm/rpc" - "github.com/ava-labs/hypersdk/pubsub" - "github.com/ava-labs/hypersdk/rpc" hutils "github.com/ava-labs/hypersdk/utils" "github.com/spf13/cobra" ) @@ -76,7 +69,7 @@ var fundFaucetCmd = &cobra.Command{ if err != nil { return err } - if _, _, err = sendAndWait(ctx, nil, &actions.Transfer{ + if _, _, err = sendAndWait(ctx, &actions.Transfer{ To: addr, Asset: ids.Empty, Value: amount, @@ -126,7 +119,7 @@ var transferCmd = &cobra.Command{ } // Generate transaction - _, _, err = sendAndWait(ctx, nil, &actions.Transfer{ + _, _, err = sendAndWait(ctx, &actions.Transfer{ To: recipient, Asset: assetID, Value: amount, @@ -169,7 +162,7 @@ var createAssetCmd = &cobra.Command{ } // Generate transaction - _, _, err = sendAndWait(ctx, nil, &actions.CreateAsset{ + _, _, err = sendAndWait(ctx, &actions.CreateAsset{ Symbol: []byte(symbol), Decimals: uint8(decimals), // already constrain above to prevent overflow Metadata: []byte(metadata), @@ -233,7 +226,7 @@ var mintAssetCmd = &cobra.Command{ } // Generate transaction - _, _, err = sendAndWait(ctx, nil, &actions.MintAsset{ + _, _, err = sendAndWait(ctx, &actions.MintAsset{ Asset: assetID, To: recipient, Value: amount, @@ -270,7 +263,7 @@ var closeOrderCmd = &cobra.Command{ } // Generate transaction - _, _, err = sendAndWait(ctx, nil, &actions.CloseOrder{ + _, _, err = sendAndWait(ctx, &actions.CloseOrder{ Order: orderID, Out: outAssetID, }, cli, scli, tcli, factory, true) @@ -356,7 +349,7 @@ var createOrderCmd = &cobra.Command{ } // Generate transaction - _, _, err = sendAndWait(ctx, nil, &actions.CreateOrder{ + _, _, err = sendAndWait(ctx, &actions.CreateOrder{ In: inAssetID, InTick: inTick, Out: outAssetID, @@ -473,7 +466,7 @@ var fillOrderCmd = &cobra.Command{ if err != nil { return err } - _, _, err = sendAndWait(ctx, nil, &actions.FillOrder{ + _, _, err = sendAndWait(ctx, &actions.FillOrder{ Order: order.ID, Owner: owner, In: inAssetID, diff --git a/examples/tokenvm/cmd/token-cli/cmd/handler.go b/examples/tokenvm/cmd/token-cli/cmd/handler.go index 2c303adc82..697189d4be 100644 --- a/examples/tokenvm/cmd/token-cli/cmd/handler.go +++ b/examples/tokenvm/cmd/token-cli/cmd/handler.go @@ -10,7 +10,6 @@ import ( "github.com/ava-labs/hypersdk/chain" "github.com/ava-labs/hypersdk/cli" "github.com/ava-labs/hypersdk/codec" - hconsts "github.com/ava-labs/hypersdk/consts" "github.com/ava-labs/hypersdk/crypto/ed25519" "github.com/ava-labs/hypersdk/examples/tokenvm/auth" "github.com/ava-labs/hypersdk/examples/tokenvm/consts" diff --git a/examples/tokenvm/cmd/token-cli/cmd/resolutions.go b/examples/tokenvm/cmd/token-cli/cmd/resolutions.go index 54dce659f6..c3939a3d24 100644 --- a/examples/tokenvm/cmd/token-cli/cmd/resolutions.go +++ b/examples/tokenvm/cmd/token-cli/cmd/resolutions.go @@ -23,27 +23,27 @@ import ( func sendAndWait( ctx context.Context, action chain.Action, cli *rpc.JSONRPCClient, scli *rpc.WebSocketClient, tcli *trpc.JSONRPCClient, factory chain.AuthFactory, printStatus bool, -) (bool, ids.ID, error) { +) (ids.ID, error) { parser, err := tcli.Parser(ctx) if err != nil { - return false, ids.Empty, err + return ids.Empty, err } _, tx, _, err := cli.GenerateTransaction(ctx, parser, action, factory) if err != nil { - return false, ids.Empty, err + return ids.Empty, err } if err := scli.RegisterTx(tx); err != nil { - return false, ids.Empty, err + return ids.Empty, err } var res *chain.Result for { txID, dErr, result, err := scli.ListenTx(ctx) if dErr != nil { - return false, ids.Empty, dErr + return ids.Empty, dErr } if err != nil { - return false, ids.Empty, err + return ids.Empty, err } if txID == tx.ID() { res = result @@ -54,7 +54,7 @@ func sendAndWait( if printStatus { handler.Root().PrintStatus(tx.ID(), res.Success) } - return res.Success, tx.ID(), nil + return tx.ID(), nil } func handleTx(c *trpc.JSONRPCClient, tx *chain.Transaction, result *chain.Result) { @@ -67,7 +67,7 @@ func handleTx(c *trpc.JSONRPCClient, tx *chain.Transaction, result *chain.Result case *actions.CreateAsset: summaryStr = fmt.Sprintf("assetID: %s symbol: %s decimals: %d metadata: %s", tx.ID(), action.Symbol, action.Decimals, action.Metadata) case *actions.MintAsset: - _, symbol, decimals, _, _, _, _, err := c.Asset(context.TODO(), action.Asset, true) + _, symbol, decimals, _, _, _, err := c.Asset(context.TODO(), action.Asset, true) if err != nil { utils.Outf("{{red}}could not fetch asset info:{{/}} %v", err) return @@ -78,7 +78,7 @@ func handleTx(c *trpc.JSONRPCClient, tx *chain.Transaction, result *chain.Result summaryStr = fmt.Sprintf("%d %s -> 🔥", action.Value, action.Asset) case *actions.Transfer: - _, symbol, decimals, _, _, _, _, err := c.Asset(context.TODO(), action.Asset, true) + _, symbol, decimals, _, _, _, err := c.Asset(context.TODO(), action.Asset, true) if err != nil { utils.Outf("{{red}}could not fetch asset info:{{/}} %v", err) return @@ -90,13 +90,13 @@ func handleTx(c *trpc.JSONRPCClient, tx *chain.Transaction, result *chain.Result } case *actions.CreateOrder: - _, inSymbol, inDecimals, _, _, _, _, err := c.Asset(context.TODO(), action.In, true) + _, inSymbol, inDecimals, _, _, _, err := c.Asset(context.TODO(), action.In, true) if err != nil { utils.Outf("{{red}}could not fetch asset info:{{/}} %v", err) return } inTickStr := utils.FormatBalance(action.InTick, inDecimals) - _, outSymbol, outDecimals, _, _, _, _, err := c.Asset(context.TODO(), action.Out, true) + _, outSymbol, outDecimals, _, _, _, err := c.Asset(context.TODO(), action.Out, true) if err != nil { utils.Outf("{{red}}could not fetch asset info:{{/}} %v", err) return @@ -106,13 +106,13 @@ func handleTx(c *trpc.JSONRPCClient, tx *chain.Transaction, result *chain.Result summaryStr = fmt.Sprintf("%s %s -> %s %s (supply: %s %s)", inTickStr, inSymbol, outTickStr, outSymbol, supplyStr, outSymbol) case *actions.FillOrder: or, _ := actions.UnmarshalOrderResult(result.Output) - _, inSymbol, inDecimals, _, _, _, _, err := c.Asset(context.TODO(), action.In, true) + _, inSymbol, inDecimals, _, _, _, err := c.Asset(context.TODO(), action.In, true) if err != nil { utils.Outf("{{red}}could not fetch asset info:{{/}} %v", err) return } inAmtStr := utils.FormatBalance(or.In, inDecimals) - _, outSymbol, outDecimals, _, _, _, _, err := c.Asset(context.TODO(), action.Out, true) + _, outSymbol, outDecimals, _, _, _, err := c.Asset(context.TODO(), action.Out, true) if err != nil { utils.Outf("{{red}}could not fetch asset info:{{/}} %v", err) return diff --git a/examples/tokenvm/cmd/token-cli/cmd/root.go b/examples/tokenvm/cmd/token-cli/cmd/root.go index e49a5e3822..e55fd77b53 100644 --- a/examples/tokenvm/cmd/token-cli/cmd/root.go +++ b/examples/tokenvm/cmd/token-cli/cmd/root.go @@ -162,9 +162,6 @@ func init() { createOrderCmd, fillOrderCmd, closeOrderCmd, - - importAssetCmd, - exportAssetCmd, ) // spam diff --git a/examples/tokenvm/cmd/token-cli/cmd/spam.go b/examples/tokenvm/cmd/token-cli/cmd/spam.go index 3360ecd99a..918d3f1a9f 100644 --- a/examples/tokenvm/cmd/token-cli/cmd/spam.go +++ b/examples/tokenvm/cmd/token-cli/cmd/spam.go @@ -87,7 +87,7 @@ var runSpamCmd = &cobra.Command{ }, func(cli *rpc.JSONRPCClient, priv *cli.PrivateKey) func(context.Context, uint64) error { // submitDummy return func(ictx context.Context, count uint64) error { - _, _, err := sendAndWait(ictx, nil, &actions.Transfer{ + _, _, err := sendAndWait(ictx, &actions.Transfer{ To: priv.Address, Value: count, // prevent duplicate txs }, cli, sclient, tclient, auth.NewED25519Factory(ed25519.PrivateKey(priv.Bytes)), false) diff --git a/examples/tokenvm/cmd/token-faucet/manager/manager.go b/examples/tokenvm/cmd/token-faucet/manager/manager.go index b445faad52..0c6586f518 100644 --- a/examples/tokenvm/cmd/token-faucet/manager/manager.go +++ b/examples/tokenvm/cmd/token-faucet/manager/manager.go @@ -122,7 +122,7 @@ func (m *Manager) sendFunds(ctx context.Context, destination codec.Address, amou if err != nil { return ids.Empty, 0, err } - submit, tx, maxFee, err := m.cli.GenerateTransaction(ctx, parser, nil, &actions.Transfer{ + submit, tx, maxFee, err := m.cli.GenerateTransaction(ctx, parser, &actions.Transfer{ To: destination, Asset: ids.Empty, Value: amount, diff --git a/examples/tokenvm/cmd/token-wallet/backend/backend.go b/examples/tokenvm/cmd/token-wallet/backend/backend.go index 2b8e8596f1..61c1fa3608 100644 --- a/examples/tokenvm/cmd/token-wallet/backend/backend.go +++ b/examples/tokenvm/cmd/token-wallet/backend/backend.go @@ -226,7 +226,7 @@ func (b *Backend) collectBlocks() { continue } - _, symbol, decimals, _, _, owner, _, err := b.tcli.Asset(b.ctx, action.Asset, true) + _, symbol, decimals, _, _, owner, err := b.tcli.Asset(b.ctx, action.Asset, true) if err != nil { b.fatal(err) return @@ -309,7 +309,7 @@ func (b *Backend) collectBlocks() { continue } - _, symbol, decimals, _, _, owner, _, err := b.tcli.Asset(b.ctx, action.Asset, true) + _, symbol, decimals, _, _, owner, err := b.tcli.Asset(b.ctx, action.Asset, true) if err != nil { b.fatal(err) return @@ -361,12 +361,12 @@ func (b *Backend) collectBlocks() { continue } - _, inSymbol, inDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, action.In, true) + _, inSymbol, inDecimals, _, _, _, err := b.tcli.Asset(b.ctx, action.In, true) if err != nil { b.fatal(err) return } - _, outSymbol, outDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, action.Out, true) + _, outSymbol, outDecimals, _, _, _, err := b.tcli.Asset(b.ctx, action.Out, true) if err != nil { b.fatal(err) return @@ -402,12 +402,12 @@ func (b *Backend) collectBlocks() { continue } - _, inSymbol, inDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, action.In, true) + _, inSymbol, inDecimals, _, _, _, err := b.tcli.Asset(b.ctx, action.In, true) if err != nil { b.fatal(err) return } - _, outSymbol, outDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, action.Out, true) + _, outSymbol, outDecimals, _, _, _, err := b.tcli.Asset(b.ctx, action.Out, true) if err != nil { b.fatal(err) return @@ -608,7 +608,7 @@ func (b *Backend) GetMyAssets() []*AssetInfo { if !owned[i] { continue } - _, symbol, decimals, metadata, supply, owner, _, err := b.tcli.Asset(b.ctx, asset, false) + _, symbol, decimals, metadata, supply, owner, err := b.tcli.Asset(b.ctx, asset, false) if err != nil { b.fatal(err) return nil @@ -639,7 +639,7 @@ func (b *Backend) CreateAsset(symbol string, decimals string, metadata string) e if err != nil { return err } - _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, nil, &actions.CreateAsset{ + _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, &actions.CreateAsset{ Symbol: []byte(symbol), Decimals: uint8(udecimals), Metadata: []byte(metadata), @@ -674,7 +674,7 @@ func (b *Backend) MintAsset(asset string, address string, amount string) error { if err != nil { return err } - _, _, decimals, _, _, _, _, err := b.tcli.Asset(b.ctx, assetID, true) + _, _, decimals, _, _, _, err := b.tcli.Asset(b.ctx, assetID, true) if err != nil { return err } @@ -694,7 +694,7 @@ func (b *Backend) MintAsset(asset string, address string, amount string) error { } // Generate transaction - _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, nil, &actions.MintAsset{ + _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, &actions.MintAsset{ To: to, Asset: assetID, Value: value, @@ -729,7 +729,7 @@ func (b *Backend) Transfer(asset string, address string, amount string, memo str if err != nil { return err } - _, symbol, decimals, _, _, _, _, err := b.tcli.Asset(b.ctx, assetID, true) + _, symbol, decimals, _, _, _, err := b.tcli.Asset(b.ctx, assetID, true) if err != nil { return err } @@ -758,7 +758,7 @@ func (b *Backend) Transfer(asset string, address string, amount string, memo str } // Generate transaction - _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, nil, &actions.Transfer{ + _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, &actions.Transfer{ To: to, Asset: assetID, Value: value, @@ -805,7 +805,7 @@ func (b *Backend) GetBalance() ([]*BalanceInfo, error) { } balances := []*BalanceInfo{} for _, asset := range assets { - _, symbol, decimals, _, _, _, _, err := b.tcli.Asset(b.ctx, asset, true) + _, symbol, decimals, _, _, _, err := b.tcli.Asset(b.ctx, asset, true) if err != nil { return nil, err } @@ -937,7 +937,7 @@ func (b *Backend) GetAllAssets() []*AssetInfo { } assets := []*AssetInfo{} for _, asset := range arr { - _, symbol, decimals, metadata, supply, owner, _, err := b.tcli.Asset(b.ctx, asset, false) + _, symbol, decimals, metadata, supply, owner, err := b.tcli.Asset(b.ctx, asset, false) if err != nil { b.fatal(err) return nil @@ -968,7 +968,7 @@ func (b *Backend) AddAsset(asset string) error { if hasAsset { return nil } - exists, _, _, _, _, owner, _, err := b.tcli.Asset(b.ctx, assetID, true) + exists, _, _, _, _, owner, err := b.tcli.Asset(b.ctx, assetID, true) if err != nil { return err } @@ -993,12 +993,12 @@ func (b *Backend) GetMyOrders() ([]*Order, error) { continue } inID := order.InAsset - _, inSymbol, inDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, inID, true) + _, inSymbol, inDecimals, _, _, _, err := b.tcli.Asset(b.ctx, inID, true) if err != nil { return nil, err } outID := order.OutAsset - _, outSymbol, outDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, outID, true) + _, outSymbol, outDecimals, _, _, _, err := b.tcli.Asset(b.ctx, outID, true) if err != nil { return nil, err } @@ -1035,7 +1035,7 @@ func (b *Backend) GetOrders(pair string) ([]*Order, error) { if err != nil { return nil, err } - _, inSymbol, inDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, inID, true) + _, inSymbol, inDecimals, _, _, _, err := b.tcli.Asset(b.ctx, inID, true) if err != nil { return nil, err } @@ -1044,7 +1044,7 @@ func (b *Backend) GetOrders(pair string) ([]*Order, error) { if err != nil { return nil, err } - _, outSymbol, outDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, outID, true) + _, outSymbol, outDecimals, _, _, _, err := b.tcli.Asset(b.ctx, outID, true) if err != nil { return nil, err } @@ -1080,11 +1080,11 @@ func (b *Backend) CreateOrder(assetIn string, inTick string, assetOut string, ou if err != nil { return err } - _, _, inDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, inID, true) + _, _, inDecimals, _, _, _, err := b.tcli.Asset(b.ctx, inID, true) if err != nil { return err } - _, outSymbol, outDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, outID, true) + _, outSymbol, outDecimals, _, _, _, err := b.tcli.Asset(b.ctx, outID, true) if err != nil { return err } @@ -1112,7 +1112,7 @@ func (b *Backend) CreateOrder(assetIn string, inTick string, assetOut string, ou } // Generate transaction - _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, nil, &actions.CreateOrder{ + _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, &actions.CreateOrder{ In: inID, InTick: iTick, Out: outID, @@ -1171,7 +1171,7 @@ func (b *Backend) FillOrder(orderID string, orderOwner string, assetIn string, i if err != nil { return err } - _, inSymbol, inDecimals, _, _, _, _, err := b.tcli.Asset(b.ctx, inID, true) + _, inSymbol, inDecimals, _, _, _, err := b.tcli.Asset(b.ctx, inID, true) if err != nil { return err } @@ -1198,7 +1198,7 @@ func (b *Backend) FillOrder(orderID string, orderOwner string, assetIn string, i } // Generate transaction - _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, nil, &actions.FillOrder{ + _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, &actions.FillOrder{ Order: oID, Owner: owner, In: inID, @@ -1255,7 +1255,7 @@ func (b *Backend) CloseOrder(orderID string, assetOut string) error { } // Generate transaction - _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, nil, &actions.CloseOrder{ + _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, &actions.CloseOrder{ Order: oID, Out: outID, }, b.factory) @@ -1395,7 +1395,7 @@ func (b *Backend) Message(message string, url string) error { } // Generate transaction - _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, nil, &actions.Transfer{ + _, tx, maxFee, err := b.cli.GenerateTransaction(b.ctx, b.parser, &actions.Transfer{ To: recipientAddr, Asset: ids.Empty, Value: fee, diff --git a/examples/tokenvm/genesis/genesis.go b/examples/tokenvm/genesis/genesis.go index 0832cb5532..4632bd332f 100644 --- a/examples/tokenvm/genesis/genesis.go +++ b/examples/tokenvm/genesis/genesis.go @@ -78,7 +78,7 @@ func Default() *Genesis { ValidityWindow: 60 * hconsts.MillisecondsPerSecond, // ms // Tx Fee Compute Parameters - BaseComputeUnits: 1, + BaseComputeUnits: 1, // Tx Fee Storage Parameters // diff --git a/examples/tokenvm/storage/storage.go b/examples/tokenvm/storage/storage.go index 70e192ae5a..4e79c005c5 100644 --- a/examples/tokenvm/storage/storage.go +++ b/examples/tokenvm/storage/storage.go @@ -44,13 +44,13 @@ const ( txPrefix = 0x0 // stateDB - balancePrefix = 0x0 - assetPrefix = 0x1 - orderPrefix = 0x2 - loanPrefix = 0x3 - heightPrefix = 0x4 - timestampPrefix = 0x5 - feePrefix = 0x6 + balancePrefix = 0x0 + assetPrefix = 0x1 + orderPrefix = 0x2 + loanPrefix = 0x3 + heightPrefix = 0x4 + timestampPrefix = 0x5 + feePrefix = 0x6 ) const ( diff --git a/examples/tokenvm/tests/integration/integration_test.go b/examples/tokenvm/tests/integration/integration_test.go index 0369048947..34e3a10be3 100644 --- a/examples/tokenvm/tests/integration/integration_test.go +++ b/examples/tokenvm/tests/integration/integration_test.go @@ -22,7 +22,6 @@ import ( "github.com/ava-labs/avalanchego/snow/choices" "github.com/ava-labs/avalanchego/snow/consensus/snowman" "github.com/ava-labs/avalanchego/snow/engine/common" - "github.com/ava-labs/avalanchego/snow/engine/snowman/block" "github.com/ava-labs/avalanchego/snow/validators" "github.com/ava-labs/avalanchego/utils/crypto/bls" "github.com/ava-labs/avalanchego/utils/logging" @@ -1684,42 +1683,6 @@ func expectBlk(i instance) func(bool) []*chain.Result { } } -// TODO: unify with expectBlk -func expectBlkWithContext(i instance) func(bool) []*chain.Result { - ctx := context.TODO() - - // manually signal ready - gomega.Ω(i.vm.Builder().Force(ctx)).To(gomega.BeNil()) - // manually ack ready sig as in engine - <-i.toEngine - - bctx := &block.Context{PChainHeight: 1} - blk, err := i.vm.BuildBlockWithContext(ctx, bctx) - gomega.Ω(err).To(gomega.BeNil()) - gomega.Ω(blk).To(gomega.Not(gomega.BeNil())) - cblk := blk.(block.WithVerifyContext) - - gomega.Ω(cblk.VerifyWithContext(ctx, bctx)).To(gomega.BeNil()) - gomega.Ω(blk.Status()).To(gomega.Equal(choices.Processing)) - - err = i.vm.SetPreference(ctx, blk.ID()) - gomega.Ω(err).To(gomega.BeNil()) - - return func(add bool) []*chain.Result { - gomega.Ω(blk.Accept(ctx)).To(gomega.BeNil()) - gomega.Ω(blk.Status()).To(gomega.Equal(choices.Accepted)) - - if add { - blocks = append(blocks, blk) - } - - lastAccepted, err := i.vm.LastAccepted(ctx) - gomega.Ω(err).To(gomega.BeNil()) - gomega.Ω(lastAccepted).To(gomega.Equal(blk.ID())) - return blk.(*chain.StatelessBlock).Results() - } -} - var _ common.AppSender = &appSender{} type appSender struct { diff --git a/x/programs/cmd/simulator/vm/genesis/genesis.go b/x/programs/cmd/simulator/vm/genesis/genesis.go index 24e9ed7162..958ca59817 100644 --- a/x/programs/cmd/simulator/vm/genesis/genesis.go +++ b/x/programs/cmd/simulator/vm/genesis/genesis.go @@ -81,7 +81,7 @@ func Default() *Genesis { MaxBlockUnits: fees.Dimensions{1_800_000, 2_000, 2_000, 2_000, 2_000}, // Tx Fee Compute Parameters - BaseComputeUnits: 1, + BaseComputeUnits: 1, // Tx Fee Storage Parameters // diff --git a/x/programs/cmd/simulator/vm/storage/storage.go b/x/programs/cmd/simulator/vm/storage/storage.go index 0f0e02f565..c3a6b70728 100644 --- a/x/programs/cmd/simulator/vm/storage/storage.go +++ b/x/programs/cmd/simulator/vm/storage/storage.go @@ -24,10 +24,10 @@ const ( // stateDB keyPrefix = 0x0 - programPrefix = 0x1 - heightPrefix = 0x2 - timestampPrefix = 0x3 - feePrefix = 0x4 + programPrefix = 0x1 + heightPrefix = 0x2 + timestampPrefix = 0x3 + feePrefix = 0x4 ) var (