From b63e5edea1dfd4e6de83b2a8e5434756ca0d5efa Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 16 Apr 2024 17:33:43 +0200 Subject: [PATCH 1/6] fix: use atomic for global counter used for parallel testing (#1932) This allows `go test -race` to pass on`gnovm/pkg/gnolang` when run in parallel mode with CPU > 1. As we use lockless atomic instructions there should be no overhead. --- gnovm/pkg/gnolang/preprocess.go | 12 +++++------- gnovm/pkg/gnolang/values_conversions.go | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index 029641f2507..33a6beea581 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -4,6 +4,7 @@ import ( "fmt" "math/big" "reflect" + "sync/atomic" "github.com/gnolang/gno/tm2/pkg/errors" ) @@ -95,7 +96,8 @@ func PredefineFileSet(store Store, pn *PackageNode, fset *FileSet) { // (like ConvertUntypedTo() for bigints and strings) // are only called during the preprocessing stage. // It is a counter because Preprocess() is recursive. -var preprocessing int +// As a global counter, use lockless atomic to support concurrency. +var preprocessing atomic.Int32 // Preprocess n whose parent block node is ctx. If any names // are defined in another file, generally you must call @@ -116,12 +118,8 @@ var preprocessing int // - TODO document what it does. func Preprocess(store Store, ctx BlockNode, n Node) Node { // Increment preprocessing counter while preprocessing. - { - preprocessing += 1 - defer func() { - preprocessing -= 1 - }() - } + preprocessing.Add(1) + defer preprocessing.Add(-1) if ctx == nil { // Generally a ctx is required, but if not, it's ok to pass in nil. diff --git a/gnovm/pkg/gnolang/values_conversions.go b/gnovm/pkg/gnolang/values_conversions.go index 66d8bcbf233..b4888878c7a 100644 --- a/gnovm/pkg/gnolang/values_conversions.go +++ b/gnovm/pkg/gnolang/values_conversions.go @@ -939,17 +939,17 @@ func ConvertUntypedTo(tv *TypedValue, t Type) { case UntypedRuneType: ConvertUntypedRuneTo(tv, t) case UntypedBigintType: - if preprocessing == 0 { + if preprocessing.Load() == 0 { panic("untyped Bigint conversion should not happen during interpretation") } ConvertUntypedBigintTo(tv, tv.V.(BigintValue), t) case UntypedBigdecType: - if preprocessing == 0 { + if preprocessing.Load() == 0 { panic("untyped Bigdec conversion should not happen during interpretation") } ConvertUntypedBigdecTo(tv, tv.V.(BigdecValue), t) case UntypedStringType: - if preprocessing == 0 { + if preprocessing.Load() == 0 { panic("untyped String conversion should not happen during interpretation") } if t.Kind() == StringKind { From 56100a7a6c0b91ccf414066096b12a071a88c615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20=C5=BDivkovi=C4=87?= Date: Tue, 16 Apr 2024 18:23:54 +0200 Subject: [PATCH 2/6] feat: slightly improve node log lines (#1916) ## Description This PR improves the log lines produced by the node binary. Before: ![cast2](https://github.com/gnolang/gno/assets/16712663/84d0b570-e7a3-410a-bb93-f20581d95e71) After: ![cast1](https://github.com/gnolang/gno/assets/16712663/bdca272d-9c2a-4249-8f70-a0c383bd7e6c)
Contributors' checklist... - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [ ] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
--- gno.land/cmd/gnoland/start.go | 15 ++++++- gno.land/cmd/gnoland/start_test.go | 69 +++++++++++++----------------- gno.land/pkg/gnoland/app.go | 13 +++--- gno.land/pkg/sdk/vm/keeper.go | 8 +--- tm2/pkg/bft/consensus/state.go | 62 +++++++++++++++++++++++---- tm2/pkg/p2p/switch.go | 7 ++- 6 files changed, 111 insertions(+), 63 deletions(-) diff --git a/gno.land/cmd/gnoland/start.go b/gno.land/cmd/gnoland/start.go index 921fcc89640..a991e2e0dc0 100644 --- a/gno.land/cmd/gnoland/start.go +++ b/gno.land/cmd/gnoland/start.go @@ -29,6 +29,15 @@ import ( "go.uber.org/zap/zapcore" ) +var startGraphic = fmt.Sprintf(` + __ __ + ____ _____ ____ / /___ _____ ____/ / + / __ %c/ __ \/ __ \/ / __ %c/ __ \/ __ / + / /_/ / / / / /_/ / / /_/ / / / / /_/ / + \__, /_/ /_/\____/_/\__,_/_/ /_/\__,_/ +/____/ +`, '`', '`') + type startCfg struct { gnoRootDir string skipFailingGenesisTxs bool @@ -268,13 +277,15 @@ func execStart(c *startCfg, io commands.IO) error { } cfg.LocalApp = gnoApp + if logFormat != log.JSONFormat { + io.Println(startGraphic) + } + gnoNode, err := node.DefaultNewNode(cfg, logger) if err != nil { return fmt.Errorf("error in creating node: %w", err) } - fmt.Fprintln(io.Err(), "Node created.") - if c.skipStart { io.ErrPrintln("'--skip-start' is set. Exiting.") return nil diff --git a/gno.land/cmd/gnoland/start_test.go b/gno.land/cmd/gnoland/start_test.go index 661d329e103..2f266d8a879 100644 --- a/gno.land/cmd/gnoland/start_test.go +++ b/gno.land/cmd/gnoland/start_test.go @@ -3,52 +3,43 @@ package main import ( "bytes" "context" - "os" - "path/filepath" - "strings" "testing" + "time" "github.com/gnolang/gno/tm2/pkg/commands" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestStartInitialize(t *testing.T) { t.Parallel() - cases := []struct { - args []string - }{ - {[]string{"start", "--skip-start", "--skip-failing-genesis-txs"}}, - // {[]string{"--skip-start"}}, - // FIXME: test seems flappy as soon as we have multiple cases. - } - os.Chdir(filepath.Join("..", "..")) // go to repo's root dir - - for _, tc := range cases { - tc := tc - name := strings.Join(tc.args, " ") - t.Run(name, func(t *testing.T) { - t.Parallel() - - mockOut := new(bytes.Buffer) - mockErr := new(bytes.Buffer) - io := commands.NewTestIO() - io.SetOut(commands.WriteNopCloser(mockOut)) - io.SetErr(commands.WriteNopCloser(mockErr)) - cmd := newRootCmd(io) - - t.Logf(`Running "gnoland %s"`, strings.Join(tc.args, " ")) - err := cmd.ParseAndRun(context.Background(), tc.args) - require.NoError(t, err) - - stdout := mockOut.String() - stderr := mockErr.String() - - require.Contains(t, stderr, "Node created.", "failed to create node") - require.Contains(t, stderr, "'--skip-start' is set. Exiting.", "not exited with skip-start") - require.NotContains(t, stdout, "panic:") - }) - } + var ( + nodeDir = t.TempDir() + + args = []string{ + "start", + "--skip-start", + "--skip-failing-genesis-txs", + "--data-dir", + nodeDir, + } + ) + + // Prepare the IO + mockOut := new(bytes.Buffer) + mockErr := new(bytes.Buffer) + io := commands.NewTestIO() + io.SetOut(commands.WriteNopCloser(mockOut)) + io.SetErr(commands.WriteNopCloser(mockErr)) + + // Create and run the command + ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) + defer cancelFn() + + cmd := newRootCmd(io) + require.NoError(t, cmd.ParseAndRun(ctx, args)) + + // Make sure the directory is created + assert.DirExists(t, nodeDir) } - -// TODO: test various configuration files? diff --git a/gno.land/pkg/gnoland/app.go b/gno.land/pkg/gnoland/app.go index f67b86fd735..d1978e76563 100644 --- a/gno.land/pkg/gnoland/app.go +++ b/gno.land/pkg/gnoland/app.go @@ -7,7 +7,6 @@ import ( "github.com/gnolang/gno/gno.land/pkg/sdk/vm" "github.com/gnolang/gno/gnovm/pkg/gnoenv" - "github.com/gnolang/gno/tm2/pkg/amino" abci "github.com/gnolang/gno/tm2/pkg/bft/abci/types" dbm "github.com/gnolang/gno/tm2/pkg/db" "github.com/gnolang/gno/tm2/pkg/log" @@ -169,13 +168,15 @@ func InitChainer(baseApp *sdk.BaseApp, acctKpr auth.AccountKeeperI, bankKpr bank } // Run genesis txs. - for i, tx := range genState.Txs { + for _, tx := range genState.Txs { res := baseApp.Deliver(tx) if res.IsErr() { - ctx.Logger().Error("LOG", "log", res.Log) - ctx.Logger().Error(fmt.Sprintf("#%d", i), "value", string(amino.MustMarshalJSON(tx))) - } else { - ctx.Logger().Info("SUCCESS:", "value", string(amino.MustMarshalJSON(tx))) + ctx.Logger().Error( + "Unable to deliver genesis tx", + "log", res.Log, + "error", res.Error, + "gas-used", res.GasUsed, + ) } resHandler(ctx, tx, res) diff --git a/gno.land/pkg/sdk/vm/keeper.go b/gno.land/pkg/sdk/vm/keeper.go index 67710be620c..e9223143bf5 100644 --- a/gno.land/pkg/sdk/vm/keeper.go +++ b/gno.land/pkg/sdk/vm/keeper.go @@ -200,7 +200,6 @@ func (vm *VMKeeper) AddPackage(ctx sdk.Context, msg MsgAddPackage) error { defer m2.Release() m2.RunMemPackage(memPkg, true) - ctx.Logger().Info("CPUCYCLES", "addpkg", m2.Cycles) return nil } @@ -285,7 +284,7 @@ func (vm *VMKeeper) Call(ctx sdk.Context, msg MsgCall) (res string, err error) { m.Release() }() rtvs := m.Eval(xn) - ctx.Logger().Info("CPUCYCLES call", "num-cycles", m.Cycles) + for i, rtv := range rtvs { res = res + rtv.String() if i < len(rtvs)-1 { @@ -349,7 +348,6 @@ func (vm *VMKeeper) Run(ctx sdk.Context, msg MsgRun) (res string, err error) { }) defer m.Release() _, pv := m.RunMemPackage(memPkg, false) - ctx.Logger().Info("CPUCYCLES", "addpkg", m.Cycles) m2 := gno.NewMachineWithOptions( gno.MachineOptions{ @@ -370,9 +368,7 @@ func (vm *VMKeeper) Run(ctx sdk.Context, msg MsgRun) (res string, err error) { m2.Release() }() m2.RunMain() - ctx.Logger().Info("CPUCYCLES call", - "cycles", m2.Cycles, - ) + res = buf.String() return res, nil } diff --git a/tm2/pkg/bft/consensus/state.go b/tm2/pkg/bft/consensus/state.go index 4e64418f6ac..a16a9d2f53d 100644 --- a/tm2/pkg/bft/consensus/state.go +++ b/tm2/pkg/bft/consensus/state.go @@ -947,8 +947,15 @@ func (cs *ConsensusState) defaultDecideProposal(height int64, round int) { part := blockParts.GetPart(i) cs.sendInternalMessage(msgInfo{&BlockPartMessage{cs.Height, cs.Round, part}, ""}) } - cs.Logger.Info("Signed proposal", "height", height, "round", round, "proposal", proposal) - cs.Logger.Debug(fmt.Sprintf("Signed proposal block: %v", block)) + + cs.Logger.Info( + "Signed proposal", + "height", height, + "round", round, + "proposal block ID", proposal.BlockID.String(), + "proposal round", proposal.POLRound, + "proposal timestamp", proposal.Timestamp.Unix(), + ) } else if !cs.replayMode { cs.Logger.Error("enterPropose: Error signing proposal", "height", height, "round", round, "err", err) } @@ -1310,9 +1317,13 @@ func (cs *ConsensusState) finalizeCommit(height int64) { panic(fmt.Sprintf("+2/3 committed an invalid block: %v", err)) } - cs.Logger.Info(fmt.Sprintf("Finalizing commit of block with %d txs", block.NumTxs), - "height", block.Height, "hash", block.Hash(), "root", block.AppHash) - cs.Logger.Info(fmt.Sprintf("%v", block)) + cs.Logger.Info( + "Finalizing commit of block", + "root", block.AppHash, + "height", block.Height, + "hash", block.Hash(), + "num txs", block.NumTxs, + ) fail.Fail() // XXX @@ -1415,7 +1426,16 @@ func (cs *ConsensusState) defaultSetProposal(proposal *types.Proposal) error { if cs.ProposalBlockParts == nil { cs.ProposalBlockParts = types.NewPartSetFromHeader(proposal.BlockID.PartsHeader) } - cs.Logger.Info("Received proposal", "proposal", proposal) + + cs.Logger.Info( + "Received proposal", + "height", proposal.Height, + "round", proposal.Round, + "proposal block ID", proposal.BlockID.String(), + "proposal round", proposal.POLRound, + "proposal timestamp", proposal.Timestamp.Unix(), + ) + return nil } @@ -1573,7 +1593,13 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool, switch vote.Type { case types.PrevoteType: prevotes := cs.Votes.Prevotes(vote.Round) - cs.Logger.Info("Added to prevote", "vote", vote, "prevotes", prevotes.StringShort()) + cs.Logger.Debug( + "Added to prevote", + "type", vote.Type, + "vote height", vote.Height, + "vote round", vote.Round, + "prevotes", prevotes.StringShort(), + ) // If +2/3 prevotes for a block or nil for *any* round: if blockID, ok := prevotes.TwoThirdsMajority(); ok { @@ -1638,7 +1664,13 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerID p2p.ID) (added bool, case types.PrecommitType: precommits := cs.Votes.Precommits(vote.Round) - cs.Logger.Info("Added to precommit", "vote", vote, "precommits", precommits.StringShort()) + cs.Logger.Debug( + "Added to precommit", + "type", vote.Type, + "vote height", vote.Height, + "vote round", vote.Round, + "precommits", precommits.StringShort(), + ) blockID, ok := precommits.TwoThirdsMajority() if ok { @@ -1713,7 +1745,19 @@ func (cs *ConsensusState) signAddVote(type_ types.SignedMsgType, hash []byte, he vote, err := cs.signVote(type_, hash, header) if err == nil { cs.sendInternalMessage(msgInfo{&VoteMessage{vote}, ""}) - cs.Logger.Info("Signed and pushed vote", "height", cs.Height, "round", cs.Round, "vote", vote, "err", err) + + cs.Logger.Info( + "Signed and pushed vote", + "height", cs.Height, + "round", cs.Round, + "type", vote.Type, + "timestamp", vote.Timestamp.String(), + "height", vote.Height, + "round", vote.Round, + "validator address", vote.ValidatorAddress, + "validator index", vote.ValidatorIndex, + ) + return vote } // if !cs.replayMode { diff --git a/tm2/pkg/p2p/switch.go b/tm2/pkg/p2p/switch.go index 9d013b42ad1..d24240f731e 100644 --- a/tm2/pkg/p2p/switch.go +++ b/tm2/pkg/p2p/switch.go @@ -246,7 +246,12 @@ func (sw *Switch) OnStop() { // NOTE: Broadcast uses goroutines, so order of broadcast may not be preserved. func (sw *Switch) Broadcast(chID byte, msgBytes []byte) chan bool { startTime := time.Now() - sw.Logger.Debug("Broadcast", "channel", chID, "msgBytes", fmt.Sprintf("%X", msgBytes)) + + sw.Logger.Debug( + "Broadcast", + "channel", chID, + "value", fmt.Sprintf("%X", msgBytes), + ) peers := sw.peers.List() var wg sync.WaitGroup From 229bf0e3fe4c02018a7344ac1aab719eaa84f39e Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Tue, 16 Apr 2024 23:03:12 +0530 Subject: [PATCH 3/6] docs: namespaces concepts page (#1909) Adds info about the namespaces and package/realm path. --- docs/concepts/namespaces.md | 35 +++++++++++++++++++++++++++++++++++ misc/docusaurus/sidebars.js | 1 + 2 files changed, 36 insertions(+) create mode 100644 docs/concepts/namespaces.md diff --git a/docs/concepts/namespaces.md b/docs/concepts/namespaces.md new file mode 100644 index 00000000000..74129697c88 --- /dev/null +++ b/docs/concepts/namespaces.md @@ -0,0 +1,35 @@ +--- +id: namespaces +--- + +# Namespaces + +Namespaces provide users with the exclusive capability to publish contracts under their designated namespaces, similar to GitHub's user and organization model. + +This feature is currently a work in progress (WIP). To learn more about namespaces, please checkout https://github.com/gnolang/gno/issues/1107. + +# Package Path + +A package path is a unique identifier for each package/realm. It specifies the location of the package source code which helps differentiate it from others. You can use a package path to: + +- Call a specific function from a package/realm. (e.g using `gnokey maketx call`) +- Import it in other packages/realms. + +Here's a breakdown of the structure of a package path: + +- Domain: The domain of the blockchain where the package is deployed. Currently, only `gno.land/` is supported. +- Type: Defines the type of package. + - `p/`: [Package](packages.md) + - `r/`: [Realm](realms.md) +- Namespace: A namespace can be included after the type (e.g., user or organization name). Namespaces are a way to group related packages or realms, but currently ownership cannot be claimed. (see [Issue #1107](https://github.com/gnolang/gno/issues/1107) for more info) +- Remaining Path: The remaining part of the path. + - Can only contain alphanumeric characters (letters and numbers) and underscores. + - No special characters allowed (except underscore). + - Cannot consist solely of underscores. It must have at least one allowed alphanumeric character. + - Cannot start with a number. It should begin with a letter. + - Cannot end with a trailing slash (`/`). + +Examples: + +- `gno.land/p/demo/avl`: This signifies a package named `avl` within the `demo` namespace. +- `gno.land/r/gnoland/home`: This signifies a realm named `home` within the `gnoland` namespace. diff --git a/misc/docusaurus/sidebars.js b/misc/docusaurus/sidebars.js index 5a2533d7a44..b7dcc861290 100644 --- a/misc/docusaurus/sidebars.js +++ b/misc/docusaurus/sidebars.js @@ -45,6 +45,7 @@ const sidebars = { items: [ 'concepts/realms', 'concepts/packages', + 'concepts/namespaces', { type: 'category', label: 'Standard Libraries', From 2a06d8e71215ebb40f990efc7d2337b90a5ca7d1 Mon Sep 17 00:00:00 2001 From: Blake <104744707+r3v4s@users.noreply.github.com> Date: Wed, 17 Apr 2024 09:58:20 +0900 Subject: [PATCH 4/6] fix: wugnot-to-respect-p_users (#1782) ### !!! BREAKING CHANGE: data type for `wugnot` public function's parameter has been changed Just like `foo20` respects a new `p/demo/users`, fix `wugnot` to respect it too. Related https://github.com/gnolang/gno/pull/1433 by @harry-hov
Contributors' checklist... - [x] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
--- examples/gno.land/r/demo/wugnot/gno.mod | 2 ++ examples/gno.land/r/demo/wugnot/wugnot.gno | 24 +++++++++++-------- .../gno.land/r/demo/wugnot/z0_filetest.gno | 4 +++- .../cmd/gnoland/testdata/issue-1786.txtar | 7 +++--- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/examples/gno.land/r/demo/wugnot/gno.mod b/examples/gno.land/r/demo/wugnot/gno.mod index 1f03ded515c..f076e90e068 100644 --- a/examples/gno.land/r/demo/wugnot/gno.mod +++ b/examples/gno.land/r/demo/wugnot/gno.mod @@ -3,4 +3,6 @@ module gno.land/r/demo/wugnot require ( gno.land/p/demo/grc/grc20 v0.0.0-latest gno.land/p/demo/ufmt v0.0.0-latest + gno.land/p/demo/users v0.0.0-latest + gno.land/r/demo/users v0.0.0-latest ) diff --git a/examples/gno.land/r/demo/wugnot/wugnot.gno b/examples/gno.land/r/demo/wugnot/wugnot.gno index 85a05ae3d6d..4896d23499e 100644 --- a/examples/gno.land/r/demo/wugnot/wugnot.gno +++ b/examples/gno.land/r/demo/wugnot/wugnot.gno @@ -6,6 +6,10 @@ import ( "gno.land/p/demo/grc/grc20" "gno.land/p/demo/ufmt" + + "gno.land/r/demo/users" + + pusers "gno.land/p/demo/users" ) var ( @@ -82,16 +86,16 @@ func TotalSupply() uint64 { return wugnot.TotalSupply() } -func BalanceOf(owner std.Address) uint64 { - balance, err := wugnot.BalanceOf(owner) +func BalanceOf(owner pusers.AddressOrName) uint64 { + balance, err := wugnot.BalanceOf(users.Resolve(owner)) if err != nil { panic(err) } return balance } -func Allowance(owner, spender std.Address) uint64 { - allowance, err := wugnot.Allowance(owner, spender) +func Allowance(owner, spender pusers.AddressOrName) uint64 { + allowance, err := wugnot.Allowance(users.Resolve(owner), users.Resolve(spender)) if err != nil { panic(err) } @@ -101,25 +105,25 @@ func Allowance(owner, spender std.Address) uint64 { // setters. // -func Transfer(to std.Address, amount uint64) { +func Transfer(to pusers.AddressOrName, amount uint64) { caller := std.PrevRealm().Addr() - err := wugnot.Transfer(caller, to, amount) + err := wugnot.Transfer(caller, users.Resolve(to), amount) if err != nil { panic(err) } } -func Approve(spender std.Address, amount uint64) { +func Approve(spender pusers.AddressOrName, amount uint64) { caller := std.PrevRealm().Addr() - err := wugnot.Approve(caller, spender, amount) + err := wugnot.Approve(caller, users.Resolve(spender), amount) if err != nil { panic(err) } } -func TransferFrom(from, to std.Address, amount uint64) { +func TransferFrom(from, to pusers.AddressOrName, amount uint64) { caller := std.PrevRealm().Addr() - err := wugnot.TransferFrom(caller, from, to, amount) + err := wugnot.TransferFrom(caller, users.Resolve(from), users.Resolve(to), amount) if err != nil { panic(err) } diff --git a/examples/gno.land/r/demo/wugnot/z0_filetest.gno b/examples/gno.land/r/demo/wugnot/z0_filetest.gno index fa2f45682b1..6eb47d7636d 100644 --- a/examples/gno.land/r/demo/wugnot/z0_filetest.gno +++ b/examples/gno.land/r/demo/wugnot/z0_filetest.gno @@ -7,6 +7,8 @@ import ( "gno.land/p/demo/testutils" "gno.land/r/demo/wugnot" + + pusers "gno.land/p/demo/users" ) var ( @@ -37,7 +39,7 @@ func main() { func printBalances() { printSingleBalance := func(name string, addr std.Address) { - wugnotBal := wugnot.BalanceOf(addr) + wugnotBal := wugnot.BalanceOf(pusers.AddressOrName(addr)) std.TestSetOrigCaller(addr) abanker := std.GetBanker(std.BankerTypeOrigSend) acoins := abanker.GetCoins(addr).AmountOf("ugnot") diff --git a/gno.land/cmd/gnoland/testdata/issue-1786.txtar b/gno.land/cmd/gnoland/testdata/issue-1786.txtar index c42cca490b6..a14f06cf9b9 100644 --- a/gno.land/cmd/gnoland/testdata/issue-1786.txtar +++ b/gno.land/cmd/gnoland/testdata/issue-1786.txtar @@ -48,6 +48,7 @@ import ( "gno.land/r/demo/wugnot" "gno.land/p/demo/ufmt" + pusers "gno.land/p/demo/users" ) func ProxyWrap() { @@ -65,17 +66,17 @@ func ProxyWrap() { wugnot.Deposit() // `proxywugnot` has ugnot // SEND WUGNOT: PROXY_WUGNOT -> USER - wugnot.Transfer(std.GetOrigCaller(), ugnotSent) + wugnot.Transfer(pusers.AddressOrName(std.GetOrigCaller()), ugnotSent) } func ProxyUnwrap(wugnotAmount uint64) { if wugnotAmount == 0 { return } - userOldWugnot := wugnot.BalanceOf(std.GetOrigCaller()) + userOldWugnot := wugnot.BalanceOf(pusers.AddressOrName(std.GetOrigCaller())) // SEND WUGNOT: USER -> PROXY_WUGNOT - wugnot.TransferFrom(std.GetOrigCaller(), std.CurrentRealm().Addr(), wugnotAmount) + wugnot.TransferFrom(pusers.AddressOrName(std.GetOrigCaller()), pusers.AddressOrName(std.CurrentRealm().Addr()), wugnotAmount) // UNWRAP IT wugnot.Withdraw(wugnotAmount) From a72e406099a18243d9c8bb3b8d7ac53ae1b3c0cb Mon Sep 17 00:00:00 2001 From: Snoppy Date: Wed, 17 Apr 2024 12:21:06 +0800 Subject: [PATCH 5/6] chore: fix typos and broken link (#1924) fix minor typo and link broken Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com> --- gnovm/stdlibs/unicode/README.md | 2 +- tm2/pkg/iavl/PERFORMANCE.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gnovm/stdlibs/unicode/README.md b/gnovm/stdlibs/unicode/README.md index d52242eae5e..208e28a89b1 100644 --- a/gnovm/stdlibs/unicode/README.md +++ b/gnovm/stdlibs/unicode/README.md @@ -1,3 +1,3 @@ -Direclty copied from go1.17.5. BSD license. +Directly copied from go1.17.5. BSD license. TestCalibrate() commented out for import reasons. diff --git a/tm2/pkg/iavl/PERFORMANCE.md b/tm2/pkg/iavl/PERFORMANCE.md index 3aac2425157..7be3e4b99fc 100644 --- a/tm2/pkg/iavl/PERFORMANCE.md +++ b/tm2/pkg/iavl/PERFORMANCE.md @@ -79,7 +79,7 @@ Some guides: Some ideas for speedups: - * [Speedup SHA256 100x on ARM](https://blog.minio.io/accelerating-sha256-by-100x-in-golang-on-arm-1517225f5ff4#.pybt7bb3w) + * [Speedup SHA256 100x on ARM](https://blog.min.io/accelerating-sha256-by-100x-in-golang-on-arm/) * [Faster SHA256 golang implementation](https://github.com/minio/sha256-simd) * [Data structure alignment](http://stackoverflow.com/questions/39063530/optimising-datastructure-word-alignment-padding-in-golang) * [Slice alignment](http://blog.chewxy.com/2016/07/25/on-the-memory-alignment-of-go-slice-values/) From 3297d0c3282b212d152d507ac4dbbb64b09f3793 Mon Sep 17 00:00:00 2001 From: Kristov Atlas <7227529+kristovatlas@users.noreply.github.com> Date: Wed, 17 Apr 2024 02:58:34 -0500 Subject: [PATCH 6/6] ci: create codeql.yml (#1915) Enabling CodeQL code security scanning support for the gno repo.
Contributors' checklist... - [ ] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests - [x] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
--------- Co-authored-by: Hariom Verma --- .github/workflows/codeql.yml | 89 ++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000000..d2eef9d7445 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,89 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "master", "chain/*" ] + pull_request: + branches: [ "master", "chain/*" ] + schedule: + - cron: '22 17 * * 3' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ubuntu-latest + timeout-minutes: 360 + permissions: + # required for all workflows + security-events: write + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: go + build-mode: autobuild + # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - if: matrix.build-mode == 'manual' + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}"