-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: move standard library initialization to genesis transactions #3168
base: master
Are you sure you want to change the base?
Changes from 98 commits
a57e99f
80a0420
947435d
530c659
30c0ef5
98b3c91
a7f0e84
63565df
e80c354
197a01c
2f65112
6c9b5b6
3bf22fb
6f90e23
94b2197
dad6992
dda4c7c
d41d5ed
59d9008
3223bf2
bcbc211
d191eed
5389cf6
f6aaa29
c603537
2f65631
ee2b0da
3f9abe1
d351434
b236499
f497d05
50ff186
b6f54c2
694ec88
9c2f3c2
be153b1
f832188
359585a
d98aded
c12f6b3
c106800
fd3286c
2e6f1f2
a15aa7b
d96766d
98e4e4f
f1cfc8e
8aa9b24
66d3e70
ce564b4
f4138d8
df80f36
60c5eeb
435a98c
32a47c8
e0f96c1
62f4f21
57749ce
34a52d2
54d6376
f7c4af1
d776227
1054240
d94c226
44056eb
fca5da2
4674563
f9d214e
c2acb22
c83ecd8
88996bc
ef0d05f
1e333e2
0f9eb5c
3247301
17ac56b
b676fc5
b31dac0
883b1b0
ab76537
03965b0
b58b9e0
4f6686f
73ad347
8b3f1a4
b39cb20
f936f6c
3e506b6
d59dd88
37eecb1
9f128d5
2e1b5df
d43e5b2
606a741
10c4cf4
b88761c
82c4769
8943a68
1231f81
c885024
6ad727e
53fa02b
1c22718
868f941
6200b27
cea9a05
b934ab2
8539d18
57acd8e
b65420d
da28696
a6cbccf
aeff181
a7939bc
80da996
50f9cad
a509eee
2d7d762
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import ( | |
"github.com/gnolang/gno/gno.land/pkg/gnoland/ugnot" | ||
"github.com/gnolang/gno/gno.land/pkg/integration" | ||
"github.com/gnolang/gno/gnovm/pkg/gnomod" | ||
"github.com/gnolang/gno/gnovm/stdlibs" | ||
"github.com/gnolang/gno/tm2/pkg/amino" | ||
tmcfg "github.com/gnolang/gno/tm2/pkg/bft/config" | ||
"github.com/gnolang/gno/tm2/pkg/bft/node" | ||
|
@@ -92,6 +93,9 @@ type Node struct { | |
var DefaultFee = std.NewFee(50000, std.MustParseCoin(ugnot.ValueString(1000000))) | ||
|
||
func NewDevNode(ctx context.Context, cfg *NodeConfig) (*Node, error) { | ||
stdlibsDeployer := crypto.MustAddressFromString("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // test1, FIXME: replace | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fixable I think with @Villaquiranm's PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think I'll wait on it |
||
stdlibsTxs := gnoland.LoadEmbeddedStdlibs(stdlibsDeployer, DefaultFee) | ||
|
||
mpkgs, err := NewPackagesMap(cfg.PackagesPathList) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable map pkgs list: %w", err) | ||
|
@@ -118,7 +122,7 @@ func NewDevNode(ctx context.Context, cfg *NodeConfig) (*Node, error) { | |
// generate genesis state | ||
genesis := gnoland.GnoGenesisState{ | ||
Balances: cfg.BalancesList, | ||
Txs: append(pkgsTxs, cfg.InitialTxs...), | ||
Txs: append(stdlibsTxs, append(pkgsTxs, cfg.InitialTxs...)...), | ||
} | ||
|
||
if err := devnode.rebuildNode(ctx, genesis); err != nil { | ||
|
@@ -268,14 +272,18 @@ func (n *Node) Reset(ctx context.Context) error { | |
return fmt.Errorf("unable to stop the node: %w", err) | ||
} | ||
|
||
// Load stdlibs | ||
stdlibsDeployer := crypto.MustAddressFromString("g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5") // test1, FIXME: replace | ||
stdlibsTxs := gnoland.LoadEmbeddedStdlibs(stdlibsDeployer, DefaultFee) | ||
|
||
// Generate a new genesis state based on the current packages | ||
pkgsTxs, err := n.pkgs.Load(DefaultFee) | ||
if err != nil { | ||
return fmt.Errorf("unable to load pkgs: %w", err) | ||
} | ||
|
||
// Append initialTxs | ||
txs := append(pkgsTxs, n.initialState...) | ||
txs := append(stdlibsTxs, append(pkgsTxs, n.initialState...)...) | ||
genesis := gnoland.GnoGenesisState{ | ||
Balances: n.config.BalancesList, | ||
Txs: txs, | ||
|
@@ -357,7 +365,8 @@ func (n *Node) getBlockStoreState(ctx context.Context) ([]gnoland.TxWithMetadata | |
// get current genesis state | ||
genesis := n.GenesisDoc().AppState.(gnoland.GnoGenesisState) | ||
|
||
initialTxs := genesis.Txs[n.loadedPackages:] // ignore previously loaded packages | ||
numStdLibs := len(stdlibs.InitOrder()) - 1 // stdlibs count minus testing lib | ||
initialTxs := genesis.Txs[n.loadedPackages+numStdLibs:] // ignore previously loaded packages | ||
|
||
state := append([]gnoland.TxWithMetadata{}, initialTxs...) | ||
|
||
|
@@ -479,8 +488,6 @@ func (n *Node) rebuildNode(ctx context.Context, genesis gnoland.GnoGenesisState) | |
// Setup node config | ||
nodeConfig := newNodeConfig(n.config.TMConfig, n.config.ChainID, genesis) | ||
nodeConfig.GenesisTxResultHandler = n.genesisTxResultHandler | ||
// Speed up stdlib loading after first start (saves about 2-3 seconds on each reload). | ||
nodeConfig.CacheStdlibLoad = true | ||
nodeConfig.Genesis.ConsensusParams.Block.MaxGas = n.config.MaxGasPerBlock | ||
|
||
// recoverFromError handles panics and converts them to errors. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,3 +99,4 @@ func main() { | |
// | ||
// ## Page 7 of 6 | ||
// [1](?page=1) | … | [5](?page=5) | [6](?page=6) | _7_ | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ func main() { | |
} | ||
|
||
// Output: | ||
// | ||
// -- INITIAL | ||
// | ||
// # Gnome 😃 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ func main() { | |
// List of all Groups: | ||
// | ||
// * [test_group](/r/demo/groups:test_group) | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,5 @@ func main() { | |
// Group Last MemberID: 0000000001 | ||
// | ||
// Group Members: | ||
// | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,5 @@ func main() { | |
// Output: | ||
// 1 | ||
// List of all Groups: | ||
// | ||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,4 @@ func main() { | |
// | ||
// * various improvements | ||
// * new shiny logo | ||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we discussed why this was needed privately, but it's worth nothing here as well 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to make an optimization in this PR to keep gnoland test around 20min like on master
I keep you posted